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