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