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