dolibarr  16.0.5
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)) {
350  $filter['t.subledger_account'] = $search_accountancy_aux_code;
351  $param .= '&search_accountancy_aux_code='.urlencode($search_accountancy_aux_code);
352  }
353  if (!empty($search_accountancy_aux_code_start)) {
354  $filter['t.subledger_account>='] = $search_accountancy_aux_code_start;
355  $param .= '&search_accountancy_aux_code_start='.urlencode($search_accountancy_aux_code_start);
356  }
357  if (!empty($search_accountancy_aux_code_end)) {
358  $filter['t.subledger_account<='] = $search_accountancy_aux_code_end;
359  $param .= '&search_accountancy_aux_code_end='.urlencode($search_accountancy_aux_code_end);
360  }
361  if (!empty($search_mvt_label)) {
362  $filter['t.label_operation'] = $search_mvt_label;
363  $param .= '&search_mvt_label='.urlencode($search_mvt_label);
364  }
365  if (!empty($search_direction)) {
366  $filter['t.sens'] = $search_direction;
367  $param .= '&search_direction='.urlencode($search_direction);
368  }
369  if (!empty($search_ledger_code)) {
370  $filter['t.code_journal'] = $search_ledger_code;
371  foreach ($search_ledger_code as $code) {
372  $param .= '&search_ledger_code[]='.urlencode($code);
373  }
374  }
375  if (!empty($search_mvt_num)) {
376  $filter['t.piece_num'] = $search_mvt_num;
377  $param .= '&search_mvt_num='.urlencode($search_mvt_num);
378  }
379  if (!empty($search_date_creation_start)) {
380  $filter['t.date_creation>='] = $search_date_creation_start;
381  $tmp = dol_getdate($search_date_creation_start);
382  $param .= '&search_date_creation_startmonth='.urlencode($tmp['mon']).'&search_date_creation_startday='.urlencode($tmp['mday']).'&search_date_creation_startyear='.urlencode($tmp['year']);
383  }
384  if (!empty($search_date_creation_end)) {
385  $filter['t.date_creation<='] = $search_date_creation_end;
386  $tmp = dol_getdate($search_date_creation_end);
387  $param .= '&search_date_creation_endmonth='.urlencode($tmp['mon']).'&search_date_creation_endday='.urlencode($tmp['mday']).'&search_date_creation_endyear='.urlencode($tmp['year']);
388  }
389  if (!empty($search_date_modification_start)) {
390  $filter['t.tms>='] = $search_date_modification_start;
391  $tmp = dol_getdate($search_date_modification_start);
392  $param .= '&search_date_modification_startmonth='.urlencode($tmp['mon']).'&search_date_modification_startday='.urlencode($tmp['mday']).'&search_date_modification_startyear='.urlencode($tmp['year']);
393  }
394  if (!empty($search_date_modification_end)) {
395  $filter['t.tms<='] = $search_date_modification_end;
396  $tmp = dol_getdate($search_date_modification_end);
397  $param .= '&search_date_modification_endmonth='.urlencode($tmp['mon']).'&search_date_modification_endday='.urlencode($tmp['mday']).'&search_date_modification_endyear='.urlencode($tmp['year']);
398  }
399  if (!empty($search_date_export_start)) {
400  $filter['t.date_export>='] = $search_date_export_start;
401  $tmp = dol_getdate($search_date_export_start);
402  $param .= '&search_date_export_startmonth='.urlencode($tmp['mon']).'&search_date_export_startday='.urlencode($tmp['mday']).'&search_date_export_startyear='.urlencode($tmp['year']);
403  }
404  if (!empty($search_date_export_end)) {
405  $filter['t.date_export<='] = $search_date_export_end;
406  $tmp = dol_getdate($search_date_export_end);
407  $param .= '&search_date_export_endmonth='.urlencode($tmp['mon']).'&search_date_export_endday='.urlencode($tmp['mday']).'&search_date_export_endyear='.urlencode($tmp['year']);
408  }
409  if (!empty($search_date_validation_start)) {
410  $filter['t.date_validated>='] = $search_date_validation_start;
411  $tmp = dol_getdate($search_date_validation_start);
412  $param .= '&search_date_validation_startmonth='.urlencode($tmp['mon']).'&search_date_validation_startday='.urlencode($tmp['mday']).'&search_date_validation_startyear='.urlencode($tmp['year']);
413  }
414  if (!empty($search_date_validation_end)) {
415  $filter['t.date_validated<='] = $search_date_validation_end;
416  $tmp = dol_getdate($search_date_validation_end);
417  $param .= '&search_date_validation_endmonth='.urlencode($tmp['mon']).'&search_date_validation_endday='.urlencode($tmp['mday']).'&search_date_validation_endyear='.urlencode($tmp['year']);
418  }
419  if (!empty($search_debit)) {
420  $filter['t.debit'] = $search_debit;
421  $param .= '&search_debit='.urlencode($search_debit);
422  }
423  if (!empty($search_credit)) {
424  $filter['t.credit'] = $search_credit;
425  $param .= '&search_credit='.urlencode($search_credit);
426  }
427  if (!empty($search_lettering_code)) {
428  $filter['t.lettering_code'] = $search_lettering_code;
429  $param .= '&search_lettering_code='.urlencode($search_lettering_code);
430  }
431  if (!empty($search_not_reconciled)) {
432  $filter['t.reconciled_option'] = $search_not_reconciled;
433  $param .= '&search_not_reconciled='.urlencode($search_not_reconciled);
434  }
435  if (!empty($search_import_key)) {
436  $filter['t.import_key'] = $search_import_key;
437  $param .= '&search_import_key='.urlencode($search_import_key);
438  }
439 
440  //if ($action == 'delbookkeepingyearconfirm' && $user->rights->accounting->mouvements->supprimer_tous) {
441  // $delmonth = GETPOST('delmonth', 'int');
442  // $delyear = GETPOST('delyear', 'int');
443  // if ($delyear == -1) {
444  // $delyear = 0;
445  // }
446  // $deljournal = GETPOST('deljournal', 'alpha');
447  // if ($deljournal == -1) {
448  // $deljournal = 0;
449  // }
450  //
451  // if (!empty($delmonth) || !empty($delyear) || !empty($deljournal)) {
452  // $result = $object->deleteByYearAndJournal($delyear, $deljournal, '', ($delmonth > 0 ? $delmonth : 0));
453  // if ($result < 0) {
454  // setEventMessages($object->error, $object->errors, 'errors');
455  // } else {
456  // setEventMessages("RecordDeleted", null, 'mesgs');
457  // }
458  //
459  // // Make a redirect to avoid to launch the delete later after a back button
460  // header("Location: list.php".($param ? '?'.$param : ''));
461  // exit;
462  // } else {
463  // setEventMessages("NoRecordDeleted", null, 'warnings');
464  // }
465  //}
466  if ($action == 'setreexport') {
467  $setreexport = GETPOST('value', 'int');
468  if (!dolibarr_set_const($db, "ACCOUNTING_REEXPORT", $setreexport, 'yesno', 0, '', $conf->entity)) {
469  $error++;
470  }
471 
472  if (!$error) {
473  if ($conf->global->ACCOUNTING_REEXPORT == 1) {
474  setEventMessages($langs->trans("ExportOfPiecesAlreadyExportedIsEnable"), null, 'mesgs');
475  } else {
476  setEventMessages($langs->trans("ExportOfPiecesAlreadyExportedIsDisable"), null, 'mesgs');
477  }
478  } else {
479  setEventMessages($langs->trans("Error"), null, 'errors');
480  }
481  }
482 
483  // Mass actions
484  $objectclass = 'Bookkeeping';
485  $objectlabel = 'Bookkeeping';
486  $permissiontoread = $user->rights->societe->lire;
487  $permissiontodelete = $user->rights->societe->supprimer;
488  $permissiontoadd = $user->rights->societe->creer;
489  $uploaddir = $conf->societe->dir_output;
490  include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
491 
492  if (!$error && $action == 'deletebookkeepingwriting' && $confirm == "yes" && $user->rights->accounting->mouvements->supprimer) {
493  $nbok = 0;
494  foreach ($toselect as $toselectid) {
495  $result = $object->fetch($toselectid);
496  if ($result > 0 && (!isset($object->date_validation) || $object->date_validation === '')) {
497  $result = $object->deleteMvtNum($object->piece_num);
498  if ($result > 0) {
499  $nbok++;
500  } else {
501  setEventMessages($object->error, $object->errors, 'errors');
502  $error++;
503  break;
504  }
505  } elseif ($result < 0) {
506  setEventMessages($object->error, $object->errors, 'errors');
507  $error++;
508  break;
509  }
510  }
511 
512  // Message for elements well deleted
513  if ($nbok > 1) {
514  setEventMessages($langs->trans("RecordsDeleted", $nbok), null, 'mesgs');
515  } elseif ($nbok > 0) {
516  setEventMessages($langs->trans("RecordDeleted", $nbok), null, 'mesgs');
517  } elseif (!$error) {
518  setEventMessages($langs->trans("NoRecordDeleted"), null, 'mesgs');
519  }
520 
521  if (!$error) {
522  header("Location: ".$_SERVER["PHP_SELF"]."?noreset=1".($param ? '&'.$param : ''));
523  exit;
524  }
525  }
526 
527  // others mass actions
528  if (!$error && getDolGlobalInt('ACCOUNTING_ENABLE_LETTERING') && $user->rights->accounting->mouvements->creer) {
529  if ($massaction == 'lettering') {
530  $lettering = new Lettering($db);
531  $nb_lettering = $lettering->bookkeepingLetteringAll($toselect);
532  if ($nb_lettering < 0) {
533  setEventMessages('', $lettering->errors, 'errors');
534  $error++;
535  $nb_lettering = max(0, abs($nb_lettering) - 2);
536  } elseif ($nb_lettering == 0) {
537  $nb_lettering = 0;
538  setEventMessages($langs->trans('AccountancyNoLetteringModified'), array(), 'mesgs');
539  }
540  if ($nb_lettering == 1) {
541  setEventMessages($langs->trans('AccountancyOneLetteringModifiedSuccessfully'), array(), 'mesgs');
542  } elseif ($nb_lettering > 1) {
543  setEventMessages($langs->trans('AccountancyLetteringModifiedSuccessfully', $nb_lettering), array(), 'mesgs');
544  }
545 
546  if (!$error) {
547  header('Location: ' . $_SERVER['PHP_SELF'] . '?noreset=1' . $param);
548  exit();
549  }
550  } elseif ($action == 'unlettering' && $confirm == "yes") {
551  $lettering = new Lettering($db);
552  $nb_lettering = $lettering->bookkeepingLetteringAll($toselect, true);
553  if ($nb_lettering < 0) {
554  setEventMessages('', $lettering->errors, 'errors');
555  $error++;
556  $nb_lettering = max(0, abs($nb_lettering) - 2);
557  } elseif ($nb_lettering == 0) {
558  $nb_lettering = 0;
559  setEventMessages($langs->trans('AccountancyNoUnletteringModified'), array(), 'mesgs');
560  }
561  if ($nb_lettering == 1) {
562  setEventMessages($langs->trans('AccountancyOneUnletteringModifiedSuccessfully'), array(), 'mesgs');
563  } elseif ($nb_lettering > 1) {
564  setEventMessages($langs->trans('AccountancyUnletteringModifiedSuccessfully', $nb_lettering), array(), 'mesgs');
565  }
566 
567  if (!$error) {
568  header('Location: ' . $_SERVER['PHP_SELF'] . '?noreset=1' . $param);
569  exit();
570  }
571  }
572  }
573 }
574 
575 // Build and execute select (used by page and export action)
576 // must de set after the action that set $filter
577 // --------------------------------------------------------------------
578 
579 $sql = 'SELECT';
580 $sql .= ' t.rowid,';
581 $sql .= " t.doc_date,";
582 $sql .= " t.doc_type,";
583 $sql .= " t.doc_ref,";
584 $sql .= " t.fk_doc,";
585 $sql .= " t.fk_docdet,";
586 $sql .= " t.thirdparty_code,";
587 $sql .= " t.subledger_account,";
588 $sql .= " t.subledger_label,";
589 $sql .= " t.numero_compte,";
590 $sql .= " t.label_compte,";
591 $sql .= " t.label_operation,";
592 $sql .= " t.debit,";
593 $sql .= " t.credit,";
594 $sql .= " t.lettering_code,";
595 $sql .= " t.montant as amount,";
596 $sql .= " t.sens,";
597 $sql .= " t.fk_user_author,";
598 $sql .= " t.import_key,";
599 $sql .= " t.code_journal,";
600 $sql .= " t.journal_label,";
601 $sql .= " t.piece_num,";
602 $sql .= " t.date_creation,";
603 $sql .= " t.tms as date_modification,";
604 $sql .= " t.date_export,";
605 $sql .= " t.date_validated as date_validation,";
606 $sql .= " t.import_key";
607 $sql .= ' FROM '.MAIN_DB_PREFIX.$object->table_element.' as t';
608 // Manage filter
609 $sqlwhere = array();
610 if (count($filter) > 0) {
611  foreach ($filter as $key => $value) {
612  if ($key == 't.doc_date') {
613  $sqlwhere[] = $key."='".$db->idate($value)."'";
614  } elseif ($key == 't.doc_date>=' || $key == 't.doc_date<=') {
615  $sqlwhere[] = $key."'".$db->idate($value)."'";
616  } elseif ($key == 't.numero_compte>=' || $key == 't.numero_compte<=' || $key == 't.subledger_account>=' || $key == 't.subledger_account<=') {
617  $sqlwhere[] = $key."'".$db->escape($value)."'";
618  } elseif ($key == 't.fk_doc' || $key == 't.fk_docdet' || $key == 't.piece_num') {
619  $sqlwhere[] = $key.'='.((int) $value);
620  } elseif ($key == 't.subledger_account' || $key == 't.numero_compte') {
621  $sqlwhere[] = $key." LIKE '".$db->escape($value)."%'";
622  } elseif ($key == 't.subledger_account') {
623  $sqlwhere[] = natural_search($key, $value, 0, 1);
624  } elseif ($key == 't.date_creation>=' || $key == 't.date_creation<=') {
625  $sqlwhere[] = $key."'".$db->idate($value)."'";
626  } elseif ($key == 't.tms>=' || $key == 't.tms<=') {
627  $sqlwhere[] = $key."'".$db->idate($value)."'";
628  } elseif ($key == 't.date_export>=' || $key == 't.date_export<=') {
629  $sqlwhere[] = $key."'".$db->idate($value)."'";
630  } elseif ($key == 't.date_validated>=' || $key == 't.date_validated<=') {
631  $sqlwhere[] = $key."'".$db->idate($value)."'";
632  } elseif ($key == 't.credit' || $key == 't.debit') {
633  $sqlwhere[] = natural_search($key, $value, 1, 1);
634  } elseif ($key == 't.reconciled_option') {
635  $sqlwhere[] = 't.lettering_code IS NULL';
636  } elseif ($key == 't.code_journal' && !empty($value)) {
637  $sqlwhere[] = natural_search("t.code_journal", join(',', $value), 3, 1);
638  } else {
639  $sqlwhere[] = natural_search($key, $value, 0, 1);
640  }
641  }
642 }
643 $sql .= ' WHERE t.entity IN ('.getEntity('accountancy').')';
644 if (empty($conf->global->ACCOUNTING_REEXPORT)) {
645  $sql .= " AND t.date_export IS NULL";
646 }
647 if (count($sqlwhere) > 0) {
648  $sql .= ' AND '.implode(' AND ', $sqlwhere);
649 }
650 if (!empty($sortfield)) {
651  $sql .= $db->order($sortfield, $sortorder);
652 }
653 //print $sql;
654 
655 
656 // Export into a file with format defined into setup (FEC, CSV, ...)
657 // Must be after definition of $sql
658 if ($action == 'export_fileconfirm' && $user->rights->accounting->mouvements->export) {
659  // 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.
660  $result = $object->fetchAll($sortorder, $sortfield, 0, 0, $filter, 'AND', (empty($conf->global->ACCOUNTING_REEXPORT) ? 0 : 1));
661 
662  if ($result < 0) {
663  setEventMessages($object->error, $object->errors, 'errors');
664  } else {
665  // Export files
666  $accountancyexport = new AccountancyExport($db);
667  $accountancyexport->export($object->lines, $formatexportset);
668 
669  $notifiedexportdate = GETPOST('notifiedexportdate', 'alpha');
670  $notifiedvalidationdate = GETPOST('notifiedvalidationdate', 'alpha');
671 
672  if (!empty($accountancyexport->errors)) {
673  setEventMessages('', $accountancyexport->errors, 'errors');
674  } elseif (!empty($notifiedexportdate) || !empty($notifiedvalidationdate)) {
675  // Specify as export : update field date_export or date_validated
676  $error = 0;
677  $db->begin();
678 
679  if (is_array($object->lines)) {
680  foreach ($object->lines as $movement) {
681  $now = dol_now();
682 
683  $sql = " UPDATE ".MAIN_DB_PREFIX."accounting_bookkeeping";
684  $sql .= " SET";
685  if (!empty($notifiedexportdate) && !empty($notifiedvalidationdate)) {
686  $sql .= " date_export = '".$db->idate($now)."'";
687  $sql .= ", date_validated = '".$db->idate($now)."'";
688  } elseif (!empty($notifiedexportdate)) {
689  $sql .= " date_export = '".$db->idate($now)."'";
690  } elseif (!empty($notifiedvalidationdate)) {
691  $sql .= " date_validated = '".$db->idate($now)."'";
692  }
693  $sql .= " WHERE rowid = ".((int) $movement->id);
694 
695  dol_syslog("/accountancy/bookkeeping/list.php Function export_file Specify movements as exported", LOG_DEBUG);
696 
697  $result = $db->query($sql);
698  if (!$result) {
699  $error++;
700  break;
701  }
702  }
703  }
704 
705  if (!$error) {
706  $db->commit();
707  // setEventMessages($langs->trans("AllExportedMovementsWereRecordedAsExportedOrValidated"), null, 'mesgs');
708  } else {
709  $error++;
710  $db->rollback();
711  setEventMessages($langs->trans("NotAllExportedMovementsCouldBeRecordedAsExportedOrValidated"), null, 'errors');
712  }
713  }
714  exit;
715  }
716 }
717 
718 
719 /*
720  * View
721  */
722 
723 $formother = new FormOther($db);
724 $formfile = new FormFile($db);
725 
726 $title_page = $langs->trans("Operations").' - '.$langs->trans("Journals");
727 
728 // Count total nb of records
729 $nbtotalofrecords = '';
730 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
731  $resql = $db->query($sql);
732  $nbtotalofrecords = $db->num_rows($resql);
733  if (($page * $limit) > $nbtotalofrecords) { // if total of record found is smaller than page * limit, goto and load page 0
734  $page = 0;
735  $offset = 0;
736  }
737 }
738 // if total of record found is smaller than limit, no need to do paging and to restart another select with limits set.
739 if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords) {
740  $num = $nbtotalofrecords;
741 } else {
742  $sql .= $db->plimit($limit + 1, $offset);
743 
744  $resql = $db->query($sql);
745  if (!$resql) {
746  dol_print_error($db);
747  exit;
748  }
749 
750  $num = $db->num_rows($resql);
751 }
752 
753 $arrayofselected = is_array($toselect) ? $toselect : array();
754 
755 // Output page
756 // --------------------------------------------------------------------
757 
758 llxHeader('', $title_page);
759 
760 $formconfirm = '';
761 
762 if ($action == 'export_file') {
763  $form_question = array();
764 
765  // If 1 or not set, we check by default.
766  $checked = (!isset($conf->global->ACCOUNTING_DEFAULT_NOT_NOTIFIED_EXPORT_DATE) || !empty($conf->global->ACCOUNTING_DEFAULT_NOT_NOTIFIED_EXPORT_DATE));
767  $form_question['notifiedexportdate'] = array(
768  'name' => 'notifiedexportdate',
769  'type' => 'checkbox',
770  'label' => $langs->trans('NotifiedExportDate'),
771  'value' => (!empty($conf->global->ACCOUNTING_DEFAULT_NOT_NOTIFIED_EXPORT_DATE) ? 'false' : 'true'),
772  );
773 
774  $form_question['separator'] = array('name'=>'separator', 'type'=>'separator');
775 
776  if (!getDolGlobalString("ACCOUNTANCY_DISABLE_CLOSURE_LINE_BY_LINE")) {
777  // If 0 or not set, we NOT check by default.
778  $checked = (isset($conf->global->ACCOUNTING_DEFAULT_NOT_NOTIFIED_VALIDATION_DATE) || !empty($conf->global->ACCOUNTING_DEFAULT_NOT_NOTIFIED_VALIDATION_DATE));
779  $form_question['notifiedvalidationdate'] = array(
780  'name' => 'notifiedvalidationdate',
781  'type' => 'checkbox',
782  'label' => $langs->trans('NotifiedValidationDate', $langs->transnoentitiesnoconv("MenuAccountancyClosure")),
783  'value' => $checked,
784  );
785 
786  $form_question['separator2'] = array('name'=>'separator2', 'type'=>'separator');
787  }
788 
789  $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?'.$param, $langs->trans("ExportFilteredList").' ('.$listofformat[$formatexportset].')', $langs->trans('ConfirmExportFile'), 'export_fileconfirm', $form_question, '', 1, 300, 600);
790 }
791 
792 //if ($action == 'delbookkeepingyear') {
793 // $form_question = array();
794 // $delyear = GETPOST('delyear', 'int');
795 // $deljournal = GETPOST('deljournal', 'alpha');
796 //
797 // if (empty($delyear)) {
798 // $delyear = dol_print_date(dol_now(), '%Y');
799 // }
800 // $month_array = array();
801 // for ($i = 1; $i <= 12; $i++) {
802 // $month_array[$i] = $langs->trans("Month".sprintf("%02d", $i));
803 // }
804 // $year_array = $formaccounting->selectyear_accountancy_bookkepping($delyear, 'delyear', 0, 'array');
805 // $journal_array = $formaccounting->select_journal($deljournal, 'deljournal', '', 1, 1, 1, '', 0, 1);
806 //
807 // $form_question['delmonth'] = array(
808 // 'name' => 'delmonth',
809 // 'type' => 'select',
810 // 'label' => $langs->trans('DelMonth'),
811 // 'values' => $month_array,
812 // 'morecss' => 'minwidth150',
813 // 'default' => ''
814 // );
815 // $form_question['delyear'] = array(
816 // 'name' => 'delyear',
817 // 'type' => 'select',
818 // 'label' => $langs->trans('DelYear'),
819 // 'values' => $year_array,
820 // 'default' => $delyear
821 // );
822 // $form_question['deljournal'] = array(
823 // 'name' => 'deljournal',
824 // 'type' => 'other', // We don't use select here, the journal_array is already a select html component
825 // 'label' => $langs->trans('DelJournal'),
826 // 'value' => $journal_array,
827 // 'default' => $deljournal
828 // );
829 //
830 // $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?'.$param, $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvt', $langs->transnoentitiesnoconv("RegistrationInAccounting")), 'delbookkeepingyearconfirm', $form_question, '', 1, 320);
831 //}
832 
833 // Print form confirm
834 print $formconfirm;
835 
836 //$param=''; param started before
837 if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
838  $param .= '&contextpage='.urlencode($contextpage);
839 }
840 if ($limit > 0 && $limit != $conf->liste_limit) {
841  $param .= '&limit='.urlencode($limit);
842 }
843 
844 // List of mass actions available
845 $arrayofmassactions = array();
846 /*
847 if (getDolGlobalInt('ACCOUNTING_ENABLE_LETTERING') && $user->rights->accounting->mouvements->creer) {
848  $arrayofmassactions['lettering'] = img_picto('', 'check', 'class="pictofixedwidth"') . $langs->trans('Lettering');
849  $arrayofmassactions['preunlettering'] = img_picto('', 'uncheck', 'class="pictofixedwidth"') . $langs->trans('Unlettering');
850 }
851 */
852 if ($user->rights->accounting->mouvements->supprimer) {
853  $arrayofmassactions['predeletebookkeepingwriting'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
854 }
855 if (GETPOST('nomassaction', 'int') || in_array($massaction, array('preunlettering', 'predeletebookkeepingwriting'))) {
856  $arrayofmassactions = array();
857 }
858 $massactionbutton = $form->selectMassAction($massaction, $arrayofmassactions);
859 
860 print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
861 print '<input type="hidden" name="token" value="'.newToken().'">';
862 print '<input type="hidden" name="action" value="list">';
863 if ($optioncss != '') {
864  print '<input type="hidden" name="optioncss" value="'.urlencode($optioncss).'">';
865 }
866 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
867 print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
868 print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
869 print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
870 
871 if (count($filter)) {
872  $buttonLabel = $langs->trans("ExportFilteredList");
873 } else {
874  $buttonLabel = $langs->trans("ExportList");
875 }
876 
877 $parameters = array('param' => $param);
878 $reshook = $hookmanager->executeHooks('addMoreActionsButtonsList', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
879 if ($reshook < 0) {
880  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
881 }
882 
883 $newcardbutton = empty($hookmanager->resPrint) ? '' : $hookmanager->resPrint;
884 
885 if (empty($reshook)) {
886  // Button re-export
887  if (!empty($conf->global->ACCOUNTING_REEXPORT)) {
888  $newcardbutton .= '<a class="valignmiddle" href="'.$_SERVER['PHP_SELF'].'?action=setreexport&token='.newToken().'&value=0'.($param ? '&'.$param : '').'">'.img_picto($langs->trans("Activated"), 'switch_on').'</a> ';
889  } else {
890  $newcardbutton .= '<a class="valignmiddle" href="'.$_SERVER['PHP_SELF'].'?action=setreexport&token='.newToken().'&value=1'.($param ? '&'.$param : '').'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a> ';
891  }
892  $newcardbutton .= '<span class="valignmiddle marginrightonly">'.$langs->trans("IncludeDocsAlreadyExported").'</span>';
893 
894  if (!empty($user->rights->accounting->mouvements->export)) {
895  $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);
896  }
897 
898  $newcardbutton .= dolGetButtonTitle($langs->trans('ViewFlatList'), '', 'fa fa-list paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/list.php?'.$param, '', 1, array('morecss' => 'marginleftonly btnTitleSelected'));
899  $newcardbutton .= dolGetButtonTitle($langs->trans('GroupByAccountAccounting'), '', 'fa fa-stream paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/listbyaccount.php?'.$param, '', 1, array('morecss' => 'marginleftonly'));
900  $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'));
901 
902  $url = './card.php?action=create';
903  if (!empty($socid)) {
904  $url .= '&socid='.$socid;
905  }
906  $newcardbutton .= dolGetButtonTitle($langs->trans('NewAccountingMvt'), '', 'fa fa-plus-circle paddingleft', $url, '', $user->rights->accounting->mouvements->creer);
907 }
908 
909 print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_accountancy', 0, $newcardbutton, '', $limit, 0, 0, 1);
910 
911 if ($massaction == 'preunlettering') {
912  print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmMassUnlettering"), $langs->trans("ConfirmMassUnletteringQuestion", count($toselect)), "unlettering", null, '', 0, 200, 500, 1);
913 } elseif ($massaction == 'predeletebookkeepingwriting') {
914  print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmMassDeleteBookkeepingWriting"), $langs->trans("ConfirmMassDeleteBookkeepingWritingQuestion", count($toselect)), "deletebookkeepingwriting", null, '', 0, 200, 500, 1);
915 }
916 
917 //$topicmail = "Information";
918 //$modelmail = "accountingbookkeeping";
919 //$objecttmp = new BookKeeping($db);
920 //$trackid = 'bk'.$object->id;
921 include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
922 
923 $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
924 $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
925 if ($massactionbutton && $contextpage != 'poslist') {
926  $selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
927 }
928 
929 $moreforfilter = '';
930 
931 $parameters = array();
932 $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook
933 if (empty($reshook)) {
934  $moreforfilter .= $hookmanager->resPrint;
935 } else {
936  $moreforfilter = $hookmanager->resPrint;
937 }
938 
939 print '<div class="div-table-responsive">';
940 print '<table class="tagtable liste centpercent">';
941 
942 // Filters lines
943 print '<tr class="liste_titre_filter">';
944 
945 // Movement number
946 if (!empty($arrayfields['t.piece_num']['checked'])) {
947  print '<td class="liste_titre"><input type="text" name="search_mvt_num" size="6" value="'.dol_escape_htmltag($search_mvt_num).'"></td>';
948 }
949 // Code journal
950 if (!empty($arrayfields['t.code_journal']['checked'])) {
951  print '<td class="liste_titre center">';
952  print $formaccounting->multi_select_journal($search_ledger_code, 'search_ledger_code', 0, 1, 1, 1, 'small maxwidth150');
953  print '</td>';
954 }
955 // Date document
956 if (!empty($arrayfields['t.doc_date']['checked'])) {
957  print '<td class="liste_titre center">';
958  print '<div class="nowrap">';
959  print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"));
960  print '</div>';
961  print '<div class="nowrap">';
962  print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to"));
963  print '</div>';
964  print '</td>';
965 }
966 // Ref document
967 if (!empty($arrayfields['t.doc_ref']['checked'])) {
968  print '<td class="liste_titre"><input type="text" name="search_doc_ref" size="8" value="'.dol_escape_htmltag($search_doc_ref).'"></td>';
969 }
970 // Accountancy account
971 if (!empty($arrayfields['t.numero_compte']['checked'])) {
972  print '<td class="liste_titre">';
973  print '<div class="nowrap">';
974  print $formaccounting->select_account($search_accountancy_code_start, 'search_accountancy_code_start', $langs->trans('From'), array(), 1, 1, 'maxwidth150', 'account');
975  print '</div>';
976  print '<div class="nowrap">';
977  print $formaccounting->select_account($search_accountancy_code_end, 'search_accountancy_code_end', $langs->trans('to'), array(), 1, 1, 'maxwidth150', 'account');
978  print '</div>';
979  print '</td>';
980 }
981 // Subledger account
982 if (!empty($arrayfields['t.subledger_account']['checked'])) {
983  print '<td class="liste_titre">';
984  // TODO For the moment we keep a free input text instead of a combo. The select_auxaccount has problem because it does not
985  // use setup of keypress to select thirdparty and this hang browser on large database.
986  if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) {
987  print '<div class="nowrap">';
988  //print $langs->trans('From').' ';
989  print $formaccounting->select_auxaccount($search_accountancy_aux_code_start, 'search_accountancy_aux_code_start', $langs->trans('From'), 'maxwidth250', 'subledgeraccount');
990  print '</div>';
991  print '<div class="nowrap">';
992  print $formaccounting->select_auxaccount($search_accountancy_aux_code_end, 'search_accountancy_aux_code_end', $langs->trans('to'), 'maxwidth250', 'subledgeraccount');
993  print '</div>';
994  } else {
995  print '<input type="text" class="maxwidth75" name="search_accountancy_aux_code" value="'.$search_accountancy_aux_code.'">';
996  }
997  print '</td>';
998 }
999 // Label operation
1000 if (!empty($arrayfields['t.label_operation']['checked'])) {
1001  print '<td class="liste_titre">';
1002  print '<input type="text" size="7" class="flat" name="search_mvt_label" value="'.$search_mvt_label.'"/>';
1003  print '</td>';
1004 }
1005 // Debit
1006 if (!empty($arrayfields['t.debit']['checked'])) {
1007  print '<td class="liste_titre right">';
1008  print '<input type="text" class="flat" name="search_debit" size="4" value="'.dol_escape_htmltag($search_debit).'">';
1009  print '</td>';
1010 }
1011 // Credit
1012 if (!empty($arrayfields['t.credit']['checked'])) {
1013  print '<td class="liste_titre right">';
1014  print '<input type="text" class="flat" name="search_credit" size="4" value="'.dol_escape_htmltag($search_credit).'">';
1015  print '</td>';
1016 }
1017 // Lettering code
1018 if (!empty($arrayfields['t.lettering_code']['checked'])) {
1019  print '<td class="liste_titre center">';
1020  print '<input type="text" size="3" class="flat" name="search_lettering_code" value="'.$search_lettering_code.'"/>';
1021  print '<br><span class="nowrap"><input type="checkbox" name="search_not_reconciled" value="notreconciled"'.($search_not_reconciled == 'notreconciled' ? ' checked' : '').'>'.$langs->trans("NotReconciled").'</span>';
1022  print '</td>';
1023 }
1024 
1025 // Fields from hook
1026 $parameters = array('arrayfields'=>$arrayfields);
1027 $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
1028 print $hookmanager->resPrint;
1029 
1030 // Date creation
1031 if (!empty($arrayfields['t.date_creation']['checked'])) {
1032  print '<td class="liste_titre center">';
1033  print '<div class="nowrap">';
1034  print $form->selectDate($search_date_creation_start, 'search_date_creation_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"));
1035  print '</div>';
1036  print '<div class="nowrap">';
1037  print $form->selectDate($search_date_creation_end, 'search_date_creation_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to"));
1038  print '</div>';
1039  print '</td>';
1040 }
1041 // Date modification
1042 if (!empty($arrayfields['t.tms']['checked'])) {
1043  print '<td class="liste_titre center">';
1044  print '<div class="nowrap">';
1045  print $form->selectDate($search_date_modification_start, 'search_date_modification_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"));
1046  print '</div>';
1047  print '<div class="nowrap">';
1048  print $form->selectDate($search_date_modification_end, 'search_date_modification_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"));
1049  print '</div>';
1050  print '</td>';
1051 }
1052 // Date export
1053 if (!empty($arrayfields['t.date_export']['checked'])) {
1054  print '<td class="liste_titre center">';
1055  print '<div class="nowrap">';
1056  print $form->selectDate($search_date_export_start, 'search_date_export_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"));
1057  print '</div>';
1058  print '<div class="nowrap">';
1059  print $form->selectDate($search_date_export_end, 'search_date_export_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to"));
1060  print '</div>';
1061  print '</td>';
1062 }
1063 // Date validation
1064 if (!empty($arrayfields['t.date_validated']['checked'])) {
1065  print '<td class="liste_titre center">';
1066  print '<div class="nowrap">';
1067  print $form->selectDate($search_date_validation_start, 'search_date_validation_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"));
1068  print '</div>';
1069  print '<div class="nowrap">';
1070  print $form->selectDate($search_date_validation_end, 'search_date_validation_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to"));
1071  print '</div>';
1072  print '</td>';
1073 }
1074 if (!empty($arrayfields['t.import_key']['checked'])) {
1075  print '<td class="liste_titre center">';
1076  print '<input class="flat searchstring maxwidth50" type="text" name="search_import_key" value="'.dol_escape_htmltag($search_import_key).'">';
1077  print '</td>';
1078 }
1079 // Action column
1080 print '<td class="liste_titre center">';
1081 $searchpicto = $form->showFilterButtons();
1082 print $searchpicto;
1083 print '</td>';
1084 print "</tr>\n";
1085 
1086 print '<tr class="liste_titre">';
1087 if (!empty($arrayfields['t.piece_num']['checked'])) {
1088  print_liste_field_titre($arrayfields['t.piece_num']['label'], $_SERVER['PHP_SELF'], "t.piece_num", "", $param, "", $sortfield, $sortorder);
1089 }
1090 if (!empty($arrayfields['t.code_journal']['checked'])) {
1091  print_liste_field_titre($arrayfields['t.code_journal']['label'], $_SERVER['PHP_SELF'], "t.code_journal", "", $param, '', $sortfield, $sortorder, 'center ');
1092 }
1093 if (!empty($arrayfields['t.doc_date']['checked'])) {
1094  print_liste_field_titre($arrayfields['t.doc_date']['label'], $_SERVER['PHP_SELF'], "t.doc_date", "", $param, '', $sortfield, $sortorder, 'center ');
1095 }
1096 if (!empty($arrayfields['t.doc_ref']['checked'])) {
1097  print_liste_field_titre($arrayfields['t.doc_ref']['label'], $_SERVER['PHP_SELF'], "t.doc_ref", "", $param, "", $sortfield, $sortorder);
1098 }
1099 if (!empty($arrayfields['t.numero_compte']['checked'])) {
1100  print_liste_field_titre($arrayfields['t.numero_compte']['label'], $_SERVER['PHP_SELF'], "t.numero_compte", "", $param, "", $sortfield, $sortorder);
1101 }
1102 if (!empty($arrayfields['t.subledger_account']['checked'])) {
1103  print_liste_field_titre($arrayfields['t.subledger_account']['label'], $_SERVER['PHP_SELF'], "t.subledger_account", "", $param, "", $sortfield, $sortorder);
1104 }
1105 if (!empty($arrayfields['t.label_operation']['checked'])) {
1106  print_liste_field_titre($arrayfields['t.label_operation']['label'], $_SERVER['PHP_SELF'], "t.label_operation", "", $param, "", $sortfield, $sortorder);
1107 }
1108 if (!empty($arrayfields['t.debit']['checked'])) {
1109  print_liste_field_titre($arrayfields['t.debit']['label'], $_SERVER['PHP_SELF'], "t.debit", "", $param, '', $sortfield, $sortorder, 'right ');
1110 }
1111 if (!empty($arrayfields['t.credit']['checked'])) {
1112  print_liste_field_titre($arrayfields['t.credit']['label'], $_SERVER['PHP_SELF'], "t.credit", "", $param, '', $sortfield, $sortorder, 'right ');
1113 }
1114 if (!empty($arrayfields['t.lettering_code']['checked'])) {
1115  print_liste_field_titre($arrayfields['t.lettering_code']['label'], $_SERVER['PHP_SELF'], "t.lettering_code", "", $param, '', $sortfield, $sortorder, 'center ');
1116 }
1117 // Hook fields
1118 $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
1119 $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
1120 print $hookmanager->resPrint;
1121 if (!empty($arrayfields['t.date_creation']['checked'])) {
1122  print_liste_field_titre($arrayfields['t.date_creation']['label'], $_SERVER['PHP_SELF'], "t.date_creation", "", $param, '', $sortfield, $sortorder, 'center ');
1123 }
1124 if (!empty($arrayfields['t.tms']['checked'])) {
1125  print_liste_field_titre($arrayfields['t.tms']['label'], $_SERVER['PHP_SELF'], "t.tms", "", $param, '', $sortfield, $sortorder, 'center ');
1126 }
1127 if (!empty($arrayfields['t.date_export']['checked'])) {
1128  print_liste_field_titre($arrayfields['t.date_export']['label'], $_SERVER['PHP_SELF'], "t.date_export", "", $param, '', $sortfield, $sortorder, 'center ');
1129 }
1130 if (!empty($arrayfields['t.date_validated']['checked'])) {
1131  print_liste_field_titre($arrayfields['t.date_validated']['label'], $_SERVER['PHP_SELF'], "t.date_validated", "", $param, '', $sortfield, $sortorder, 'center ');
1132 }
1133 if (!empty($arrayfields['t.import_key']['checked'])) {
1134  print_liste_field_titre($arrayfields['t.import_key']['label'], $_SERVER["PHP_SELF"], "t.import_key", "", $param, '', $sortfield, $sortorder, 'center ');
1135 }
1136 print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
1137 print "</tr>\n";
1138 
1139 
1140 $line = new BookKeepingLine();
1141 
1142 // Loop on record
1143 // --------------------------------------------------------------------
1144 $i = 0;
1145 $totalarray = array();
1146 $totalarray['val'] = array ();
1147 $totalarray['nbfield'] = 0;
1148 $total_debit = 0;
1149 $total_credit = 0;
1150 $totalarray['val']['totaldebit'] = 0;
1151 $totalarray['val']['totalcredit'] = 0;
1152 
1153 while ($i < min($num, $limit)) {
1154  $obj = $db->fetch_object($resql);
1155  if (empty($obj)) {
1156  break; // Should not happen
1157  }
1158 
1159  $line->id = $obj->rowid;
1160  $line->doc_date = $db->jdate($obj->doc_date);
1161  $line->doc_type = $obj->doc_type;
1162  $line->doc_ref = $obj->doc_ref;
1163  $line->fk_doc = $obj->fk_doc;
1164  $line->fk_docdet = $obj->fk_docdet;
1165  $line->thirdparty_code = $obj->thirdparty_code;
1166  $line->subledger_account = $obj->subledger_account;
1167  $line->subledger_label = $obj->subledger_label;
1168  $line->numero_compte = $obj->numero_compte;
1169  $line->label_compte = $obj->label_compte;
1170  $line->label_operation = $obj->label_operation;
1171  $line->debit = $obj->debit;
1172  $line->credit = $obj->credit;
1173  $line->montant = $obj->amount; // deprecated
1174  $line->amount = $obj->amount;
1175  $line->sens = $obj->sens;
1176  $line->lettering_code = $obj->lettering_code;
1177  $line->fk_user_author = $obj->fk_user_author;
1178  $line->import_key = $obj->import_key;
1179  $line->code_journal = $obj->code_journal;
1180  $line->journal_label = $obj->journal_label;
1181  $line->piece_num = $obj->piece_num;
1182  $line->date_creation = $db->jdate($obj->date_creation);
1183  $line->date_modification = $db->jdate($obj->date_modification);
1184  $line->date_export = $db->jdate($obj->date_export);
1185  $line->date_validation = $db->jdate($obj->date_validation);
1186 
1187  $total_debit += $line->debit;
1188  $total_credit += $line->credit;
1189 
1190  print '<tr class="oddeven">';
1191 
1192  // Piece number
1193  if (!empty($arrayfields['t.piece_num']['checked'])) {
1194  print '<td>';
1195  $object->id = $line->id;
1196  $object->piece_num = $line->piece_num;
1197  print $object->getNomUrl(1, '', 0, '', 1);
1198  print '</td>';
1199  if (!$i) {
1200  $totalarray['nbfield']++;
1201  }
1202  }
1203 
1204  // Journal code
1205  if (!empty($arrayfields['t.code_journal']['checked'])) {
1206  $accountingjournal = new AccountingJournal($db);
1207  $result = $accountingjournal->fetch('', $line->code_journal);
1208  $journaltoshow = (($result > 0) ? $accountingjournal->getNomUrl(0, 0, 0, '', 0) : $line->code_journal);
1209  print '<td class="center">'.$journaltoshow.'</td>';
1210  if (!$i) {
1211  $totalarray['nbfield']++;
1212  }
1213  }
1214 
1215  // Document date
1216  if (!empty($arrayfields['t.doc_date']['checked'])) {
1217  print '<td class="center">'.dol_print_date($line->doc_date, 'day').'</td>';
1218  if (!$i) {
1219  $totalarray['nbfield']++;
1220  }
1221  }
1222 
1223  // Document ref
1224  if (!empty($arrayfields['t.doc_ref']['checked'])) {
1225  if ($line->doc_type == 'customer_invoice') {
1226  $langs->loadLangs(array('bills'));
1227 
1228  require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
1229  $objectstatic = new Facture($db);
1230  $objectstatic->fetch($line->fk_doc);
1231  //$modulepart = 'facture';
1232 
1233  $filename = dol_sanitizeFileName($line->doc_ref);
1234  $filedir = $conf->facture->dir_output.'/'.dol_sanitizeFileName($line->doc_ref);
1235  $urlsource = $_SERVER['PHP_SELF'].'?id='.$objectstatic->id;
1236  $documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir);
1237  } elseif ($line->doc_type == 'supplier_invoice') {
1238  $langs->loadLangs(array('bills'));
1239 
1240  require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
1241  $objectstatic = new FactureFournisseur($db);
1242  $objectstatic->fetch($line->fk_doc);
1243  //$modulepart = 'invoice_supplier';
1244 
1245  $filename = dol_sanitizeFileName($line->doc_ref);
1246  $filedir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($line->fk_doc, 2, 0, 0, $objectstatic, $modulepart).dol_sanitizeFileName($line->doc_ref);
1247  $subdir = get_exdir($objectstatic->id, 2, 0, 0, $objectstatic, $modulepart).dol_sanitizeFileName($line->doc_ref);
1248  $documentlink = $formfile->getDocumentsLink($objectstatic->element, $subdir, $filedir);
1249  } elseif ($line->doc_type == 'expense_report') {
1250  $langs->loadLangs(array('trips'));
1251 
1252  require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
1253  $objectstatic = new ExpenseReport($db);
1254  $objectstatic->fetch($line->fk_doc);
1255  //$modulepart = 'expensereport';
1256 
1257  $filename = dol_sanitizeFileName($line->doc_ref);
1258  $filedir = $conf->expensereport->dir_output.'/'.dol_sanitizeFileName($line->doc_ref);
1259  $urlsource = $_SERVER['PHP_SELF'].'?id='.$objectstatic->id;
1260  $documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir);
1261  } elseif ($line->doc_type == 'bank') {
1262  require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
1263  $objectstatic = new AccountLine($db);
1264  $objectstatic->fetch($line->fk_doc);
1265  } else {
1266  // Other type
1267  }
1268 
1269  $labeltoshow = '';
1270  $labeltoshowalt = '';
1271  if ($line->doc_type == 'customer_invoice' || $line->doc_type == 'supplier_invoice' || $line->doc_type == 'expense_report') {
1272  $labeltoshow .= $objectstatic->getNomUrl(1, '', 0, 0, '', 0, -1, 1);
1273  $labeltoshow .= $documentlink;
1274  $labeltoshowalt .= $objectstatic->ref;
1275  } elseif ($line->doc_type == 'bank') {
1276  $labeltoshow .= $objectstatic->getNomUrl(1);
1277  $labeltoshowalt .= $objectstatic->ref;
1278  $bank_ref = strstr($line->doc_ref, '-');
1279  $labeltoshow .= " " . $bank_ref;
1280  $labeltoshowalt .= " " . $bank_ref;
1281  } else {
1282  $labeltoshow .= $line->doc_ref;
1283  $labeltoshowalt .= $line->doc_ref;
1284  }
1285 
1286  print '<td class="nowraponall tdoverflowmax200" title="'.dol_escape_htmltag($labeltoshowalt).'">';
1287  print $labeltoshow;
1288  print "</td>\n";
1289  if (!$i) {
1290  $totalarray['nbfield']++;
1291  }
1292  }
1293 
1294  // Account number
1295  if (!empty($arrayfields['t.numero_compte']['checked'])) {
1296  print '<td>'.length_accountg($line->numero_compte).'</td>';
1297  if (!$i) {
1298  $totalarray['nbfield']++;
1299  }
1300  }
1301 
1302  // Subledger account
1303  if (!empty($arrayfields['t.subledger_account']['checked'])) {
1304  print '<td>'.length_accounta($line->subledger_account).'</td>';
1305  if (!$i) {
1306  $totalarray['nbfield']++;
1307  }
1308  }
1309 
1310  // Label operation
1311  if (!empty($arrayfields['t.label_operation']['checked'])) {
1312  print '<td class="small tdoverflowmax200" title="'.dol_escape_htmltag($line->label_operation).'">'.dol_escape_htmltag($line->label_operation).'</td>';
1313  if (!$i) {
1314  $totalarray['nbfield']++;
1315  }
1316  }
1317 
1318  // Amount debit
1319  if (!empty($arrayfields['t.debit']['checked'])) {
1320  print '<td class="right nowraponall amount">'.($line->debit != 0 ? price($line->debit) : '').'</td>';
1321  if (!$i) {
1322  $totalarray['nbfield']++;
1323  }
1324  if (!$i) {
1325  $totalarray['pos'][$totalarray['nbfield']] = 'totaldebit';
1326  }
1327  $totalarray['val']['totaldebit'] += $line->debit;
1328  }
1329 
1330  // Amount credit
1331  if (!empty($arrayfields['t.credit']['checked'])) {
1332  print '<td class="right nowraponall amount">'.($line->credit != 0 ? price($line->credit) : '').'</td>';
1333  if (!$i) {
1334  $totalarray['nbfield']++;
1335  }
1336  if (!$i) {
1337  $totalarray['pos'][$totalarray['nbfield']] = 'totalcredit';
1338  }
1339  $totalarray['val']['totalcredit'] += $line->credit;
1340  }
1341 
1342  // Lettering code
1343  if (!empty($arrayfields['t.lettering_code']['checked'])) {
1344  print '<td class="center">'.$line->lettering_code.'</td>';
1345  if (!$i) {
1346  $totalarray['nbfield']++;
1347  }
1348  }
1349 
1350  // Fields from hook
1351  $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
1352  $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook
1353  print $hookmanager->resPrint;
1354 
1355  // Creation operation date
1356  if (!empty($arrayfields['t.date_creation']['checked'])) {
1357  print '<td class="center">'.dol_print_date($line->date_creation, 'dayhour').'</td>';
1358  if (!$i) {
1359  $totalarray['nbfield']++;
1360  }
1361  }
1362 
1363  // Modification operation date
1364  if (!empty($arrayfields['t.tms']['checked'])) {
1365  print '<td class="center">'.dol_print_date($line->date_modification, 'dayhour').'</td>';
1366  if (!$i) {
1367  $totalarray['nbfield']++;
1368  }
1369  }
1370 
1371  // Exported operation date
1372  if (!empty($arrayfields['t.date_export']['checked'])) {
1373  print '<td class="center nowraponall">'.dol_print_date($line->date_export, 'dayhour').'</td>';
1374  if (!$i) {
1375  $totalarray['nbfield']++;
1376  }
1377  }
1378 
1379  // Validated operation date
1380  if (!empty($arrayfields['t.date_validated']['checked'])) {
1381  print '<td class="center nowraponall">'.dol_print_date($line->date_validation, 'dayhour').'</td>';
1382  if (!$i) {
1383  $totalarray['nbfield']++;
1384  }
1385  }
1386 
1387  if (!empty($arrayfields['t.import_key']['checked'])) {
1388  print '<td class="tdoverflowmax100">'.$obj->import_key."</td>\n";
1389  if (!$i) {
1390  $totalarray['nbfield']++;
1391  }
1392  }
1393 
1394  // Action column
1395  print '<td class="nowraponall center">';
1396  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
1397  $selected = 0;
1398  if (in_array($line->id, $arrayofselected)) {
1399  $selected = 1;
1400  }
1401  print '<input id="cb'.$line->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$line->id.'"'.($selected ? ' checked="checked"' : '').' />';
1402  }
1403  print '</td>';
1404 
1405  if (!$i) {
1406  $totalarray['nbfield']++;
1407  }
1408 
1409  print "</tr>\n";
1410 
1411  $i++;
1412 }
1413 
1414 // Show total line
1415 include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
1416 
1417 
1418 print "</table>";
1419 print '</div>';
1420 
1421 // TODO Replace this with mass delete action
1422 //if ($user->rights->accounting->mouvements->supprimer_tous) {
1423 // print '<div class="tabsAction tabsActionNoBottom">'."\n";
1424 // print '<a class="butActionDelete" name="button_delmvt" href="'.$_SERVER["PHP_SELF"].'?action=delbookkeepingyear&token='.newToken().($param ? '&'.$param : '').'">'.$langs->trans("DeleteMvt").'</a>';
1425 // print '</div>';
1426 //}
1427 
1428 print '</form>';
1429 
1430 // End of page
1431 llxFooter();
1432 $db->close();
dol_getdate
dol_getdate($timestamp, $fast=false, $forcetimezone='')
Return an array with locale date info.
Definition: functions.lib.php:2713
dol_escape_htmltag
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.
Definition: functions.lib.php:1468
dol_sanitizeFileName
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
Definition: functions.lib.php:1226
llxFooter
llxFooter()
Empty footer.
Definition: wrapper.php:73
GETPOST
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Definition: functions.lib.php:484
FactureFournisseur
Class to manage suppliers invoices.
Definition: fournisseur.facture.class.php:53
dol_print_error
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
Definition: functions.lib.php:4844
BookKeepingLine
Class BookKeepingLine.
Definition: bookkeeping.class.php:2135
$form
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:142
FormOther
Classe permettant la generation de composants html autre Only common components are here.
Definition: html.formother.class.php:39
Facture
Class to manage invoices.
Definition: facture.class.php:60
FormAccounting
Class to manage generation of HTML components for accounting management.
Definition: html.formaccounting.class.php:33
dol_print_date
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
Definition: functions.lib.php:2514
img_picto
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
Definition: functions.lib.php:3880
get_exdir
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart='')
Return a path to have a the directory according to object where files are stored.
Definition: functions.lib.php:6549
$formconfirm
$formconfirm
if ($action == 'delbookkeepingyear') {
Definition: listbyaccount.php:576
AccountancyExport
Manage the different format accountancy export.
Definition: accountancyexport.class.php:44
FormFile
Class to offer components to list and upload files.
Definition: html.formfile.class.php:36
AccountingJournal
Class to manage accounting accounts.
Definition: accountingjournal.class.php:27
dolGetButtonTitle
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.
Definition: functions.lib.php:10605
dol_syslog
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
Definition: functions.lib.php:1603
print_barre_liste
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.
Definition: functions.lib.php:5257
getDolGlobalString
if(!function_exists('utf8_encode')) if(!function_exists('utf8_decode')) getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
Definition: functions.lib.php:80
dol_get_last_day
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
newToken
newToken()
Return the value of token currently saved into session with name 'newtoken'.
Definition: functions.lib.php:10878
isModEnabled
isModEnabled($module)
Is Dolibarr module enabled.
Definition: functions.lib.php:105
BookKeeping
Class to manage Ledger (General Ledger and Subledger)
Definition: bookkeeping.class.php:33
dolibarr_set_const
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
GETPOSTISSET
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
Definition: functions.lib.php:386
print_liste_field_titre
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
Definition: functions.lib.php:5026
Lettering
Class Lettering.
Definition: lettering.class.php:34
natural_search
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...
Definition: functions.lib.php:9420
Form
Class to manage generation of HTML components Only common components must be here.
Definition: html.form.class.php:52
AccountLine
Class to manage bank transaction lines.
Definition: account.class.php:1779
ExpenseReport
Class to manage Trips and Expenses.
Definition: expensereport.class.php:36
dol_now
dol_now($mode='auto')
Return date for now.
Definition: functions.lib.php:2845
$resql
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
price
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.
Definition: functions.lib.php:5541
setEventMessages
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
Definition: functions.lib.php:8137
accessforbidden
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 ...
Definition: security.lib.php:933
dol_mktime
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...
Definition: functions.lib.php:2757
getDolGlobalInt
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
Definition: functions.lib.php:93
llxHeader
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