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