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