dolibarr 24.0.0-beta
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
214if (!getDolGlobalString('ACCOUNTING_ENABLE_LETTERING')) {
215 unset($arrayfields['t.lettering_code']);
216}
217
218$error = 0;
219
220if (!isModEnabled('accounting')) {
222}
223if ($user->socid > 0) {
225}
226if (!$user->hasRight('accounting', 'mouvements', 'lire')) {
228}
229
230// Permissions
231$permissiontoread = $user->hasRight('accounting', 'mouvements', 'lire');
232$permissiontoadd = $user->hasRight('accounting', 'mouvements', 'creer');
233$permissiontodelete = $user->hasRight('accounting', 'mouvements', 'supprimer');
234$permissiontoexport = $user->hasRight('accounting', 'mouvements', 'export');
235
236
237/*
238 * Actions
239 */
240
241$param = '';
242$filter = array();
243
244if (GETPOST('cancel', 'alpha')) {
245 $action = 'list';
246 $massaction = '';
247}
248if (!GETPOST('confirmmassaction', 'alpha') &&
249 !in_array($massaction, [
250 'pregeneralunmatchingmanual',
251 'predeletebookkeepingwriting',
252 'preclonebookkeepingwriting',
253 'preassignaccountbookkeepingwriting',
254 'prereturnaccountbookkeepingwriting'
255 ])) {
256 $massaction = '';
257}
258
259$parameters = array('socid' => $socid);
260$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
261if ($reshook < 0) {
262 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
263}
264
265if (empty($reshook)) {
266 include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
267
268 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
269 $search_mvt_num = '';
270 $search_doc_type = '';
271 $search_doc_ref = '';
272 $search_doc_date = '';
273 $search_account_category = '';
274 $search_accountancy_code = '';
275 $search_accountancy_code_start = '';
276 $search_accountancy_code_end = '';
277 $search_accountancy_aux_code = '';
278 $search_accountancy_aux_code_start = '';
279 $search_accountancy_aux_code_end = '';
280 $search_mvt_label = '';
281 $search_direction = '';
282 $search_ledger_code = array();
283 $search_date_start = '';
284 $search_date_end = '';
285 $search_date_creation_start = '';
286 $search_date_creation_end = '';
287 $search_date_modification_start = '';
288 $search_date_modification_end = '';
289 $search_date_export_start = '';
290 $search_date_export_end = '';
291 $search_date_validation_start = '';
292 $search_date_validation_end = '';
293 // Due date start
294 $search_date_due_start_day = '';
295 $search_date_due_start_month = '';
296 $search_date_due_start_year = '';
297 $search_date_due_start = '';
298 // Due date end
299 $search_date_due_end_day = '';
300 $search_date_due_end_month = '';
301 $search_date_due_end_year = '';
302 $search_date_due_end = '';
303 $search_debit = '';
304 $search_credit = '';
305 $search_lettering_code = '';
306 $search_not_reconciled = '';
307 $search_import_key = '';
308 $toselect = array();
309 unset($_SESSION['DOLDATE_search_date_start_accountancy_day']);
310 unset($_SESSION['DOLDATE_search_date_start_accountancy_month']);
311 unset($_SESSION['DOLDATE_search_date_start_accountancy_year']);
312 unset($_SESSION['DOLDATE_search_date_end_accountancy_day']);
313 unset($_SESSION['DOLDATE_search_date_end_accountancy_month']);
314 unset($_SESSION['DOLDATE_search_date_end_accountancy_year']);
315 }
316
317 // Must be after the remove filter action, before the export.
318 if (!empty($search_date_start)) {
319 $filter['t.doc_date>='] = $search_date_start;
320 $tmp = dol_getdate($search_date_start);
321 $param .= '&search_date_startmonth='.((int) $tmp['mon']).'&search_date_startday='.((int) $tmp['mday']).'&search_date_startyear='.((int) $tmp['year']);
322 }
323 if (!empty($search_date_end)) {
324 $filter['t.doc_date<='] = $search_date_end;
325 $tmp = dol_getdate($search_date_end);
326 $param .= '&search_date_endmonth='.((int) $tmp['mon']).'&search_date_endday='.((int) $tmp['mday']).'&search_date_endyear='.((int) $tmp['year']);
327 }
328 if (!empty($search_doc_date)) {
329 $filter['t.doc_date'] = $search_doc_date;
330 $tmp = dol_getdate($search_doc_date);
331 $param .= '&doc_datemonth='.((int) $tmp['mon']).'&doc_dateday='.((int) $tmp['mday']).'&doc_dateyear='.((int) $tmp['year']);
332 }
333 if (!empty($search_doc_type)) {
334 $filter['t.doc_type'] = $search_doc_type;
335 $param .= '&search_doc_type='.urlencode($search_doc_type);
336 }
337 if (!empty($search_doc_ref)) {
338 $filter['t.doc_ref'] = $search_doc_ref;
339 $param .= '&search_doc_ref='.urlencode($search_doc_ref);
340 }
341 if ($search_account_category != '-1' && !empty($search_account_category)) {
342 require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountancycategory.class.php';
343 $accountingcategory = new AccountancyCategory($db);
344
345 $listofaccountsforgroup = $accountingcategory->getCptsCat(0, 'fk_accounting_category = '.((int) $search_account_category));
346 $listofaccountsforgroup2 = array();
347 if (is_array($listofaccountsforgroup)) {
348 foreach ($listofaccountsforgroup as $tmpval) {
349 $listofaccountsforgroup2[] = "'".$db->escape((string) $tmpval['account_number'])."'";
350 }
351 }
352 if (!empty($listofaccountsforgroup2)) {
353 $filter['t.search_accounting_code_in'] = implode(',', $listofaccountsforgroup2);
354 } else {
355 $filter['t.search_accounting_code_in'] = "''";
356 setEventMessages($langs->trans("ThisCategoryHasNoItems"), null, 'warnings');
357 }
358 $param .= '&search_account_category='.urlencode((string) ($search_account_category));
359 }
360 if (!empty($search_accountancy_code)) {
361 $filter['t.numero_compte'] = $search_accountancy_code;
362 $param .= '&search_accountancy_code='.urlencode($search_accountancy_code);
363 }
364 if (!empty($search_accountancy_code_start)) {
365 $filter['t.numero_compte>='] = $search_accountancy_code_start;
366 $param .= '&search_accountancy_code_start='.urlencode($search_accountancy_code_start);
367 }
368 if (!empty($search_accountancy_code_end)) {
369 $filter['t.numero_compte<='] = $search_accountancy_code_end;
370 $param .= '&search_accountancy_code_end='.urlencode($search_accountancy_code_end);
371 }
372 if (!empty($search_accountancy_aux_code)) {
373 $filter['t.subledger_account'] = $search_accountancy_aux_code;
374 $param .= '&search_accountancy_aux_code='.urlencode($search_accountancy_aux_code);
375 }
376 if (!empty($search_accountancy_aux_code_start)) {
377 $filter['t.subledger_account>='] = $search_accountancy_aux_code_start;
378 $param .= '&search_accountancy_aux_code_start='.urlencode($search_accountancy_aux_code_start);
379 }
380 if (!empty($search_accountancy_aux_code_end)) {
381 $filter['t.subledger_account<='] = $search_accountancy_aux_code_end;
382 $param .= '&search_accountancy_aux_code_end='.urlencode($search_accountancy_aux_code_end);
383 }
384 if (!empty($search_mvt_label)) {
385 $filter['t.label_operation'] = $search_mvt_label;
386 $param .= '&search_mvt_label='.urlencode($search_mvt_label);
387 }
388 if (!empty($search_direction)) {
389 $filter['t.sens'] = $search_direction;
390 $param .= '&search_direction='.urlencode($search_direction);
391 }
392 if (!empty($search_ledger_code)) {
393 $filter['t.code_journal'] = $search_ledger_code;
394 foreach ($search_ledger_code as $code) {
395 $param .= '&search_ledger_code[]='.urlencode($code);
396 }
397 }
398 if (!empty($search_mvt_num)) {
399 $filter['t.piece_num'] = $search_mvt_num;
400 $param .= '&search_mvt_num='.urlencode((string) ($search_mvt_num));
401 }
402 if (!empty($search_date_creation_start)) {
403 $filter['t.date_creation>='] = $search_date_creation_start;
404 $tmp = dol_getdate($search_date_creation_start);
405 $param .= '&search_date_creation_startmonth='.((int) $tmp['mon']).'&search_date_creation_startday='.((int) $tmp['mday']).'&search_date_creation_startyear='.((int) $tmp['year']);
406 }
407 if (!empty($search_date_creation_end)) {
408 $filter['t.date_creation<='] = $search_date_creation_end;
409 $tmp = dol_getdate($search_date_creation_end);
410 $param .= '&search_date_creation_endmonth='.((int) $tmp['mon']).'&search_date_creation_endday='.((int) $tmp['mday']).'&search_date_creation_endyear='.((int) $tmp['year']);
411 }
412 if (!empty($search_date_modification_start)) {
413 $filter['t.tms>='] = $search_date_modification_start;
414 $tmp = dol_getdate($search_date_modification_start);
415 $param .= '&search_date_modification_startmonth='.((int) $tmp['mon']).'&search_date_modification_startday='.((int) $tmp['mday']).'&search_date_modification_startyear='.((int) $tmp['year']);
416 }
417 if (!empty($search_date_modification_end)) {
418 $filter['t.tms<='] = $search_date_modification_end;
419 $tmp = dol_getdate($search_date_modification_end);
420 $param .= '&search_date_modification_endmonth='.((int) $tmp['mon']).'&search_date_modification_endday='.((int) $tmp['mday']).'&search_date_modification_endyear='.((int) $tmp['year']);
421 }
422 if (!empty($search_date_export_start)) {
423 $filter['t.date_export>='] = $search_date_export_start;
424 $tmp = dol_getdate($search_date_export_start);
425 $param .= '&search_date_export_startmonth='.((int) $tmp['mon']).'&search_date_export_startday='.((int) $tmp['mday']).'&search_date_export_startyear='.((int) $tmp['year']);
426 }
427 if (!empty($search_date_export_end)) {
428 $filter['t.date_export<='] = $search_date_export_end;
429 $tmp = dol_getdate($search_date_export_end);
430 $param .= '&search_date_export_endmonth='.((int) $tmp['mon']).'&search_date_export_endday='.((int) $tmp['mday']).'&search_date_export_endyear='.((int) $tmp['year']);
431 }
432 if (!empty($search_date_validation_start)) {
433 $filter['t.date_validated>='] = $search_date_validation_start;
434 $tmp = dol_getdate($search_date_validation_start);
435 $param .= '&search_date_validation_startmonth='.((int) $tmp['mon']).'&search_date_validation_startday='.((int) $tmp['mday']).'&search_date_validation_startyear='.((int) $tmp['year']);
436 }
437 if (!empty($search_date_validation_end)) {
438 $filter['t.date_validated<='] = $search_date_validation_end;
439 $tmp = dol_getdate($search_date_validation_end);
440 $param .= '&search_date_validation_endmonth='.((int) $tmp['mon']).'&search_date_validation_endday='.((int) $tmp['mday']).'&search_date_validation_endyear='.((int) $tmp['year']);
441 }
442 // Due date start
443 if (!empty($search_date_due_start)) {
444 $filter['t.date_lim_reglement>='] = $search_date_due_start;
445 $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;
446 }
447 // Due date end
448 if (!empty($search_date_due_end)) {
449 $filter['t.date_lim_reglement<='] = $search_date_due_end;
450 $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;
451 }
452 if (!empty($search_debit)) {
453 $filter['t.debit'] = $search_debit;
454 $param .= '&search_debit='.urlencode($search_debit);
455 }
456 if (!empty($search_credit)) {
457 $filter['t.credit'] = $search_credit;
458 $param .= '&search_credit='.urlencode($search_credit);
459 }
460 if (!empty($search_lettering_code)) {
461 $filter['t.lettering_code'] = $search_lettering_code;
462 $param .= '&search_lettering_code='.urlencode($search_lettering_code);
463 }
464 if (!empty($search_not_reconciled)) {
465 $filter['t.reconciled_option'] = $search_not_reconciled;
466 $param .= '&search_not_reconciled='.urlencode($search_not_reconciled);
467 }
468 if (!empty($search_import_key)) {
469 $filter['t.import_key'] = $search_import_key;
470 $param .= '&search_import_key='.urlencode($search_import_key);
471 }
472
473 // Actions
474 if ($action === 'exporttopdf' && $permissiontoadd) {
475 $object->fetchAll('ASC,ASC,ASC', 'code_journal,doc_date,piece_num', 0, 0, $filter);
476 require_once DOL_DOCUMENT_ROOT . '/core/modules/accountancy/doc/pdf_bookkeeping.modules.php';
477 $pdf = new pdf_bookkeeping($db);
478 $pdf->fromDate = $search_date_start;
479 $pdf->toDate = $search_date_end;
480
481 $result = $pdf->write_file($object, $langs);
482
483 if ($result < 0) {
484 setEventMessage($pdf->error, "errors");
485 } else {
486 // Generated PDF is directly sent to the browser
487 exit;
488 }
489 }
490
491 // Mass actions
492 $objectclass = 'Bookkeeping';
493 $objectlabel = 'Bookkeeping';
494 $uploaddir = $conf->societe->dir_output;
495
496 global $error;
498 include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
499
500 if (!$error && $action == 'deletebookkeepingwriting' && $confirm == "yes" && $user->hasRight('accounting', 'mouvements', 'supprimer')) {
501 $db->begin();
502
503 if (getDolGlobalInt('ACCOUNTING_ENABLE_LETTERING')) {
504 $lettering = new Lettering($db);
505 $nb_lettering = $lettering->bookkeepingLetteringAll($toselect, true);
506 if ($nb_lettering < 0) {
507 setEventMessages('', $lettering->errors, 'errors');
508 $error += 1;
509 }
510 }
511
512 $nbok = 0;
513 $result = 0;
514 if (!$error) {
515 foreach ($toselect as $toselectid) {
516 $result = $object->fetch($toselectid);
517 if ($result > 0 && (!isset($object->date_validation) || $object->date_validation === '')) {
518 $result = $object->deleteMvtNum($object->piece_num);
519 if ($result > 0) {
520 $nbok++;
521 } else {
522 setEventMessages($object->error, $object->errors, 'errors');
523 $error += 1;
524 break;
525 }
526 } elseif ($result < 0) {
527 setEventMessages($object->error, $object->errors, 'errors');
528 $error += 1;
529 break;
530 } elseif (isset($object->date_validation) && $object->date_validation != '') {
531 setEventMessages($langs->trans("ValidatedRecordWhereFound"), null, 'errors');
532 $error += 1;
533 break;
534 }
535 }
536 }
537
538 if (!$error) {
539 $db->commit();
540
541 // Message for elements well deleted
542 if ($nbok > 1) {
543 setEventMessages($langs->trans("RecordsDeleted", $nbok), null, 'mesgs');
544 } elseif ($nbok > 0) {
545 setEventMessages($langs->trans("RecordDeleted", $nbok), null, 'mesgs');
546 } else {
547 setEventMessages($langs->trans("NoRecordDeleted"), null, 'mesgs');
548 }
549
550 header("Location: ".$_SERVER["PHP_SELF"]."?noreset=1".($param ? '&'.$param : ''));
551 exit;
552 } else {
553 $db->rollback();
554 }
555 }
556
557 // massaction cloning
558 if (!$error && $action == 'clonebookkeepingwriting' && $confirm == "yes" && $user->hasRight('accounting', 'mouvements', 'creer')) {
559 $result = $object->newCloneMass($toselect, $journal_code, $massdate);
560 if ($result == -1) {
561 $error += 1;
562 }
563 if ($error) {
564 $db->commit();
565 header("Location: ".$_SERVER["PHP_SELF"]."?noreset=1".($param ? '&'.$param : ''));
566 exit;
567 } else {
568 $db->rollback();
569 }
570 }
571
572 // massaction assign new account
573 if (!$error && $action == 'assignaccountbookkeepingwriting' && $confirm == "yes" && $user->hasRight('accounting', 'mouvements', 'creer')) {
574 $result = $object->assignAccountMass($toselect, (int) $account);
575 if ($result == -1) {
576 $error += 1;
577 }
578 if (!$error) {
579 $db->commit();
580 header("Location: ".$_SERVER["PHP_SELF"]."?noreset=1".($param ? '&'.$param : ''));
581 exit();
582 } else {
583 $db->rollback();
584 }
585 }
586
587 // mass action return account
588 if (!$error && $action == 'returnaccountbookkeepingwriting' && $confirm == "yes" && $user->hasRight('accounting', 'mouvements', 'creer')) {
589 $result = $object->newReturnAccount($toselect, $journal_code, $massdate);
590 if ($result == -1) {
591 $error += 1;
592 }
593 if (!$error) {
594 $db->commit();
595 header("Location: ".$_SERVER["PHP_SELF"]."?noreset=1".($param ? '&'.$param : ''));
596 exit();
597 } else {
598 $db->rollback();
599 }
600 }
601
602 // mass actions on matching
603 if (!$error && getDolGlobalInt('ACCOUNTING_ENABLE_LETTERING')) {
604 if ($massaction == 'generalmatchingmanual' && $permissiontoadd) {
605 $lettering = new Lettering($db);
606 $result = $lettering->updateGeneralMatching($toselect);
607 if ($result < 0) {
608 setEventMessages('', $lettering->errors, 'errors');
609 } else {
610 setEventMessages($langs->trans($result == 0 ? 'AccountancyNoMachingModified' : 'AccountancyOneMatchingModifiedSuccessfully'), array(), 'mesgs');
611 header('Location: ' . $_SERVER['PHP_SELF'] . '?noreset=1' . $param);
612 exit();
613 }
614 } elseif ($massaction == 'generalmatchingpartial' && $permissiontoadd) {
615 $lettering = new Lettering($db);
616 $result = $lettering->updateGeneralMatching($toselect, true);
617 if ($result < 0) {
618 setEventMessages('', $lettering->errors, 'errors');
619 } else {
620 setEventMessages($langs->trans($result == 0 ? 'AccountancyNoMachingModified' : 'AccountancyOneMatchingModifiedSuccessfully'), array(), 'mesgs');
621 header('Location: ' . $_SERVER['PHP_SELF'] . '?noreset=1' . $param);
622 exit;
623 }
624 } elseif ($action == 'generalunmatchingmanual' && $confirm == 'yes' && $permissiontodelete) {
625 $lettering = new Lettering($db);
626 $result = $lettering->deleteGeneralMatching($toselect);
627 if ($result < 0) {
628 setEventMessages('', $lettering->errors, 'errors');
629 } else {
630 setEventMessages($langs->trans($result == 0 ? 'AccountancyNoUnmatchingModified' : 'AccountancyOneUnmatchingModifiedSuccessfully'), [], 'mesgs');
631 header('Location: ' . $_SERVER['PHP_SELF'] . '?noreset=1' . $param);
632 exit;
633 }
634 }
635 }
636}
637
638// Build and execute select (used by page and export action)
639// must de set after the action that set $filter
640// --------------------------------------------------------------------
641
642$sql = 'SELECT';
643$sql .= ' t.rowid,';
644$sql .= " t.doc_date,";
645$sql .= " t.doc_type,";
646$sql .= " t.doc_ref,";
647$sql .= " t.fk_doc,";
648$sql .= " t.fk_docdet,";
649$sql .= " t.thirdparty_code,";
650$sql .= " t.subledger_account,";
651$sql .= " t.subledger_label,";
652$sql .= " t.numero_compte,";
653$sql .= " t.label_compte,";
654$sql .= " t.label_operation,";
655$sql .= " t.debit,";
656$sql .= " t.credit,";
657$sql .= " t.lettering_code,";
658$sql .= " t.matching_general,";
659$sql .= " t.montant as amount,";
660$sql .= " t.sens,";
661$sql .= " t.fk_user_author,";
662$sql .= " t.import_key,";
663$sql .= " t.code_journal,";
664$sql .= " t.journal_label,";
665$sql .= " t.piece_num,";
666$sql .= " t.ref,";
667$sql .= " t.date_creation,";
668$sql .= " t.tms as date_modification,";
669$sql .= " t.date_export,";
670$sql .= " t.date_validated as date_validation,";
671$sql .= " t.date_lim_reglement,";
672$sql .= " t.import_key";
673
674$sqlfields = $sql; // $sql fields to remove for count total
675
676$sql .= ' FROM '.MAIN_DB_PREFIX.$object->table_element.' as t';
677// Manage filter
678$sqlwhere = array();
679if (count($filter) > 0) {
680 foreach ($filter as $key => $value) {
681 if ($key == 't.doc_date') {
682 $sqlwhere[] = $db->sanitize($key)." = '".$db->idate($value)."'";
683 } elseif ($key == 't.doc_date>=') {
684 $sqlwhere[] = "t.doc_date >= '".$db->idate($value)."'";
685 } elseif ($key == 't.doc_date<=') {
686 $sqlwhere[] = "t.doc_date <= '".$db->idate($value)."'";
687 } elseif ($key == 't.numero_compte>=') {
688 $sqlwhere[] = "t.numero_compte >= '".$db->escape($value)."'";
689 } elseif ($key == 't.numero_compte<=') {
690 $sqlwhere[] = "t.numero_compte <= '".$db->escape($value)."'";
691 } elseif ($key == 't.subledger_account>=') {
692 $sqlwhere[] = "t.subledger_account >= '".$db->escape($value)."'";
693 } elseif ($key == 't.subledger_account<=') {
694 $sqlwhere[] = "t.subledger_account <= '".$db->escape($value)."'";
695 /* } elseif ($key == 't.fk_doc' || $key == 't.fk_docdet' || $key == 't.piece_num') { // these fields doesn't exists
696 $sqlwhere[] = $db->sanitize($key).' = '.((int) $value); */
697 } elseif ($key == 't.subledger_account' || $key == 't.numero_compte') {
698 $sqlwhere[] = $db->sanitize($key)." LIKE '".$db->escape($db->escapeforlike($value))."%'";
699 /* } elseif ($key == 't.subledger_account') { // test is always false
700 $sqlwhere[] = natural_search($key, $value, 0, 1); */
701 } elseif ($key == 't.tms>=') {
702 $sqlwhere[] = "t.tms >= '".$db->idate($value)."'";
703 } elseif ($key == 't.tms<=') {
704 $sqlwhere[] = "t.tms <= '".$db->idate($value)."'";
705 } elseif ($key == 't.date_creation>=') {
706 $sqlwhere[] = "t.date_creation >= '".$db->idate($value)."'";
707 } elseif ($key == 't.date_creation<=') {
708 $sqlwhere[] = "t.date_creation <= '".$db->idate($value)."'";
709 } elseif ($key == 't.date_export>=') {
710 $sqlwhere[] = "t.date_export >= '".$db->idate($value)."'";
711 } elseif ($key == 't.date_export<=') {
712 $sqlwhere[] = "t.date_export <= '".$db->idate($value)."'";
713 } elseif ($key == 't.date_validated>=') {
714 $sqlwhere[] = "t.date_validated >= '".$db->idate($value)."'";
715 } elseif ($key == 't.date_validated<=') {
716 $sqlwhere[] = "t.date_validated <= '".$db->idate($value)."'";
717 } elseif ($key == 't.date_lim_reglement>=') {
718 $sqlwhere[] = "t.date_lim_reglement >= '".$db->idate($value)."'";
719 } elseif ($key == 't.date_lim_reglement<=') {
720 $sqlwhere[] = "t.date_lim_reglement <= '".$db->idate($value)."'";
721 } elseif ($key == 't.credit' || $key == 't.debit') {
722 $sqlwhere[] = natural_search($key, $value, 1, 1);
723 } elseif ($key == 't.reconciled_option') {
724 $sqlwhere[] = 't.lettering_code IS NULL';
725 } elseif ($key == 't.code_journal' && !empty($value)) { // @phpstan-ignore-line false positive on !empty
726 if (is_array($value)) {
727 $sqlwhere[] = natural_search("t.code_journal", implode(',', $value), 3, 1);
728 } else {
729 $sqlwhere[] = natural_search("t.code_journal", $value, 3, 1);
730 }
731 } elseif ($key == 't.search_accounting_code_in' && !empty($value)) { // @phpstan-ignore-line false positive on !empty
732 $sqlwhere[] = 't.numero_compte IN ('.$db->sanitize($value, 1).')';
733 } else {
734 $sqlwhere[] = natural_search($key, $value, 0, 1);
735 }
736 }
737}
738$sql .= ' WHERE t.entity IN ('.getEntity('accountancy').')';
739
740if (count($sqlwhere) > 0) {
741 $sql .= ' AND '.implode(' AND ', $sqlwhere);
742}
743//print $sql;
744
745/*
746 * View
747 */
748
749$formother = new FormOther($db);
750$formfile = new FormFile($db);
751
752$title_page = $langs->trans("Operations").' - '.$langs->trans("Journals");
753
754// Count total nb of records
755$nbtotalofrecords = '';
756if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
757 /* The fast and low memory method to get and count full list converts the sql into a sql count */
758 $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql);
759 $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount);
760 $resql = $db->query($sqlforcount);
761 if ($resql) {
762 $objforcount = $db->fetch_object($resql);
763 $nbtotalofrecords = $objforcount->nbtotalofrecords;
764 } else {
766 }
767
768 if (($page * $limit) > (int) $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
769 $page = 0;
770 $offset = 0;
771 }
772 $db->free($resql);
773}
774
775
776// Complete request and execute it with limit
777$sql .= $db->order($sortfield, $sortorder);
778if ($limit) {
779 $sql .= $db->plimit($limit + 1, $offset);
780}
781
782$resql = $db->query($sql);
783if (!$resql) {
785 exit;
786}
787
788$num = $db->num_rows($resql);
789
790$arrayofselected = is_array($toselect) ? $toselect : array();
791
792// Output page
793// --------------------------------------------------------------------
794$help_url = 'EN:Module_Double_Entry_Accounting|FR:Module_Comptabilit&eacute;_en_Partie_Double';
795llxHeader('', $title_page, $help_url, '', 0, 0, '', '', '', 'mod-accountancy accountancy-consultation page-journal');
796
797$formconfirm = '';
798
799// Print form confirm
800print $formconfirm;
801
802//$param=''; param started before
803if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
804 $param .= '&contextpage='.urlencode($contextpage);
805}
806if ($limit > 0 && $limit != $conf->liste_limit) {
807 $param .= '&limit='.((int) $limit);
808}
809
810// List of mass actions available
811$arrayofmassactions = array();
812if (getDolGlobalInt('ACCOUNTING_ENABLE_LETTERING') && $user->hasRight('accounting', 'mouvements', 'creer')) {
813 $arrayofmassactions['generalmatchingmanual'] = img_picto('', 'check', 'class="pictofixedwidth"') . $langs->trans('GeneralMatchingManual');
814 $arrayofmassactions['generalmatchingpartial'] = img_picto('', 'check', 'class="pictofixedwidth"') . $langs->trans('GeneralMatchingPartial');
815 $arrayofmassactions['pregeneralunmatchingmanual'] = img_picto('', 'uncheck', 'class="pictofixedwidth"') . $langs->trans('GeneralUnmatchingManual');
816}
817if ($user->hasRight('accounting', 'mouvements', 'creer')) {
818 $arrayofmassactions['preclonebookkeepingwriting'] = img_picto('', 'clone', 'class="pictofixedwidth"').$langs->trans("Clone");
819}
820if ($user->hasRight('accounting', 'mouvements', 'creer')) {
821 $arrayofmassactions['preassignaccountbookkeepingwriting'] = img_picto('', 'fa-exchange-alt', 'class="pictofixedwidth"').$langs->trans("AssignAccount");
822}
823if ($user->hasRight('accounting', 'mouvements', 'creer')) {
824 $arrayofmassactions['prereturnaccountbookkeepingwriting'] = img_picto('', 'undo', 'class="pictofixedwidth"').$langs->trans("ReturnAccount");
825}
826if ($user->hasRight('accounting', 'mouvements', 'supprimer')) {
827 $arrayofmassactions['predeletebookkeepingwriting'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
828}
829
830if (GETPOSTINT('nomassaction')
831 || in_array($massaction,
832 array(
833 'pregeneralunmatchingmanual',
834 'predeletebookkeepingwriting',
835 'preclonebookkeepingwriting',
836 'preassignaccountbookkeepingwriting',
837 'prereturnaccountbookkeepingwriting'
838 )
839 )) {
840 $arrayofmassactions = array();
841}
842$massactionbutton = $form->selectMassAction($massaction, $arrayofmassactions);
843
844print '<form method="POST" id="searchFormList" action="'.dolBuildUrl($_SERVER["PHP_SELF"]).'">';
845print '<input type="hidden" name="token" value="'.newToken().'">';
846print '<input type="hidden" name="action" value="list">';
847if ($optioncss != '') {
848 print '<input type="hidden" name="optioncss" value="'.urlencode($optioncss).'">';
849}
850print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
851print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
852print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
853print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
854
855if (count($filter)) {
856 $buttonLabel = $langs->trans("ExportFilteredList");
857} else {
858 $buttonLabel = $langs->trans("ExportList");
859}
860
861$parameters = array('param' => $param);
862$reshook = $hookmanager->executeHooks('addMoreActionsButtonsList', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
863if ($reshook < 0) {
864 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
865}
866
867$newcardbutton = empty($hookmanager->resPrint) ? '' : $hookmanager->resPrint;
868
869if (empty($reshook)) {
870 $newcardbutton .= dolGetButtonTitle($langs->trans('ViewFlatList'), '', 'fa fa-list paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/list.php?'.$param, '', 1, array('morecss' => 'marginleftonly btnTitleSelected'));
871 $newcardbutton .= dolGetButtonTitle($langs->trans('GroupByAccountAccounting'), '', 'fa fa-stream paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/listbyaccount.php?'.$param, '', 1, array('morecss' => 'marginleftonly'));
872 $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'));
873 $newcardbutton .= dolGetButtonTitle($langs->trans('ExportToPdf'), '', 'fa fa-file-pdf paddingleft', $_SERVER['PHP_SELF'] . '?token=' . newToken() . '&action=exporttopdf&' . $param, '', $permissiontoexport, array('morecss' => 'marginleftonly'));
874
875 $url = './card.php?action=create'.(!empty($type) ? '&type=sub' : '').'&backtopage='.urlencode($_SERVER['PHP_SELF']);
876 if (!empty($socid)) {
877 $url .= '&socid='.$socid;
878 }
879 $newcardbutton .= dolGetButtonTitleSeparator();
880 $newcardbutton .= dolGetButtonTitle($langs->trans('NewAccountingMvt'), '', 'fa fa-plus-circle paddingleft', $url, '', $permissiontoadd);
881}
882
883print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_accountancy', 0, $newcardbutton, '', $limit, 0, 0, 1);
884
885if ($massaction == 'pregeneralunmatchingmanual') {
886 print $form->formconfirm($_SERVER['PHP_SELF'], $langs->trans('ConfirmMassGeneralUnmatchingManual'), $langs->trans("ConfirmMassGeneralUnmatchingQuestion", count($toselect)), "generalunmatchingmanual", null, '', 0, 200, 500, 1);
887} elseif ($massaction == 'predeletebookkeepingwriting') {
888 print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmMassDeleteBookkeepingWriting"), $langs->trans("ConfirmMassDeleteBookkeepingWritingQuestion", count($toselect)), "deletebookkeepingwriting", null, '', 0, 200, 500, 1);
889} elseif ($massaction == 'preassignaccountbookkeepingwriting') {
890 $input = $formaccounting->select_account('', 'account', 1);
891 $formquestion = array(array('type' => 'other', 'name' => 'account', 'label' => '<span class="fieldrequired">' . $langs->trans("AccountAccountingShort") . '</span>', 'value' => $input),);
892 print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("confirmMassAssignAccountBookkeepingWritingConfirm"), $langs->trans("ConfirmMassAssignAccountBookkeepingWritingQuestion", count($toselect)), "assignaccountbookkeepingwriting", $formquestion, '', 0, 200, 500, 1);
893} elseif ($massaction == 'preclonebookkeepingwriting') {
894 $input1 = $form->selectDate('', 'massdate', 0, 0, 0, "create_mvt", 1, 1);
895 $input2 = $formaccounting->select_journal($journal_code, 'code_journal', 0, 0, 1, 1) . '</td>';
896 $formquestion = array(
897 array(
898 'type' => 'other',
899 'name' => 'massdate',
900 'label' => '<span class="fieldrequired">' . $langs->trans("Docdate") . '</span>',
901 'value' => $input1
902 )
903 );
904
905 if (getDolGlobalString('ACCOUNTING_CLONING_ENABLE_INPUT_JOURNAL')) {
906 $formquestion[] = array(
907 'type' => 'text',
908 'name' => 'code_journal',
909 'label' => '<span class="fieldrequired">' . $langs->trans("Codejournal") . '</span>',
910 'value' => $input2
911 );
912 }
913
914 print $form->formconfirm(
915 $_SERVER["PHP_SELF"],
916 $langs->trans("ConfirmMassCloneBookkeepingWriting"),
917 $langs->trans("ConfirmMassCloneBookkeepingWritingQuestion", count($toselect)),
918 "clonebookkeepingwriting",
919 $formquestion,
920 '', 0, 200, 500, 1
921 );
922} elseif ($massaction == 'prereturnaccountbookkeepingwriting') {
923 $input1 = $form->selectDate('', 'massdate', 0, 0, 0, "create_mvt", 1, 1);
924 $formquestion = array(array('type' => 'other', 'name' => 'massdate', 'label' => '<span class="fieldrequired">' . $langs->trans("Docdate") . '</span>', 'value' => $input1));
925 print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmMassReturnAccountBookkeepingWriting"), $langs->trans("ConfirmMassReturnAccountBookkeepingWritingQuestion", count($toselect)), "returnaccountbookkeepingwriting", $formquestion, '', 0, 200, 500, 1);
926}
927
928//$topicmail = "Information";
929//$modelmail = "accountingbookkeeping";
930//$objecttmp = new BookKeeping($db);
931//$trackid = 'bk'.$object->id;
932include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
933
934$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
935$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, $conf->main_checkbox_left_column); // This also change content of $arrayfields
936if ($massactionbutton && $contextpage != 'poslist') {
937 $selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
938}
939
940$moreforfilter = '';
941$moreforfilter .= '<div class="divsearchfield">';
942$moreforfilter .= $langs->trans('AccountingCategory').': ';
943$moreforfilter .= '<div class="nowrap inline-block">';
944$moreforfilter .= $formaccounting->select_accounting_category($search_account_category, 'search_account_category', 1, 0, 0, 0);
945$moreforfilter .= '</div>';
946$moreforfilter .= '</div>';
947
948$parameters = array();
949$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
950if (empty($reshook)) {
951 $moreforfilter .= $hookmanager->resPrint;
952} else {
953 $moreforfilter = $hookmanager->resPrint;
954}
955
956print '<div class="liste_titre liste_titre_bydiv centpercent">';
957print $moreforfilter;
958print '</div>';
959
960print '<div class="div-table-responsive">';
961print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">';
962
963// Filters lines
964print '<tr class="liste_titre_filter">';
965// Action column
966if ($conf->main_checkbox_left_column) {
967 print '<td class="liste_titre center">';
968 $searchpicto = $form->showFilterButtons('left');
969 print $searchpicto;
970 print '</td>';
971}
972// Movement number
973if (!empty($arrayfields['t.piece_num']['checked'])) {
974 print '<td class="liste_titre"><input type="text" name="search_mvt_num" size="6" value="'.dol_escape_htmltag($search_mvt_num).'"></td>';
975}
976// Code journal
977if (!empty($arrayfields['t.code_journal']['checked'])) {
978 print '<td class="liste_titre center">';
979 print $formaccounting->multi_select_journal($search_ledger_code, 'search_ledger_code', 0, 1, 1, 1, 'maxwidth75');
980 print '</td>';
981}
982// Date document
983if (!empty($arrayfields['t.doc_date']['checked'])) {
984 print '<td class="liste_titre center">';
985 print '<div class="nowrapfordate">';
986 print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"));
987 print '</div>';
988 print '<div class="nowrapfordate">';
989 print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to"));
990 print '</div>';
991 print '</td>';
992}
993// Ref document
994if (!empty($arrayfields['t.doc_ref']['checked'])) {
995 print '<td class="liste_titre"><input type="text" name="search_doc_ref" class="width75" value="'.dol_escape_htmltag($search_doc_ref).'"></td>';
996}
997// Accountancy account
998if (!empty($arrayfields['t.numero_compte']['checked'])) {
999 print '<td class="liste_titre">';
1000 print '<div class="nowrap">';
1001 print $formaccounting->select_account($search_accountancy_code_start, 'search_accountancy_code_start', $langs->trans('From'), array(), 1, 1, 'maxwidth150', 'account');
1002 print '</div>';
1003 print '<div class="nowrap">';
1004 print $formaccounting->select_account($search_accountancy_code_end, 'search_accountancy_code_end', $langs->trans('to'), array(), 1, 1, 'maxwidth150', 'account');
1005 print '</div>';
1006 print '</td>';
1007}
1008// Subledger account
1009if (!empty($arrayfields['t.subledger_account']['checked'])) {
1010 print '<td class="liste_titre">';
1011 print '<div class="nowrap">';
1012 print $formaccounting->select_auxaccount($search_accountancy_aux_code_start, 'search_accountancy_aux_code_start', $langs->trans('From'), 'maxwidth250', 'subledgeraccount');
1013 print '</div>';
1014 print '<div class="nowrap">';
1015 print $formaccounting->select_auxaccount($search_accountancy_aux_code_end, 'search_accountancy_aux_code_end', $langs->trans('to'), 'maxwidth250', 'subledgeraccount');
1016 print '</div>';
1017 print '</td>';
1018}
1019// Label operation
1020if (!empty($arrayfields['t.label_operation']['checked'])) {
1021 print '<td class="liste_titre">';
1022 print '<input type="text" size="7" class="flat" name="search_mvt_label" value="'.dol_escape_htmltag($search_mvt_label).'"/>';
1023 print '</td>';
1024}
1025// Debit
1026if (!empty($arrayfields['t.debit']['checked'])) {
1027 print '<td class="liste_titre right">';
1028 print '<input type="text" class="flat" name="search_debit" size="4" value="'.dol_escape_htmltag($search_debit).'">';
1029 print '</td>';
1030}
1031// Credit
1032if (!empty($arrayfields['t.credit']['checked'])) {
1033 print '<td class="liste_titre right">';
1034 print '<input type="text" class="flat" name="search_credit" size="4" value="'.dol_escape_htmltag($search_credit).'">';
1035 print '</td>';
1036}
1037// Matching code
1038if (!empty($arrayfields['t.lettering_code']['checked'])) {
1039 print '<td class="liste_titre center">';
1040 print '<input type="text" size="3" class="flat" name="search_lettering_code" value="'.dol_escape_htmltag($search_lettering_code).'"/>';
1041 print '<br><span class="nowrap"><input type="checkbox" name="search_not_reconciled" value="notreconciled"'.($search_not_reconciled == 'notreconciled' ? ' checked' : '').'>'.$langs->trans("NotReconciled").'</span>';
1042 print '</td>';
1043}
1044
1045// Fields from hook
1046$parameters = array('arrayfields' => $arrayfields);
1047$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
1048print $hookmanager->resPrint;
1049
1050// Date creation
1051if (!empty($arrayfields['t.date_creation']['checked'])) {
1052 print '<td class="liste_titre center">';
1053 print '<div class="nowrapfordate">';
1054 print $form->selectDate($search_date_creation_start, 'search_date_creation_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"));
1055 print '</div>';
1056 print '<div class="nowrapfordate">';
1057 print $form->selectDate($search_date_creation_end, 'search_date_creation_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to"));
1058 print '</div>';
1059 print '</td>';
1060}
1061// Date modification
1062if (!empty($arrayfields['t.tms']['checked'])) {
1063 print '<td class="liste_titre center">';
1064 print '<div class="nowrapfordate">';
1065 print $form->selectDate($search_date_modification_start, 'search_date_modification_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"));
1066 print '</div>';
1067 print '<div class="nowrapfordate">';
1068 print $form->selectDate($search_date_modification_end, 'search_date_modification_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to"));
1069 print '</div>';
1070 print '</td>';
1071}
1072// Date export
1073if (!empty($arrayfields['t.date_export']['checked'])) {
1074 print '<td class="liste_titre center">';
1075 print '<div class="nowrapfordate">';
1076 print $form->selectDate($search_date_export_start, 'search_date_export_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"));
1077 print '</div>';
1078 print '<div class="nowrapfordate">';
1079 print $form->selectDate($search_date_export_end, 'search_date_export_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to"));
1080 print '</div>';
1081 print '</td>';
1082}
1083// Date validation
1084if (!empty($arrayfields['t.date_validated']['checked'])) {
1085 print '<td class="liste_titre center">';
1086 print '<div class="nowrapfordate">';
1087 print $form->selectDate($search_date_validation_start, 'search_date_validation_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"));
1088 print '</div>';
1089 print '<div class="nowrapfordate">';
1090 print $form->selectDate($search_date_validation_end, 'search_date_validation_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to"));
1091 print '</div>';
1092 print '</td>';
1093}
1094// Due date start and end
1095if (!empty($arrayfields['t.date_lim_reglement']['checked'])) {
1096 print '<td class="liste_titre center">';
1097 print '<div class="nowrapfordate">';
1098 print $form->selectDate($search_date_due_start, 'search_date_due_start_', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"));
1099 print '</div>';
1100 print '<div class="nowrapfordate">';
1101 print $form->selectDate($search_date_due_end, 'search_date_due_end_', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to"));
1102 print '</div>';
1103 print '</td>';
1104}
1105if (!empty($arrayfields['t.import_key']['checked'])) {
1106 print '<td class="liste_titre center">';
1107 print '<input class="flat searchstring maxwidth50" type="text" name="search_import_key" value="'.dol_escape_htmltag($search_import_key).'">';
1108 print '</td>';
1109}
1110// Action column
1111if (!$conf->main_checkbox_left_column) {
1112 print '<td class="liste_titre center">';
1113 $searchpicto = $form->showFilterButtons();
1114 print $searchpicto;
1115 print '</td>';
1116}
1117print "</tr>\n";
1118
1119print '<tr class="liste_titre">';
1120if ($conf->main_checkbox_left_column) {
1121 print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch actioncolumn ');
1122}
1123if (!empty($arrayfields['t.piece_num']['checked'])) {
1124 print_liste_field_titre($arrayfields['t.piece_num']['label'], $_SERVER['PHP_SELF'], "t.piece_num", "", $param, "", $sortfield, $sortorder);
1125}
1126if (!empty($arrayfields['t.code_journal']['checked'])) {
1127 print_liste_field_titre($arrayfields['t.code_journal']['label'], $_SERVER['PHP_SELF'], "t.code_journal", "", $param, '', $sortfield, $sortorder, 'center ');
1128}
1129if (!empty($arrayfields['t.doc_date']['checked'])) {
1130 print_liste_field_titre($arrayfields['t.doc_date']['label'], $_SERVER['PHP_SELF'], "t.doc_date", "", $param, '', $sortfield, $sortorder, 'center ');
1131}
1132if (!empty($arrayfields['t.doc_ref']['checked'])) {
1133 print_liste_field_titre($arrayfields['t.doc_ref']['label'], $_SERVER['PHP_SELF'], "t.doc_ref", "", $param, "", $sortfield, $sortorder);
1134}
1135if (!empty($arrayfields['t.numero_compte']['checked'])) {
1136 print_liste_field_titre($arrayfields['t.numero_compte']['label'], $_SERVER['PHP_SELF'], "t.numero_compte", "", $param, "", $sortfield, $sortorder);
1137}
1138if (!empty($arrayfields['t.subledger_account']['checked'])) {
1139 print_liste_field_titre($arrayfields['t.subledger_account']['label'], $_SERVER['PHP_SELF'], "t.subledger_account", "", $param, "", $sortfield, $sortorder);
1140}
1141if (!empty($arrayfields['t.label_operation']['checked'])) {
1142 print_liste_field_titre($arrayfields['t.label_operation']['label'], $_SERVER['PHP_SELF'], "t.label_operation", "", $param, "", $sortfield, $sortorder);
1143}
1144if (!empty($arrayfields['t.debit']['checked'])) {
1145 print_liste_field_titre($arrayfields['t.debit']['label'], $_SERVER['PHP_SELF'], "t.debit", "", $param, '', $sortfield, $sortorder, 'right ');
1146}
1147if (!empty($arrayfields['t.credit']['checked'])) {
1148 print_liste_field_titre($arrayfields['t.credit']['label'], $_SERVER['PHP_SELF'], "t.credit", "", $param, '', $sortfield, $sortorder, 'right ');
1149}
1150if (!empty($arrayfields['t.lettering_code']['checked'])) {
1151 print_liste_field_titre($arrayfields['t.lettering_code']['label'], $_SERVER['PHP_SELF'], "t.lettering_code", "", $param, '', $sortfield, $sortorder, 'center ');
1152}
1153// Hook fields
1154$parameters = array('arrayfields' => $arrayfields, 'param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder);
1155$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
1156print $hookmanager->resPrint;
1157if (!empty($arrayfields['t.date_creation']['checked'])) {
1158 print_liste_field_titre($arrayfields['t.date_creation']['label'], $_SERVER['PHP_SELF'], "t.date_creation", "", $param, '', $sortfield, $sortorder, 'center ');
1159}
1160if (!empty($arrayfields['t.tms']['checked'])) {
1161 print_liste_field_titre($arrayfields['t.tms']['label'], $_SERVER['PHP_SELF'], "t.tms", "", $param, '', $sortfield, $sortorder, 'center ');
1162}
1163if (!empty($arrayfields['t.date_export']['checked'])) {
1164 print_liste_field_titre($arrayfields['t.date_export']['label'], $_SERVER['PHP_SELF'], "t.date_export,t.doc_date", "", $param, '', $sortfield, $sortorder, 'center ');
1165}
1166if (!empty($arrayfields['t.date_validated']['checked'])) {
1167 print_liste_field_titre($arrayfields['t.date_validated']['label'], $_SERVER['PHP_SELF'], "t.date_validated,t.doc_date", "", $param, '', $sortfield, $sortorder, 'center ');
1168}
1169// Due date
1170if (!empty($arrayfields['t.date_lim_reglement']['checked'])) {
1171 print_liste_field_titre($arrayfields['t.date_lim_reglement']['label'], $_SERVER['PHP_SELF'], 't.date_lim_reglement', '', $param, '', $sortfield, $sortorder, 'center ');
1172}
1173if (!empty($arrayfields['t.import_key']['checked'])) {
1174 print_liste_field_titre($arrayfields['t.import_key']['label'], $_SERVER["PHP_SELF"], "t.import_key", "", $param, '', $sortfield, $sortorder, 'center ');
1175}
1176if (!$conf->main_checkbox_left_column) {
1177 print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
1178}
1179print "</tr>\n";
1180
1181
1182$line = new BookKeepingLine($db);
1183
1184// Loop on record
1185// --------------------------------------------------------------------
1186$i = 0;
1187$totalarray = array();
1188$totalarray['nbfield'] = 0;
1189$totalarray['val'] = array();
1190$totalarray['val']['totaldebit'] = 0;
1191$totalarray['val']['totalcredit'] = 0;
1192
1193while ($i < min($num, $limit)) {
1194 $obj = $db->fetch_object($resql);
1195 if (empty($obj)) {
1196 break; // Should not happen
1197 }
1198
1199 $line->id = $obj->rowid;
1200 $line->doc_date = $db->jdate($obj->doc_date);
1201 $line->doc_type = $obj->doc_type;
1202 $line->doc_ref = $obj->doc_ref;
1203 $line->fk_doc = $obj->fk_doc;
1204 $line->fk_docdet = $obj->fk_docdet;
1205 $line->thirdparty_code = $obj->thirdparty_code;
1206 $line->subledger_account = $obj->subledger_account;
1207 $line->subledger_label = $obj->subledger_label;
1208 $line->numero_compte = $obj->numero_compte;
1209 $line->label_compte = $obj->label_compte;
1210 $line->label_operation = $obj->label_operation;
1211 $line->debit = $obj->debit;
1212 $line->credit = $obj->credit;
1213 $line->montant = $obj->amount; // deprecated
1214 $line->amount = $obj->amount;
1215 $line->sens = $obj->sens;
1216 $line->lettering_code = $obj->lettering_code;
1217 $line->matching_general = $obj->matching_general;
1218 $line->fk_user_author = $obj->fk_user_author;
1219 $line->import_key = $obj->import_key;
1220 $line->code_journal = $obj->code_journal;
1221 $line->journal_label = $obj->journal_label;
1222 $line->piece_num = $obj->piece_num;
1223 $line->ref = $obj->ref;
1224 $line->date_creation = $db->jdate($obj->date_creation);
1225 $line->date_modification = $db->jdate($obj->date_modification);
1226 $line->date_export = $db->jdate($obj->date_export);
1227 $line->date_validation = $db->jdate($obj->date_validation);
1228 // Due date
1229 $line->date_lim_reglement = $db->jdate($obj->date_lim_reglement);
1230
1231 print '<tr class="oddeven">';
1232 // Action column
1233 if ($conf->main_checkbox_left_column) {
1234 print '<td class="nowraponall center">';
1235 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
1236 $selected = 0;
1237 if (in_array($line->id, $arrayofselected)) {
1238 $selected = 1;
1239 }
1240 print '<input id="cb'.$line->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$line->id.'"'.($selected ? ' checked="checked"' : '').' />';
1241 }
1242 print '</td>';
1243 if (!$i) {
1244 $totalarray['nbfield']++;
1245 }
1246 }
1247
1248 // Piece number
1249 if (!empty($arrayfields['t.piece_num']['checked'])) {
1250 print '<td class="nowraponall">';
1251 $object->id = $line->id;
1252 $object->piece_num = $line->piece_num;
1253 $object->ref = $line->ref;
1254 print $object->getNomUrl(1, '', 0, '', 1);
1255 print '<span class="hideonsmartphone">';
1256 if (!empty($line->date_export)) {
1257 print img_picto($langs->trans("DateExport").": ".dol_print_date($line->date_export, 'dayhour')." (".$langs->trans("TransactionExportDesc").")", 'fa-file-export', 'class="paddingleft pictofixedwidth opacitymedium"');
1258 }
1259 if (!empty($line->date_validation)) {
1260 print img_picto($langs->trans("DateValidation").": ".dol_print_date($line->date_validation, 'dayhour')." (".$langs->trans("TransactionBlockedLockedDesc").")", 'fa-lock', 'class="paddingleft pictofixedwidth opacitymedium"');
1261 }
1262 print '</span>';
1263 print '</td>';
1264 if (!$i) {
1265 $totalarray['nbfield']++;
1266 }
1267 }
1268
1269 // Journal code
1270 if (!empty($arrayfields['t.code_journal']['checked'])) {
1271 if (empty($conf->cache['accountingjournal'][$line->code_journal])) {
1272 $accountingjournal = new AccountingJournal($db);
1273 $accountingjournal->fetch(0, $line->code_journal);
1274 $conf->cache['accountingjournal'][$line->code_journal] = $accountingjournal;
1275 } else {
1276 $accountingjournal = $conf->cache['accountingjournal'][$line->code_journal];
1277 }
1278
1279 $journaltoshow = (($accountingjournal->id > 0) ? $accountingjournal->getNomUrl(0, 0, 0, '', 0) : $line->code_journal);
1280 print '<td class="center tdoverflowmax150">'.$journaltoshow.'</td>';
1281 if (!$i) {
1282 $totalarray['nbfield']++;
1283 }
1284 }
1285
1286 // Document date
1287 if (!empty($arrayfields['t.doc_date']['checked'])) {
1288 print '<td class="center">'.dol_print_date($line->doc_date, 'day').'</td>';
1289 if (!$i) {
1290 $totalarray['nbfield']++;
1291 }
1292 }
1293
1294 // Document ref
1295 $modulepart = ''; // may be used by include*.tpl.php
1296 if (!empty($arrayfields['t.doc_ref']['checked'])) {
1297 $documentlink = '';
1298 $objectstatic = null;
1299
1300 if ($line->doc_type === 'customer_invoice') {
1301 $langs->loadLangs(array('bills'));
1302
1303 require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
1304 $objectstatic = new Facture($db);
1305 $objectstatic->fetch($line->fk_doc);
1306 //$modulepart = 'facture';
1307
1308 $filename = dol_sanitizeFileName($line->doc_ref);
1309 $filedir = $conf->invoice->dir_output.'/'.dol_sanitizeFileName($line->doc_ref);
1310 $urlsource = $_SERVER['PHP_SELF'].'?id='.$objectstatic->id;
1311 $documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir);
1312 } elseif ($line->doc_type === 'supplier_invoice') {
1313 $langs->loadLangs(array('bills'));
1314
1315 require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
1316 $objectstatic = new FactureFournisseur($db);
1317 $objectstatic->fetch($line->fk_doc);
1318
1319 $modulepart = 'invoice_supplier';
1320 $filename = dol_sanitizeFileName($line->doc_ref);
1321
1322 //$filedir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($line->fk_doc, 2, 0, 0, $objectstatic, $modulepart).dol_sanitizeFileName($line->doc_ref);
1323 //$subdir = get_exdir($objectstatic->id, 2, 0, 0, $objectstatic, $modulepart).dol_sanitizeFileName($line->doc_ref);
1324 $filedir = getMultidirOutput($objectstatic, '', 1).dol_sanitizeFileName($line->doc_ref);
1325 $subdir = getMultidirOutput($objectstatic, '', 1, 'outputrel').dol_sanitizeFileName($line->doc_ref);
1326 //var_dump($filedir); var_dump($subdir);
1327
1328 if ($objectstatic->id > 0) {
1329 $documentlink = $formfile->getDocumentsLink($objectstatic->element, $subdir, $filedir);
1330 } else {
1331 $documentlink = $line->doc_ref;
1332 }
1333 } elseif ($line->doc_type === 'expense_report') {
1334 $langs->loadLangs(array('trips'));
1335
1336 require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
1337 $objectstatic = new ExpenseReport($db);
1338 $objectstatic->fetch($line->fk_doc);
1339 //$modulepart = 'expensereport';
1340
1341 $filename = dol_sanitizeFileName($line->doc_ref);
1342 $filedir = $conf->expensereport->dir_output.'/'.dol_sanitizeFileName($line->doc_ref);
1343 $urlsource = $_SERVER['PHP_SELF'].'?id='.$objectstatic->id;
1344 $documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir);
1345 } elseif ($line->doc_type === 'bank') {
1346 require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
1347 $objectstatic = new AccountLine($db);
1348 $objectstatic->fetch($line->fk_doc);
1349 } else {
1350 // Other type
1351 }
1352
1353 $labeltoshow = '';
1354 $labeltoshowalt = '';
1355 $classforlabel = '';
1356 if (($line->doc_type === 'customer_invoice' || $line->doc_type === 'supplier_invoice' || $line->doc_type === 'expense_report') && is_object($objectstatic)) {
1357 $labeltoshow .= $objectstatic->getNomUrl(1, '', 0, 0, '', 0, -1, 1);
1358 $labeltoshow .= $documentlink;
1359 $labeltoshowalt .= $objectstatic->ref;
1360 } elseif ($line->doc_type === 'bank' && is_object($objectstatic)) {
1361 $labeltoshow .= $objectstatic->getNomUrl(1);
1362 $labeltoshowalt .= $objectstatic->ref;
1363 $bank_ref = strstr($line->doc_ref, '-');
1364 $labeltoshow .= " " . $bank_ref;
1365 $labeltoshowalt .= " " . $bank_ref;
1366 } else {
1367 $labeltoshow .= $line->doc_ref;
1368 $labeltoshowalt .= $line->doc_ref;
1369 $classforlabel = 'tdoverflowmax250';
1370 }
1371
1372 print '<td class="nowraponall'.($classforlabel ? ' '.$classforlabel : '').'" title="'.dol_escape_htmltag($labeltoshowalt).'">';
1373 print $labeltoshow;
1374 print "</td>\n";
1375 if (!$i) {
1376 $totalarray['nbfield']++;
1377 }
1378 }
1379
1380 // Account number
1381 if (!empty($arrayfields['t.numero_compte']['checked'])) {
1382 print '<td>'.length_accountg($line->numero_compte).'</td>';
1383 if (!$i) {
1384 $totalarray['nbfield']++;
1385 }
1386 }
1387
1388 // Subledger account
1389 if (!empty($arrayfields['t.subledger_account']['checked'])) {
1390 print '<td>'.length_accounta($line->subledger_account).'</td>';
1391 if (!$i) {
1392 $totalarray['nbfield']++;
1393 }
1394 }
1395
1396 // Label operation
1397 if (!empty($arrayfields['t.label_operation']['checked'])) {
1398 print '<td class="small tdoverflowmax200" title="'.dol_escape_htmltag($line->label_operation).'">'.dol_escape_htmltag($line->label_operation).'</td>';
1399 if (!$i) {
1400 $totalarray['nbfield']++;
1401 }
1402 }
1403
1404 // Amount debit
1405 if (!empty($arrayfields['t.debit']['checked'])) {
1406 print '<td class="right nowraponall amount">'.($line->debit != 0 ? price($line->debit) : '').'</td>';
1407 if (!$i) {
1408 $totalarray['nbfield']++;
1409 }
1410 if (!$i) {
1411 $totalarray['pos'][$totalarray['nbfield']] = 'totaldebit';
1412 }
1413 $totalarray['val']['totaldebit'] += $line->debit;
1414 }
1415
1416 // Amount credit
1417 if (!empty($arrayfields['t.credit']['checked'])) {
1418 print '<td class="right nowraponall amount">'.($line->credit != 0 ? price($line->credit) : '').'</td>';
1419 if (!$i) {
1420 $totalarray['nbfield']++;
1421 }
1422 if (!$i) {
1423 $totalarray['pos'][$totalarray['nbfield']] = 'totalcredit';
1424 }
1425 $totalarray['val']['totalcredit'] += $line->credit;
1426 }
1427
1428 // Matching code
1429 if (!empty($arrayfields['t.lettering_code']['checked'])) {
1430 $tooltipText = "";
1431 $icon = "";
1432 $badge = "";
1433 if (!empty($line->matching_general)) {
1434 $tooltipText .= $langs->trans('GeneralMatching');
1435 $icon .= "fa-book";
1436 $badge .= "badge-status4";
1437 } elseif (empty($line->matching_general) && !empty($line->lettering_code)) {
1438 $tooltipText .= $langs->trans('AuxiliaryMatching');
1439 $icon .= "fa-user";
1440 $badge .= "badge-status1";
1441 }
1442 print '<td class="center classfortooltip" title="'.$tooltipText.'"><span class="badge '.$badge.'"><i class="fas '.$icon.' fa-xs"></i> '.$line->lettering_code.'</span></td>';
1443 if (!$i) {
1444 $totalarray['nbfield']++;
1445 }
1446 }
1447
1448 // Fields from hook
1449 $parameters = array('arrayfields' => $arrayfields, 'obj' => $obj, 'i' => $i, 'totalarray' => &$totalarray);
1450 $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook
1451 print $hookmanager->resPrint;
1452
1453 // Creation operation date
1454 if (!empty($arrayfields['t.date_creation']['checked'])) {
1455 print '<td class="center">'.dol_print_date($line->date_creation, 'dayhour', 'tzuserrel').'</td>';
1456 if (!$i) {
1457 $totalarray['nbfield']++;
1458 }
1459 }
1460
1461 // Modification operation date
1462 if (!empty($arrayfields['t.tms']['checked'])) {
1463 print '<td class="center">'.dol_print_date($line->date_modification, 'dayhour', 'tzuserrel').'</td>';
1464 if (!$i) {
1465 $totalarray['nbfield']++;
1466 }
1467 }
1468
1469 // Exported operation date
1470 if (!empty($arrayfields['t.date_export']['checked'])) {
1471 print '<td class="center nowraponall">'.dol_print_date($line->date_export, 'dayhour', 'tzuserrel').'</td>';
1472 if (!$i) {
1473 $totalarray['nbfield']++;
1474 }
1475 }
1476
1477 // Validated operation date
1478 if (!empty($arrayfields['t.date_validated']['checked'])) {
1479 print '<td class="center nowraponall">'.dol_print_date($line->date_validation, 'dayhour', 'tzuserrel').'</td>';
1480 if (!$i) {
1481 $totalarray['nbfield']++;
1482 }
1483 }
1484
1485 // Due date
1486 if (!empty($arrayfields['t.date_lim_reglement']['checked'])) {
1487 print '<td class="center">'.dol_print_date($line->date_lim_reglement, 'day').'</td>';
1488 if (!$i) {
1489 $totalarray['nbfield']++;
1490 }
1491 }
1492
1493 if (!empty($arrayfields['t.import_key']['checked'])) {
1494 print '<td class="tdoverflowmax125" title="'.dol_escape_htmltag($obj->import_key).'">'.dol_escape_htmltag($obj->import_key)."</td>\n";
1495 if (!$i) {
1496 $totalarray['nbfield']++;
1497 }
1498 }
1499
1500 // Action column
1501 if (!$conf->main_checkbox_left_column) {
1502 print '<td class="nowraponall center">';
1503 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
1504 $selected = 0;
1505 if (in_array($line->id, $arrayofselected)) {
1506 $selected = 1;
1507 }
1508 print '<input id="cb'.$line->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$line->id.'"'.($selected ? ' checked="checked"' : '').' />';
1509 }
1510 print '</td>';
1511 if (!$i) {
1512 $totalarray['nbfield']++;
1513 }
1514 }
1515
1516
1517 print "</tr>\n";
1518
1519 $i++;
1520}
1521
1522// Show total line
1523include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
1524
1525// If no record found
1526if ($num == 0) {
1527 $colspan = 1;
1528 foreach ($arrayfields as $key => $val) {
1529 if (!empty($val['checked'])) {
1530 $colspan++;
1531 }
1532 }
1533 print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
1534}
1535
1536$parameters = array('arrayfields' => $arrayfields, 'sql' => $sql);
1537$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1538print $hookmanager->resPrint;
1539
1540print "</table>";
1541print '</div>';
1542
1543print '</form>';
1544
1545// End of page
1546llxFooter();
1547
1548$db->close();
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
$totalarray
Definition list.php:497
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:623
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)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
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.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
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...
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.