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