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