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