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