dolibarr  13.0.2
listbysubaccount.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2016 Neil Orley <neil.orley@oeris.fr>
3  * Copyright (C) 2013-2016 Olivier Geffroy <jeff@jeffinfo.com>
4  * Copyright (C) 2013-2016 Florian Henry <florian.henry@open-concept.pro>
5  * Copyright (C) 2013-2020 Alexandre Spangaro <aspangaro@open-dsi.fr>
6  * Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <https://www.gnu.org/licenses/>.
20  */
21 
28 require '../../main.inc.php';
29 
30 require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
31 require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php';
32 require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php';
33 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
34 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
35 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
36 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
37 
38 // Load translation files required by the page
39 $langs->loadLangs(array("accountancy", "compta"));
40 
41 $action = GETPOST('action', 'aZ09');
42 $search_date_startyear = GETPOST('search_date_startyear', 'int');
43 $search_date_startmonth = GETPOST('search_date_startmonth', 'int');
44 $search_date_startday = GETPOST('search_date_startday', 'int');
45 $search_date_endyear = GETPOST('search_date_endyear', 'int');
46 $search_date_endmonth = GETPOST('search_date_endmonth', 'int');
47 $search_date_endday = GETPOST('search_date_endday', 'int');
48 $search_date_start = dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear);
49 $search_date_end = dol_mktime(0, 0, 0, $search_date_endmonth, $search_date_endday, $search_date_endyear);
50 $search_doc_date = dol_mktime(0, 0, 0, GETPOST('doc_datemonth', 'int'), GETPOST('doc_dateday', 'int'), GETPOST('doc_dateyear', 'int'));
51 $search_date_export_startyear = GETPOST('search_date_export_startyear', 'int');
52 $search_date_export_startmonth = GETPOST('search_date_export_startmonth', 'int');
53 $search_date_export_startday = GETPOST('search_date_export_startday', 'int');
54 $search_date_export_endyear = GETPOST('search_date_export_endyear', 'int');
55 $search_date_export_endmonth = GETPOST('search_date_export_endmonth', 'int');
56 $search_date_export_endday = GETPOST('search_date_export_endday', 'int');
57 $search_date_export_start = dol_mktime(0, 0, 0, $search_date_export_startmonth, $search_date_export_startday, $search_date_export_startyear);
58 $search_date_export_end = dol_mktime(0, 0, 0, $search_date_export_endmonth, $search_date_export_endday, $search_date_export_endyear);
59 
60 $search_accountancy_code = GETPOST("search_accountancy_code");
61 $search_accountancy_code_start = GETPOST('search_accountancy_code_start', 'alpha');
62 if ($search_accountancy_code_start == - 1) {
63  $search_accountancy_code_start = '';
64 }
65 $search_accountancy_code_end = GETPOST('search_accountancy_code_end', 'alpha');
66 if ($search_accountancy_code_end == - 1) {
67  $search_accountancy_code_end = '';
68 }
69 $search_doc_ref = GETPOST('search_doc_ref', 'alpha');
70 $search_label_operation = GETPOST('search_label_operation', 'alpha');
71 $search_mvt_num = GETPOST('search_mvt_num', 'int');
72 $search_direction = GETPOST('search_direction', 'alpha');
73 $search_ledger_code = GETPOST('search_ledger_code', 'alpha');
74 $search_debit = GETPOST('search_debit', 'alpha');
75 $search_credit = GETPOST('search_credit', 'alpha');
76 $search_lettering_code = GETPOST('search_lettering_code', 'alpha');
77 $search_not_reconciled = GETPOST('search_not_reconciled', 'alpha');
78 
79 if (GETPOST("button_delmvt_x") || GETPOST("button_delmvt.x") || GETPOST("button_delmvt")) {
80  $action = 'delbookkeepingyear';
81 }
82 
83 // Load variable for pagination
84 $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : (empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION) ? $conf->liste_limit : $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION);
85 $sortfield = GETPOST('sortfield', 'aZ09comma');
86 $sortorder = GETPOST('sortorder', 'aZ09comma');
87 $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
88 if (empty($page) || $page < 0) { $page = 0; }
89 $offset = $limit * $page;
90 $pageprev = $page - 1;
91 $pagenext = $page + 1;
92 if ($sortorder == "") $sortorder = "ASC";
93 if ($sortfield == "") $sortfield = "t.doc_date,t.rowid";
94 
95 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
96 $object = new BookKeeping($db);
97 $formfile = new FormFile($db);
98 $hookmanager->initHooks(array('bookkeepingbysubaccountlist'));
99 
100 $formaccounting = new FormAccounting($db);
101 $form = new Form($db);
102 
103 if (empty($search_date_start) && empty($search_date_end) && !GETPOSTISSET('search_date_startday') && !GETPOSTISSET('search_date_startmonth') && !GETPOSTISSET('search_date_starthour')) {
104  $sql = "SELECT date_start, date_end from ".MAIN_DB_PREFIX."accounting_fiscalyear ";
105  $sql .= " where date_start < '".$db->idate(dol_now())."' and date_end > '".$db->idate(dol_now())."'";
106  $sql .= $db->plimit(1);
107  $res = $db->query($sql);
108 
109  if ($res->num_rows > 0) {
110  $fiscalYear = $db->fetch_object($res);
111  $search_date_start = strtotime($fiscalYear->date_start);
112  $search_date_end = strtotime($fiscalYear->date_end);
113  } else {
114  $month_start = ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1);
115  $year_start = dol_print_date(dol_now(), '%Y');
116  if (dol_print_date(dol_now(), '%m') < $month_start) $year_start--; // If current month is lower that starting fiscal month, we start last year
117  $year_end = $year_start + 1;
118  $month_end = $month_start - 1;
119  if ($month_end < 1)
120  {
121  $month_end = 12;
122  $year_end--;
123  }
124  $search_date_start = dol_mktime(0, 0, 0, $month_start, 1, $year_start);
125  $search_date_end = dol_get_last_day($year_end, $month_end);
126  }
127 }
128 
129 $arrayfields = array(
130  // 't.subledger_account'=>array('label'=>$langs->trans("SubledgerAccount"), 'checked'=>1),
131  't.piece_num'=>array('label'=>$langs->trans("TransactionNumShort"), 'checked'=>1),
132  't.code_journal'=>array('label'=>$langs->trans("Codejournal"), 'checked'=>1),
133  't.doc_date'=>array('label'=>$langs->trans("Docdate"), 'checked'=>1),
134  't.doc_ref'=>array('label'=>$langs->trans("Piece"), 'checked'=>1),
135  't.label_operation'=>array('label'=>$langs->trans("Label"), 'checked'=>1),
136  't.debit'=>array('label'=>$langs->trans("Debit"), 'checked'=>1),
137  't.credit'=>array('label'=>$langs->trans("Credit"), 'checked'=>1),
138  't.lettering_code'=>array('label'=>$langs->trans("LetteringCode"), 'checked'=>1),
139  't.date_export'=>array('label'=>$langs->trans("DateExport"), 'checked'=>1),
140 );
141 
142 if (empty($conf->global->ACCOUNTING_ENABLE_LETTERING)) unset($arrayfields['t.lettering_code']);
143 
144 if ($search_date_start && empty($search_date_startyear)) {
145  $tmparray = dol_getdate($search_date_start);
146  $search_date_startyear = $tmparray['year'];
147  $search_date_startmonth = $tmparray['mon'];
148  $search_date_startday = $tmparray['mday'];
149 }
150 if ($search_date_end && empty($search_date_endyear)) {
151  $tmparray = dol_getdate($search_date_end);
152  $search_date_endyear = $tmparray['year'];
153  $search_date_endmonth = $tmparray['mon'];
154  $search_date_endday = $tmparray['mday'];
155 }
156 
157 
158 /*
159  * Action
160  */
161 
162 if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; }
163 if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; }
164 
165 $parameters = array('socid'=>$socid);
166 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
167 if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
168 
169 if (empty($reshook))
170 {
171  include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
172 
173  if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers
174  {
175  $search_doc_date = '';
176  $search_accountancy_code = '';
177  $search_accountancy_code_start = '';
178  $search_accountancy_code_end = '';
179  $search_label_account = '';
180  $search_doc_ref = '';
181  $search_label_operation = '';
182  $search_mvt_num = '';
183  $search_direction = '';
184  $search_ledger_code = '';
185  $search_date_start = '';
186  $search_date_end = '';
187  $search_date_startyear = '';
188  $search_date_startmonth = '';
189  $search_date_startday = '';
190  $search_date_endyear = '';
191  $search_date_endmonth = '';
192  $search_date_endday = '';
193  $search_date_export_start = '';
194  $search_date_export_end = '';
195  $search_date_export_startyear = '';
196  $search_date_export_startmonth = '';
197  $search_date_export_startday = '';
198  $search_date_export_endyear = '';
199  $search_date_export_endmonth = '';
200  $search_date_export_endday = '';
201  $search_debit = '';
202  $search_credit = '';
203  $search_lettering_code = '';
204  $search_not_reconciled = '';
205  }
206 
207  // Must be after the remove filter action, before the export.
208  $param = '';
209  $filter = array();
210 
211  if (!empty($search_date_start)) {
212  $filter['t.doc_date>='] = $search_date_start;
213  $param .= '&search_date_startmonth='.$search_date_startmonth.'&search_date_startday='.$search_date_startday.'&search_date_startyear='.$search_date_startyear;
214  }
215  if (!empty($search_date_end)) {
216  $filter['t.doc_date<='] = $search_date_end;
217  $param .= '&search_date_endmonth='.$search_date_endmonth.'&search_date_endday='.$search_date_endday.'&search_date_endyear='.$search_date_endyear;
218  }
219  if (!empty($search_doc_date)) {
220  $filter['t.doc_date'] = $search_doc_date;
221  $param .= '&doc_datemonth='.GETPOST('doc_datemonth', 'int').'&doc_dateday='.GETPOST('doc_dateday', 'int').'&doc_dateyear='.GETPOST('doc_dateyear', 'int');
222  }
223  if (!empty($search_accountancy_code_start)) {
224  $filter['t.subledger_account>='] = $search_accountancy_code_start;
225  $param .= '&search_accountancy_code_start='.urlencode($search_accountancy_code_start);
226  }
227  if (!empty($search_accountancy_code_end)) {
228  $filter['t.subledger_account<='] = $search_accountancy_code_end;
229  $param .= '&search_accountancy_code_end='.urlencode($search_accountancy_code_end);
230  }
231  if (!empty($search_label_account)) {
232  $filter['t.label_compte'] = $search_label_account;
233  $param .= '&search_label_compte='.urlencode($search_label_account);
234  }
235  if (!empty($search_mvt_num)) {
236  $filter['t.piece_num'] = $search_mvt_num;
237  $param .= '&search_mvt_num='.urlencode($search_mvt_num);
238  }
239  if (!empty($search_doc_ref)) {
240  $filter['t.doc_ref'] = $search_doc_ref;
241  $param .= '&search_doc_ref='.urlencode($search_doc_ref);
242  }
243  if (!empty($search_label_operation)) {
244  $filter['t.label_operation'] = $search_label_operation;
245  $param .= '&search_label_operation='.urlencode($search_label_operation);
246  }
247  if (!empty($search_direction)) {
248  $filter['t.sens'] = $search_direction;
249  $param .= '&search_direction='.urlencode($search_direction);
250  }
251  if (!empty($search_ledger_code)) {
252  $filter['t.code_journal'] = $search_ledger_code;
253  $param .= '&search_ledger_code='.urlencode($search_ledger_code);
254  }
255  if (!empty($search_debit)) {
256  $filter['t.debit'] = $search_debit;
257  $param .= '&search_debit='.urlencode($search_debit);
258  }
259  if (!empty($search_credit)) {
260  $filter['t.credit'] = $search_credit;
261  $param .= '&search_credit='.urlencode($search_credit);
262  }
263  if (!empty($search_lettering_code)) {
264  $filter['t.lettering_code'] = $search_lettering_code;
265  $param .= '&search_lettering_code='.urlencode($search_lettering_code);
266  }
267  if (!empty($search_not_reconciled)) {
268  $filter['t.reconciled_option'] = $search_not_reconciled;
269  $param .= '&search_not_reconciled='.urlencode($search_not_reconciled);
270  }
271  if (!empty($search_date_export_start)) {
272  $filter['t.date_export>='] = $search_date_export_start;
273  $param .= '&search_date_export_startmonth='.$search_date_export_startmonth.'&search_date_export_startday='.$search_date_export_startday.'&search_date_export_startyear='.$search_date_export_startyear;
274  }
275  if (!empty($search_date_export_end)) {
276  $filter['t.date_export<='] = $search_date_export_end;
277  $param .= '&search_date_export_endmonth='.$search_date_export_endmonth.'&search_date_export_endday='.$search_date_export_endday.'&search_date_export_endyear='.$search_date_export_endyear;
278  }
279 }
280 
281 if ($action == 'delbookkeeping' && $user->rights->accounting->mouvements->supprimer) {
282  $import_key = GETPOST('importkey', 'alpha');
283 
284  if (!empty($import_key)) {
285  $result = $object->deleteByImportkey($import_key);
286  if ($result < 0) {
287  setEventMessages($object->error, $object->errors, 'errors');
288  }
289 
290  // Make a redirect to avoid to launch the delete later after a back button
291  header("Location: ".$_SERVER["PHP_SELF"].($param ? '?'.$param : ''));
292  exit;
293  }
294 }
295 if ($action == 'delbookkeepingyearconfirm' && $user->rights->accounting->mouvements->supprimer_tous) {
296  $delmonth = GETPOST('delmonth', 'int');
297  $delyear = GETPOST('delyear', 'int');
298  if ($delyear == -1) {
299  $delyear = 0;
300  }
301  $deljournal = GETPOST('deljournal', 'alpha');
302  if ($deljournal == -1) {
303  $deljournal = 0;
304  }
305 
306  if (!empty($delmonth) || !empty($delyear) || !empty($deljournal))
307  {
308  $result = $object->deleteByYearAndJournal($delyear, $deljournal, '', ($delmonth > 0 ? $delmonth : 0));
309  if ($result < 0) {
310  setEventMessages($object->error, $object->errors, 'errors');
311  } else {
312  setEventMessages("RecordDeleted", null, 'mesgs');
313  }
314 
315  // Make a redirect to avoid to launch the delete later after a back button
316  header("Location: ".$_SERVER["PHP_SELF"].($param ? '?'.$param : ''));
317  exit;
318  } else {
319  setEventMessages("NoRecordDeleted", null, 'warnings');
320  }
321 }
322 if ($action == 'delmouvconfirm' && $user->rights->accounting->mouvements->supprimer) {
323  $mvt_num = GETPOST('mvt_num', 'int');
324 
325  if (!empty($mvt_num)) {
326  $result = $object->deleteMvtNum($mvt_num);
327  if ($result < 0) {
328  setEventMessages($object->error, $object->errors, 'errors');
329  } else {
330  setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs');
331  }
332 
333  header("Location: ".$_SERVER["PHP_SELF"]."?noreset=1".($param ? '&'.$param : ''));
334  exit;
335  }
336 }
337 
338 
339 /*
340  * View
341  */
342 
343 $formaccounting = new FormAccounting($db);
344 $formfile = new FormFile($db);
345 $formother = new FormOther($db);
346 $form = new Form($db);
347 
348 $title_page = $langs->trans("Operations").' - '.$langs->trans("VueByAccountAccounting").' ('.$langs->trans("BookkeepingSubAccount").')';
349 
350 llxHeader('', $title_page);
351 
352 
353 // List
354 $nbtotalofrecords = '';
355 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
356  $nbtotalofrecords = $object->fetchAllByAccount($sortorder, $sortfield, 0, 0, $filter, 'AND', 1);
357  if ($nbtotalofrecords < 0) {
358  setEventMessages($object->error, $object->errors, 'errors');
359  }
360 }
361 
362 $result = $object->fetchAllByAccount($sortorder, $sortfield, $limit, $offset, $filter, 'AND', 1);
363 
364 if ($result < 0) {
365  setEventMessages($object->error, $object->errors, 'errors');
366 }
367 
368 $num = count($object->lines);
369 
370 
371 if ($action == 'delmouv') {
372  $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?mvt_num='.GETPOST('mvt_num'), $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvtPartial'), 'delmouvconfirm', '', 0, 1);
373  print $formconfirm;
374 }
375 if ($action == 'delbookkeepingyear') {
376  $form_question = array();
377  $delyear = GETPOST('delyear', 'int');
378  $deljournal = GETPOST('deljournal', 'alpha');
379 
380  if (empty($delyear)) {
381  $delyear = dol_print_date(dol_now(), '%Y');
382  }
383  $month_array = array();
384  for ($i = 1; $i <= 12; $i++) {
385  $month_array[$i] = $langs->trans("Month".sprintf("%02d", $i));
386  }
387  $year_array = $formaccounting->selectyear_accountancy_bookkepping($delyear, 'delyear', 0, 'array');
388  $journal_array = $formaccounting->select_journal($deljournal, 'deljournal', '', 1, 1, 1, '', 0, 1);
389 
390  $form_question['delmonth'] = array(
391  'name' => 'delmonth',
392  'type' => 'select',
393  'label' => $langs->trans('DelMonth'),
394  'values' => $month_array,
395  'default' => ''
396  );
397  $form_question['delyear'] = array(
398  'name' => 'delyear',
399  'type' => 'select',
400  'label' => $langs->trans('DelYear'),
401  'values' => $year_array,
402  'default' => $delyear
403  );
404  $form_question['deljournal'] = array(
405  'name' => 'deljournal',
406  'type' => 'other', // We don't use select here, the journal_array is already a select html component
407  'label' => $langs->trans('DelJournal'),
408  'value' => $journal_array,
409  'default' => $deljournal
410  );
411 
412  $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?'.$param, $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvt', $langs->transnoentitiesnoconv("RegistrationInAccounting")), 'delbookkeepingyearconfirm', $form_question, '', 1, 300);
413  print $formconfirm;
414 }
415 
416 
417 print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
418 print '<input type="hidden" name="token" value="'.newToken().'">';
419 print '<input type="hidden" name="action" value="list">';
420 if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
421 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
422 print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
423 print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
424 
425 
426 $parameters = array();
427 $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
428 if (empty($reshook)) {
429  $newcardbutton = dolGetButtonTitle($langs->trans('ViewFlatList'), '', 'fa fa-list paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/list.php?'.$param);
430  $newcardbutton .= dolGetButtonTitle($langs->trans('GroupByAccountAccounting'), '', 'fa fa-stream paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/listbyaccount.php?'.$param, '', 1, array('morecss' => 'marginleftonly'));
431  $newcardbutton .= dolGetButtonTitle($langs->trans('GroupBySubAccountAccounting'), '', 'fa fa-align-left vmirror paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/listbysubaccount.php?'.$param, '', 1, array('morecss' => 'marginleftonly btnTitleSelected'));
432  $newcardbutton .= dolGetButtonTitle($langs->trans('NewAccountingMvt'), '', 'fa fa-plus-circle paddingleft', DOL_URL_ROOT.'/accountancy/bookkeeping/card.php?action=create');
433 }
434 
435 if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
436 if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
437 
438 print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $result, $nbtotalofrecords, 'title_accountancy', 0, $newcardbutton, '', $limit, 0, 0, 1);
439 
440 print info_admin($langs->trans("WarningRecordWithoutSubledgerAreExcluded"));
441 
442 $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
443 $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
444 if ($massactionbutton) $selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
445 
446 // Reverse sort order
447 if (preg_match('/^asc/i', $sortorder)) $sortorder = "asc";
448 else $sortorder = "desc";
449 
450 $moreforfilter = '';
451 
452 // Accountancy account
453 $moreforfilter .= '<div class="divsearchfield">';
454 $moreforfilter .= $langs->trans('AccountAccounting').': ';
455 $moreforfilter .= '<div class="nowrap inline-block">';
456 $moreforfilter .= $langs->trans('From').' ';
457 $moreforfilter .= $formaccounting->select_auxaccount($search_accountancy_code_start, 'search_accountancy_code_start', 1, 'maxwidth200');
458 $moreforfilter .= ' '.$langs->trans('to').' ';
459 $moreforfilter .= $formaccounting->select_auxaccount($search_accountancy_code_end, 'search_accountancy_code_end', 1, 'maxwidth200');
460 $moreforfilter .= '</div>';
461 $moreforfilter .= '</div>';
462 
463 $parameters = array();
464 $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook
465 if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint;
466 else $moreforfilter = $hookmanager->resPrint;
467 
468 print '<div class="liste_titre liste_titre_bydiv centpercent">';
469 print $moreforfilter;
470 print '</div>';
471 
472 print '<div class="div-table-responsive">';
473 print '<table class="tagtable liste centpercent">';
474 
475 // Filters lines
476 print '<tr class="liste_titre_filter">';
477 
478 // Movement number
479 if (!empty($arrayfields['t.piece_num']['checked']))
480 {
481  print '<td class="liste_titre"><input type="text" name="search_mvt_num" size="6" value="'.dol_escape_htmltag($search_mvt_num).'"></td>';
482 }
483 // Code journal
484 if (!empty($arrayfields['t.code_journal']['checked'])) {
485  print '<td class="liste_titre center"><input type="text" name="search_ledger_code" size="3" value="'.dol_escape_htmltag($search_ledger_code).'"></td>';
486 }
487 // Date document
488 if (!empty($arrayfields['t.doc_date']['checked'])) {
489  print '<td class="liste_titre center">';
490  print '<div class="nowrap">';
491  print $form->selectDate($search_date_start, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"));
492  print '</div>';
493  print '<div class="nowrap">';
494  print $form->selectDate($search_date_end, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to"));
495  print '</div>';
496  print '</td>';
497 }
498 // Ref document
499 if (!empty($arrayfields['t.doc_ref']['checked'])) {
500  print '<td class="liste_titre"><input type="text" size="7" class="flat" name="search_doc_ref" value="'.dol_escape_htmltag($search_doc_ref).'"/></td>';
501 }
502 // Label operation
503 if (!empty($arrayfields['t.label_operation']['checked'])) {
504  print '<td class="liste_titre"><input type="text" size="7" class="flat" name="search_label_operation" value="'.dol_escape_htmltag($search_label_operation).'"/></td>';
505 }
506 // Debit
507 if (!empty($arrayfields['t.debit']['checked'])) {
508  print '<td class="liste_titre right"><input type="text" class="flat" name="search_debit" size="4" value="'.dol_escape_htmltag($search_debit).'"></td>';
509 }
510 // Credit
511 if (!empty($arrayfields['t.credit']['checked'])) {
512  print '<td class="liste_titre right"><input type="text" class="flat" name="search_credit" size="4" value="'.dol_escape_htmltag($search_credit).'"></td>';
513 }
514 // Lettering code
515 if (!empty($arrayfields['t.lettering_code']['checked']))
516 {
517  print '<td class="liste_titre center">';
518  print '<input type="text" size="3" class="flat" name="search_lettering_code" value="'.$search_lettering_code.'"/>';
519  print '<br><span class="nowrap"><input type="checkbox" name="search_not_reconciled" value="notreconciled"'.($search_not_reconciled == 'notreconciled' ? ' checked' : '').'>'.$langs->trans("NotReconciled").'</span>';
520  print '</td>';
521 }
522 // Date export
523 if (!empty($arrayfields['t.date_export']['checked'])) {
524  print '<td class="liste_titre center">';
525  print '<div class="nowrap">';
526  print $form->selectDate($search_date_export_start, 'search_date_export_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"));
527  print '</div>';
528  print '<div class="nowrap">';
529  print $form->selectDate($search_date_export_end, 'search_date_export_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to"));
530  print '</div>';
531  print '</td>';
532 }
533 
534 // Fields from hook
535 $parameters = array('arrayfields'=>$arrayfields);
536 $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
537 print $hookmanager->resPrint;
538 
539 // Action column
540 print '<td class="liste_titre center">';
541 $searchpicto = $form->showFilterButtons();
542 print $searchpicto;
543 print '</td>';
544 print "</tr>\n";
545 
546 print '<tr class="liste_titre">';
547 if (!empty($arrayfields['t.piece_num']['checked'])) print_liste_field_titre($arrayfields['t.piece_num']['label'], $_SERVER['PHP_SELF'], "t.piece_num", "", $param, '', $sortfield, $sortorder);
548 if (!empty($arrayfields['t.code_journal']['checked'])) print_liste_field_titre($arrayfields['t.code_journal']['label'], $_SERVER['PHP_SELF'], "t.code_journal", "", $param, '', $sortfield, $sortorder, 'center ');
549 if (!empty($arrayfields['t.doc_date']['checked'])) print_liste_field_titre($arrayfields['t.doc_date']['label'], $_SERVER['PHP_SELF'], "t.doc_date", "", $param, '', $sortfield, $sortorder, 'center ');
550 if (!empty($arrayfields['t.doc_ref']['checked'])) print_liste_field_titre($arrayfields['t.doc_ref']['label'], $_SERVER['PHP_SELF'], "t.doc_ref", "", $param, "", $sortfield, $sortorder);
551 if (!empty($arrayfields['t.label_operation']['checked'])) print_liste_field_titre($arrayfields['t.label_operation']['label'], $_SERVER['PHP_SELF'], "t.label_operation", "", $param, "", $sortfield, $sortorder);
552 if (!empty($arrayfields['t.debit']['checked'])) print_liste_field_titre($arrayfields['t.debit']['label'], $_SERVER['PHP_SELF'], "t.debit", "", $param, '', $sortfield, $sortorder, 'right ');
553 if (!empty($arrayfields['t.credit']['checked'])) print_liste_field_titre($arrayfields['t.credit']['label'], $_SERVER['PHP_SELF'], "t.credit", "", $param, '', $sortfield, $sortorder, 'right ');
554 if (!empty($arrayfields['t.lettering_code']['checked'])) print_liste_field_titre($arrayfields['t.lettering_code']['label'], $_SERVER['PHP_SELF'], "t.lettering_code", "", $param, '', $sortfield, $sortorder, 'center ');
555 if (!empty($arrayfields['t.date_export']['checked'])) print_liste_field_titre($arrayfields['t.date_export']['label'], $_SERVER['PHP_SELF'], "t.date_export", "", $param, '', $sortfield, $sortorder, 'center ');
556 // Hook fields
557 $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
558 $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
559 print $hookmanager->resPrint;
560 print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
561 print "</tr>\n";
562 
563 
564 $total_debit = 0;
565 $total_credit = 0;
566 $sous_total_debit = 0;
567 $sous_total_credit = 0;
568 $displayed_account_number = null; // Start with undefined to be able to distinguish with empty
569 
570 // Loop on record
571 // --------------------------------------------------------------------
572 $i = 0;
573 $totalarray = array();
574 while ($i < min($num, $limit))
575 {
576  $line = $object->lines[$i];
577 
578  $total_debit += $line->debit;
579  $total_credit += $line->credit;
580 
581  $accountg = length_accounta($line->subledger_account);
582  //if (empty($accountg)) $accountg = '-';
583 
584  // Is it a break ?
585  if ($accountg != $displayed_account_number || !isset($displayed_account_number)) {
586  $colnumber = 5;
587  $colnumberend = 7;
588 
589  if (empty($conf->global->ACCOUNTING_ENABLE_LETTERING) || empty($arrayfields['t.lettering_code']['checked'])) $colnumber--;
590  if (empty($arrayfields['t.date_export']['checked'])) $colnumber--;
591 
592  $colspan = $totalarray['nbfield'] - $colnumber;
593  $colspanend = $totalarray['nbfield'] - $colnumberend;
594  // Show a subtotal by accounting account
595  if (isset($displayed_account_number)) {
596  print '<tr class="liste_total">';
597  print '<td class="right" colspan="'.$colspan.'">'.$langs->trans("TotalForAccount").' '.length_accounta($displayed_account_number).':</td>';
598  print '<td class="nowrap right">'.price($sous_total_debit).'</td>';
599  print '<td class="nowrap right">'.price($sous_total_credit).'</td>';
600  print '<td colspan="'.$colspanend.'"></td>';
601  print '</tr>';
602  // Show balance of last shown account
603  $balance = $sous_total_debit - $sous_total_credit;
604  print '<tr class="liste_total">';
605  print '<td class="right" colspan="'.$colspan.'">'.$langs->trans("Balance").':</td>';
606  if ($balance > 0)
607  {
608  print '<td class="nowraponall right">';
609  print price($sous_total_debit - $sous_total_credit);
610  print '</td>';
611  print '<td></td>';
612  } else {
613  print '<td></td>';
614  print '<td class="nowraponall right">';
615  print price($sous_total_credit - $sous_total_debit);
616  print '</td>';
617  }
618  print '<td colspan="'.$colspanend.'"></td>';
619  print '</tr>';
620  }
621 
622  // Show the break account
623  print "<tr>";
624  print '<td colspan="'.($totalarray['nbfield'] ? $totalarray['nbfield'] : 10).'" style="font-weight:bold; border-bottom: 1pt solid black;">';
625  if ($line->subledger_account != "" && $line->subledger_account != '-1') {
626  print $object->get_compte_desc($line->numero_compte).' : '.length_accounta($line->subledger_account);
627  } else {
628  // Should not happen: subledger account must be null or a non empty value
629  print '<span class="error">'.$langs->trans("Unknown");
630  if ($line->subledger_label) {
631  print ' ('.$line->subledger_label.')';
632  $htmltext = 'EmptyStringForSubledgerAccountButSubledgerLabelDefined';
633  } else {
634  $htmltext = 'EmptyStringForSubledgerAccountAndSubledgerLabel';
635  }
636  print $form->textwithpicto('', $htmltext);
637  print '</span>';
638  }
639  print '</td>';
640  print '</tr>';
641 
642  $displayed_account_number = $accountg;
643  //if (empty($displayed_account_number)) $displayed_account_number='-';
644  $sous_total_debit = 0;
645  $sous_total_credit = 0;
646 
647  $colspan = 0;
648  }
649 
650  print '<tr class="oddeven">';
651 
652  // Piece number
653  if (!empty($arrayfields['t.piece_num']['checked']))
654  {
655  print '<td>';
656  $object->id = $line->id;
657  $object->piece_num = $line->piece_num;
658  print $object->getNomUrl(1, '', 0, '', 1);
659  print '</td>';
660  if (!$i) $totalarray['nbfield']++;
661  }
662 
663  // Journal code
664  if (!empty($arrayfields['t.code_journal']['checked']))
665  {
666  $accountingjournal = new AccountingJournal($db);
667  $result = $accountingjournal->fetch('', $line->code_journal);
668  $journaltoshow = (($result > 0) ? $accountingjournal->getNomUrl(0, 0, 0, '', 0) : $line->code_journal);
669  print '<td class="center">'.$journaltoshow.'</td>';
670  if (!$i) $totalarray['nbfield']++;
671  }
672 
673  // Document date
674  if (!empty($arrayfields['t.doc_date']['checked']))
675  {
676  print '<td class="center">'.dol_print_date($line->doc_date, 'day').'</td>';
677  if (!$i) $totalarray['nbfield']++;
678  }
679 
680  // Document ref
681  if (!empty($arrayfields['t.doc_ref']['checked']))
682  {
683  if ($line->doc_type == 'customer_invoice')
684  {
685  $langs->loadLangs(array('bills'));
686 
687  require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
688  $objectstatic = new Facture($db);
689  $objectstatic->fetch($line->fk_doc);
690  //$modulepart = 'facture';
691 
692  $filename = dol_sanitizeFileName($line->doc_ref);
693  $filedir = $conf->facture->dir_output.'/'.dol_sanitizeFileName($line->doc_ref);
694  $urlsource = $_SERVER['PHP_SELF'].'?id='.$objectstatic->id;
695  $documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir);
696  } elseif ($line->doc_type == 'supplier_invoice')
697  {
698  $langs->loadLangs(array('bills'));
699 
700  require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
701  $objectstatic = new FactureFournisseur($db);
702  $objectstatic->fetch($line->fk_doc);
703  //$modulepart = 'invoice_supplier';
704 
705  $filename = dol_sanitizeFileName($line->doc_ref);
706  $filedir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($line->fk_doc, 2, 0, 0, $objectstatic, $modulepart).dol_sanitizeFileName($line->doc_ref);
707  $subdir = get_exdir($objectstatic->id, 2, 0, 0, $objectstatic, $modulepart).dol_sanitizeFileName($line->doc_ref);
708  $documentlink = $formfile->getDocumentsLink($objectstatic->element, $subdir, $filedir);
709  } elseif ($line->doc_type == 'expense_report')
710  {
711  $langs->loadLangs(array('trips'));
712 
713  require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
714  $objectstatic = new ExpenseReport($db);
715  $objectstatic->fetch($line->fk_doc);
716  //$modulepart = 'expensereport';
717 
718  $filename = dol_sanitizeFileName($line->doc_ref);
719  $filedir = $conf->expensereport->dir_output.'/'.dol_sanitizeFileName($line->doc_ref);
720  $urlsource = $_SERVER['PHP_SELF'].'?id='.$objectstatic->id;
721  $documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir);
722  } else {
723  // Other type
724  }
725 
726  print '<td class="maxwidth400">';
727 
728  print '<table class="nobordernopadding"><tr class="nocellnopadd">';
729  // Picto + Ref
730  print '<td class="nobordernopadding">';
731 
732  if ($line->doc_type == 'customer_invoice' || $line->doc_type == 'supplier_invoice' || $line->doc_type == 'expense_report')
733  {
734  print $objectstatic->getNomUrl(1, '', 0, 0, '', 0, -1, 1);
735  print $documentlink;
736  } else {
737  print $line->doc_ref;
738  }
739  print '</td></tr></table>';
740 
741  print "</td>\n";
742  if (!$i) $totalarray['nbfield']++;
743  }
744 
745  // Label operation
746  if (!empty($arrayfields['t.label_operation']['checked'])) {
747  // Affiche un lien vers la facture client/fournisseur
748  $doc_ref = preg_replace('/\(.*\)/', '', $line->doc_ref);
749  print strlen(length_accounta($line->subledger_account)) == 0 ? '<td>'.$line->label_operation.'</td>' : '<td>'.$line->label_operation.'<br><span style="font-size:0.8em">('.length_accounta($line->subledger_account).')</span></td>';
750  if (!$i) $totalarray['nbfield']++;
751  }
752 
753  // Amount debit
754  if (!empty($arrayfields['t.debit']['checked']))
755  {
756  print '<td class="nowrap right">'.($line->debit ? price($line->debit) : '').'</td>';
757  if (!$i) $totalarray['nbfield']++;
758  if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'totaldebit';
759  $totalarray['val']['totaldebit'] += $line->debit;
760  }
761 
762  // Amount credit
763  if (!empty($arrayfields['t.credit']['checked'])) {
764  print '<td class="nowrap right">'.($line->credit ? price($line->credit) : '').'</td>';
765  if (!$i) $totalarray['nbfield']++;
766  if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'totalcredit';
767  $totalarray['val']['totalcredit'] += $line->credit;
768  }
769 
770  // Lettering code
771  if (!empty($arrayfields['t.lettering_code']['checked']))
772  {
773  print '<td class="center">'.$line->lettering_code.'</td>';
774  if (!$i) $totalarray['nbfield']++;
775  }
776 
777  // Exported operation date
778  if (!empty($arrayfields['t.date_export']['checked']))
779  {
780  print '<td class="center">'.dol_print_date($line->date_export, 'dayhour').'</td>';
781  if (!$i) $totalarray['nbfield']++;
782  }
783 
784  // Fields from hook
785  $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj);
786  $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook
787  print $hookmanager->resPrint;
788 
789  // Action column
790  print '<td class="nowraponall center">';
791  if (empty($line->date_export)) {
792  if ($user->rights->accounting->mouvements->creer) {
793  print '<a class="editfielda" href="'.DOL_URL_ROOT.'/accountancy/bookkeeping/card.php?piece_num='.$line->piece_num.$param.'&page='.$page.($sortfield ? '&sortfield='.$sortfield : '').($sortorder ? '&sortorder='.$sortorder : '').'">'.img_edit().'</a>';
794  }
795  if ($user->rights->accounting->mouvements->supprimer) {
796  print ' &nbsp; <a class="paddingleft" href="'.$_SERVER['PHP_SELF'].'?action=delmouv&mvt_num='.$line->piece_num.$param.'&page='.$page.($sortfield ? '&sortfield='.$sortfield : '').($sortorder ? '&sortorder='.$sortorder : '').'">'.img_delete().'</a>';
797  }
798  }
799  print '</td>';
800  if (!$i) $totalarray['nbfield']++;
801 
802  // Comptabilise le sous-total
803  $sous_total_debit += $line->debit;
804  $sous_total_credit += $line->credit;
805 
806  print "</tr>\n";
807 
808  $i++;
809 }
810 
811 if ($num > 0) {
812  $colspan = $totalarray['nbfield'] - $colnumber;
813  $colspanend = $totalarray['nbfield'] - $colnumberend;
814  print '<tr class="liste_total">';
815  print '<td class="right" colspan="'.$colspan.'">'.$langs->trans("TotalForAccount").' '.$accountg.':</td>';
816  print '<td class="nowrap right">'.price($sous_total_debit).'</td>';
817  print '<td class="nowrap right">'.price($sous_total_credit).'</td>';
818  print '<td colspan="'.$colspanend.'"></td>';
819  print '</tr>';
820  // Show balance of last shown account
821  $balance = $sous_total_debit - $sous_total_credit;
822  print '<tr class="liste_total">';
823  print '<td class="right" colspan="'.$colspan.'">'.$langs->trans("Balance").':</td>';
824  if ($balance > 0)
825  {
826  print '<td class="nowraponall right">';
827  print price($sous_total_debit - $sous_total_credit);
828  print '</td>';
829  print '<td></td>';
830  } else {
831  print '<td></td>';
832  print '<td class="nowraponall right">';
833  print price($sous_total_credit - $sous_total_debit);
834  print '</td>';
835  }
836  print '<td colspan="'.$colspanend.'"></td>';
837  print '</tr>';
838 }
839 
840 // Show total line
841 include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
842 
843 
844 print "</table>";
845 print '</div>';
846 
847 // TODO Replace this with mass delete action
848 if ($user->rights->accounting->mouvements->supprimer_tous) {
849  print '<div class="tabsAction tabsActionNoBottom">'."\n";
850  print '<a class="butActionDelete" name="button_delmvt" href="'.$_SERVER["PHP_SELF"].'?action=delbookkeepingyear'.($param ? '&'.$param : '').'">'.$langs->trans("DeleteMvt").'</a>';
851  print '</div>';
852 }
853 
854 print '</form>';
855 
856 // End of page
857 llxFooter();
858 $db->close();
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
img_edit($titlealt= 'default', $float=0, $other= '')
Show logo editer/modifier fiche.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm= 'auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
dolGetButtonTitle($label, $helpText= '', $iconClass= 'fa fa-file', $url= '', $id= '', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
dol_now($mode= 'auto')
Return date for now.
Class to manage suppliers invoices.
price($amount, $form=0, $outlangs= '', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code= '')
Function to format a value into an amount for visual output Function used into PDF and HTML pages...
Class to manage Ledger (General Ledger and Subledger)
llxHeader()
Empty header.
Definition: wrapper.php:45
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
print_barre_liste($titre, $page, $file, $options= '', $sortfield= '', $sortorder= '', $morehtmlcenter= '', $num=-1, $totalnboflines= '', $picto= 'generic', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow= '')
Print a title with navigation controls for pagination.
Class to manage generation of HTML components Only common components must be here.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname.
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
Classe permettant la generation de composants html autre Only common components are here...
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart= '')
Return a path to have a the directory according to object where files are stored. ...
dol_getdate($timestamp, $fast=false, $forcetimezone= '')
Return an array with locale date info.
length_accounta($accounta)
Return Auxiliary accounting account of thirdparties with defined length.
dol_sanitizeFileName($str, $newstr= '_', $unaccent=1)
Clean a string to use it as a file name.
Class to manage Trips and Expenses.
Class to offer components to list and upload files.
print $_SERVER["PHP_SELF"]
Edit parameters.
dol_get_last_day($year, $month=12, $gm=false)
Return GMT time for last day of a month or year.
Definition: date.lib.php:498
print
Draft customers invoices.
Definition: index.php:89
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
Class to manage generation of HTML components for accounting management.
Class to manage accounting accounts.
Class to manage invoices.
llxFooter()
Empty footer.
Definition: wrapper.php:59
img_delete($titlealt= 'default', $other= 'class="pictodelete"', $morecss= '')
Show delete logo.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin= '1', $morecss= '', $textfordropdown= '')
Show information for admin users or standard users.