dolibarr 24.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-2026 Alexandre Spangaro <alexandre@inovea-conseil.com>
5 * Copyright (C) 2022 Lionel Vessiller <lvessiller@open-dsi.fr>
6 * Copyright (C) 2016-2017 Laurent Destailleur <eldy@users.sourceforge.net>
7 * Copyright (C) 2018-2025 Frédéric France <frederic.france@free.fr>
8 * Copyright (C) 2022 Progiseize <a.bisotti@progiseiea-conseil.com>
9 * Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
10 * Copyright (C) 2025 Nicolas Barrouillet <nicolas@pragma-tech.fr>
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 3 of the License, or
15 * (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program. If not, see <https://www.gnu.org/licenses/>.
24 */
25
32// Load Dolibarr environment
33require '../../main.inc.php';
41require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
42require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfiscalyear.class.php';
43require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
44require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
45require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
46require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
47require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
48require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php';
49require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php';
50require_once DOL_DOCUMENT_ROOT.'/accountancy/class/lettering.class.php';
51
52// Load translation files required by the page
53$langs->loadLangs(array("accountancy", "categories", "compta", "other"));
54
55// Get Parameters
56$socid = GETPOSTINT('socid');
57$journal_code = GETPOST('code_journal', 'alpha');
58$account = GETPOST("account", 'int');
59$massdate = dol_mktime(0, 0, 0, GETPOSTINT('massdatemonth'), GETPOSTINT('massdateday'), GETPOSTINT('massdateyear'));
60
61// action+display Parameters
62$action = GETPOST('action', 'aZ09');
63$massaction = GETPOST('massaction', 'alpha');
64$confirm = GETPOST('confirm', 'alpha');
65$toselect = GETPOST('toselect', 'array:int');
66$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : str_replace('_', '', basename(dirname(__FILE__)).basename(__FILE__, '.php'));
67
68// Search Parameters
69$search_mvt_num = GETPOST('search_mvt_num', 'alpha');
70$search_doc_type = GETPOST("search_doc_type", 'alpha');
71$search_doc_ref = GETPOST("search_doc_ref", 'alpha');
72
73$search_doc_date = GETPOSTDATE('doc_date', 'getpost'); // deprecated. Can use 'search_date_start/end'
74
75$search_date_start = GETPOSTDATE('search_date_start', 'getpost', 'auto', 'search_date_start_accountancy');
76$search_date_end = GETPOSTDATE('search_date_end', 'getpostend', 'auto', 'search_date_end_accountancy');
77
78$search_date_creation_start = GETPOSTDATE('search_date_creation_start', 'getpost');
79$search_date_creation_end = GETPOSTDATE('search_date_creation_end', 'getpostend');
80
81$search_date_modification_start = GETPOSTDATE('search_date_modification_start', 'getpost');
82$search_date_modification_end = GETPOSTDATE('search_date_modification_end', 'getpostend');
83
84$search_date_export_start = GETPOSTDATE('search_date_export_start', 'getpost');
85$search_date_export_end = GETPOSTDATE('search_date_export_end', 'getpostend');
86
87$search_date_validation_start = GETPOSTDATE('search_date_validation_start', 'getpost');
88$search_date_validation_end = GETPOSTDATE('search_date_validation_end', 'getpostend');
89
90// Due date start
91$search_date_due_start_day = GETPOSTINT('search_date_due_start_day');
92$search_date_due_start_month = GETPOSTINT('search_date_due_start_month');
93$search_date_due_start_year = GETPOSTINT('search_date_due_start_year');
94$search_date_due_start = GETPOSTDATE('search_date_due_start_', 'getpost');
95
96// Due date end
97$search_date_due_end_day = GETPOSTINT('search_date_due_end_day');
98$search_date_due_end_month = GETPOSTINT('search_date_due_end_month');
99$search_date_due_end_year = GETPOSTINT('search_date_due_end_year');
100$search_date_due_end = GETPOSTDATE('search_date_due_end_', 'getpostend');
101
102$search_import_key = GETPOST("search_import_key", 'alpha');
103
104$search_account_category = GETPOSTINT('search_account_category');
105
106$search_accountancy_code = GETPOST("search_accountancy_code", 'alpha');
107$search_accountancy_code_start = GETPOST('search_accountancy_code_start', 'alpha');
108if ($search_accountancy_code_start == - 1) {
109 $search_accountancy_code_start = '';
110}
111$search_accountancy_code_end = GETPOST('search_accountancy_code_end', 'alpha');
112if ($search_accountancy_code_end == - 1) {
113 $search_accountancy_code_end = '';
114}
115
116$search_accountancy_aux_code = GETPOST("search_accountancy_aux_code", 'alpha');
117$search_accountancy_aux_code_start = GETPOST('search_accountancy_aux_code_start', 'alpha');
118if ($search_accountancy_aux_code_start == - 1) {
119 $search_accountancy_aux_code_start = '';
120}
121$search_accountancy_aux_code_end = GETPOST('search_accountancy_aux_code_end', 'alpha');
122if ($search_accountancy_aux_code_end == - 1) {
123 $search_accountancy_aux_code_end = '';
124}
125$search_mvt_label = GETPOST('search_mvt_label', 'alpha');
126$search_direction = GETPOST('search_direction', 'alpha');
127$search_debit = GETPOST('search_debit', 'alpha');
128$search_credit = GETPOST('search_credit', 'alpha');
129$search_ledger_code = GETPOST('search_ledger_code', 'array');
130$search_lettering_code = GETPOST('search_lettering_code', 'alpha');
131$search_not_reconciled = GETPOST('search_not_reconciled', 'alpha');
132
133// Load variable for pagination
134$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : getDolGlobalString('ACCOUNTING_LIMIT_LIST_VENTILATION', $conf->liste_limit);
135$sortfield = GETPOST('sortfield', 'aZ09comma');
136$sortorder = GETPOST('sortorder', 'aZ09comma');
137$optioncss = GETPOST('optioncss', 'alpha');
138$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
139if (empty($page) || $page < 0) {
140 $page = 0;
141}
142$offset = $limit * $page;
143$pageprev = $page - 1;
144$pagenext = $page + 1;
145if ($sortorder == "") {
146 $sortorder = "ASC";
147}
148if ($sortfield == "") {
149 $sortfield = "t.piece_num,t.rowid";
150}
151
152// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
153$object = new BookKeeping($db);
154$hookmanager->initHooks(array('bookkeepinglist'));
155
156$formfiscalyear = new FormFiscalYear($db);
157$formaccounting = new FormAccounting($db);
158$form = new Form($db);
159
160if (!in_array($action, array('delmouv', 'delmouvconfirm')) && !GETPOSTISSET('begin') && !GETPOSTISSET('formfilteraction') && GETPOST('page', 'alpha') == '' && !GETPOSTINT('noreset') && $user->hasRight('accounting', 'mouvements', 'export')) {
161 if (empty($search_date_start) && empty($search_date_end) && !GETPOSTISSET('restore_lastsearch_values') && !GETPOST('search_mvt_num') && !GETPOST('search_accountancy_code_start')) {
162 $sql = "SELECT date_start, date_end";
163 $sql .= " FROM ".MAIN_DB_PREFIX."accounting_fiscalyear ";
164 if (getDolGlobalInt('ACCOUNTANCY_FISCALYEAR_DEFAULT')) {
165 $sql .= " WHERE rowid = " . getDolGlobalInt('ACCOUNTANCY_FISCALYEAR_DEFAULT');
166 } else {
167 $sql .= " WHERE date_start < '" . $db->idate(dol_now()) . "' and date_end > '" . $db->idate(dol_now()) . "'";
168 }
169 $sql .= $db->plimit(1);
170 $res = $db->query($sql);
171
172 if ($db->num_rows($res) > 0) {
173 $fiscalYear = $db->fetch_object($res);
174 $search_date_start = strtotime($fiscalYear->date_start);
175 $search_date_end = strtotime($fiscalYear->date_end);
176 } else {
177 $month_start = getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1);
178 $year_start = (int) dol_print_date(dol_now(), '%Y');
179 if (dol_print_date(dol_now(), '%m') < $month_start) {
180 $year_start--; // If current month is lower that starting fiscal month, we start last year
181 }
182 $year_end = $year_start + 1;
183 $month_end = $month_start - 1;
184 if ($month_end < 1) {
185 $month_end = 12;
186 $year_end--;
187 }
188 $search_date_start = dol_mktime(0, 0, 0, $month_start, 1, $year_start);
189 $search_date_end = dol_get_last_day($year_end, $month_end);
190 }
191 }
192}
193
194
195$arrayfields = array(
196 't.piece_num' => array('label' => $langs->trans("TransactionNumShort"), 'checked' => '1'),
197 't.code_journal' => array('label' => $langs->trans("Codejournal"), 'checked' => '1'),
198 't.doc_date' => array('label' => $langs->trans("Docdate"), 'checked' => '1'),
199 't.doc_ref' => array('label' => $langs->trans("Piece"), 'checked' => '1'),
200 't.numero_compte' => array('label' => $langs->trans("AccountAccountingShort"), 'checked' => '1'),
201 't.subledger_account' => array('label' => $langs->trans("SubledgerAccount"), 'checked' => '1'),
202 't.label_operation' => array('label' => $langs->trans("Label"), 'checked' => '1'),
203 't.debit' => array('label' => $langs->trans("AccountingDebit"), 'checked' => '1'),
204 't.credit' => array('label' => $langs->trans("AccountingCredit"), 'checked' => '1'),
205 't.lettering_code' => array('label' => $langs->trans("LetteringCode"), 'checked' => '1'),
206 't.date_creation' => array('label' => $langs->trans("DateCreation"), 'checked' => '0'),
207 't.tms' => array('label' => $langs->trans("DateModification"), 'checked' => '0'),
208 't.date_export' => array('label' => $langs->trans("DateExport"), 'checked' => '0'),
209 't.date_validated' => array('label' => $langs->trans("DateValidationAndLock"), 'checked' => '0', 'enabled' => (string) (int) !getDolGlobalString("ACCOUNTANCY_DISABLE_CLOSURE_LINE_BY_LINE")),
210 't.date_lim_reglement' => array('label' => $langs->trans("DateDue"), 'checked' => '0'),
211 't.import_key' => array('label' => $langs->trans("ImportId"), 'checked' => '0', 'position' => 1100),
212);
213// Add hook to complete $arrayfield
214$parameters = array('arrayfields' => &$arrayfields);
215$reshook = $hookmanager->executeHooks('completeArrayFields', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
216
217if (!getDolGlobalString('ACCOUNTING_ENABLE_LETTERING')) {
218 unset($arrayfields['t.lettering_code']);
219}
220
221$error = 0;
222
223if (!isModEnabled('accounting')) {
225}
226if ($user->socid > 0) {
228}
229if (!$user->hasRight('accounting', 'mouvements', 'lire')) {
231}
232
233// Permissions
234$permissiontoread = $user->hasRight('accounting', 'mouvements', 'lire');
235$permissiontoadd = $user->hasRight('accounting', 'mouvements', 'creer');
236$permissiontodelete = $user->hasRight('accounting', 'mouvements', 'supprimer');
237$permissiontoexport = $user->hasRight('accounting', 'mouvements', 'export');
238
239
240/*
241 * Actions
242 */
243
244$param = '';
245$filter = array();
246
247if (GETPOST('cancel', 'alpha')) {
248 $action = 'list';
249 $massaction = '';
250}
251if (!GETPOST('confirmmassaction', 'alpha') &&
252 !in_array($massaction, [
253 'pregeneralunmatchingmanual',
254 'predeletebookkeepingwriting',
255 'preclonebookkeepingwriting',
256 'preassignaccountbookkeepingwriting',
257 'prereturnaccountbookkeepingwriting'
258 ])) {
259 $massaction = '';
260}
261
262$parameters = array('socid' => $socid);
263$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
264if ($reshook < 0) {
265 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
266}
267
268if (empty($reshook)) {
269 include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
270
271 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
272 $search_mvt_num = '';
273 $search_doc_type = '';
274 $search_doc_ref = '';
275 $search_doc_date = '';
276 $search_account_category = '';
277 $search_accountancy_code = '';
278 $search_accountancy_code_start = '';
279 $search_accountancy_code_end = '';
280 $search_accountancy_aux_code = '';
281 $search_accountancy_aux_code_start = '';
282 $search_accountancy_aux_code_end = '';
283 $search_mvt_label = '';
284 $search_direction = '';
285 $search_ledger_code = array();
286 $search_date_start = '';
287 $search_date_end = '';
288 $search_date_creation_start = '';
289 $search_date_creation_end = '';
290 $search_date_modification_start = '';
291 $search_date_modification_end = '';
292 $search_date_export_start = '';
293 $search_date_export_end = '';
294 $search_date_validation_start = '';
295 $search_date_validation_end = '';
296 // Due date start
297 $search_date_due_start_day = '';
298 $search_date_due_start_month = '';
299 $search_date_due_start_year = '';
300 $search_date_due_start = '';
301 // Due date end
302 $search_date_due_end_day = '';
303 $search_date_due_end_month = '';
304 $search_date_due_end_year = '';
305 $search_date_due_end = '';
306 $search_debit = '';
307 $search_credit = '';
308 $search_lettering_code = '';
309 $search_not_reconciled = '';
310 $search_import_key = '';
311 $toselect = array();
312 unset($_SESSION['DOLDATE_search_date_start_accountancy_day']);
313 unset($_SESSION['DOLDATE_search_date_start_accountancy_month']);
314 unset($_SESSION['DOLDATE_search_date_start_accountancy_year']);
315 unset($_SESSION['DOLDATE_search_date_end_accountancy_day']);
316 unset($_SESSION['DOLDATE_search_date_end_accountancy_month']);
317 unset($_SESSION['DOLDATE_search_date_end_accountancy_year']);
318 }
319
320 // Must be after the remove filter action, before the export.
321 if (!empty($search_date_start)) {
322 $filter['t.doc_date>='] = $search_date_start;
323 $tmp = dol_getdate($search_date_start);
324 $param .= '&search_date_startmonth='.((int) $tmp['mon']).'&search_date_startday='.((int) $tmp['mday']).'&search_date_startyear='.((int) $tmp['year']);
325 }
326 if (!empty($search_date_end)) {
327 $filter['t.doc_date<='] = $search_date_end;
328 $tmp = dol_getdate($search_date_end);
329 $param .= '&search_date_endmonth='.((int) $tmp['mon']).'&search_date_endday='.((int) $tmp['mday']).'&search_date_endyear='.((int) $tmp['year']);
330 }
331 if (!empty($search_doc_date)) {
332 $filter['t.doc_date'] = $search_doc_date;
333 $tmp = dol_getdate($search_doc_date);
334 $param .= '&doc_datemonth='.((int) $tmp['mon']).'&doc_dateday='.((int) $tmp['mday']).'&doc_dateyear='.((int) $tmp['year']);
335 }
336 if (!empty($search_doc_type)) {
337 $filter['t.doc_type'] = $search_doc_type;
338 $param .= '&search_doc_type='.urlencode($search_doc_type);
339 }
340 if (!empty($search_doc_ref)) {
341 $filter['t.doc_ref'] = $search_doc_ref;
342 $param .= '&search_doc_ref='.urlencode($search_doc_ref);
343 }
344 if ($search_account_category != '-1' && !empty($search_account_category)) {
345 require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountancycategory.class.php';
346 $accountingcategory = new AccountancyCategory($db);
347
348 $listofaccountsforgroup = $accountingcategory->getCptsCat(0, 'fk_accounting_category = '.((int) $search_account_category));
349 $listofaccountsforgroup2 = array();
350 if (is_array($listofaccountsforgroup)) {
351 foreach ($listofaccountsforgroup as $tmpval) {
352 $listofaccountsforgroup2[] = "'".$db->escape((string) $tmpval['account_number'])."'";
353 }
354 }
355 if (!empty($listofaccountsforgroup2)) {
356 $filter['t.search_accounting_code_in'] = implode(',', $listofaccountsforgroup2);
357 } else {
358 $filter['t.search_accounting_code_in'] = "''";
359 setEventMessages($langs->trans("ThisCategoryHasNoItems"), null, 'warnings');
360 }
361 $param .= '&search_account_category='.urlencode((string) ($search_account_category));
362 }
363 if (!empty($search_accountancy_code)) {
364 $filter['t.numero_compte'] = $search_accountancy_code;
365 $param .= '&search_accountancy_code='.urlencode($search_accountancy_code);
366 }
367 if (!empty($search_accountancy_code_start)) {
368 $filter['t.numero_compte>='] = $search_accountancy_code_start;
369 $param .= '&search_accountancy_code_start='.urlencode($search_accountancy_code_start);
370 }
371 if (!empty($search_accountancy_code_end)) {
372 $filter['t.numero_compte<='] = $search_accountancy_code_end;
373 $param .= '&search_accountancy_code_end='.urlencode($search_accountancy_code_end);
374 }
375 if (!empty($search_accountancy_aux_code)) {
376 $filter['t.subledger_account'] = $search_accountancy_aux_code;
377 $param .= '&search_accountancy_aux_code='.urlencode($search_accountancy_aux_code);
378 }
379 if (!empty($search_accountancy_aux_code_start)) {
380 $filter['t.subledger_account>='] = $search_accountancy_aux_code_start;
381 $param .= '&search_accountancy_aux_code_start='.urlencode($search_accountancy_aux_code_start);
382 }
383 if (!empty($search_accountancy_aux_code_end)) {
384 $filter['t.subledger_account<='] = $search_accountancy_aux_code_end;
385 $param .= '&search_accountancy_aux_code_end='.urlencode($search_accountancy_aux_code_end);
386 }
387 if (!empty($search_mvt_label)) {
388 $filter['t.label_operation'] = $search_mvt_label;
389 $param .= '&search_mvt_label='.urlencode($search_mvt_label);
390 }
391 if (!empty($search_direction)) {
392 $filter['t.sens'] = $search_direction;
393 $param .= '&search_direction='.urlencode($search_direction);
394 }
395 if (!empty($search_ledger_code)) {
396 $filter['t.code_journal'] = $search_ledger_code;
397 foreach ($search_ledger_code as $code) {
398 $param .= '&search_ledger_code[]='.urlencode($code);
399 }
400 }
401 if (!empty($search_mvt_num)) {
402 $filter['t.piece_num'] = $search_mvt_num;
403 $param .= '&search_mvt_num='.urlencode((string) ($search_mvt_num));
404 }
405 if (!empty($search_date_creation_start)) {
406 $filter['t.date_creation>='] = $search_date_creation_start;
407 $tmp = dol_getdate($search_date_creation_start);
408 $param .= '&search_date_creation_startmonth='.((int) $tmp['mon']).'&search_date_creation_startday='.((int) $tmp['mday']).'&search_date_creation_startyear='.((int) $tmp['year']);
409 }
410 if (!empty($search_date_creation_end)) {
411 $filter['t.date_creation<='] = $search_date_creation_end;
412 $tmp = dol_getdate($search_date_creation_end);
413 $param .= '&search_date_creation_endmonth='.((int) $tmp['mon']).'&search_date_creation_endday='.((int) $tmp['mday']).'&search_date_creation_endyear='.((int) $tmp['year']);
414 }
415 if (!empty($search_date_modification_start)) {
416 $filter['t.tms>='] = $search_date_modification_start;
417 $tmp = dol_getdate($search_date_modification_start);
418 $param .= '&search_date_modification_startmonth='.((int) $tmp['mon']).'&search_date_modification_startday='.((int) $tmp['mday']).'&search_date_modification_startyear='.((int) $tmp['year']);
419 }
420 if (!empty($search_date_modification_end)) {
421 $filter['t.tms<='] = $search_date_modification_end;
422 $tmp = dol_getdate($search_date_modification_end);
423 $param .= '&search_date_modification_endmonth='.((int) $tmp['mon']).'&search_date_modification_endday='.((int) $tmp['mday']).'&search_date_modification_endyear='.((int) $tmp['year']);
424 }
425 if (!empty($search_date_export_start)) {
426 $filter['t.date_export>='] = $search_date_export_start;
427 $tmp = dol_getdate($search_date_export_start);
428 $param .= '&search_date_export_startmonth='.((int) $tmp['mon']).'&search_date_export_startday='.((int) $tmp['mday']).'&search_date_export_startyear='.((int) $tmp['year']);
429 }
430 if (!empty($search_date_export_end)) {
431 $filter['t.date_export<='] = $search_date_export_end;
432 $tmp = dol_getdate($search_date_export_end);
433 $param .= '&search_date_export_endmonth='.((int) $tmp['mon']).'&search_date_export_endday='.((int) $tmp['mday']).'&search_date_export_endyear='.((int) $tmp['year']);
434 }
435 if (!empty($search_date_validation_start)) {
436 $filter['t.date_validated>='] = $search_date_validation_start;
437 $tmp = dol_getdate($search_date_validation_start);
438 $param .= '&search_date_validation_startmonth='.((int) $tmp['mon']).'&search_date_validation_startday='.((int) $tmp['mday']).'&search_date_validation_startyear='.((int) $tmp['year']);
439 }
440 if (!empty($search_date_validation_end)) {
441 $filter['t.date_validated<='] = $search_date_validation_end;
442 $tmp = dol_getdate($search_date_validation_end);
443 $param .= '&search_date_validation_endmonth='.((int) $tmp['mon']).'&search_date_validation_endday='.((int) $tmp['mday']).'&search_date_validation_endyear='.((int) $tmp['year']);
444 }
445 // Due date start
446 if (!empty($search_date_due_start)) {
447 $filter['t.date_lim_reglement>='] = $search_date_due_start;
448 $param .= '&search_date_due_start_day='.$search_date_due_start_day.'&search_date_due_start_month='.$search_date_due_start_month.'&search_date_due_start_year='.$search_date_due_start_year;
449 }
450 // Due date end
451 if (!empty($search_date_due_end)) {
452 $filter['t.date_lim_reglement<='] = $search_date_due_end;
453 $param .= '&search_date_due_end_day='.$search_date_due_end_day.'&search_date_due_end_month='.$search_date_due_end_month.'&search_date_due_end_year='.$search_date_due_end_year;
454 }
455 if (!empty($search_debit)) {
456 $filter['t.debit'] = $search_debit;
457 $param .= '&search_debit='.urlencode($search_debit);
458 }
459 if (!empty($search_credit)) {
460 $filter['t.credit'] = $search_credit;
461 $param .= '&search_credit='.urlencode($search_credit);
462 }
463 if (!empty($search_lettering_code)) {
464 $filter['t.lettering_code'] = $search_lettering_code;
465 $param .= '&search_lettering_code='.urlencode($search_lettering_code);
466 }
467 if (!empty($search_not_reconciled)) {
468 $filter['t.reconciled_option'] = $search_not_reconciled;
469 $param .= '&search_not_reconciled='.urlencode($search_not_reconciled);
470 }
471 if (!empty($search_import_key)) {
472 $filter['t.import_key'] = $search_import_key;
473 $param .= '&search_import_key='.urlencode($search_import_key);
474 }
475
476 // Actions
477 if ($action === 'exporttopdf' && $permissiontoadd) {
478 $object->fetchAll('ASC,ASC,ASC', 'code_journal,doc_date,piece_num', 0, 0, $filter);
479 require_once DOL_DOCUMENT_ROOT . '/core/modules/accountancy/doc/pdf_bookkeeping.modules.php';
480 $pdf = new pdf_bookkeeping($db);
481 $pdf->fromDate = $search_date_start;
482 $pdf->toDate = $search_date_end;
483
484 $result = $pdf->write_file($object, $langs);
485
486 if ($result < 0) {
487 setEventMessage($pdf->error, "errors");
488 } else {
489 // Generated PDF is directly sent to the browser
490 exit;
491 }
492 }
493
494 // Mass actions
495 $objectclass = 'Bookkeeping';
496 $objectlabel = 'Bookkeeping';
497 $uploaddir = $conf->societe->dir_output;
498
499 global $error;
501 include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
502
503 if (!$error && $action == 'deletebookkeepingwriting' && $confirm == "yes" && $user->hasRight('accounting', 'mouvements', 'supprimer')) {
504 $db->begin();
505
506 if (getDolGlobalInt('ACCOUNTING_ENABLE_LETTERING')) {
507 $lettering = new Lettering($db);
508 $nb_lettering = $lettering->bookkeepingLetteringAll($toselect, true);
509 if ($nb_lettering < 0) {
510 setEventMessages('', $lettering->errors, 'errors');
511 $error += 1;
512 }
513 }
514
515 $nbok = 0;
516 $result = 0;
517 if (!$error) {
518 foreach ($toselect as $toselectid) {
519 $result = $object->fetch($toselectid);
520 if ($result > 0 && (!isset($object->date_validation) || $object->date_validation === '')) {
521 $result = $object->deleteMvtNum($object->piece_num);
522 if ($result > 0) {
523 $nbok++;
524 } else {
525 setEventMessages($object->error, $object->errors, 'errors');
526 $error += 1;
527 break;
528 }
529 } elseif ($result < 0) {
530 setEventMessages($object->error, $object->errors, 'errors');
531 $error += 1;
532 break;
533 } elseif (isset($object->date_validation) && $object->date_validation != '') {
534 setEventMessages($langs->trans("ValidatedRecordWhereFound"), null, 'errors');
535 $error += 1;
536 break;
537 }
538 }
539 }
540
541 if (!$error) {
542 $db->commit();
543
544 // Message for elements well deleted
545 if ($nbok > 1) {
546 setEventMessages($langs->trans("RecordsDeleted", $nbok), null, 'mesgs');
547 } elseif ($nbok > 0) {
548 setEventMessages($langs->trans("RecordDeleted", $nbok), null, 'mesgs');
549 } else {
550 setEventMessages($langs->trans("NoRecordDeleted"), null, 'mesgs');
551 }
552
553 header("Location: ".$_SERVER["PHP_SELF"]."?noreset=1".($param ? '&'.$param : ''));
554 exit;
555 } else {
556 $db->rollback();
557 }
558 }
559
560 // massaction cloning
561 if (!$error && $action == 'clonebookkeepingwriting' && $confirm == "yes" && $user->hasRight('accounting', 'mouvements', 'creer')) {
562 $result = $object->newCloneMass($toselect, $journal_code, $massdate);
563 if ($result == -1) {
564 $error += 1;
565 }
566 if ($error) {
567 $db->commit();
568 header("Location: ".$_SERVER["PHP_SELF"]."?noreset=1".($param ? '&'.$param : ''));
569 exit;
570 } else {
571 $db->rollback();
572 }
573 }
574
575 // massaction assign new account
576 if (!$error && $action == 'assignaccountbookkeepingwriting' && $confirm == "yes" && $user->hasRight('accounting', 'mouvements', 'creer')) {
577 $result = $object->assignAccountMass($toselect, (int) $account);
578 if ($result == -1) {
579 $error += 1;
580 }
581 if (!$error) {
582 $db->commit();
583 header("Location: ".$_SERVER["PHP_SELF"]."?noreset=1".($param ? '&'.$param : ''));
584 exit();
585 } else {
586 $db->rollback();
587 }
588 }
589
590 // mass action return account
591 if (!$error && $action == 'returnaccountbookkeepingwriting' && $confirm == "yes" && $user->hasRight('accounting', 'mouvements', 'creer')) {
592 $result = $object->newReturnAccount($toselect, $journal_code, $massdate);
593 if ($result == -1) {
594 $error += 1;
595 }
596 if (!$error) {
597 $db->commit();
598 header("Location: ".$_SERVER["PHP_SELF"]."?noreset=1".($param ? '&'.$param : ''));
599 exit();
600 } else {
601 $db->rollback();
602 }
603 }
604
605 // mass actions on matching
606 if (!$error && getDolGlobalInt('ACCOUNTING_ENABLE_LETTERING')) {
607 if ($massaction == 'generalmatchingmanual' && $permissiontoadd) {
608 $lettering = new Lettering($db);
609 $result = $lettering->updateGeneralMatching($toselect);
610 if ($result < 0) {
611 setEventMessages('', $lettering->errors, 'errors');
612 } else {
613 setEventMessages($langs->trans($result == 0 ? 'AccountancyNoMachingModified' : 'AccountancyOneMatchingModifiedSuccessfully'), array(), 'mesgs');
614 header('Location: ' . $_SERVER['PHP_SELF'] . '?noreset=1' . $param);
615 exit();
616 }
617 } elseif ($massaction == 'generalmatchingpartial' && $permissiontoadd) {
618 $lettering = new Lettering($db);
619 $result = $lettering->updateGeneralMatching($toselect, true);
620 if ($result < 0) {
621 setEventMessages('', $lettering->errors, 'errors');
622 } else {
623 setEventMessages($langs->trans($result == 0 ? 'AccountancyNoMachingModified' : 'AccountancyOneMatchingModifiedSuccessfully'), array(), 'mesgs');
624 header('Location: ' . $_SERVER['PHP_SELF'] . '?noreset=1' . $param);
625 exit;
626 }
627 } elseif ($action == 'generalunmatchingmanual' && $confirm == 'yes' && $permissiontodelete) {
628 $lettering = new Lettering($db);
629 $result = $lettering->deleteGeneralMatching($toselect);
630 if ($result < 0) {
631 setEventMessages('', $lettering->errors, 'errors');
632 } else {
633 setEventMessages($langs->trans($result == 0 ? 'AccountancyNoUnmatchingModified' : 'AccountancyOneUnmatchingModifiedSuccessfully'), [], 'mesgs');
634 header('Location: ' . $_SERVER['PHP_SELF'] . '?noreset=1' . $param);
635 exit;
636 }
637 }
638 }
639}
640
641// Build and execute select (used by page and export action)
642// must de set after the action that set $filter
643// --------------------------------------------------------------------
644
645$sql = 'SELECT';
646$sql .= ' t.rowid,';
647$sql .= " t.doc_date,";
648$sql .= " t.doc_type,";
649$sql .= " t.doc_ref,";
650$sql .= " t.fk_doc,";
651$sql .= " t.fk_docdet,";
652$sql .= " t.thirdparty_code,";
653$sql .= " t.subledger_account,";
654$sql .= " t.subledger_label,";
655$sql .= " t.numero_compte,";
656$sql .= " t.label_compte,";
657$sql .= " t.label_operation,";
658$sql .= " t.debit,";
659$sql .= " t.credit,";
660$sql .= " t.lettering_code,";
661$sql .= " t.matching_general,";
662$sql .= " t.montant as amount,";
663$sql .= " t.sens,";
664$sql .= " t.fk_user_author,";
665$sql .= " t.import_key,";
666$sql .= " t.code_journal,";
667$sql .= " t.journal_label,";
668$sql .= " t.piece_num,";
669$sql .= " t.ref,";
670$sql .= " t.date_creation,";
671$sql .= " t.tms as date_modification,";
672$sql .= " t.date_export,";
673$sql .= " t.date_validated as date_validation,";
674$sql .= " t.date_lim_reglement,";
675$sql .= " t.import_key";
676
677$sqlfields = $sql; // $sql fields to remove for count total
678
679$sql .= ' FROM '.MAIN_DB_PREFIX.$object->table_element.' as t';
680// Manage filter
681$sqlwhere = array();
682if (count($filter) > 0) {
683 foreach ($filter as $key => $value) {
684 if ($key == 't.doc_date') {
685 $sqlwhere[] = $db->sanitize($key)." = '".$db->idate($value)."'";
686 } elseif ($key == 't.doc_date>=') {
687 $sqlwhere[] = "t.doc_date >= '".$db->idate($value)."'";
688 } elseif ($key == 't.doc_date<=') {
689 $sqlwhere[] = "t.doc_date <= '".$db->idate($value)."'";
690 } elseif ($key == 't.numero_compte>=') {
691 $sqlwhere[] = "t.numero_compte >= '".$db->escape($value)."'";
692 } elseif ($key == 't.numero_compte<=') {
693 $sqlwhere[] = "t.numero_compte <= '".$db->escape($value)."'";
694 } elseif ($key == 't.subledger_account>=') {
695 $sqlwhere[] = "t.subledger_account >= '".$db->escape($value)."'";
696 } elseif ($key == 't.subledger_account<=') {
697 $sqlwhere[] = "t.subledger_account <= '".$db->escape($value)."'";
698 } elseif ($key == 't.piece_num') {
699 // piece_num is an integer column, a LIKE on it is translated to ILIKE by the pgsql driver and fails
700 $sqlwhere[] = natural_search($key, $value, 1, 1);
701 } elseif ($key == 't.subledger_account' || $key == 't.numero_compte') {
702 $sqlwhere[] = $db->sanitize($key)." LIKE '".$db->escape($db->escapeforlike($value))."%'";
703 /* } elseif ($key == 't.subledger_account') { // test is always false
704 $sqlwhere[] = natural_search($key, $value, 0, 1); */
705 } elseif ($key == 't.tms>=') {
706 $sqlwhere[] = "t.tms >= '".$db->idate($value)."'";
707 } elseif ($key == 't.tms<=') {
708 $sqlwhere[] = "t.tms <= '".$db->idate($value)."'";
709 } elseif ($key == 't.date_creation>=') {
710 $sqlwhere[] = "t.date_creation >= '".$db->idate($value)."'";
711 } elseif ($key == 't.date_creation<=') {
712 $sqlwhere[] = "t.date_creation <= '".$db->idate($value)."'";
713 } elseif ($key == 't.date_export>=') {
714 $sqlwhere[] = "t.date_export >= '".$db->idate($value)."'";
715 } elseif ($key == 't.date_export<=') {
716 $sqlwhere[] = "t.date_export <= '".$db->idate($value)."'";
717 } elseif ($key == 't.date_validated>=') {
718 $sqlwhere[] = "t.date_validated >= '".$db->idate($value)."'";
719 } elseif ($key == 't.date_validated<=') {
720 $sqlwhere[] = "t.date_validated <= '".$db->idate($value)."'";
721 } elseif ($key == 't.date_lim_reglement>=') {
722 $sqlwhere[] = "t.date_lim_reglement >= '".$db->idate($value)."'";
723 } elseif ($key == 't.date_lim_reglement<=') {
724 $sqlwhere[] = "t.date_lim_reglement <= '".$db->idate($value)."'";
725 } elseif ($key == 't.credit' || $key == 't.debit') {
726 $sqlwhere[] = natural_search($key, $value, 1, 1);
727 } elseif ($key == 't.reconciled_option') {
728 $sqlwhere[] = 't.lettering_code IS NULL';
729 } elseif ($key == 't.code_journal' && !empty($value)) { // @phpstan-ignore-line false positive on !empty
730 if (is_array($value)) {
731 $sqlwhere[] = natural_search("t.code_journal", implode(',', $value), 3, 1);
732 } else {
733 $sqlwhere[] = natural_search("t.code_journal", $value, 3, 1);
734 }
735 } elseif ($key == 't.search_accounting_code_in' && !empty($value)) { // @phpstan-ignore-line false positive on !empty
736 $sqlwhere[] = 't.numero_compte IN ('.$db->sanitize($value, 1).')';
737 } else {
738 $sqlwhere[] = natural_search($key, $value, 0, 1);
739 }
740 }
741}
742$sql .= ' WHERE t.entity IN ('.getEntity('accountancy').')';
743
744if (count($sqlwhere) > 0) {
745 $sql .= ' AND '.implode(' AND ', $sqlwhere);
746}
747//print $sql;
748
749/*
750 * View
751 */
752
753$formother = new FormOther($db);
754$formfile = new FormFile($db);
755
756$title_page = $langs->trans("Operations").' - '.$langs->trans("Journals");
757
758// Count total nb of records
759$nbtotalofrecords = '';
760if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
761 /* The fast and low memory method to get and count full list converts the sql into a sql count */
762 $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql);
763 $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount);
764 $resql = $db->query($sqlforcount);
765 if ($resql) {
766 $objforcount = $db->fetch_object($resql);
767 $nbtotalofrecords = $objforcount->nbtotalofrecords;
768 } else {
770 }
771
772 if (($page * $limit) > (int) $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
773 $page = 0;
774 $offset = 0;
775 }
776 $db->free($resql);
777}
778
779
780// Complete request and execute it with limit
781$sql .= $db->order($sortfield, $sortorder);
782if ($limit) {
783 $sql .= $db->plimit($limit + 1, $offset);
784}
785
786$resql = $db->query($sql);
787if (!$resql) {
789 exit;
790}
791
792$num = $db->num_rows($resql);
793
794$arrayofselected = is_array($toselect) ? $toselect : array();
795
796// Output page
797// --------------------------------------------------------------------
798$help_url = 'EN:Module_Double_Entry_Accounting|FR:Module_Comptabilit&eacute;_en_Partie_Double';
799llxHeader('', $title_page, $help_url, '', 0, 0, '', '', '', 'mod-accountancy accountancy-consultation page-journal');
800
801$formconfirm = '';
802
803// Print form confirm
804print $formconfirm;
805
806//$param=''; param started before
807if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
808 $param .= '&contextpage='.urlencode($contextpage);
809}
810if ($limit > 0 && $limit != $conf->liste_limit) {
811 $param .= '&limit='.((int) $limit);
812}
813
814// List of mass actions available
815$arrayofmassactions = array();
816if (getDolGlobalInt('ACCOUNTING_ENABLE_LETTERING') && $user->hasRight('accounting', 'mouvements', 'creer')) {
817 $arrayofmassactions['generalmatchingmanual'] = img_picto('', 'check', 'class="pictofixedwidth"') . $langs->trans('GeneralMatchingManual');
818 $arrayofmassactions['generalmatchingpartial'] = img_picto('', 'check', 'class="pictofixedwidth"') . $langs->trans('GeneralMatchingPartial');
819 $arrayofmassactions['pregeneralunmatchingmanual'] = img_picto('', 'uncheck', 'class="pictofixedwidth"') . $langs->trans('GeneralUnmatchingManual');
820}
821if ($user->hasRight('accounting', 'mouvements', 'creer')) {
822 $arrayofmassactions['preclonebookkeepingwriting'] = img_picto('', 'clone', 'class="pictofixedwidth"').$langs->trans("Clone");
823}
824if ($user->hasRight('accounting', 'mouvements', 'creer')) {
825 $arrayofmassactions['preassignaccountbookkeepingwriting'] = img_picto('', 'fa-exchange-alt', 'class="pictofixedwidth"').$langs->trans("AssignAccount");
826}
827if ($user->hasRight('accounting', 'mouvements', 'creer')) {
828 $arrayofmassactions['prereturnaccountbookkeepingwriting'] = img_picto('', 'undo', 'class="pictofixedwidth"').$langs->trans("ReturnAccount");
829}
830if ($user->hasRight('accounting', 'mouvements', 'supprimer')) {
831 $arrayofmassactions['predeletebookkeepingwriting'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
832}
833
834if (GETPOSTINT('nomassaction')
835 || in_array($massaction,
836 array(
837 'pregeneralunmatchingmanual',
838 'predeletebookkeepingwriting',
839 'preclonebookkeepingwriting',
840 'preassignaccountbookkeepingwriting',
841 'prereturnaccountbookkeepingwriting'
842 )
843 )) {
844 $arrayofmassactions = array();
845}
846$massactionbutton = $form->selectMassAction($massaction, $arrayofmassactions);
847
848print '<form method="POST" id="searchFormList" action="'.dolBuildUrl($_SERVER["PHP_SELF"]).'">';
849print '<input type="hidden" name="token" value="'.newToken().'">';
850print '<input type="hidden" name="action" value="list">';
851if ($optioncss != '') {
852 print '<input type="hidden" name="optioncss" value="'.urlencode($optioncss).'">';
853}
854print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
855print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
856print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
857print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
858
859if (count($filter)) {
860 $buttonLabel = $langs->trans("ExportFilteredList");
861} else {
862 $buttonLabel = $langs->trans("ExportList");
863}
864
865$parameters = array('param' => $param);
866$reshook = $hookmanager->executeHooks('addMoreActionsButtonsList', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
867if ($reshook < 0) {
868 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
869}
870
871$newcardbutton = empty($hookmanager->resPrint) ? '' : $hookmanager->resPrint;
872
873if (empty($reshook)) {
874 $newcardbutton .= dolGetButtonTitle($langs->trans('ViewFlatList'), '', 'fa fa-list paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/list.php?'.$param, '', 1, array('morecss' => 'marginleftonly btnTitleSelected'));
875 $newcardbutton .= dolGetButtonTitle($langs->trans('GroupByAccountAccounting'), '', 'fa fa-stream paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/listbyaccount.php?'.$param, '', 1, array('morecss' => 'marginleftonly'));
876 $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'));
877 $newcardbutton .= dolGetButtonTitle($langs->trans('ExportToPdf'), '', 'fa fa-file-pdf paddingleft', $_SERVER['PHP_SELF'] . '?token=' . newToken() . '&action=exporttopdf&' . $param, '', $permissiontoexport, array('morecss' => 'marginleftonly'));
878
879 $url = './card.php?action=create'.(!empty($type) ? '&type=sub' : '').'&backtopage='.urlencode($_SERVER['PHP_SELF']);
880 if (!empty($socid)) {
881 $url .= '&socid='.$socid;
882 }
883 $newcardbutton .= dolGetButtonTitleSeparator();
884 $newcardbutton .= dolGetButtonTitle($langs->trans('NewAccountingMvt'), '', 'fa fa-plus-circle paddingleft', $url, '', $permissiontoadd);
885}
886
887print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_accountancy', 0, $newcardbutton, '', $limit, 0, 0, 1);
888
889if ($massaction == 'pregeneralunmatchingmanual') {
890 print $form->formconfirm($_SERVER['PHP_SELF'], $langs->trans('ConfirmMassGeneralUnmatchingManual'), $langs->trans("ConfirmMassGeneralUnmatchingQuestion", count($toselect)), "generalunmatchingmanual", null, '', 0, 200, 500, 1);
891} elseif ($massaction == 'predeletebookkeepingwriting') {
892 print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmMassDeleteBookkeepingWriting"), $langs->trans("ConfirmMassDeleteBookkeepingWritingQuestion", count($toselect)), "deletebookkeepingwriting", null, '', 0, 200, 500, 1);
893} elseif ($massaction == 'preassignaccountbookkeepingwriting') {
894 $input = $formaccounting->select_account('', 'account', 1);
895 $formquestion = array(array('type' => 'other', 'name' => 'account', 'label' => '<span class="fieldrequired">' . $langs->trans("AccountAccountingShort") . '</span>', 'value' => $input),);
896 print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("confirmMassAssignAccountBookkeepingWritingConfirm"), $langs->trans("ConfirmMassAssignAccountBookkeepingWritingQuestion", count($toselect)), "assignaccountbookkeepingwriting", $formquestion, '', 0, 200, 500, 1);
897} elseif ($massaction == 'preclonebookkeepingwriting') {
898 $input1 = $form->selectDate('', 'massdate', 0, 0, 0, "create_mvt", 1, 1);
899 $input2 = $formaccounting->select_journal($journal_code, 'code_journal', 0, 0, 1, 1) . '</td>';
900 $formquestion = array(
901 array(
902 'type' => 'other',
903 'name' => 'massdate',
904 'label' => '<span class="fieldrequired">' . $langs->trans("Docdate") . '</span>',
905 'value' => $input1
906 )
907 );
908
909 if (getDolGlobalString('ACCOUNTING_CLONING_ENABLE_INPUT_JOURNAL')) {
910 $formquestion[] = array(
911 'type' => 'text',
912 'name' => 'code_journal',
913 'label' => '<span class="fieldrequired">' . $langs->trans("Codejournal") . '</span>',
914 'value' => $input2
915 );
916 }
917
918 print $form->formconfirm(
919 $_SERVER["PHP_SELF"],
920 $langs->trans("ConfirmMassCloneBookkeepingWriting"),
921 $langs->trans("ConfirmMassCloneBookkeepingWritingQuestion", count($toselect)),
922 "clonebookkeepingwriting",
923 $formquestion,
924 '', 0, 200, 500, 1
925 );
926} elseif ($massaction == 'prereturnaccountbookkeepingwriting') {
927 $input1 = $form->selectDate('', 'massdate', 0, 0, 0, "create_mvt", 1, 1);
928 $formquestion = array(array('type' => 'other', 'name' => 'massdate', 'label' => '<span class="fieldrequired">' . $langs->trans("Docdate") . '</span>', 'value' => $input1));
929 print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmMassReturnAccountBookkeepingWriting"), $langs->trans("ConfirmMassReturnAccountBookkeepingWritingQuestion", count($toselect)), "returnaccountbookkeepingwriting", $formquestion, '', 0, 200, 500, 1);
930}
931
932//$topicmail = "Information";
933//$modelmail = "accountingbookkeeping";
934//$objecttmp = new BookKeeping($db);
935//$trackid = 'bk'.$object->id;
936include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
937
938$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
939$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, $conf->main_checkbox_left_column); // This also change content of $arrayfields
940if ($massactionbutton && $contextpage != 'poslist') {
941 $selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
942}
943
944$moreforfilter = '';
945$moreforfilter .= '<div class="divsearchfield">';
946$moreforfilter .= $langs->trans('AccountingCategory').': ';
947$moreforfilter .= '<div class="nowrap inline-block">';
948$moreforfilter .= $formaccounting->select_accounting_category($search_account_category, 'search_account_category', 1, 0, 0, 0);
949$moreforfilter .= '</div>';
950$moreforfilter .= '</div>';
951
952$parameters = array();
953$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
954if (empty($reshook)) {
955 $moreforfilter .= $hookmanager->resPrint;
956} else {
957 $moreforfilter = $hookmanager->resPrint;
958}
959
960print '<div class="liste_titre liste_titre_bydiv centpercent">';
961print $moreforfilter;
962print '</div>';
963
964print '<div class="div-table-responsive">';
965print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">';
966
967// Filters lines
968print '<tr class="liste_titre_filter">';
969// Action column
970if ($conf->main_checkbox_left_column) {
971 print '<td class="liste_titre center">';
972 $searchpicto = $form->showFilterButtons('left');
973 print $searchpicto;
974 print '</td>';
975}
976// Movement number
977if (!empty($arrayfields['t.piece_num']['checked'])) {
978 print '<td class="liste_titre"><input type="text" name="search_mvt_num" size="6" value="'.dol_escape_htmltag($search_mvt_num).'"></td>';
979}
980// Code journal
981if (!empty($arrayfields['t.code_journal']['checked'])) {
982 print '<td class="liste_titre center">';
983 print $formaccounting->multi_select_journal($search_ledger_code, 'search_ledger_code', 0, 1, 1, 1, 'maxwidth75');
984 print '</td>';
985}
986// Date document
987if (!empty($arrayfields['t.doc_date']['checked'])) {
988 print '<td class="liste_titre center">';
989 print '<div class="nowrapfordate">';
990 print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"));
991 print '</div>';
992 print '<div class="nowrapfordate">';
993 print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to"));
994 print '</div>';
995 print '</td>';
996}
997// Ref document
998if (!empty($arrayfields['t.doc_ref']['checked'])) {
999 print '<td class="liste_titre"><input type="text" name="search_doc_ref" class="width75" value="'.dol_escape_htmltag($search_doc_ref).'"></td>';
1000}
1001// Accountancy account
1002if (!empty($arrayfields['t.numero_compte']['checked'])) {
1003 print '<td class="liste_titre">';
1004 print '<div class="nowrap">';
1005 print $formaccounting->select_account($search_accountancy_code_start, 'search_accountancy_code_start', $langs->trans('From'), array(), 1, 1, 'maxwidth150', 'account');
1006 print '</div>';
1007 print '<div class="nowrap">';
1008 print $formaccounting->select_account($search_accountancy_code_end, 'search_accountancy_code_end', $langs->trans('to'), array(), 1, 1, 'maxwidth150', 'account');
1009 print '</div>';
1010 print '</td>';
1011}
1012// Subledger account
1013if (!empty($arrayfields['t.subledger_account']['checked'])) {
1014 print '<td class="liste_titre">';
1015 print '<div class="nowrap">';
1016 print $formaccounting->select_auxaccount($search_accountancy_aux_code_start, 'search_accountancy_aux_code_start', $langs->trans('From'), 'maxwidth250', 'subledgeraccount');
1017 print '</div>';
1018 print '<div class="nowrap">';
1019 print $formaccounting->select_auxaccount($search_accountancy_aux_code_end, 'search_accountancy_aux_code_end', $langs->trans('to'), 'maxwidth250', 'subledgeraccount');
1020 print '</div>';
1021 print '</td>';
1022}
1023// Label operation
1024if (!empty($arrayfields['t.label_operation']['checked'])) {
1025 print '<td class="liste_titre">';
1026 print '<input type="text" size="7" class="flat" name="search_mvt_label" value="'.dol_escape_htmltag($search_mvt_label).'"/>';
1027 print '</td>';
1028}
1029// Debit
1030if (!empty($arrayfields['t.debit']['checked'])) {
1031 print '<td class="liste_titre right">';
1032 print '<input type="text" class="flat" name="search_debit" size="4" value="'.dol_escape_htmltag($search_debit).'">';
1033 print '</td>';
1034}
1035// Credit
1036if (!empty($arrayfields['t.credit']['checked'])) {
1037 print '<td class="liste_titre right">';
1038 print '<input type="text" class="flat" name="search_credit" size="4" value="'.dol_escape_htmltag($search_credit).'">';
1039 print '</td>';
1040}
1041// Matching code
1042if (!empty($arrayfields['t.lettering_code']['checked'])) {
1043 print '<td class="liste_titre center">';
1044 print '<input type="text" size="3" class="flat" name="search_lettering_code" value="'.dol_escape_htmltag($search_lettering_code).'"/>';
1045 print '<br><span class="nowrap"><input type="checkbox" name="search_not_reconciled" value="notreconciled"'.($search_not_reconciled == 'notreconciled' ? ' checked' : '').'>'.$langs->trans("NotReconciled").'</span>';
1046 print '</td>';
1047}
1048
1049// Fields from hook
1050$parameters = array('arrayfields' => $arrayfields);
1051$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
1052print $hookmanager->resPrint;
1053
1054// Date creation
1055if (!empty($arrayfields['t.date_creation']['checked'])) {
1056 print '<td class="liste_titre center">';
1057 print '<div class="nowrapfordate">';
1058 print $form->selectDate($search_date_creation_start, 'search_date_creation_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"));
1059 print '</div>';
1060 print '<div class="nowrapfordate">';
1061 print $form->selectDate($search_date_creation_end, 'search_date_creation_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to"));
1062 print '</div>';
1063 print '</td>';
1064}
1065// Date modification
1066if (!empty($arrayfields['t.tms']['checked'])) {
1067 print '<td class="liste_titre center">';
1068 print '<div class="nowrapfordate">';
1069 print $form->selectDate($search_date_modification_start, 'search_date_modification_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"));
1070 print '</div>';
1071 print '<div class="nowrapfordate">';
1072 print $form->selectDate($search_date_modification_end, 'search_date_modification_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to"));
1073 print '</div>';
1074 print '</td>';
1075}
1076// Date export
1077if (!empty($arrayfields['t.date_export']['checked'])) {
1078 print '<td class="liste_titre center">';
1079 print '<div class="nowrapfordate">';
1080 print $form->selectDate($search_date_export_start, 'search_date_export_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"));
1081 print '</div>';
1082 print '<div class="nowrapfordate">';
1083 print $form->selectDate($search_date_export_end, 'search_date_export_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to"));
1084 print '</div>';
1085 print '</td>';
1086}
1087// Date validation
1088if (!empty($arrayfields['t.date_validated']['checked'])) {
1089 print '<td class="liste_titre center">';
1090 print '<div class="nowrapfordate">';
1091 print $form->selectDate($search_date_validation_start, 'search_date_validation_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"));
1092 print '</div>';
1093 print '<div class="nowrapfordate">';
1094 print $form->selectDate($search_date_validation_end, 'search_date_validation_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to"));
1095 print '</div>';
1096 print '</td>';
1097}
1098// Due date start and end
1099if (!empty($arrayfields['t.date_lim_reglement']['checked'])) {
1100 print '<td class="liste_titre center">';
1101 print '<div class="nowrapfordate">';
1102 print $form->selectDate($search_date_due_start, 'search_date_due_start_', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"));
1103 print '</div>';
1104 print '<div class="nowrapfordate">';
1105 print $form->selectDate($search_date_due_end, 'search_date_due_end_', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to"));
1106 print '</div>';
1107 print '</td>';
1108}
1109if (!empty($arrayfields['t.import_key']['checked'])) {
1110 print '<td class="liste_titre center">';
1111 print '<input class="flat searchstring maxwidth50" type="text" name="search_import_key" value="'.dol_escape_htmltag($search_import_key).'">';
1112 print '</td>';
1113}
1114// Action column
1115if (!$conf->main_checkbox_left_column) {
1116 print '<td class="liste_titre center">';
1117 $searchpicto = $form->showFilterButtons();
1118 print $searchpicto;
1119 print '</td>';
1120}
1121print "</tr>\n";
1122
1123print '<tr class="liste_titre">';
1124if ($conf->main_checkbox_left_column) {
1125 print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch actioncolumn ');
1126}
1127if (!empty($arrayfields['t.piece_num']['checked'])) {
1128 print_liste_field_titre($arrayfields['t.piece_num']['label'], $_SERVER['PHP_SELF'], "t.piece_num", "", $param, "", $sortfield, $sortorder);
1129}
1130if (!empty($arrayfields['t.code_journal']['checked'])) {
1131 print_liste_field_titre($arrayfields['t.code_journal']['label'], $_SERVER['PHP_SELF'], "t.code_journal", "", $param, '', $sortfield, $sortorder, 'center ');
1132}
1133if (!empty($arrayfields['t.doc_date']['checked'])) {
1134 print_liste_field_titre($arrayfields['t.doc_date']['label'], $_SERVER['PHP_SELF'], "t.doc_date", "", $param, '', $sortfield, $sortorder, 'center ');
1135}
1136if (!empty($arrayfields['t.doc_ref']['checked'])) {
1137 print_liste_field_titre($arrayfields['t.doc_ref']['label'], $_SERVER['PHP_SELF'], "t.doc_ref", "", $param, "", $sortfield, $sortorder);
1138}
1139if (!empty($arrayfields['t.numero_compte']['checked'])) {
1140 print_liste_field_titre($arrayfields['t.numero_compte']['label'], $_SERVER['PHP_SELF'], "t.numero_compte", "", $param, "", $sortfield, $sortorder);
1141}
1142if (!empty($arrayfields['t.subledger_account']['checked'])) {
1143 print_liste_field_titre($arrayfields['t.subledger_account']['label'], $_SERVER['PHP_SELF'], "t.subledger_account", "", $param, "", $sortfield, $sortorder);
1144}
1145if (!empty($arrayfields['t.label_operation']['checked'])) {
1146 print_liste_field_titre($arrayfields['t.label_operation']['label'], $_SERVER['PHP_SELF'], "t.label_operation", "", $param, "", $sortfield, $sortorder);
1147}
1148if (!empty($arrayfields['t.debit']['checked'])) {
1149 print_liste_field_titre($arrayfields['t.debit']['label'], $_SERVER['PHP_SELF'], "t.debit", "", $param, '', $sortfield, $sortorder, 'right ');
1150}
1151if (!empty($arrayfields['t.credit']['checked'])) {
1152 print_liste_field_titre($arrayfields['t.credit']['label'], $_SERVER['PHP_SELF'], "t.credit", "", $param, '', $sortfield, $sortorder, 'right ');
1153}
1154if (!empty($arrayfields['t.lettering_code']['checked'])) {
1155 print_liste_field_titre($arrayfields['t.lettering_code']['label'], $_SERVER['PHP_SELF'], "t.lettering_code", "", $param, '', $sortfield, $sortorder, 'center ');
1156}
1157// Hook fields
1158$parameters = array('arrayfields' => $arrayfields, 'param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder);
1159$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
1160print $hookmanager->resPrint;
1161if (!empty($arrayfields['t.date_creation']['checked'])) {
1162 print_liste_field_titre($arrayfields['t.date_creation']['label'], $_SERVER['PHP_SELF'], "t.date_creation", "", $param, '', $sortfield, $sortorder, 'center ');
1163}
1164if (!empty($arrayfields['t.tms']['checked'])) {
1165 print_liste_field_titre($arrayfields['t.tms']['label'], $_SERVER['PHP_SELF'], "t.tms", "", $param, '', $sortfield, $sortorder, 'center ');
1166}
1167if (!empty($arrayfields['t.date_export']['checked'])) {
1168 print_liste_field_titre($arrayfields['t.date_export']['label'], $_SERVER['PHP_SELF'], "t.date_export,t.doc_date", "", $param, '', $sortfield, $sortorder, 'center ');
1169}
1170if (!empty($arrayfields['t.date_validated']['checked'])) {
1171 print_liste_field_titre($arrayfields['t.date_validated']['label'], $_SERVER['PHP_SELF'], "t.date_validated,t.doc_date", "", $param, '', $sortfield, $sortorder, 'center ');
1172}
1173// Due date
1174if (!empty($arrayfields['t.date_lim_reglement']['checked'])) {
1175 print_liste_field_titre($arrayfields['t.date_lim_reglement']['label'], $_SERVER['PHP_SELF'], 't.date_lim_reglement', '', $param, '', $sortfield, $sortorder, 'center ');
1176}
1177if (!empty($arrayfields['t.import_key']['checked'])) {
1178 print_liste_field_titre($arrayfields['t.import_key']['label'], $_SERVER["PHP_SELF"], "t.import_key", "", $param, '', $sortfield, $sortorder, 'center ');
1179}
1180if (!$conf->main_checkbox_left_column) {
1181 print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
1182}
1183print "</tr>\n";
1184
1185
1186$line = new BookKeepingLine($db);
1187
1188// Loop on record
1189// --------------------------------------------------------------------
1190$i = 0;
1191$totalarray = array();
1192$totalarray['nbfield'] = 0;
1193$totalarray['val'] = array();
1194$totalarray['val']['totaldebit'] = 0;
1195$totalarray['val']['totalcredit'] = 0;
1196
1197while ($i < min($num, $limit)) {
1198 $obj = $db->fetch_object($resql);
1199 if (empty($obj)) {
1200 break; // Should not happen
1201 }
1202
1203 $line->id = $obj->rowid;
1204 $line->doc_date = $db->jdate($obj->doc_date);
1205 $line->doc_type = $obj->doc_type;
1206 $line->doc_ref = $obj->doc_ref;
1207 $line->fk_doc = $obj->fk_doc;
1208 $line->fk_docdet = $obj->fk_docdet;
1209 $line->thirdparty_code = $obj->thirdparty_code;
1210 $line->subledger_account = $obj->subledger_account;
1211 $line->subledger_label = $obj->subledger_label;
1212 $line->numero_compte = $obj->numero_compte;
1213 $line->label_compte = $obj->label_compte;
1214 $line->label_operation = $obj->label_operation;
1215 $line->debit = $obj->debit;
1216 $line->credit = $obj->credit;
1217 $line->montant = $obj->amount; // deprecated
1218 $line->amount = $obj->amount;
1219 $line->sens = $obj->sens;
1220 $line->lettering_code = $obj->lettering_code;
1221 $line->matching_general = $obj->matching_general;
1222 $line->fk_user_author = $obj->fk_user_author;
1223 $line->import_key = $obj->import_key;
1224 $line->code_journal = $obj->code_journal;
1225 $line->journal_label = $obj->journal_label;
1226 $line->piece_num = $obj->piece_num;
1227 $line->ref = $obj->ref;
1228 $line->date_creation = $db->jdate($obj->date_creation);
1229 $line->date_modification = $db->jdate($obj->date_modification);
1230 $line->date_export = $db->jdate($obj->date_export);
1231 $line->date_validation = $db->jdate($obj->date_validation);
1232 // Due date
1233 $line->date_lim_reglement = $db->jdate($obj->date_lim_reglement);
1234
1235 print '<tr class="oddeven">';
1236 // Action column
1237 if ($conf->main_checkbox_left_column) {
1238 print '<td class="nowraponall center">';
1239 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
1240 $selected = 0;
1241 if (in_array($line->id, $arrayofselected)) {
1242 $selected = 1;
1243 }
1244 print '<input id="cb'.$line->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$line->id.'"'.($selected ? ' checked="checked"' : '').' />';
1245 }
1246 print '</td>';
1247 if (!$i) {
1248 $totalarray['nbfield']++;
1249 }
1250 }
1251
1252 // Piece number
1253 if (!empty($arrayfields['t.piece_num']['checked'])) {
1254 print '<td class="nowraponall">';
1255 $object->id = $line->id;
1256 $object->piece_num = $line->piece_num;
1257 $object->ref = $line->ref;
1258 print $object->getNomUrl(1, '', 0, '', 1);
1259 print '<span class="hideonsmartphone">';
1260 if (!empty($line->date_export)) {
1261 print img_picto($langs->trans("DateExport").": ".dol_print_date($line->date_export, 'dayhour')." (".$langs->trans("TransactionExportDesc").")", 'fa-file-export', 'class="paddingleft pictofixedwidth opacitymedium"');
1262 }
1263 if (!empty($line->date_validation)) {
1264 print img_picto($langs->trans("DateValidation").": ".dol_print_date($line->date_validation, 'dayhour')." (".$langs->trans("TransactionBlockedLockedDesc").")", 'fa-lock', 'class="paddingleft pictofixedwidth opacitymedium"');
1265 }
1266 print '</span>';
1267 print '</td>';
1268 if (!$i) {
1269 $totalarray['nbfield']++;
1270 }
1271 }
1272
1273 // Journal code
1274 if (!empty($arrayfields['t.code_journal']['checked'])) {
1275 if (empty($conf->cache['accountingjournal'][$line->code_journal])) {
1276 $accountingjournal = new AccountingJournal($db);
1277 $accountingjournal->fetch(0, $line->code_journal);
1278 $conf->cache['accountingjournal'][$line->code_journal] = $accountingjournal;
1279 } else {
1280 $accountingjournal = $conf->cache['accountingjournal'][$line->code_journal];
1281 }
1282
1283 $journaltoshow = (($accountingjournal->id > 0) ? $accountingjournal->getNomUrl(0, 0, 0, '', 0) : $line->code_journal);
1284 print '<td class="center tdoverflowmax150">'.$journaltoshow.'</td>';
1285 if (!$i) {
1286 $totalarray['nbfield']++;
1287 }
1288 }
1289
1290 // Document date
1291 if (!empty($arrayfields['t.doc_date']['checked'])) {
1292 print '<td class="center">'.dol_print_date($line->doc_date, 'day').'</td>';
1293 if (!$i) {
1294 $totalarray['nbfield']++;
1295 }
1296 }
1297
1298 // Document ref
1299 $modulepart = ''; // may be used by include*.tpl.php
1300 if (!empty($arrayfields['t.doc_ref']['checked'])) {
1301 $documentlink = '';
1302 $objectstatic = null;
1303
1304 if ($line->doc_type === 'customer_invoice') {
1305 $langs->loadLangs(array('bills'));
1306
1307 require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
1308 $objectstatic = new Facture($db);
1309 $objectstatic->fetch($line->fk_doc);
1310 //$modulepart = 'facture';
1311
1312 $filename = dol_sanitizeFileName($line->doc_ref);
1313 $filedir = $conf->invoice->dir_output.'/'.dol_sanitizeFileName($line->doc_ref);
1314 $urlsource = $_SERVER['PHP_SELF'].'?id='.$objectstatic->id;
1315 $documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir);
1316 } elseif ($line->doc_type === 'supplier_invoice') {
1317 $langs->loadLangs(array('bills'));
1318
1319 require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
1320 $objectstatic = new FactureFournisseur($db);
1321 $objectstatic->fetch($line->fk_doc);
1322
1323 $modulepart = 'invoice_supplier';
1324 $filename = dol_sanitizeFileName($line->doc_ref);
1325
1326 //$filedir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($line->fk_doc, 2, 0, 0, $objectstatic, $modulepart).dol_sanitizeFileName($line->doc_ref);
1327 //$subdir = get_exdir($objectstatic->id, 2, 0, 0, $objectstatic, $modulepart).dol_sanitizeFileName($line->doc_ref);
1328 $filedir = getMultidirOutput($objectstatic, '', 1).dol_sanitizeFileName($line->doc_ref);
1329 $subdir = getMultidirOutput($objectstatic, '', 1, 'outputrel').dol_sanitizeFileName($line->doc_ref);
1330 //var_dump($filedir); var_dump($subdir);
1331
1332 if ($objectstatic->id > 0) {
1333 $documentlink = $formfile->getDocumentsLink($objectstatic->element, $subdir, $filedir);
1334 } else {
1335 $documentlink = $line->doc_ref;
1336 }
1337 } elseif ($line->doc_type === 'expense_report') {
1338 $langs->loadLangs(array('trips'));
1339
1340 require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
1341 $objectstatic = new ExpenseReport($db);
1342 $objectstatic->fetch($line->fk_doc);
1343 //$modulepart = 'expensereport';
1344
1345 $filename = dol_sanitizeFileName($line->doc_ref);
1346 $filedir = $conf->expensereport->dir_output.'/'.dol_sanitizeFileName($line->doc_ref);
1347 $urlsource = $_SERVER['PHP_SELF'].'?id='.$objectstatic->id;
1348 $documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir);
1349 } elseif ($line->doc_type === 'bank') {
1350 require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
1351 $objectstatic = new AccountLine($db);
1352 $objectstatic->fetch($line->fk_doc);
1353 } else {
1354 // Other type
1355 }
1356
1357 $labeltoshow = '';
1358 $labeltoshowalt = '';
1359 $classforlabel = '';
1360 if (($line->doc_type === 'customer_invoice' || $line->doc_type === 'supplier_invoice' || $line->doc_type === 'expense_report') && is_object($objectstatic)) {
1361 $labeltoshow .= $objectstatic->getNomUrl(1, '', 0, 0, '', 0, -1, 1);
1362 $labeltoshow .= $documentlink;
1363 $labeltoshowalt .= $objectstatic->ref;
1364 } elseif ($line->doc_type === 'bank' && is_object($objectstatic)) {
1365 $labeltoshow .= $objectstatic->getNomUrl(1);
1366 $labeltoshowalt .= $objectstatic->ref;
1367 $bank_ref = strstr($line->doc_ref, '-');
1368 $labeltoshow .= " " . $bank_ref;
1369 $labeltoshowalt .= " " . $bank_ref;
1370 } else {
1371 $labeltoshow .= $line->doc_ref;
1372 $labeltoshowalt .= $line->doc_ref;
1373 $classforlabel = 'tdoverflowmax250';
1374 }
1375
1376 print '<td class="nowraponall'.($classforlabel ? ' '.$classforlabel : '').'" title="'.dol_escape_htmltag($labeltoshowalt).'">';
1377 print $labeltoshow;
1378 print "</td>\n";
1379 if (!$i) {
1380 $totalarray['nbfield']++;
1381 }
1382 }
1383
1384 // Account number
1385 if (!empty($arrayfields['t.numero_compte']['checked'])) {
1386 print '<td>'.length_accountg($line->numero_compte).'</td>';
1387 if (!$i) {
1388 $totalarray['nbfield']++;
1389 }
1390 }
1391
1392 // Subledger account
1393 if (!empty($arrayfields['t.subledger_account']['checked'])) {
1394 print '<td>'.length_accounta($line->subledger_account).'</td>';
1395 if (!$i) {
1396 $totalarray['nbfield']++;
1397 }
1398 }
1399
1400 // Label operation
1401 if (!empty($arrayfields['t.label_operation']['checked'])) {
1402 print '<td class="small tdoverflowmax200" title="'.dol_escape_htmltag($line->label_operation).'">'.dol_escape_htmltag($line->label_operation).'</td>';
1403 if (!$i) {
1404 $totalarray['nbfield']++;
1405 }
1406 }
1407
1408 // Amount debit
1409 if (!empty($arrayfields['t.debit']['checked'])) {
1410 print '<td class="right nowraponall amount">'.($line->debit != 0 ? price($line->debit) : '').'</td>';
1411 if (!$i) {
1412 $totalarray['nbfield']++;
1413 }
1414 if (!$i) {
1415 $totalarray['pos'][$totalarray['nbfield']] = 'totaldebit';
1416 }
1417 $totalarray['val']['totaldebit'] += $line->debit;
1418 }
1419
1420 // Amount credit
1421 if (!empty($arrayfields['t.credit']['checked'])) {
1422 print '<td class="right nowraponall amount">'.($line->credit != 0 ? price($line->credit) : '').'</td>';
1423 if (!$i) {
1424 $totalarray['nbfield']++;
1425 }
1426 if (!$i) {
1427 $totalarray['pos'][$totalarray['nbfield']] = 'totalcredit';
1428 }
1429 $totalarray['val']['totalcredit'] += $line->credit;
1430 }
1431
1432 // Matching code
1433 if (!empty($arrayfields['t.lettering_code']['checked'])) {
1434 $tooltipText = "";
1435 $icon = "";
1436 $badge = "";
1437 if (!empty($line->matching_general)) {
1438 $tooltipText .= $langs->trans('GeneralMatching');
1439 $icon .= "fa-book";
1440 $badge .= "badge-status4";
1441 } elseif (empty($line->matching_general) && !empty($line->lettering_code)) {
1442 $tooltipText .= $langs->trans('AuxiliaryMatching');
1443 $icon .= "fa-user";
1444 $badge .= "badge-status1";
1445 }
1446 print '<td class="center classfortooltip" title="'.$tooltipText.'"><span class="badge '.$badge.'"><i class="fas '.$icon.' fa-xs"></i> '.$line->lettering_code.'</span></td>';
1447 if (!$i) {
1448 $totalarray['nbfield']++;
1449 }
1450 }
1451
1452 // Fields from hook
1453 $parameters = array('arrayfields' => $arrayfields, 'obj' => $obj, 'i' => $i, 'totalarray' => &$totalarray);
1454 $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook
1455 print $hookmanager->resPrint;
1456
1457 // Creation operation date
1458 if (!empty($arrayfields['t.date_creation']['checked'])) {
1459 print '<td class="center">'.dol_print_date($line->date_creation, 'dayhour', 'tzuserrel').'</td>';
1460 if (!$i) {
1461 $totalarray['nbfield']++;
1462 }
1463 }
1464
1465 // Modification operation date
1466 if (!empty($arrayfields['t.tms']['checked'])) {
1467 print '<td class="center">'.dol_print_date($line->date_modification, 'dayhour', 'tzuserrel').'</td>';
1468 if (!$i) {
1469 $totalarray['nbfield']++;
1470 }
1471 }
1472
1473 // Exported operation date
1474 if (!empty($arrayfields['t.date_export']['checked'])) {
1475 print '<td class="center nowraponall">'.dol_print_date($line->date_export, 'dayhour', 'tzuserrel').'</td>';
1476 if (!$i) {
1477 $totalarray['nbfield']++;
1478 }
1479 }
1480
1481 // Validated operation date
1482 if (!empty($arrayfields['t.date_validated']['checked'])) {
1483 print '<td class="center nowraponall">'.dol_print_date($line->date_validation, 'dayhour', 'tzuserrel').'</td>';
1484 if (!$i) {
1485 $totalarray['nbfield']++;
1486 }
1487 }
1488
1489 // Due date
1490 if (!empty($arrayfields['t.date_lim_reglement']['checked'])) {
1491 print '<td class="center">'.dol_print_date($line->date_lim_reglement, 'day').'</td>';
1492 if (!$i) {
1493 $totalarray['nbfield']++;
1494 }
1495 }
1496
1497 if (!empty($arrayfields['t.import_key']['checked'])) {
1498 print '<td class="tdoverflowmax125" title="'.dol_escape_htmltag($obj->import_key).'">'.dol_escape_htmltag($obj->import_key)."</td>\n";
1499 if (!$i) {
1500 $totalarray['nbfield']++;
1501 }
1502 }
1503
1504 // Action column
1505 if (!$conf->main_checkbox_left_column) {
1506 print '<td class="nowraponall center">';
1507 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
1508 $selected = 0;
1509 if (in_array($line->id, $arrayofselected)) {
1510 $selected = 1;
1511 }
1512 print '<input id="cb'.$line->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$line->id.'"'.($selected ? ' checked="checked"' : '').' />';
1513 }
1514 print '</td>';
1515 if (!$i) {
1516 $totalarray['nbfield']++;
1517 }
1518 }
1519
1520
1521 print "</tr>\n";
1522
1523 $i++;
1524}
1525
1526// Show total line
1527include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
1528
1529// If no record found
1530if ($num == 0) {
1531 $colspan = 1;
1532 foreach ($arrayfields as $key => $val) {
1533 if (!empty($val['checked'])) {
1534 $colspan++;
1535 }
1536 }
1537 print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
1538}
1539
1540$parameters = array('arrayfields' => $arrayfields, 'sql' => $sql);
1541$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1542print $hookmanager->resPrint;
1543
1544print "</table>";
1545print '</div>';
1546
1547print '</form>';
1548
1549// End of page
1550llxFooter();
1551
1552$db->close();
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
$totalarray
Definition list.php:501
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:91
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:73
Class to manage bank transaction lines.
Class to manage categories of an accounting account.
Class to manage accounting journals.
Class to manage Ledger (General Ledger and Subledger)
Class BookKeepingLine.
Class to manage Trips and Expenses.
Class to manage suppliers invoices.
Class to manage invoices.
Class to manage generation of HTML components for accounting management.
Class to offer components to list and upload files.
Class to manage generation of HTML components for accounting management.
Class to manage generation of HTML components Only common components must be here.
Class to help generate other html components Only common components are here.
Class Lettering.
Class to build sending documents with model Espadon.
dol_get_last_day($year, $month=12, $gm=false)
Return GMT time for last day of a month or year.
Definition date.lib.php:624
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
dol_now($mode='gmt')
Return date for now.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
GETPOSTDATE($prefix, $hourTime='', $gm='auto', $saverestore='')
Helper function that combines values of a dolibarr DatePicker (such as Form\selectDate) for year,...
print_liste_field_titre($name, $file="", $field="", $begin="", $param="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $selectlimitsuffix=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
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.
setEventMessage($mesgs, $style='mesgs', $noduplicate=0, $attop=0)
Set event message in dol_events session object.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
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.
natural_search($fields, $value, $mode=0, $nofirstand=0, $sqltoadd='')
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
getMultidirOutput($object, $module='', $forobject=0, $mode='output')
Return the full path of the directory where a module (or an object of a module) stores its files.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
dolGetButtonTitleSeparator($moreClass="")
Add space between dolGetButtonTitle.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
dol_getdate($timestamp, $fast=false, $forcetimezone='')
Return an array with locale date info.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.