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