dolibarr  16.0.1
list.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2013-2016 Olivier Geffroy <jeff@jeffinfo.com>
3  * Copyright (C) 2013-2016 Florian Henry <florian.henry@open-concept.pro>
4  * Copyright (C) 2013-2022 Alexandre Spangaro <aspangaro@open-dsi.fr>
5  * Copyright (C) 2016-2017 Laurent Destailleur <eldy@users.sourceforge.net>
6  * Copyright (C) 2018-2021 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 require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountancyexport.class.php';
30 require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
31 require_once DOL_DOCUMENT_ROOT.'/accountancy/class/lettering.class.php';
32 require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php';
33 require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.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/class/html.formaccounting.class.php';
37 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
38 require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
39 
40 // Load translation files required by the page
41 $langs->loadLangs(array("accountancy", "compta"));
42 
43 $socid = GETPOST('socid', 'int');
44 
45 $action = GETPOST('action', 'aZ09');
46 $massaction = GETPOST('massaction', 'alpha');
47 $confirm = GETPOST('confirm', 'alpha');
48 $toselect = GETPOST('toselect', 'array');
49 $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'bookkeepinglist';
50 $search_mvt_num = GETPOST('search_mvt_num', 'int');
51 $search_doc_type = GETPOST("search_doc_type", 'alpha');
52 $search_doc_ref = GETPOST("search_doc_ref", 'alpha');
53 $search_date_startyear = GETPOST('search_date_startyear', 'int');
54 $search_date_startmonth = GETPOST('search_date_startmonth', 'int');
55 $search_date_startday = GETPOST('search_date_startday', 'int');
56 $search_date_endyear = GETPOST('search_date_endyear', 'int');
57 $search_date_endmonth = GETPOST('search_date_endmonth', 'int');
58 $search_date_endday = GETPOST('search_date_endday', 'int');
59 $search_date_start = dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear);
60 $search_date_end = dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear);
61 $search_doc_date = dol_mktime(0, 0, 0, GETPOST('doc_datemonth', 'int'), GETPOST('doc_dateday', 'int'), GETPOST('doc_dateyear', 'int'));
62 $search_date_creation_startyear = GETPOST('search_date_creation_startyear', 'int');
63 $search_date_creation_startmonth = GETPOST('search_date_creation_startmonth', 'int');
64 $search_date_creation_startday = GETPOST('search_date_creation_startday', 'int');
65 $search_date_creation_endyear = GETPOST('search_date_creation_endyear', 'int');
66 $search_date_creation_endmonth = GETPOST('search_date_creation_endmonth', 'int');
67 $search_date_creation_endday = GETPOST('search_date_creation_endday', 'int');
68 $search_date_creation_start = dol_mktime(0, 0, 0, $search_date_creation_startmonth, $search_date_creation_startday, $search_date_creation_startyear);
69 $search_date_creation_end = dol_mktime(23, 59, 59, $search_date_creation_endmonth, $search_date_creation_endday, $search_date_creation_endyear);
70 $search_date_modification_startyear = GETPOST('search_date_modification_startyear', 'int');
71 $search_date_modification_startmonth = GETPOST('search_date_modification_startmonth', 'int');
72 $search_date_modification_startday = GETPOST('search_date_modification_startday', 'int');
73 $search_date_modification_endyear = GETPOST('search_date_modification_endyear', 'int');
74 $search_date_modification_endmonth = GETPOST('search_date_modification_endmonth', 'int');
75 $search_date_modification_endday = GETPOST('search_date_modification_endday', 'int');
76 $search_date_modification_start = dol_mktime(0, 0, 0, $search_date_modification_startmonth, $search_date_modification_startday, $search_date_modification_startyear);
77 $search_date_modification_end = dol_mktime(23, 59, 59, $search_date_modification_endmonth, $search_date_modification_endday, $search_date_modification_endyear);
78 $search_date_export_startyear = GETPOST('search_date_export_startyear', 'int');
79 $search_date_export_startmonth = GETPOST('search_date_export_startmonth', 'int');
80 $search_date_export_startday = GETPOST('search_date_export_startday', 'int');
81 $search_date_export_endyear = GETPOST('search_date_export_endyear', 'int');
82 $search_date_export_endmonth = GETPOST('search_date_export_endmonth', 'int');
83 $search_date_export_endday = GETPOST('search_date_export_endday', 'int');
84 $search_date_export_start = dol_mktime(0, 0, 0, $search_date_export_startmonth, $search_date_export_startday, $search_date_export_startyear);
85 $search_date_export_end = dol_mktime(23, 59, 59, $search_date_export_endmonth, $search_date_export_endday, $search_date_export_endyear);
86 $search_date_validation_startyear = GETPOST('search_date_validation_startyear', 'int');
87 $search_date_validation_startmonth = GETPOST('search_date_validation_startmonth', 'int');
88 $search_date_validation_startday = GETPOST('search_date_validation_startday', 'int');
89 $search_date_validation_endyear = GETPOST('search_date_validation_endyear', 'int');
90 $search_date_validation_endmonth = GETPOST('search_date_validation_endmonth', 'int');
91 $search_date_validation_endday = GETPOST('search_date_validation_endday', 'int');
92 $search_date_validation_start = dol_mktime(0, 0, 0, $search_date_validation_startmonth, $search_date_validation_startday, $search_date_validation_startyear);
93 $search_date_validation_end = dol_mktime(23, 59, 59, $search_date_validation_endmonth, $search_date_validation_endday, $search_date_validation_endyear);
94 $search_import_key = GETPOST("search_import_key", 'alpha');
95 
96 //var_dump($search_date_start);exit;
97 if (GETPOST("button_delmvt_x") || GETPOST("button_delmvt.x") || GETPOST("button_delmvt")) {
98  $action = 'delbookkeepingyear';
99 }
100 if (GETPOST("button_export_file_x") || GETPOST("button_export_file.x") || GETPOST("button_export_file")) {
101  $action = 'export_file';
102 }
103 
104 $search_accountancy_code = GETPOST("search_accountancy_code");
105 $search_accountancy_code_start = GETPOST('search_accountancy_code_start', 'alpha');
106 if ($search_accountancy_code_start == - 1) {
107  $search_accountancy_code_start = '';
108 }
109 $search_accountancy_code_end = GETPOST('search_accountancy_code_end', 'alpha');
110 if ($search_accountancy_code_end == - 1) {
111  $search_accountancy_code_end = '';
112 }
113 
114 $search_accountancy_aux_code = GETPOST("search_accountancy_aux_code", 'alpha');
115 $search_accountancy_aux_code_start = GETPOST('search_accountancy_aux_code_start', 'alpha');
116 if ($search_accountancy_aux_code_start == - 1) {
117  $search_accountancy_aux_code_start = '';
118 }
119 $search_accountancy_aux_code_end = GETPOST('search_accountancy_aux_code_end', 'alpha');
120 if ($search_accountancy_aux_code_end == - 1) {
121  $search_accountancy_aux_code_end = '';
122 }
123 $search_mvt_label = GETPOST('search_mvt_label', 'alpha');
124 $search_direction = GETPOST('search_direction', 'alpha');
125 $search_debit = GETPOST('search_debit', 'alpha');
126 $search_credit = GETPOST('search_credit', 'alpha');
127 $search_ledger_code = GETPOST('search_ledger_code', 'array');
128 $search_lettering_code = GETPOST('search_lettering_code', 'alpha');
129 $search_not_reconciled = GETPOST('search_not_reconciled', 'alpha');
130 
131 // Load variable for pagination
132 $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : (empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION) ? $conf->liste_limit : $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION);
133 $sortfield = GETPOST('sortfield', 'aZ09comma');
134 $sortorder = GETPOST('sortorder', 'aZ09comma');
135 $optioncss = GETPOST('optioncss', 'alpha');
136 $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
137 if (empty($page) || $page < 0) {
138  $page = 0;
139 }
140 $offset = $limit * $page;
141 $pageprev = $page - 1;
142 $pagenext = $page + 1;
143 if ($sortorder == "") {
144  $sortorder = "ASC";
145 }
146 if ($sortfield == "") {
147  $sortfield = "t.piece_num,t.rowid";
148 }
149 
150 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
151 $object = new BookKeeping($db);
152 $hookmanager->initHooks(array('bookkeepinglist'));
153 
154 $formaccounting = new FormAccounting($db);
155 $form = new Form($db);
156 
157 if (!in_array($action, array('export_file', 'delmouv', 'delmouvconfirm')) && !GETPOSTISSET('begin') && !GETPOSTISSET('formfilteraction') && GETPOST('page', 'int') == '' && !GETPOST('noreset', 'int') && $user->rights->accounting->mouvements->export) {
158  if (empty($search_date_start) && empty($search_date_end) && !GETPOSTISSET('restore_lastsearch_values') && !GETPOST('search_accountancy_code_start')) {
159  $query = "SELECT date_start, date_end from ".MAIN_DB_PREFIX."accounting_fiscalyear ";
160  $query .= " where date_start < '".$db->idate(dol_now())."' and date_end > '".$db->idate(dol_now())."' limit 1";
161  $res = $db->query($query);
162 
163  if ($res->num_rows > 0) {
164  $fiscalYear = $db->fetch_object($res);
165  $search_date_start = strtotime($fiscalYear->date_start);
166  $search_date_end = strtotime($fiscalYear->date_end);
167  } else {
168  $month_start = ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1);
169  $year_start = dol_print_date(dol_now(), '%Y');
170  if (dol_print_date(dol_now(), '%m') < $month_start) {
171  $year_start--; // If current month is lower that starting fiscal month, we start last year
172  }
173  $year_end = $year_start + 1;
174  $month_end = $month_start - 1;
175  if ($month_end < 1) {
176  $month_end = 12;
177  $year_end--;
178  }
179  $search_date_start = dol_mktime(0, 0, 0, $month_start, 1, $year_start);
180  $search_date_end = dol_get_last_day($year_end, $month_end);
181  }
182  }
183 }
184 
185 
186 $arrayfields = array(
187  't.piece_num'=>array('label'=>$langs->trans("TransactionNumShort"), 'checked'=>1),
188  't.code_journal'=>array('label'=>$langs->trans("Codejournal"), 'checked'=>1),
189  't.doc_date'=>array('label'=>$langs->trans("Docdate"), 'checked'=>1),
190  't.doc_ref'=>array('label'=>$langs->trans("Piece"), 'checked'=>1),
191  't.numero_compte'=>array('label'=>$langs->trans("AccountAccountingShort"), 'checked'=>1),
192  't.subledger_account'=>array('label'=>$langs->trans("SubledgerAccount"), 'checked'=>1),
193  't.label_operation'=>array('label'=>$langs->trans("Label"), 'checked'=>1),
194  't.debit'=>array('label'=>$langs->trans("Debit"), 'checked'=>1),
195  't.credit'=>array('label'=>$langs->trans("Credit"), 'checked'=>1),
196  't.lettering_code'=>array('label'=>$langs->trans("LetteringCode"), 'checked'=>1),
197  't.date_creation'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0),
198  't.tms'=>array('label'=>$langs->trans("DateModification"), 'checked'=>0),
199  't.date_export'=>array('label'=>$langs->trans("DateExport"), 'checked'=>1),
200  't.date_validated'=>array('label'=>$langs->trans("DateValidationAndLock"), 'checked'=>1, 'enabled'=>!getDolGlobalString("ACCOUNTANCY_DISABLE_CLOSURE_LINE_BY_LINE")),
201  't.import_key'=>array('label'=>$langs->trans("ImportId"), 'checked'=>0, 'position'=>1100),
202 );
203 
204 if (empty($conf->global->ACCOUNTING_ENABLE_LETTERING)) {
205  unset($arrayfields['t.lettering_code']);
206 }
207 
208 $accountancyexport = new AccountancyExport($db);
209 $listofformat = $accountancyexport->getType();
210 $formatexportset = getDolGlobalString('ACCOUNTING_EXPORT_MODELCSV');
211 if (empty($listofformat[$formatexportset])) {
212  $formatexportset = 1;
213 }
214 
215 $error = 0;
216 
217 if (!isModEnabled('accounting')) {
218  accessforbidden();
219 }
220 if ($user->socid > 0) {
221  accessforbidden();
222 }
223 if (empty($user->rights->accounting->mouvements->lire)) {
224  accessforbidden();
225 }
226 
227 
228 /*
229  * Actions
230  */
231 
232 $param = '';
233 
234 if (GETPOST('cancel', 'alpha')) {
235  $action = 'list'; $massaction = '';
236 }
237 if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'preunlettering' && $massaction != 'predeletebookkeepingwriting') {
238  $massaction = '';
239 }
240 
241 $parameters = array('socid'=>$socid);
242 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
243 if ($reshook < 0) {
244  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
245 }
246 
247 if (empty($reshook)) {
248  include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
249 
250  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
251  $search_mvt_num = '';
252  $search_doc_type = '';
253  $search_doc_ref = '';
254  $search_doc_date = '';
255  $search_accountancy_code = '';
256  $search_accountancy_code_start = '';
257  $search_accountancy_code_end = '';
258  $search_accountancy_aux_code = '';
259  $search_accountancy_aux_code_start = '';
260  $search_accountancy_aux_code_end = '';
261  $search_mvt_label = '';
262  $search_direction = '';
263  $search_ledger_code = array();
264  $search_date_startyear = '';
265  $search_date_startmonth = '';
266  $search_date_startday = '';
267  $search_date_endyear = '';
268  $search_date_endmonth = '';
269  $search_date_endday = '';
270  $search_date_start = '';
271  $search_date_end = '';
272  $search_date_creation_startyear = '';
273  $search_date_creation_startmonth = '';
274  $search_date_creation_startday = '';
275  $search_date_creation_endyear = '';
276  $search_date_creation_endmonth = '';
277  $search_date_creation_endday = '';
278  $search_date_creation_start = '';
279  $search_date_creation_end = '';
280  $search_date_modification_startyear = '';
281  $search_date_modification_startmonth = '';
282  $search_date_modification_startday = '';
283  $search_date_modification_endyear = '';
284  $search_date_modification_endmonth = '';
285  $search_date_modification_endday = '';
286  $search_date_modification_start = '';
287  $search_date_modification_end = '';
288  $search_date_export_startyear = '';
289  $search_date_export_startmonth = '';
290  $search_date_export_startday = '';
291  $search_date_export_endyear = '';
292  $search_date_export_endmonth = '';
293  $search_date_export_endday = '';
294  $search_date_export_start = '';
295  $search_date_export_end = '';
296  $search_date_validation_startyear = '';
297  $search_date_validation_startmonth = '';
298  $search_date_validation_startday = '';
299  $search_date_validation_endyear = '';
300  $search_date_validation_endmonth = '';
301  $search_date_validation_endday = '';
302  $search_date_validation_start = '';
303  $search_date_validation_end = '';
304  $search_debit = '';
305  $search_credit = '';
306  $search_lettering_code = '';
307  $search_not_reconciled = '';
308  $search_import_key = '';
309  $toselect = array();
310  }
311 
312  // Must be after the remove filter action, before the export.
313  $filter = array();
314  if (!empty($search_date_start)) {
315  $filter['t.doc_date>='] = $search_date_start;
316  $tmp = dol_getdate($search_date_start);
317  $param .= '&search_date_startmonth='.urlencode($tmp['mon']).'&search_date_startday='.urlencode($tmp['mday']).'&search_date_startyear='.urlencode($tmp['year']);
318  }
319  if (!empty($search_date_end)) {
320  $filter['t.doc_date<='] = $search_date_end;
321  $tmp = dol_getdate($search_date_end);
322  $param .= '&search_date_endmonth='.urlencode($tmp['mon']).'&search_date_endday='.urlencode($tmp['mday']).'&search_date_endyear='.urlencode($tmp['year']);
323  }
324  if (!empty($search_doc_date)) {
325  $filter['t.doc_date'] = $search_doc_date;
326  $tmp = dol_getdate($search_doc_date);
327  $param .= '&doc_datemonth='.urlencode($tmp['mon']).'&doc_dateday='.urlencode($tmp['mday']).'&doc_dateyear='.urlencode($tmp['year']);
328  }
329  if (!empty($search_doc_type)) {
330  $filter['t.doc_type'] = $search_doc_type;
331  $param .= '&search_doc_type='.urlencode($search_doc_type);
332  }
333  if (!empty($search_doc_ref)) {
334  $filter['t.doc_ref'] = $search_doc_ref;
335  $param .= '&search_doc_ref='.urlencode($search_doc_ref);
336  }
337  if (!empty($search_accountancy_code)) {
338  $filter['t.numero_compte'] = $search_accountancy_code;
339  $param .= '&search_accountancy_code='.urlencode($search_accountancy_code);
340  }
341  if (!empty($search_accountancy_code_start)) {
342  $filter['t.numero_compte>='] = $search_accountancy_code_start;
343  $param .= '&search_accountancy_code_start='.urlencode($search_accountancy_code_start);
344  }
345  if (!empty($search_accountancy_code_end)) {
346  $filter['t.numero_compte<='] = $search_accountancy_code_end;
347  $param .= '&search_accountancy_code_end='.urlencode($search_accountancy_code_end);
348  }
349  if (!empty($search_accountancy_aux_code_start)) {
350  $filter['t.subledger_account>='] = $search_accountancy_aux_code_start;
351  $param .= '&search_accountancy_aux_code_start='.urlencode($search_accountancy_aux_code_start);
352  }
353  if (!empty($search_accountancy_aux_code_end)) {
354  $filter['t.subledger_account<='] = $search_accountancy_aux_code_end;
355  $param .= '&search_accountancy_aux_code_end='.urlencode($search_accountancy_aux_code_end);
356  }
357  if (!empty($search_mvt_label)) {
358  $filter['t.label_operation'] = $search_mvt_label;
359  $param .= '&search_mvt_label='.urlencode($search_mvt_label);
360  }
361  if (!empty($search_direction)) {
362  $filter['t.sens'] = $search_direction;
363  $param .= '&search_direction='.urlencode($search_direction);
364  }
365  if (!empty($search_ledger_code)) {
366  $filter['t.code_journal'] = $search_ledger_code;
367  foreach ($search_ledger_code as $code) {
368  $param .= '&search_ledger_code[]='.urlencode($code);
369  }
370  }
371  if (!empty($search_mvt_num)) {
372  $filter['t.piece_num'] = $search_mvt_num;
373  $param .= '&search_mvt_num='.urlencode($search_mvt_num);
374  }
375  if (!empty($search_date_creation_start)) {
376  $filter['t.date_creation>='] = $search_date_creation_start;
377  $tmp = dol_getdate($search_date_creation_start);
378  $param .= '&search_date_creation_startmonth='.urlencode($tmp['mon']).'&search_date_creation_startday='.urlencode($tmp['mday']).'&search_date_creation_startyear='.urlencode($tmp['year']);
379  }
380  if (!empty($search_date_creation_end)) {
381  $filter['t.date_creation<='] = $search_date_creation_end;
382  $tmp = dol_getdate($search_date_creation_end);
383  $param .= '&search_date_creation_endmonth='.urlencode($tmp['mon']).'&search_date_creation_endday='.urlencode($tmp['mday']).'&search_date_creation_endyear='.urlencode($tmp['year']);
384  }
385  if (!empty($search_date_modification_start)) {
386  $filter['t.tms>='] = $search_date_modification_start;
387  $tmp = dol_getdate($search_date_modification_start);
388  $param .= '&search_date_modification_startmonth='.urlencode($tmp['mon']).'&search_date_modification_startday='.urlencode($tmp['mday']).'&search_date_modification_startyear='.urlencode($tmp['year']);
389  }
390  if (!empty($search_date_modification_end)) {
391  $filter['t.tms<='] = $search_date_modification_end;
392  $tmp = dol_getdate($search_date_modification_end);
393  $param .= '&search_date_modification_endmonth='.urlencode($tmp['mon']).'&search_date_modification_endday='.urlencode($tmp['mday']).'&search_date_modification_endyear='.urlencode($tmp['year']);
394  }
395  if (!empty($search_date_export_start)) {
396  $filter['t.date_export>='] = $search_date_export_start;
397  $tmp = dol_getdate($search_date_export_start);
398  $param .= '&search_date_export_startmonth='.urlencode($tmp['mon']).'&search_date_export_startday='.urlencode($tmp['mday']).'&search_date_export_startyear='.urlencode($tmp['year']);
399  }
400  if (!empty($search_date_export_end)) {
401  $filter['t.date_export<='] = $search_date_export_end;
402  $tmp = dol_getdate($search_date_export_end);
403  $param .= '&search_date_export_endmonth='.urlencode($tmp['mon']).'&search_date_export_endday='.urlencode($tmp['mday']).'&search_date_export_endyear='.urlencode($tmp['year']);
404  }
405  if (!empty($search_date_validation_start)) {
406  $filter['t.date_validated>='] = $search_date_validation_start;
407  $tmp = dol_getdate($search_date_validation_start);
408  $param .= '&search_date_validation_startmonth='.urlencode($tmp['mon']).'&search_date_validation_startday='.urlencode($tmp['mday']).'&search_date_validation_startyear='.urlencode($tmp['year']);
409  }
410  if (!empty($search_date_validation_end)) {
411  $filter['t.date_validated<='] = $search_date_validation_end;
412  $tmp = dol_getdate($search_date_validation_end);
413  $param .= '&search_date_validation_endmonth='.urlencode($tmp['mon']).'&search_date_validation_endday='.urlencode($tmp['mday']).'&search_date_validation_endyear='.urlencode($tmp['year']);
414  }
415  if (!empty($search_debit)) {
416  $filter['t.debit'] = $search_debit;
417  $param .= '&search_debit='.urlencode($search_debit);
418  }
419  if (!empty($search_credit)) {
420  $filter['t.credit'] = $search_credit;
421  $param .= '&search_credit='.urlencode($search_credit);
422  }
423  if (!empty($search_lettering_code)) {
424  $filter['t.lettering_code'] = $search_lettering_code;
425  $param .= '&search_lettering_code='.urlencode($search_lettering_code);
426  }
427  if (!empty($search_not_reconciled)) {
428  $filter['t.reconciled_option'] = $search_not_reconciled;
429  $param .= '&search_not_reconciled='.urlencode($search_not_reconciled);
430  }
431  if (!empty($search_import_key)) {
432  $filter['t.import_key'] = $search_import_key;
433  $param .= '&search_import_key='.urlencode($search_import_key);
434  }
435 
436  //if ($action == 'delbookkeepingyearconfirm' && $user->rights->accounting->mouvements->supprimer_tous) {
437  // $delmonth = GETPOST('delmonth', 'int');
438  // $delyear = GETPOST('delyear', 'int');
439  // if ($delyear == -1) {
440  // $delyear = 0;
441  // }
442  // $deljournal = GETPOST('deljournal', 'alpha');
443  // if ($deljournal == -1) {
444  // $deljournal = 0;
445  // }
446  //
447  // if (!empty($delmonth) || !empty($delyear) || !empty($deljournal)) {
448  // $result = $object->deleteByYearAndJournal($delyear, $deljournal, '', ($delmonth > 0 ? $delmonth : 0));
449  // if ($result < 0) {
450  // setEventMessages($object->error, $object->errors, 'errors');
451  // } else {
452  // setEventMessages("RecordDeleted", null, 'mesgs');
453  // }
454  //
455  // // Make a redirect to avoid to launch the delete later after a back button
456  // header("Location: list.php".($param ? '?'.$param : ''));
457  // exit;
458  // } else {
459  // setEventMessages("NoRecordDeleted", null, 'warnings');
460  // }
461  //}
462  if ($action == 'setreexport') {
463  $setreexport = GETPOST('value', 'int');
464  if (!dolibarr_set_const($db, "ACCOUNTING_REEXPORT", $setreexport, 'yesno', 0, '', $conf->entity)) {
465  $error++;
466  }
467 
468  if (!$error) {
469  if ($conf->global->ACCOUNTING_REEXPORT == 1) {
470  setEventMessages($langs->trans("ExportOfPiecesAlreadyExportedIsEnable"), null, 'mesgs');
471  } else {
472  setEventMessages($langs->trans("ExportOfPiecesAlreadyExportedIsDisable"), null, 'mesgs');
473  }
474  } else {
475  setEventMessages($langs->trans("Error"), null, 'errors');
476  }
477  }
478 
479  // Mass actions
480  $objectclass = 'Bookkeeping';
481  $objectlabel = 'Bookkeeping';
482  $permissiontoread = $user->rights->societe->lire;
483  $permissiontodelete = $user->rights->societe->supprimer;
484  $permissiontoadd = $user->rights->societe->creer;
485  $uploaddir = $conf->societe->dir_output;
486  include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
487 
488  if (!$error && $action == 'deletebookkeepingwriting' && $confirm == "yes" && $user->rights->accounting->mouvements->supprimer) {
489  $nbok = 0;
490  foreach ($toselect as $toselectid) {
491  $result = $object->fetch($toselectid);
492  if ($result > 0 && (!isset($object->date_validation) || $object->date_validation === '')) {
493  $result = $object->deleteMvtNum($object->piece_num);
494  if ($result > 0) {
495  $nbok++;
496  } else {
497  setEventMessages($object->error, $object->errors, 'errors');
498  $error++;
499  break;
500  }
501  } elseif ($result < 0) {
502  setEventMessages($object->error, $object->errors, 'errors');
503  $error++;
504  break;
505  }
506  }
507 
508  // Message for elements well deleted
509  if ($nbok > 1) {
510  setEventMessages($langs->trans("RecordsDeleted", $nbok), null, 'mesgs');
511  } elseif ($nbok > 0) {
512  setEventMessages($langs->trans("RecordDeleted", $nbok), null, 'mesgs');
513  } elseif (!$error) {
514  setEventMessages($langs->trans("NoRecordDeleted"), null, 'mesgs');
515  }
516 
517  if (!$error) {
518  header("Location: ".$_SERVER["PHP_SELF"]."?noreset=1".($param ? '&'.$param : ''));
519  exit;
520  }
521  }
522 
523  // others mass actions
524  if (!$error && getDolGlobalInt('ACCOUNTING_ENABLE_LETTERING') && $user->rights->accounting->mouvements->creer) {
525  if ($massaction == 'lettering') {
526  $lettering = new Lettering($db);
527  $nb_lettering = $lettering->bookkeepingLetteringAll($toselect);
528  if ($nb_lettering < 0) {
529  setEventMessages('', $lettering->errors, 'errors');
530  $error++;
531  $nb_lettering = max(0, abs($nb_lettering) - 2);
532  } elseif ($nb_lettering == 0) {
533  $nb_lettering = 0;
534  setEventMessages($langs->trans('AccountancyNoLetteringModified'), array(), 'mesgs');
535  }
536  if ($nb_lettering == 1) {
537  setEventMessages($langs->trans('AccountancyOneLetteringModifiedSuccessfully'), array(), 'mesgs');
538  } elseif ($nb_lettering > 1) {
539  setEventMessages($langs->trans('AccountancyLetteringModifiedSuccessfully', $nb_lettering), array(), 'mesgs');
540  }
541 
542  if (!$error) {
543  header('Location: ' . $_SERVER['PHP_SELF'] . '?noreset=1' . $param);
544  exit();
545  }
546  } elseif ($action == 'unlettering' && $confirm == "yes") {
547  $lettering = new Lettering($db);
548  $nb_lettering = $lettering->bookkeepingLetteringAll($toselect, true);
549  if ($nb_lettering < 0) {
550  setEventMessages('', $lettering->errors, 'errors');
551  $error++;
552  $nb_lettering = max(0, abs($nb_lettering) - 2);
553  } elseif ($nb_lettering == 0) {
554  $nb_lettering = 0;
555  setEventMessages($langs->trans('AccountancyNoUnletteringModified'), array(), 'mesgs');
556  }
557  if ($nb_lettering == 1) {
558  setEventMessages($langs->trans('AccountancyOneUnletteringModifiedSuccessfully'), array(), 'mesgs');
559  } elseif ($nb_lettering > 1) {
560  setEventMessages($langs->trans('AccountancyUnletteringModifiedSuccessfully', $nb_lettering), array(), 'mesgs');
561  }
562 
563  if (!$error) {
564  header('Location: ' . $_SERVER['PHP_SELF'] . '?noreset=1' . $param);
565  exit();
566  }
567  }
568  }
569 }
570 
571 // Build and execute select (used by page and export action)
572 // must de set after the action that set $filter
573 // --------------------------------------------------------------------
574 
575 $sql = 'SELECT';
576 $sql .= ' t.rowid,';
577 $sql .= " t.doc_date,";
578 $sql .= " t.doc_type,";
579 $sql .= " t.doc_ref,";
580 $sql .= " t.fk_doc,";
581 $sql .= " t.fk_docdet,";
582 $sql .= " t.thirdparty_code,";
583 $sql .= " t.subledger_account,";
584 $sql .= " t.subledger_label,";
585 $sql .= " t.numero_compte,";
586 $sql .= " t.label_compte,";
587 $sql .= " t.label_operation,";
588 $sql .= " t.debit,";
589 $sql .= " t.credit,";
590 $sql .= " t.lettering_code,";
591 $sql .= " t.montant as amount,";
592 $sql .= " t.sens,";
593 $sql .= " t.fk_user_author,";
594 $sql .= " t.import_key,";
595 $sql .= " t.code_journal,";
596 $sql .= " t.journal_label,";
597 $sql .= " t.piece_num,";
598 $sql .= " t.date_creation,";
599 $sql .= " t.tms as date_modification,";
600 $sql .= " t.date_export,";
601 $sql .= " t.date_validated as date_validation,";
602 $sql .= " t.import_key";
603 $sql .= ' FROM '.MAIN_DB_PREFIX.$object->table_element.' as t';
604 // Manage filter
605 $sqlwhere = array();
606 if (count($filter) > 0) {
607  foreach ($filter as $key => $value) {
608  if ($key == 't.doc_date') {
609  $sqlwhere[] = $key."='".$db->idate($value)."'";
610  } elseif ($key == 't.doc_date>=' || $key == 't.doc_date<=') {
611  $sqlwhere[] = $key."'".$db->idate($value)."'";
612  } elseif ($key == 't.numero_compte>=' || $key == 't.numero_compte<=' || $key == 't.subledger_account>=' || $key == 't.subledger_account<=') {
613  $sqlwhere[] = $key."'".$db->escape($value)."'";
614  } elseif ($key == 't.fk_doc' || $key == 't.fk_docdet' || $key == 't.piece_num') {
615  $sqlwhere[] = $key.'='.((int) $value);
616  } elseif ($key == 't.subledger_account' || $key == 't.numero_compte') {
617  $sqlwhere[] = $key." LIKE '".$db->escape($value)."%'";
618  } elseif ($key == 't.subledger_account') {
619  $sqlwhere[] = natural_search($key, $value, 0, 1);
620  } elseif ($key == 't.date_creation>=' || $key == 't.date_creation<=') {
621  $sqlwhere[] = $key."'".$db->idate($value)."'";
622  } elseif ($key == 't.tms>=' || $key == 't.tms<=') {
623  $sqlwhere[] = $key."'".$db->idate($value)."'";
624  } elseif ($key == 't.date_export>=' || $key == 't.date_export<=') {
625  $sqlwhere[] = $key."'".$db->idate($value)."'";
626  } elseif ($key == 't.date_validated>=' || $key == 't.date_validated<=') {
627  $sqlwhere[] = $key."'".$db->idate($value)."'";
628  } elseif ($key == 't.credit' || $key == 't.debit') {
629  $sqlwhere[] = natural_search($key, $value, 1, 1);
630  } elseif ($key == 't.reconciled_option') {
631  $sqlwhere[] = 't.lettering_code IS NULL';
632  } elseif ($key == 't.code_journal' && !empty($value)) {
633  $sqlwhere[] = natural_search("t.code_journal", join(',', $value), 3, 1);
634  } else {
635  $sqlwhere[] = natural_search($key, $value, 0, 1);
636  }
637  }
638 }
639 $sql .= ' WHERE t.entity IN ('.getEntity('accountancy').')';
640 if (empty($conf->global->ACCOUNTING_REEXPORT)) {
641  $sql .= " AND t.date_export IS NULL";
642 }
643 if (count($sqlwhere) > 0) {
644  $sql .= ' AND '.implode(' AND ', $sqlwhere);
645 }
646 if (!empty($sortfield)) {
647  $sql .= $db->order($sortfield, $sortorder);
648 }
649 //print $sql;
650 
651 
652 // Export into a file with format defined into setup (FEC, CSV, ...)
653 // Must be after definition of $sql
654 if ($action == 'export_fileconfirm' && $user->rights->accounting->mouvements->export) {
655  // TODO Replace the fetchAll to get all ->line followed by call to ->export(). It consumew too much memory on large export. Replace this with the query($sql) and loop on each line to export them.
656  $result = $object->fetchAll($sortorder, $sortfield, 0, 0, $filter, 'AND', (empty($conf->global->ACCOUNTING_REEXPORT) ? 0 : 1));
657 
658  if ($result < 0) {
659  setEventMessages($object->error, $object->errors, 'errors');
660  } else {
661  // Export files
662  $accountancyexport = new AccountancyExport($db);
663  $accountancyexport->export($object->lines, $formatexportset);
664 
665  $notifiedexportdate = GETPOST('notifiedexportdate', 'alpha');
666  $notifiedvalidationdate = GETPOST('notifiedvalidationdate', 'alpha');
667 
668  if (!empty($accountancyexport->errors)) {
669  setEventMessages('', $accountancyexport->errors, 'errors');
670  } elseif (!empty($notifiedexportdate) || !empty($notifiedvalidationdate)) {
671  // Specify as export : update field date_export or date_validated
672  $error = 0;
673  $db->begin();
674 
675  if (is_array($object->lines)) {
676  foreach ($object->lines as $movement) {
677  $now = dol_now();
678 
679  $sql = " UPDATE ".MAIN_DB_PREFIX."accounting_bookkeeping";
680  $sql .= " SET";
681  if (!empty($notifiedexportdate) && !empty($notifiedvalidationdate)) {
682  $sql .= " date_export = '".$db->idate($now)."'";
683  $sql .= ", date_validated = '".$db->idate($now)."'";
684  } elseif (!empty($notifiedexportdate)) {
685  $sql .= " date_export = '".$db->idate($now)."'";
686  } elseif (!empty($notifiedvalidationdate)) {
687  $sql .= " date_validated = '".$db->idate($now)."'";
688  }
689  $sql .= " WHERE rowid = ".((int) $movement->id);
690 
691  dol_syslog("/accountancy/bookkeeping/list.php Function export_file Specify movements as exported", LOG_DEBUG);
692 
693  $result = $db->query($sql);
694  if (!$result) {
695  $error++;
696  break;
697  }
698  }
699  }
700 
701  if (!$error) {
702  $db->commit();
703  // setEventMessages($langs->trans("AllExportedMovementsWereRecordedAsExportedOrValidated"), null, 'mesgs');
704  } else {
705  $error++;
706  $db->rollback();
707  setEventMessages($langs->trans("NotAllExportedMovementsCouldBeRecordedAsExportedOrValidated"), null, 'errors');
708  }
709  }
710  exit;
711  }
712 }
713 
714 
715 /*
716  * View
717  */
718 
719 $formother = new FormOther($db);
720 $formfile = new FormFile($db);
721 
722 $title_page = $langs->trans("Operations").' - '.$langs->trans("Journals");
723 
724 // Count total nb of records
725 $nbtotalofrecords = '';
726 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
727  $resql = $db->query($sql);
728  $nbtotalofrecords = $db->num_rows($resql);
729  if (($page * $limit) > $nbtotalofrecords) { // if total of record found is smaller than page * limit, goto and load page 0
730  $page = 0;
731  $offset = 0;
732  }
733 }
734 // if total of record found is smaller than limit, no need to do paging and to restart another select with limits set.
735 if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords) {
736  $num = $nbtotalofrecords;
737 } else {
738  $sql .= $db->plimit($limit + 1, $offset);
739 
740  $resql = $db->query($sql);
741  if (!$resql) {
742  dol_print_error($db);
743  exit;
744  }
745 
746  $num = $db->num_rows($resql);
747 }
748 
749 $arrayofselected = is_array($toselect) ? $toselect : array();
750 
751 // Output page
752 // --------------------------------------------------------------------
753 
754 llxHeader('', $title_page);
755 
756 $formconfirm = '';
757 
758 if ($action == 'export_file') {
759  $form_question = array();
760 
761  // If 1 or not set, we check by default.
762  $checked = (!isset($conf->global->ACCOUNTING_DEFAULT_NOT_NOTIFIED_EXPORT_DATE) || !empty($conf->global->ACCOUNTING_DEFAULT_NOT_NOTIFIED_EXPORT_DATE));
763  $form_question['notifiedexportdate'] = array(
764  'name' => 'notifiedexportdate',
765  'type' => 'checkbox',
766  'label' => $langs->trans('NotifiedExportDate'),
767  'value' => (!empty($conf->global->ACCOUNTING_DEFAULT_NOT_NOTIFIED_EXPORT_DATE) ? 'false' : 'true'),
768  );
769 
770  $form_question['separator'] = array('name'=>'separator', 'type'=>'separator');
771 
772  if (!getDolGlobalString("ACCOUNTANCY_DISABLE_CLOSURE_LINE_BY_LINE")) {
773  // If 0 or not set, we NOT check by default.
774  $checked = (isset($conf->global->ACCOUNTING_DEFAULT_NOT_NOTIFIED_VALIDATION_DATE) || !empty($conf->global->ACCOUNTING_DEFAULT_NOT_NOTIFIED_VALIDATION_DATE));
775  $form_question['notifiedvalidationdate'] = array(
776  'name' => 'notifiedvalidationdate',
777  'type' => 'checkbox',
778  'label' => $langs->trans('NotifiedValidationDate', $langs->transnoentitiesnoconv("MenuAccountancyClosure")),
779  'value' => $checked,
780  );
781 
782  $form_question['separator2'] = array('name'=>'separator2', 'type'=>'separator');
783  }
784 
785  $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?'.$param, $langs->trans("ExportFilteredList").' ('.$listofformat[$formatexportset].')', $langs->trans('ConfirmExportFile'), 'export_fileconfirm', $form_question, '', 1, 300, 600);
786 }
787 
788 //if ($action == 'delbookkeepingyear') {
789 // $form_question = array();
790 // $delyear = GETPOST('delyear', 'int');
791 // $deljournal = GETPOST('deljournal', 'alpha');
792 //
793 // if (empty($delyear)) {
794 // $delyear = dol_print_date(dol_now(), '%Y');
795 // }
796 // $month_array = array();
797 // for ($i = 1; $i <= 12; $i++) {
798 // $month_array[$i] = $langs->trans("Month".sprintf("%02d", $i));
799 // }
800 // $year_array = $formaccounting->selectyear_accountancy_bookkepping($delyear, 'delyear', 0, 'array');
801 // $journal_array = $formaccounting->select_journal($deljournal, 'deljournal', '', 1, 1, 1, '', 0, 1);
802 //
803 // $form_question['delmonth'] = array(
804 // 'name' => 'delmonth',
805 // 'type' => 'select',
806 // 'label' => $langs->trans('DelMonth'),
807 // 'values' => $month_array,
808 // 'morecss' => 'minwidth150',
809 // 'default' => ''
810 // );
811 // $form_question['delyear'] = array(
812 // 'name' => 'delyear',
813 // 'type' => 'select',
814 // 'label' => $langs->trans('DelYear'),
815 // 'values' => $year_array,
816 // 'default' => $delyear
817 // );
818 // $form_question['deljournal'] = array(
819 // 'name' => 'deljournal',
820 // 'type' => 'other', // We don't use select here, the journal_array is already a select html component
821 // 'label' => $langs->trans('DelJournal'),
822 // 'value' => $journal_array,
823 // 'default' => $deljournal
824 // );
825 //
826 // $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?'.$param, $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvt', $langs->transnoentitiesnoconv("RegistrationInAccounting")), 'delbookkeepingyearconfirm', $form_question, '', 1, 320);
827 //}
828 
829 // Print form confirm
830 print $formconfirm;
831 
832 //$param=''; param started before
833 if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
834  $param .= '&contextpage='.urlencode($contextpage);
835 }
836 if ($limit > 0 && $limit != $conf->liste_limit) {
837  $param .= '&limit='.urlencode($limit);
838 }
839 
840 // List of mass actions available
841 $arrayofmassactions = array();
842 /*
843 if (getDolGlobalInt('ACCOUNTING_ENABLE_LETTERING') && $user->rights->accounting->mouvements->creer) {
844  $arrayofmassactions['lettering'] = img_picto('', 'check', 'class="pictofixedwidth"') . $langs->trans('Lettering');
845  $arrayofmassactions['preunlettering'] = img_picto('', 'uncheck', 'class="pictofixedwidth"') . $langs->trans('Unlettering');
846 }
847 */
848 if ($user->rights->accounting->mouvements->supprimer) {
849  $arrayofmassactions['predeletebookkeepingwriting'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
850 }
851 if (GETPOST('nomassaction', 'int') || in_array($massaction, array('preunlettering', 'predeletebookkeepingwriting'))) {
852  $arrayofmassactions = array();
853 }
854 $massactionbutton = $form->selectMassAction($massaction, $arrayofmassactions);
855 
856 print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
857 print '<input type="hidden" name="token" value="'.newToken().'">';
858 print '<input type="hidden" name="action" value="list">';
859 if ($optioncss != '') {
860  print '<input type="hidden" name="optioncss" value="'.urlencode($optioncss).'">';
861 }
862 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
863 print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
864 print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
865 print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
866 
867 if (count($filter)) {
868  $buttonLabel = $langs->trans("ExportFilteredList");
869 } else {
870  $buttonLabel = $langs->trans("ExportList");
871 }
872 
873 $parameters = array();
874 $reshook = $hookmanager->executeHooks('addMoreActionsButtonsList', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
875 if (empty($reshook)) {
876  // Button re-export
877  if (!empty($conf->global->ACCOUNTING_REEXPORT)) {
878  $newcardbutton = '<a class="valignmiddle" href="'.$_SERVER['PHP_SELF'].'?action=setreexport&token='.newToken().'&value=0'.($param ? '&'.$param : '').'">'.img_picto($langs->trans("Activated"), 'switch_on').'</a> ';
879  } else {
880  $newcardbutton = '<a class="valignmiddle" href="'.$_SERVER['PHP_SELF'].'?action=setreexport&token='.newToken().'&value=1'.($param ? '&'.$param : '').'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a> ';
881  }
882  $newcardbutton .= '<span class="valignmiddle marginrightonly">'.$langs->trans("IncludeDocsAlreadyExported").'</span>';
883 
884  if (!empty($user->rights->accounting->mouvements->export)) {
885  $newcardbutton .= dolGetButtonTitle($buttonLabel, $langs->trans("ExportFilteredList").' ('.$listofformat[$formatexportset].')', 'fa fa-file-export paddingleft', $_SERVER["PHP_SELF"].'?action=export_file'.($param ? '&'.$param : ''), $user->rights->accounting->mouvements->export);
886  }
887 
888  $newcardbutton .= dolGetButtonTitle($langs->trans('ViewFlatList'), '', 'fa fa-list paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/list.php?'.$param, '', 1, array('morecss' => 'marginleftonly btnTitleSelected'));
889  $newcardbutton .= dolGetButtonTitle($langs->trans('GroupByAccountAccounting'), '', 'fa fa-stream paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/listbyaccount.php?'.$param, '', 1, array('morecss' => 'marginleftonly'));
890  $newcardbutton .= dolGetButtonTitle($langs->trans('GroupBySubAccountAccounting'), '', 'fa fa-align-left vmirror paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/listbyaccount.php?type=sub'.$param, '', 1, array('morecss' => 'marginleftonly'));
891 
892  $url = './card.php?action=create';
893  if (!empty($socid)) {
894  $url .= '&socid='.$socid;
895  }
896  $newcardbutton .= dolGetButtonTitle($langs->trans('NewAccountingMvt'), '', 'fa fa-plus-circle paddingleft', $url, '', $user->rights->accounting->mouvements->creer);
897 }
898 
899 print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_accountancy', 0, $newcardbutton, '', $limit, 0, 0, 1);
900 
901 if ($massaction == 'preunlettering') {
902  print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmMassUnlettering"), $langs->trans("ConfirmMassUnletteringQuestion", count($toselect)), "unlettering", null, '', 0, 200, 500, 1);
903 } elseif ($massaction == 'predeletebookkeepingwriting') {
904  print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmMassDeleteBookkeepingWriting"), $langs->trans("ConfirmMassDeleteBookkeepingWritingQuestion", count($toselect)), "deletebookkeepingwriting", null, '', 0, 200, 500, 1);
905 }
906 
907 //$topicmail = "Information";
908 //$modelmail = "accountingbookkeeping";
909 //$objecttmp = new BookKeeping($db);
910 //$trackid = 'bk'.$object->id;
911 include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
912 
913 $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
914 $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
915 if ($massactionbutton && $contextpage != 'poslist') {
916  $selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
917 }
918 
919 $moreforfilter = '';
920 
921 $parameters = array();
922 $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook
923 if (empty($reshook)) {
924  $moreforfilter .= $hookmanager->resPrint;
925 } else {
926  $moreforfilter = $hookmanager->resPrint;
927 }
928 
929 print '<div class="div-table-responsive">';
930 print '<table class="tagtable liste centpercent">';
931 
932 // Filters lines
933 print '<tr class="liste_titre_filter">';
934 
935 // Movement number
936 if (!empty($arrayfields['t.piece_num']['checked'])) {
937  print '<td class="liste_titre"><input type="text" name="search_mvt_num" size="6" value="'.dol_escape_htmltag($search_mvt_num).'"></td>';
938 }
939 // Code journal
940 if (!empty($arrayfields['t.code_journal']['checked'])) {
941  print '<td class="liste_titre center">';
942  print $formaccounting->multi_select_journal($search_ledger_code, 'search_ledger_code', 0, 1, 1, 1, 'small maxwidth150');
943  print '</td>';
944 }
945 // Date document
946 if (!empty($arrayfields['t.doc_date']['checked'])) {
947  print '<td class="liste_titre center">';
948  print '<div class="nowrap">';
949  print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"));
950  print '</div>';
951  print '<div class="nowrap">';
952  print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to"));
953  print '</div>';
954  print '</td>';
955 }
956 // Ref document
957 if (!empty($arrayfields['t.doc_ref']['checked'])) {
958  print '<td class="liste_titre"><input type="text" name="search_doc_ref" size="8" value="'.dol_escape_htmltag($search_doc_ref).'"></td>';
959 }
960 // Accountancy account
961 if (!empty($arrayfields['t.numero_compte']['checked'])) {
962  print '<td class="liste_titre">';
963  print '<div class="nowrap">';
964  print $formaccounting->select_account($search_accountancy_code_start, 'search_accountancy_code_start', $langs->trans('From'), array(), 1, 1, 'maxwidth150', 'account');
965  print '</div>';
966  print '<div class="nowrap">';
967  print $formaccounting->select_account($search_accountancy_code_end, 'search_accountancy_code_end', $langs->trans('to'), array(), 1, 1, 'maxwidth150', 'account');
968  print '</div>';
969  print '</td>';
970 }
971 // Subledger account
972 if (!empty($arrayfields['t.subledger_account']['checked'])) {
973  print '<td class="liste_titre">';
974  // TODO For the moment we keep a free input text instead of a combo. The select_auxaccount has problem because it does not
975  // use setup of keypress to select thirdparty and this hang browser on large database.
976  if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) {
977  print '<div class="nowrap">';
978  //print $langs->trans('From').' ';
979  print $formaccounting->select_auxaccount($search_accountancy_aux_code_start, 'search_accountancy_aux_code_start', $langs->trans('From'), 'maxwidth250', 'subledgeraccount');
980  print '</div>';
981  print '<div class="nowrap">';
982  print $formaccounting->select_auxaccount($search_accountancy_aux_code_end, 'search_accountancy_aux_code_end', $langs->trans('to'), 'maxwidth250', 'subledgeraccount');
983  print '</div>';
984  } else {
985  print '<input type="text" class="maxwidth75" name="search_accountancy_aux_code" value="'.$search_accountancy_aux_code.'">';
986  }
987  print '</td>';
988 }
989 // Label operation
990 if (!empty($arrayfields['t.label_operation']['checked'])) {
991  print '<td class="liste_titre">';
992  print '<input type="text" size="7" class="flat" name="search_mvt_label" value="'.$search_mvt_label.'"/>';
993  print '</td>';
994 }
995 // Debit
996 if (!empty($arrayfields['t.debit']['checked'])) {
997  print '<td class="liste_titre right">';
998  print '<input type="text" class="flat" name="search_debit" size="4" value="'.dol_escape_htmltag($search_debit).'">';
999  print '</td>';
1000 }
1001 // Credit
1002 if (!empty($arrayfields['t.credit']['checked'])) {
1003  print '<td class="liste_titre right">';
1004  print '<input type="text" class="flat" name="search_credit" size="4" value="'.dol_escape_htmltag($search_credit).'">';
1005  print '</td>';
1006 }
1007 // Lettering code
1008 if (!empty($arrayfields['t.lettering_code']['checked'])) {
1009  print '<td class="liste_titre center">';
1010  print '<input type="text" size="3" class="flat" name="search_lettering_code" value="'.$search_lettering_code.'"/>';
1011  print '<br><span class="nowrap"><input type="checkbox" name="search_not_reconciled" value="notreconciled"'.($search_not_reconciled == 'notreconciled' ? ' checked' : '').'>'.$langs->trans("NotReconciled").'</span>';
1012  print '</td>';
1013 }
1014 
1015 // Fields from hook
1016 $parameters = array('arrayfields'=>$arrayfields);
1017 $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
1018 print $hookmanager->resPrint;
1019 
1020 // Date creation
1021 if (!empty($arrayfields['t.date_creation']['checked'])) {
1022  print '<td class="liste_titre center">';
1023  print '<div class="nowrap">';
1024  print $form->selectDate($search_date_creation_start, 'search_date_creation_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"));
1025  print '</div>';
1026  print '<div class="nowrap">';
1027  print $form->selectDate($search_date_creation_end, 'search_date_creation_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to"));
1028  print '</div>';
1029  print '</td>';
1030 }
1031 // Date modification
1032 if (!empty($arrayfields['t.tms']['checked'])) {
1033  print '<td class="liste_titre center">';
1034  print '<div class="nowrap">';
1035  print $form->selectDate($search_date_modification_start, 'search_date_modification_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"));
1036  print '</div>';
1037  print '<div class="nowrap">';
1038  print $form->selectDate($search_date_modification_end, 'search_date_modification_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"));
1039  print '</div>';
1040  print '</td>';
1041 }
1042 // Date export
1043 if (!empty($arrayfields['t.date_export']['checked'])) {
1044  print '<td class="liste_titre center">';
1045  print '<div class="nowrap">';
1046  print $form->selectDate($search_date_export_start, 'search_date_export_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"));
1047  print '</div>';
1048  print '<div class="nowrap">';
1049  print $form->selectDate($search_date_export_end, 'search_date_export_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to"));
1050  print '</div>';
1051  print '</td>';
1052 }
1053 // Date validation
1054 if (!empty($arrayfields['t.date_validated']['checked'])) {
1055  print '<td class="liste_titre center">';
1056  print '<div class="nowrap">';
1057  print $form->selectDate($search_date_validation_start, 'search_date_validation_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"));
1058  print '</div>';
1059  print '<div class="nowrap">';
1060  print $form->selectDate($search_date_validation_end, 'search_date_validation_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to"));
1061  print '</div>';
1062  print '</td>';
1063 }
1064 if (!empty($arrayfields['t.import_key']['checked'])) {
1065  print '<td class="liste_titre center">';
1066  print '<input class="flat searchstring maxwidth50" type="text" name="search_import_key" value="'.dol_escape_htmltag($search_import_key).'">';
1067  print '</td>';
1068 }
1069 // Action column
1070 print '<td class="liste_titre center">';
1071 $searchpicto = $form->showFilterButtons();
1072 print $searchpicto;
1073 print '</td>';
1074 print "</tr>\n";
1075 
1076 print '<tr class="liste_titre">';
1077 if (!empty($arrayfields['t.piece_num']['checked'])) {
1078  print_liste_field_titre($arrayfields['t.piece_num']['label'], $_SERVER['PHP_SELF'], "t.piece_num", "", $param, "", $sortfield, $sortorder);
1079 }
1080 if (!empty($arrayfields['t.code_journal']['checked'])) {
1081  print_liste_field_titre($arrayfields['t.code_journal']['label'], $_SERVER['PHP_SELF'], "t.code_journal", "", $param, '', $sortfield, $sortorder, 'center ');
1082 }
1083 if (!empty($arrayfields['t.doc_date']['checked'])) {
1084  print_liste_field_titre($arrayfields['t.doc_date']['label'], $_SERVER['PHP_SELF'], "t.doc_date", "", $param, '', $sortfield, $sortorder, 'center ');
1085 }
1086 if (!empty($arrayfields['t.doc_ref']['checked'])) {
1087  print_liste_field_titre($arrayfields['t.doc_ref']['label'], $_SERVER['PHP_SELF'], "t.doc_ref", "", $param, "", $sortfield, $sortorder);
1088 }
1089 if (!empty($arrayfields['t.numero_compte']['checked'])) {
1090  print_liste_field_titre($arrayfields['t.numero_compte']['label'], $_SERVER['PHP_SELF'], "t.numero_compte", "", $param, "", $sortfield, $sortorder);
1091 }
1092 if (!empty($arrayfields['t.subledger_account']['checked'])) {
1093  print_liste_field_titre($arrayfields['t.subledger_account']['label'], $_SERVER['PHP_SELF'], "t.subledger_account", "", $param, "", $sortfield, $sortorder);
1094 }
1095 if (!empty($arrayfields['t.label_operation']['checked'])) {
1096  print_liste_field_titre($arrayfields['t.label_operation']['label'], $_SERVER['PHP_SELF'], "t.label_operation", "", $param, "", $sortfield, $sortorder);
1097 }
1098 if (!empty($arrayfields['t.debit']['checked'])) {
1099  print_liste_field_titre($arrayfields['t.debit']['label'], $_SERVER['PHP_SELF'], "t.debit", "", $param, '', $sortfield, $sortorder, 'right ');
1100 }
1101 if (!empty($arrayfields['t.credit']['checked'])) {
1102  print_liste_field_titre($arrayfields['t.credit']['label'], $_SERVER['PHP_SELF'], "t.credit", "", $param, '', $sortfield, $sortorder, 'right ');
1103 }
1104 if (!empty($arrayfields['t.lettering_code']['checked'])) {
1105  print_liste_field_titre($arrayfields['t.lettering_code']['label'], $_SERVER['PHP_SELF'], "t.lettering_code", "", $param, '', $sortfield, $sortorder, 'center ');
1106 }
1107 // Hook fields
1108 $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
1109 $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
1110 print $hookmanager->resPrint;
1111 if (!empty($arrayfields['t.date_creation']['checked'])) {
1112  print_liste_field_titre($arrayfields['t.date_creation']['label'], $_SERVER['PHP_SELF'], "t.date_creation", "", $param, '', $sortfield, $sortorder, 'center ');
1113 }
1114 if (!empty($arrayfields['t.tms']['checked'])) {
1115  print_liste_field_titre($arrayfields['t.tms']['label'], $_SERVER['PHP_SELF'], "t.tms", "", $param, '', $sortfield, $sortorder, 'center ');
1116 }
1117 if (!empty($arrayfields['t.date_export']['checked'])) {
1118  print_liste_field_titre($arrayfields['t.date_export']['label'], $_SERVER['PHP_SELF'], "t.date_export", "", $param, '', $sortfield, $sortorder, 'center ');
1119 }
1120 if (!empty($arrayfields['t.date_validated']['checked'])) {
1121  print_liste_field_titre($arrayfields['t.date_validated']['label'], $_SERVER['PHP_SELF'], "t.date_validated", "", $param, '', $sortfield, $sortorder, 'center ');
1122 }
1123 if (!empty($arrayfields['t.import_key']['checked'])) {
1124  print_liste_field_titre($arrayfields['t.import_key']['label'], $_SERVER["PHP_SELF"], "t.import_key", "", $param, '', $sortfield, $sortorder, 'center ');
1125 }
1126 print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
1127 print "</tr>\n";
1128 
1129 
1130 $line = new BookKeepingLine();
1131 
1132 // Loop on record
1133 // --------------------------------------------------------------------
1134 $i = 0;
1135 $totalarray = array();
1136 $totalarray['val'] = array ();
1137 $totalarray['nbfield'] = 0;
1138 $total_debit = 0;
1139 $total_credit = 0;
1140 $totalarray['val']['totaldebit'] = 0;
1141 $totalarray['val']['totalcredit'] = 0;
1142 
1143 while ($i < min($num, $limit)) {
1144  $obj = $db->fetch_object($resql);
1145  if (empty($obj)) {
1146  break; // Should not happen
1147  }
1148 
1149  $line->id = $obj->rowid;
1150  $line->doc_date = $db->jdate($obj->doc_date);
1151  $line->doc_type = $obj->doc_type;
1152  $line->doc_ref = $obj->doc_ref;
1153  $line->fk_doc = $obj->fk_doc;
1154  $line->fk_docdet = $obj->fk_docdet;
1155  $line->thirdparty_code = $obj->thirdparty_code;
1156  $line->subledger_account = $obj->subledger_account;
1157  $line->subledger_label = $obj->subledger_label;
1158  $line->numero_compte = $obj->numero_compte;
1159  $line->label_compte = $obj->label_compte;
1160  $line->label_operation = $obj->label_operation;
1161  $line->debit = $obj->debit;
1162  $line->credit = $obj->credit;
1163  $line->montant = $obj->amount; // deprecated
1164  $line->amount = $obj->amount;
1165  $line->sens = $obj->sens;
1166  $line->lettering_code = $obj->lettering_code;
1167  $line->fk_user_author = $obj->fk_user_author;
1168  $line->import_key = $obj->import_key;
1169  $line->code_journal = $obj->code_journal;
1170  $line->journal_label = $obj->journal_label;
1171  $line->piece_num = $obj->piece_num;
1172  $line->date_creation = $db->jdate($obj->date_creation);
1173  $line->date_modification = $db->jdate($obj->date_modification);
1174  $line->date_export = $db->jdate($obj->date_export);
1175  $line->date_validation = $db->jdate($obj->date_validation);
1176 
1177  $total_debit += $line->debit;
1178  $total_credit += $line->credit;
1179 
1180  print '<tr class="oddeven">';
1181 
1182  // Piece number
1183  if (!empty($arrayfields['t.piece_num']['checked'])) {
1184  print '<td>';
1185  $object->id = $line->id;
1186  $object->piece_num = $line->piece_num;
1187  print $object->getNomUrl(1, '', 0, '', 1);
1188  print '</td>';
1189  if (!$i) {
1190  $totalarray['nbfield']++;
1191  }
1192  }
1193 
1194  // Journal code
1195  if (!empty($arrayfields['t.code_journal']['checked'])) {
1196  $accountingjournal = new AccountingJournal($db);
1197  $result = $accountingjournal->fetch('', $line->code_journal);
1198  $journaltoshow = (($result > 0) ? $accountingjournal->getNomUrl(0, 0, 0, '', 0) : $line->code_journal);
1199  print '<td class="center">'.$journaltoshow.'</td>';
1200  if (!$i) {
1201  $totalarray['nbfield']++;
1202  }
1203  }
1204 
1205  // Document date
1206  if (!empty($arrayfields['t.doc_date']['checked'])) {
1207  print '<td class="center">'.dol_print_date($line->doc_date, 'day').'</td>';
1208  if (!$i) {
1209  $totalarray['nbfield']++;
1210  }
1211  }
1212 
1213  // Document ref
1214  if (!empty($arrayfields['t.doc_ref']['checked'])) {
1215  if ($line->doc_type == 'customer_invoice') {
1216  $langs->loadLangs(array('bills'));
1217 
1218  require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
1219  $objectstatic = new Facture($db);
1220  $objectstatic->fetch($line->fk_doc);
1221  //$modulepart = 'facture';
1222 
1223  $filename = dol_sanitizeFileName($line->doc_ref);
1224  $filedir = $conf->facture->dir_output.'/'.dol_sanitizeFileName($line->doc_ref);
1225  $urlsource = $_SERVER['PHP_SELF'].'?id='.$objectstatic->id;
1226  $documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir);
1227  } elseif ($line->doc_type == 'supplier_invoice') {
1228  $langs->loadLangs(array('bills'));
1229 
1230  require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
1231  $objectstatic = new FactureFournisseur($db);
1232  $objectstatic->fetch($line->fk_doc);
1233  //$modulepart = 'invoice_supplier';
1234 
1235  $filename = dol_sanitizeFileName($line->doc_ref);
1236  $filedir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($line->fk_doc, 2, 0, 0, $objectstatic, $modulepart).dol_sanitizeFileName($line->doc_ref);
1237  $subdir = get_exdir($objectstatic->id, 2, 0, 0, $objectstatic, $modulepart).dol_sanitizeFileName($line->doc_ref);
1238  $documentlink = $formfile->getDocumentsLink($objectstatic->element, $subdir, $filedir);
1239  } elseif ($line->doc_type == 'expense_report') {
1240  $langs->loadLangs(array('trips'));
1241 
1242  require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
1243  $objectstatic = new ExpenseReport($db);
1244  $objectstatic->fetch($line->fk_doc);
1245  //$modulepart = 'expensereport';
1246 
1247  $filename = dol_sanitizeFileName($line->doc_ref);
1248  $filedir = $conf->expensereport->dir_output.'/'.dol_sanitizeFileName($line->doc_ref);
1249  $urlsource = $_SERVER['PHP_SELF'].'?id='.$objectstatic->id;
1250  $documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir);
1251  } elseif ($line->doc_type == 'bank') {
1252  require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
1253  $objectstatic = new AccountLine($db);
1254  $objectstatic->fetch($line->fk_doc);
1255  } else {
1256  // Other type
1257  }
1258 
1259  $labeltoshow = '';
1260  $labeltoshowalt = '';
1261  if ($line->doc_type == 'customer_invoice' || $line->doc_type == 'supplier_invoice' || $line->doc_type == 'expense_report') {
1262  $labeltoshow .= $objectstatic->getNomUrl(1, '', 0, 0, '', 0, -1, 1);
1263  $labeltoshow .= $documentlink;
1264  $labeltoshowalt .= $objectstatic->ref;
1265  } elseif ($line->doc_type == 'bank') {
1266  $labeltoshow .= $objectstatic->getNomUrl(1);
1267  $labeltoshowalt .= $objectstatic->ref;
1268  $bank_ref = strstr($line->doc_ref, '-');
1269  $labeltoshow .= " " . $bank_ref;
1270  $labeltoshowalt .= " " . $bank_ref;
1271  } else {
1272  $labeltoshow .= $line->doc_ref;
1273  $labeltoshowalt .= $line->doc_ref;
1274  }
1275 
1276  print '<td class="nowraponall tdoverflowmax200" title="'.dol_escape_htmltag($labeltoshowalt).'">';
1277  print $labeltoshow;
1278  print "</td>\n";
1279  if (!$i) {
1280  $totalarray['nbfield']++;
1281  }
1282  }
1283 
1284  // Account number
1285  if (!empty($arrayfields['t.numero_compte']['checked'])) {
1286  print '<td>'.length_accountg($line->numero_compte).'</td>';
1287  if (!$i) {
1288  $totalarray['nbfield']++;
1289  }
1290  }
1291 
1292  // Subledger account
1293  if (!empty($arrayfields['t.subledger_account']['checked'])) {
1294  print '<td>'.length_accounta($line->subledger_account).'</td>';
1295  if (!$i) {
1296  $totalarray['nbfield']++;
1297  }
1298  }
1299 
1300  // Label operation
1301  if (!empty($arrayfields['t.label_operation']['checked'])) {
1302  print '<td class="small tdoverflowmax200" title="'.dol_escape_htmltag($line->label_operation).'">'.dol_escape_htmltag($line->label_operation).'</td>';
1303  if (!$i) {
1304  $totalarray['nbfield']++;
1305  }
1306  }
1307 
1308  // Amount debit
1309  if (!empty($arrayfields['t.debit']['checked'])) {
1310  print '<td class="right nowraponall amount">'.($line->debit != 0 ? price($line->debit) : '').'</td>';
1311  if (!$i) {
1312  $totalarray['nbfield']++;
1313  }
1314  if (!$i) {
1315  $totalarray['pos'][$totalarray['nbfield']] = 'totaldebit';
1316  }
1317  $totalarray['val']['totaldebit'] += $line->debit;
1318  }
1319 
1320  // Amount credit
1321  if (!empty($arrayfields['t.credit']['checked'])) {
1322  print '<td class="right nowraponall amount">'.($line->credit != 0 ? price($line->credit) : '').'</td>';
1323  if (!$i) {
1324  $totalarray['nbfield']++;
1325  }
1326  if (!$i) {
1327  $totalarray['pos'][$totalarray['nbfield']] = 'totalcredit';
1328  }
1329  $totalarray['val']['totalcredit'] += $line->credit;
1330  }
1331 
1332  // Lettering code
1333  if (!empty($arrayfields['t.lettering_code']['checked'])) {
1334  print '<td class="center">'.$line->lettering_code.'</td>';
1335  if (!$i) {
1336  $totalarray['nbfield']++;
1337  }
1338  }
1339 
1340  // Fields from hook
1341  $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
1342  $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook
1343  print $hookmanager->resPrint;
1344 
1345  // Creation operation date
1346  if (!empty($arrayfields['t.date_creation']['checked'])) {
1347  print '<td class="center">'.dol_print_date($line->date_creation, 'dayhour').'</td>';
1348  if (!$i) {
1349  $totalarray['nbfield']++;
1350  }
1351  }
1352 
1353  // Modification operation date
1354  if (!empty($arrayfields['t.tms']['checked'])) {
1355  print '<td class="center">'.dol_print_date($line->date_modification, 'dayhour').'</td>';
1356  if (!$i) {
1357  $totalarray['nbfield']++;
1358  }
1359  }
1360 
1361  // Exported operation date
1362  if (!empty($arrayfields['t.date_export']['checked'])) {
1363  print '<td class="center nowraponall">'.dol_print_date($line->date_export, 'dayhour').'</td>';
1364  if (!$i) {
1365  $totalarray['nbfield']++;
1366  }
1367  }
1368 
1369  // Validated operation date
1370  if (!empty($arrayfields['t.date_validated']['checked'])) {
1371  print '<td class="center nowraponall">'.dol_print_date($line->date_validation, 'dayhour').'</td>';
1372  if (!$i) {
1373  $totalarray['nbfield']++;
1374  }
1375  }
1376 
1377  if (!empty($arrayfields['t.import_key']['checked'])) {
1378  print '<td class="tdoverflowmax100">'.$obj->import_key."</td>\n";
1379  if (!$i) {
1380  $totalarray['nbfield']++;
1381  }
1382  }
1383 
1384  // Action column
1385  print '<td class="nowraponall center">';
1386  if (($massactionbutton || $massaction) && $contextpage != 'poslist') { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
1387  $selected = 0;
1388  if (in_array($line->id, $arrayofselected)) {
1389  $selected = 1;
1390  }
1391  print '<input id="cb'.$line->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$line->id.'"'.($selected ? ' checked="checked"' : '').' />';
1392  }
1393  print '</td>';
1394 
1395  if (!$i) {
1396  $totalarray['nbfield']++;
1397  }
1398 
1399  print "</tr>\n";
1400 
1401  $i++;
1402 }
1403 
1404 // Show total line
1405 include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
1406 
1407 
1408 print "</table>";
1409 print '</div>';
1410 
1411 // TODO Replace this with mass delete action
1412 //if ($user->rights->accounting->mouvements->supprimer_tous) {
1413 // print '<div class="tabsAction tabsActionNoBottom">'."\n";
1414 // print '<a class="butActionDelete" name="button_delmvt" href="'.$_SERVER["PHP_SELF"].'?action=delbookkeepingyear&token='.newToken().($param ? '&'.$param : '').'">'.$langs->trans("DeleteMvt").'</a>';
1415 // print '</div>';
1416 //}
1417 
1418 print '</form>';
1419 
1420 // End of page
1421 llxFooter();
1422 $db->close();
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
Class Lettering.
if($cancel &&!$id) if($action== 'add'&&!$cancel) if($action== 'delete') if($id) $form
Actions.
Definition: card.php:142
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.
dolibarr_set_const($db, $name, $value, $type= 'chaine', $visible=0, $note= '', $entity=1)
Insert a parameter (key,value) into database (delete old key then insert it again).
Definition: admin.lib.php:627
if(!function_exists('utf8_encode')) if(!function_exists('utf8_decode')) getDolGlobalString($key, $default= '')
Return dolibarr global constant string value.
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:59
Class to manage bank transaction lines.
Class to manage suppliers invoices.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags= '', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields...
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)
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 from a POST of a form...
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it&#39;s its name (generic function)
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
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.
accessforbidden($message= '', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
natural_search($fields, $value, $mode=0, $nofirstand=0)
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
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.
if(isModEnabled('facture')&&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur')&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)&&$user->rights->fournisseur->facture->lire)||(isModEnabled('supplier_invoice')&&$user->rights->supplier_invoice->lire)) if(isModEnabled('don')&&!empty($user->rights->don->lire)) if(isModEnabled('tax')&&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture')&&isModEnabled('commande')&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
Definition: index.php:742
dol_get_last_day($year, $month=12, $gm=false)
Return GMT time for last day of a month or year.
Definition: date.lib.php:570
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.
Manage the different format accountancy export.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
newToken()
Return the value of token currently saved into session with name &#39;newtoken&#39;.
isModEnabled($module)
Is Dolibarr module enabled.
Class to manage accounting accounts.
Class to manage invoices.
llxFooter()
Empty footer.
Definition: wrapper.php:73
Class BookKeepingLine.
$formconfirm
if ($action == &#39;delbookkeepingyear&#39;) {