dolibarr 21.0.0-alpha
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-2024 Alexandre Spangaro <alexandre@inovea-conseil.com>
5 * Copyright (C) 2022 Lionel Vessiller <lvessiller@open-dsi.fr>
6 * Copyright (C) 2016-2017 Laurent Destailleur <eldy@users.sourceforge.net>
7 * Copyright (C) 2018-2024 Frédéric France <frederic.france@free.fr>
8 * Copyright (C) 2022 Progiseize <a.bisotti@progiseize.fr>
9 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 3 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program. If not, see <https://www.gnu.org/licenses/>.
23 */
24
31// Load Dolibarr environment
32require '../../main.inc.php';
33require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountancyexport.class.php';
34require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
35require_once DOL_DOCUMENT_ROOT.'/accountancy/class/lettering.class.php';
36require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php';
37require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php';
38require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
39require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
40require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
41require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
42require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
43
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 a technical object to manage hooks of page. Note that conf->hooks_modules contains an 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 = (int) 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['id'])."'";
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 = getDolGlobalString('ACCOUNTING_DEFAULT_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 if (getDolGlobalString('ACCOUNTING_EXPORT_MODELCSV') == AccountancyExport::$EXPORT_TYPE_QUADRATUS
841 || getDolGlobalString('ACCOUNTING_EXPORT_MODELCSV') == AccountancyExport::$EXPORT_TYPE_FEC
842 || getDolGlobalString('ACCOUNTING_EXPORT_MODELCSV') == AccountancyExport::$EXPORT_TYPE_FEC2
843 ) {
844 $form_question['notifiedexportfull'] = array(
845 'name' => 'notifiedexportfull',
846 'type' => 'checkbox',
847 'label' => $langs->trans('NotifiedExportFull'),
848 'value' => 'false',
849 );
850 }
851
852 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?'.$param, $langs->trans("ExportFilteredList").'...', $langs->trans('ConfirmExportFile'), 'export_fileconfirm', $form_question, '', 1, 390, 700);
853}
854
855// Print form confirm
856print $formconfirm;
857
858//$param=''; param started before
859if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
860 $param .= '&contextpage='.urlencode($contextpage);
861}
862if ($limit > 0 && $limit != $conf->liste_limit) {
863 $param .= '&limit='.urlencode($limit);
864}
865
866// List of mass actions available
867$arrayofmassactions = array();
868$massactionbutton = $form->selectMassAction($massaction, $arrayofmassactions);
869
870print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
871print '<input type="hidden" name="token" value="'.newToken().'">';
872print '<input type="hidden" name="action" value="list">';
873if ($optioncss != '') {
874 print '<input type="hidden" name="optioncss" value="'.urlencode($optioncss).'">';
875}
876print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
877print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
878print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
879print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
880
881if (count($filter)) {
882 $buttonLabel = $langs->trans("ExportFilteredList");
883} else {
884 $buttonLabel = $langs->trans("ExportList");
885}
886
887$parameters = array('param' => $param);
888$reshook = $hookmanager->executeHooks('addMoreActionsButtonsList', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
889if ($reshook < 0) {
890 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
891}
892
893$newcardbutton = empty($hookmanager->resPrint) ? '' : $hookmanager->resPrint;
894if (empty($reshook)) {
895 // Button re-export
896 if (!getDolGlobalString('ACCOUNTING_REEXPORT')) {
897 $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"');
898 $newcardbutton .= '<span class="valignmiddle marginrightonly paddingleft">'.$langs->trans("ClickToShowAlreadyExportedLines").'</span>';
899 $newcardbutton .= '</a>';
900 } else {
901 $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"');
902 $newcardbutton .= '<span class="valignmiddle marginrightonly paddingleft">'.$langs->trans("DocsAlreadyExportedAreIncluded").'</span>';
903 $newcardbutton .= '</a>';
904 }
905
906 if ($user->hasRight('accounting', 'mouvements', 'export')) {
907 $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'));
908 }
909}
910
911print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_accountancy', 0, $newcardbutton, '', $limit, 0, 0, 1);
912
913// Not display message when all the list of docs are included
914if (!getDolGlobalString('ACCOUNTING_REEXPORT')) {
915 print info_admin($langs->trans("WarningDataDisappearsWhenDataIsExported"), 0, 0, '0', 'hideonsmartphone info');
916}
917
918//$topicmail = "Information";
919//$modelmail = "accountingbookkeeping";
920//$objecttmp = new BookKeeping($db);
921//$trackid = 'bk'.$object->id;
922include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
923
924$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
925$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')); // This also change content of $arrayfields
926if ($massactionbutton && $contextpage != 'poslist') {
927 $selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
928}
929
930$moreforfilter = '';
931
932if (!empty($search_account_category)) {
933 $moreforfilter .= '<div class="divsearchfield">';
934 $moreforfilter .= $langs->trans('AccountingCategory').': ';
935 $moreforfilter .= '<div class="nowrap inline-block">';
936 $moreforfilter .= $formaccounting->select_accounting_category($search_account_category, 'search_account_category', 1, 0, 0, 0);
937 $moreforfilter .= '</div>';
938 $moreforfilter .= '</div>';
939}
940
941$parameters = array();
942$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
943if (empty($reshook)) {
944 $moreforfilter .= $hookmanager->resPrint;
945} else {
946 $moreforfilter = $hookmanager->resPrint;
947}
948
949if ($moreforfilter) {
950 print '<div class="liste_titre liste_titre_bydiv centpercent">';
951 print $moreforfilter;
952 print '</div>';
953}
954
955print '<div class="div-table-responsive">';
956print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">';
957
958// Filters lines
959print '<tr class="liste_titre_filter">';
960// Action column
961if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
962 print '<td class="liste_titre center">';
963 $searchpicto = $form->showFilterButtons('left');
964 print $searchpicto;
965 print '</td>';
966}
967// Movement number
968if (!empty($arrayfields['t.piece_num']['checked'])) {
969 print '<td class="liste_titre"><input type="text" class="width50" name="search_mvt_num" value="'.dol_escape_htmltag($search_mvt_num).'"></td>';
970}
971// Code journal
972if (!empty($arrayfields['t.code_journal']['checked'])) {
973 print '<td class="liste_titre center">';
974 print $formaccounting->multi_select_journal($search_ledger_code, 'search_ledger_code', 0, 1, 1, 1, 'small maxwidth75');
975 print '</td>';
976}
977// Date document
978if (!empty($arrayfields['t.doc_date']['checked'])) {
979 print '<td class="liste_titre center">';
980 print '<div class="nowrapfordate">';
981 print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"));
982 print '</div>';
983 print '<div class="nowrapfordate">';
984 print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to"));
985 print '</div>';
986 print '</td>';
987}
988// Ref document
989if (!empty($arrayfields['t.doc_ref']['checked'])) {
990 print '<td class="liste_titre"><input type="text" name="search_doc_ref" class="width75" value="'.dol_escape_htmltag($search_doc_ref).'"></td>';
991}
992// Accountancy account
993if (!empty($arrayfields['t.numero_compte']['checked'])) {
994 print '<td class="liste_titre">';
995 print '<div class="nowrap">';
996 print $formaccounting->select_account($search_accountancy_code_start, 'search_accountancy_code_start', $langs->trans('From'), array(), 1, 1, 'maxwidth150', 'account');
997 print '</div>';
998 print '<div class="nowrap">';
999 print $formaccounting->select_account($search_accountancy_code_end, 'search_accountancy_code_end', $langs->trans('to'), array(), 1, 1, 'maxwidth150', 'account');
1000 print '</div>';
1001 print '</td>';
1002}
1003// Subledger account
1004if (!empty($arrayfields['t.subledger_account']['checked'])) {
1005 print '<td class="liste_titre">';
1006 // TODO For the moment we keep a free input text instead of a combo. The select_auxaccount has problem because it does not
1007 // use setup of "keypress to select thirdparty" and this hangs browser on large databases.
1008 if (getDolGlobalString('ACCOUNTANCY_COMBO_FOR_AUX')) {
1009 print '<div class="nowrap">';
1010 //print $langs->trans('From').' ';
1011 print $formaccounting->select_auxaccount($search_accountancy_aux_code_start, 'search_accountancy_aux_code_start', $langs->trans('From'), 'maxwidth150', 'subledgeraccount');
1012 print '</div>';
1013 print '<div class="nowrap">';
1014 print $formaccounting->select_auxaccount($search_accountancy_aux_code_end, 'search_accountancy_aux_code_end', $langs->trans('to'), 'maxwidth150', 'subledgeraccount');
1015 print '</div>';
1016 } else {
1017 print '<input type="text" class="maxwidth75" name="search_accountancy_aux_code" value="'.dol_escape_htmltag($search_accountancy_aux_code).'">';
1018 }
1019 print '</td>';
1020}
1021// Label operation
1022if (!empty($arrayfields['t.label_operation']['checked'])) {
1023 print '<td class="liste_titre">';
1024 print '<input type="text" size="7" class="flat" name="search_mvt_label" value="'.dol_escape_htmltag($search_mvt_label).'"/>';
1025 print '</td>';
1026}
1027// Debit
1028if (!empty($arrayfields['t.debit']['checked'])) {
1029 print '<td class="liste_titre right">';
1030 print '<input type="text" class="flat" name="search_debit" size="4" value="'.dol_escape_htmltag($search_debit).'">';
1031 print '</td>';
1032}
1033// Credit
1034if (!empty($arrayfields['t.credit']['checked'])) {
1035 print '<td class="liste_titre right">';
1036 print '<input type="text" class="flat" name="search_credit" size="4" value="'.dol_escape_htmltag($search_credit).'">';
1037 print '</td>';
1038}
1039// Lettering code
1040if (!empty($arrayfields['t.lettering_code']['checked'])) {
1041 print '<td class="liste_titre center">';
1042 print '<input type="text" size="3" class="flat" name="search_lettering_code" value="'.dol_escape_htmltag($search_lettering_code).'"/>';
1043 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>';
1044 print '</td>';
1045}
1046
1047// Fields from hook
1048$parameters = array('arrayfields' => $arrayfields);
1049$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
1050print $hookmanager->resPrint;
1051
1052// Date creation
1053if (!empty($arrayfields['t.date_creation']['checked'])) {
1054 print '<td class="liste_titre center">';
1055 print '<div class="nowrapfordate">';
1056 print $form->selectDate($search_date_creation_start, 'search_date_creation_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"));
1057 print '</div>';
1058 print '<div class="nowrapfordate">';
1059 print $form->selectDate($search_date_creation_end, 'search_date_creation_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to"));
1060 print '</div>';
1061 print '</td>';
1062}
1063// Date modification
1064if (!empty($arrayfields['t.tms']['checked'])) {
1065 print '<td class="liste_titre center">';
1066 print '<div class="nowrapfordate">';
1067 print $form->selectDate($search_date_modification_start, 'search_date_modification_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"));
1068 print '</div>';
1069 print '<div class="nowrapfordate">';
1070 print $form->selectDate($search_date_modification_end, 'search_date_modification_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"));
1071 print '</div>';
1072 print '</td>';
1073}
1074// Date export
1075if (!empty($arrayfields['t.date_export']['checked'])) {
1076 print '<td class="liste_titre center">';
1077 print '<div class="nowrapfordate">';
1078 print $form->selectDate($search_date_export_start, 'search_date_export_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"));
1079 print '</div>';
1080 print '<div class="nowrapfordate">';
1081 print $form->selectDate($search_date_export_end, 'search_date_export_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to"));
1082 print '</div>';
1083 print '</td>';
1084}
1085// Date validation
1086if (!empty($arrayfields['t.date_validated']['checked'])) {
1087 print '<td class="liste_titre center">';
1088 print '<div class="nowrapfordate">';
1089 print $form->selectDate($search_date_validation_start, 'search_date_validation_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"));
1090 print '</div>';
1091 print '<div class="nowrapfordate">';
1092 print $form->selectDate($search_date_validation_end, 'search_date_validation_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to"));
1093 print '</div>';
1094 print '</td>';
1095}
1096if (!empty($arrayfields['t.import_key']['checked'])) {
1097 print '<td class="liste_titre center">';
1098 print '<input class="flat searchstring maxwidth50" type="text" name="search_import_key" value="'.dol_escape_htmltag($search_import_key).'">';
1099 print '</td>';
1100}
1101// Action column
1102if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1103 print '<td class="liste_titre center">';
1104 $searchpicto = $form->showFilterButtons();
1105 print $searchpicto;
1106 print '</td>';
1107}
1108print "</tr>\n";
1109
1110print '<tr class="liste_titre">';
1111if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1112 print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch actioncolumn ');
1113}
1114if (!empty($arrayfields['t.piece_num']['checked'])) {
1115 print_liste_field_titre($arrayfields['t.piece_num']['label'], $_SERVER['PHP_SELF'], "t.piece_num", "", $param, "", $sortfield, $sortorder);
1116}
1117if (!empty($arrayfields['t.code_journal']['checked'])) {
1118 print_liste_field_titre($arrayfields['t.code_journal']['label'], $_SERVER['PHP_SELF'], "t.code_journal", "", $param, '', $sortfield, $sortorder, 'center ');
1119}
1120if (!empty($arrayfields['t.doc_date']['checked'])) {
1121 print_liste_field_titre($arrayfields['t.doc_date']['label'], $_SERVER['PHP_SELF'], "t.doc_date", "", $param, '', $sortfield, $sortorder, 'center ');
1122}
1123if (!empty($arrayfields['t.doc_ref']['checked'])) {
1124 print_liste_field_titre($arrayfields['t.doc_ref']['label'], $_SERVER['PHP_SELF'], "t.doc_ref", "", $param, "", $sortfield, $sortorder);
1125}
1126if (!empty($arrayfields['t.numero_compte']['checked'])) {
1127 print_liste_field_titre($arrayfields['t.numero_compte']['label'], $_SERVER['PHP_SELF'], "t.numero_compte", "", $param, "", $sortfield, $sortorder);
1128}
1129if (!empty($arrayfields['t.subledger_account']['checked'])) {
1130 print_liste_field_titre($arrayfields['t.subledger_account']['label'], $_SERVER['PHP_SELF'], "t.subledger_account", "", $param, "", $sortfield, $sortorder);
1131}
1132if (!empty($arrayfields['t.label_operation']['checked'])) {
1133 print_liste_field_titre($arrayfields['t.label_operation']['label'], $_SERVER['PHP_SELF'], "t.label_operation", "", $param, "", $sortfield, $sortorder);
1134}
1135if (!empty($arrayfields['t.debit']['checked'])) {
1136 print_liste_field_titre($arrayfields['t.debit']['label'], $_SERVER['PHP_SELF'], "t.debit", "", $param, '', $sortfield, $sortorder, 'right ');
1137}
1138if (!empty($arrayfields['t.credit']['checked'])) {
1139 print_liste_field_titre($arrayfields['t.credit']['label'], $_SERVER['PHP_SELF'], "t.credit", "", $param, '', $sortfield, $sortorder, 'right ');
1140}
1141if (!empty($arrayfields['t.lettering_code']['checked'])) {
1142 print_liste_field_titre($arrayfields['t.lettering_code']['label'], $_SERVER['PHP_SELF'], "t.lettering_code", "", $param, '', $sortfield, $sortorder, 'center ');
1143}
1144// Hook fields
1145$parameters = array('arrayfields' => $arrayfields, 'param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder);
1146$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
1147print $hookmanager->resPrint;
1148if (!empty($arrayfields['t.date_creation']['checked'])) {
1149 print_liste_field_titre($arrayfields['t.date_creation']['label'], $_SERVER['PHP_SELF'], "t.date_creation", "", $param, '', $sortfield, $sortorder, 'center ');
1150}
1151if (!empty($arrayfields['t.tms']['checked'])) {
1152 print_liste_field_titre($arrayfields['t.tms']['label'], $_SERVER['PHP_SELF'], "t.tms", "", $param, '', $sortfield, $sortorder, 'center ');
1153}
1154if (!empty($arrayfields['t.date_export']['checked'])) {
1155 print_liste_field_titre($arrayfields['t.date_export']['label'], $_SERVER['PHP_SELF'], "t.date_export,t.doc_date", "", $param, '', $sortfield, $sortorder, 'center ');
1156}
1157if (!empty($arrayfields['t.date_validated']['checked'])) {
1158 print_liste_field_titre($arrayfields['t.date_validated']['label'], $_SERVER['PHP_SELF'], "t.date_validated,t.doc_date", "", $param, '', $sortfield, $sortorder, 'center ');
1159}
1160if (!empty($arrayfields['t.import_key']['checked'])) {
1161 print_liste_field_titre($arrayfields['t.import_key']['label'], $_SERVER["PHP_SELF"], "t.import_key", "", $param, '', $sortfield, $sortorder, 'center ');
1162}
1163if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1164 print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
1165}
1166print "</tr>\n";
1167
1168
1169$line = new BookKeepingLine($db);
1170
1171// Loop on record
1172// --------------------------------------------------------------------
1173$i = 0;
1174$totalarray = array();
1175$totalarray['nbfield'] = 0;
1176$totalarray['val'] = array();
1177$totalarray['val']['totaldebit'] = 0;
1178$totalarray['val']['totalcredit'] = 0;
1179
1180while ($i < min($num, $limit)) {
1181 $obj = $db->fetch_object($resql);
1182 if (empty($obj)) {
1183 break; // Should not happen
1184 }
1185
1186 $line->id = $obj->rowid;
1187 $line->doc_date = $db->jdate($obj->doc_date);
1188 $line->doc_type = $obj->doc_type;
1189 $line->doc_ref = $obj->doc_ref;
1190 $line->fk_doc = $obj->fk_doc;
1191 $line->fk_docdet = $obj->fk_docdet;
1192 $line->thirdparty_code = $obj->thirdparty_code;
1193 $line->subledger_account = $obj->subledger_account;
1194 $line->subledger_label = $obj->subledger_label;
1195 $line->numero_compte = $obj->numero_compte;
1196 $line->label_compte = $obj->label_compte;
1197 $line->label_operation = $obj->label_operation;
1198 $line->debit = $obj->debit;
1199 $line->credit = $obj->credit;
1200 $line->montant = $obj->amount; // deprecated
1201 $line->amount = $obj->amount;
1202 $line->sens = $obj->sens;
1203 $line->lettering_code = $obj->lettering_code;
1204 $line->fk_user_author = $obj->fk_user_author;
1205 $line->import_key = $obj->import_key;
1206 $line->code_journal = $obj->code_journal;
1207 $line->journal_label = $obj->journal_label;
1208 $line->piece_num = $obj->piece_num;
1209 $line->date_creation = $db->jdate($obj->date_creation);
1210 $line->date_modification = $db->jdate($obj->date_modification);
1211 $line->date_export = $db->jdate($obj->date_export);
1212 $line->date_validation = $db->jdate($obj->date_validation);
1213
1214 print '<tr class="oddeven">';
1215 // Action column
1216 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1217 print '<td class="nowraponall center">';
1218 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
1219 $selected = 0;
1220 if (in_array($line->id, $arrayofselected)) {
1221 $selected = 1;
1222 }
1223 print '<input id="cb'.$line->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$line->id.'"'.($selected ? ' checked="checked"' : '').' />';
1224 }
1225 print '</td>';
1226 if (!$i) {
1227 $totalarray['nbfield']++;
1228 }
1229 }
1230
1231 // Piece number
1232 if (!empty($arrayfields['t.piece_num']['checked'])) {
1233 print '<td>';
1234 $object->id = $line->id;
1235 $object->piece_num = $line->piece_num;
1236 print $object->getNomUrl(1, '', 0, '', 1);
1237 print '</td>';
1238 if (!$i) {
1239 $totalarray['nbfield']++;
1240 }
1241 }
1242
1243 // Journal code
1244 if (!empty($arrayfields['t.code_journal']['checked'])) {
1245 $accountingjournal = new AccountingJournal($db);
1246 $result = $accountingjournal->fetch(0, $line->code_journal);
1247 $journaltoshow = (($result > 0) ? $accountingjournal->getNomUrl(0, 0, 0, '', 0) : $line->code_journal);
1248 print '<td class="center tdoverflowmax150">'.$journaltoshow.'</td>';
1249 if (!$i) {
1250 $totalarray['nbfield']++;
1251 }
1252 }
1253
1254 // Document date
1255 if (!empty($arrayfields['t.doc_date']['checked'])) {
1256 print '<td class="center">'.dol_print_date($line->doc_date, 'day').'</td>';
1257 if (!$i) {
1258 $totalarray['nbfield']++;
1259 }
1260 }
1261
1262 // Document ref
1263 $modulepart = '';
1264 if (!empty($arrayfields['t.doc_ref']['checked'])) {
1265 $documentlink = '';
1266 $objectstatic = null;
1267 if ($line->doc_type == 'customer_invoice') {
1268 $langs->loadLangs(array('bills'));
1269
1270 require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
1271 $objectstatic = new Facture($db);
1272 $objectstatic->fetch($line->fk_doc);
1273
1274 if ($objectstatic->id > 0) {
1275 $filename = dol_sanitizeFileName($line->doc_ref);
1276 $filedir = $conf->invoice->dir_output.'/'.dol_sanitizeFileName($line->doc_ref);
1277 $urlsource = $_SERVER['PHP_SELF'].'?id='.$objectstatic->id;
1278 $documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir);
1279 }
1280 } elseif ($line->doc_type == 'supplier_invoice') {
1281 $langs->loadLangs(array('bills'));
1282
1283 require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
1284 $objectstatic = new FactureFournisseur($db);
1285 $objectstatic->fetch($line->fk_doc);
1286
1287 if ($objectstatic->id > 0) {
1288 $modulepart = 'invoice_supplier';
1289 $filename = dol_sanitizeFileName($line->doc_ref);
1290 $filedir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($line->fk_doc, 2, 0, 0, $objectstatic, $objectstatic->element).dol_sanitizeFileName($line->doc_ref);
1291 $subdir = get_exdir($objectstatic->id, 2, 0, 0, $objectstatic, $objectstatic->element).dol_sanitizeFileName($line->doc_ref);
1292 $documentlink = $formfile->getDocumentsLink($objectstatic->element, $subdir, $filedir);
1293 }
1294 } elseif ($line->doc_type == 'expense_report') {
1295 $langs->loadLangs(array('trips'));
1296
1297 require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
1298 $objectstatic = new ExpenseReport($db);
1299 $objectstatic->fetch($line->fk_doc);
1300
1301 if ($objectstatic->id > 0) {
1302 $filename = dol_sanitizeFileName($line->doc_ref);
1303 $filedir = $conf->expensereport->dir_output.'/'.dol_sanitizeFileName($line->doc_ref);
1304 $urlsource = $_SERVER['PHP_SELF'].'?id='.$objectstatic->id;
1305 $documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir);
1306 }
1307 } elseif ($line->doc_type == 'bank') {
1308 require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
1309 $objectstatic = new AccountLine($db);
1310 $objectstatic->fetch($line->fk_doc);
1311 } else {
1312 // Other type
1313 }
1314
1315 $labeltoshowhtml = '';
1316 $labeltoshowalt = '';
1317 if (($objectstatic instanceof CommonObject) && in_array($line->doc_type, array('customer_invoice', 'supplier_invoice', 'expense_report'))) {
1318 if ($objectstatic->id > 0) {
1319 $labeltoshowhtml .= $objectstatic->getNomUrl(1, '', 0, 0, '', 0, -1, 1);
1320 $labeltoshowhtml .= $documentlink;
1321 $labeltoshowalt .= $objectstatic->ref;
1322 } else {
1323 $labeltoshowhtml = '<span class="opacitymedium">'.$langs->trans("Deleted").'</span>';
1324 }
1325 } elseif ($line->doc_type == 'bank') {
1326 $labeltoshowhtml .= $objectstatic->getNomUrl(1);
1327 $labeltoshowalt .= $objectstatic->ref;
1328 $bank_ref = strstr($line->doc_ref, '-');
1329 $labeltoshowhtml .= " " . $bank_ref;
1330 $labeltoshowalt .= " " . $bank_ref;
1331 } else {
1332 $labeltoshowhtml .= $line->doc_ref;
1333 $labeltoshowalt .= $line->doc_ref;
1334 }
1335
1336 print '<td class="nowraponall tdoverflowmax150" title="'.dolPrintHTMLForAttribute($labeltoshowalt).'">';
1337 print $labeltoshowhtml;
1338 print "</td>\n";
1339 if (!$i) {
1340 $totalarray['nbfield']++;
1341 }
1342 }
1343
1344 // Account number
1345 if (!empty($arrayfields['t.numero_compte']['checked'])) {
1346 print '<td>'.length_accountg($line->numero_compte).'</td>';
1347 if (!$i) {
1348 $totalarray['nbfield']++;
1349 }
1350 }
1351
1352 // Subledger account
1353 if (!empty($arrayfields['t.subledger_account']['checked'])) {
1354 print '<td>'.length_accounta($line->subledger_account).'</td>';
1355 if (!$i) {
1356 $totalarray['nbfield']++;
1357 }
1358 }
1359
1360 // Label operation
1361 if (!empty($arrayfields['t.label_operation']['checked'])) {
1362 print '<td class="small tdoverflowmax200" title="'.dol_escape_htmltag($line->label_operation).'">'.dol_escape_htmltag($line->label_operation).'</td>';
1363 if (!$i) {
1364 $totalarray['nbfield']++;
1365 }
1366 }
1367
1368 // Amount debit
1369 if (!empty($arrayfields['t.debit']['checked'])) {
1370 print '<td class="right nowraponall amount">'.($line->debit != 0 ? price($line->debit) : '').'</td>';
1371 if (!$i) {
1372 $totalarray['nbfield']++;
1373 }
1374 if (!$i) {
1375 $totalarray['pos'][$totalarray['nbfield']] = 'totaldebit';
1376 }
1377 $totalarray['val']['totaldebit'] += $line->debit;
1378 }
1379
1380 // Amount credit
1381 if (!empty($arrayfields['t.credit']['checked'])) {
1382 print '<td class="right nowraponall amount">'.($line->credit != 0 ? price($line->credit) : '').'</td>';
1383 if (!$i) {
1384 $totalarray['nbfield']++;
1385 }
1386 if (!$i) {
1387 $totalarray['pos'][$totalarray['nbfield']] = 'totalcredit';
1388 }
1389 $totalarray['val']['totalcredit'] += $line->credit;
1390 }
1391
1392 // Lettering code
1393 if (!empty($arrayfields['t.lettering_code']['checked'])) {
1394 print '<td class="center">'.$line->lettering_code.'</td>';
1395 if (!$i) {
1396 $totalarray['nbfield']++;
1397 }
1398 }
1399
1400 // Fields from hook
1401 $parameters = array('arrayfields' => $arrayfields, 'obj' => $obj, 'i' => $i, 'totalarray' => &$totalarray);
1402 $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook
1403 print $hookmanager->resPrint;
1404
1405 // Creation operation date
1406 if (!empty($arrayfields['t.date_creation']['checked'])) {
1407 print '<td class="center">'.dol_print_date($line->date_creation, 'dayhour', 'tzuserrel').'</td>';
1408 if (!$i) {
1409 $totalarray['nbfield']++;
1410 }
1411 }
1412
1413 // Modification operation date
1414 if (!empty($arrayfields['t.tms']['checked'])) {
1415 print '<td class="center">'.dol_print_date($line->date_modification, 'dayhour', 'tzuserrel').'</td>';
1416 if (!$i) {
1417 $totalarray['nbfield']++;
1418 }
1419 }
1420
1421 // Exported operation date
1422 if (!empty($arrayfields['t.date_export']['checked'])) {
1423 print '<td class="center nowraponall">'.dol_print_date($line->date_export, 'dayhour', 'tzuserrel').'</td>';
1424 if (!$i) {
1425 $totalarray['nbfield']++;
1426 }
1427 }
1428
1429 // Validated operation date
1430 if (!empty($arrayfields['t.date_validated']['checked'])) {
1431 print '<td class="center nowraponall">'.dol_print_date($line->date_validation, 'dayhour', 'tzuserrel').'</td>';
1432 if (!$i) {
1433 $totalarray['nbfield']++;
1434 }
1435 }
1436
1437 if (!empty($arrayfields['t.import_key']['checked'])) {
1438 print '<td class="tdoverflowmax100">'.$obj->import_key."</td>\n";
1439 if (!$i) {
1440 $totalarray['nbfield']++;
1441 }
1442 }
1443
1444 // Action column
1445 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1446 print '<td class="nowraponall center">';
1447 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
1448 $selected = 0;
1449 if (in_array($line->id, $arrayofselected)) {
1450 $selected = 1;
1451 }
1452 print '<input id="cb'.$line->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$line->id.'"'.($selected ? ' checked="checked"' : '').' />';
1453 }
1454 print '</td>';
1455 if (!$i) {
1456 $totalarray['nbfield']++;
1457 }
1458 }
1459
1460
1461 print "</tr>\n";
1462
1463 $i++;
1464}
1465
1466// Show total line
1467include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
1468
1469// If no record found
1470if ($num == 0) {
1471 $colspan = 1;
1472 foreach ($arrayfields as $key => $val) {
1473 if (!empty($val['checked'])) {
1474 $colspan++;
1475 }
1476 }
1477 print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
1478}
1479
1480$parameters = array('arrayfields' => $arrayfields, 'sql' => $sql);
1481$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1482print $hookmanager->resPrint;
1483
1484print "</table>";
1485print '</div>';
1486
1487print '</form>';
1488
1489// End of page
1490llxFooter();
1491
1492$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($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:70
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:615
llxFooter()
Footer empty.
Definition document.php:107
dol_filesize($pathoffile)
Return size of a file.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $selectlimitsuffix=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
natural_search($fields, $value, $mode=0, $nofirstand=0)
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
newToken()
Return the value of token currently saved into session with name 'newtoken'.
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
readfileLowMemory($fullpath_original_file_osencoded, $method=-1)
Return a file on output using a low memory.
dol_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 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.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.