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';
45$langs->loadLangs(array(
"accountancy",
"compta"));
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);
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');
102 $action =
'delbookkeepingyear';
104if (
GETPOST(
"button_export_file_x") ||
GETPOST(
"button_export_file.x") ||
GETPOST(
"button_export_file")) {
105 $action =
'export_file';
108$search_account_category =
GETPOSTINT(
'search_account_category');
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 =
'';
115$search_accountancy_code_end =
GETPOST(
'search_accountancy_code_end',
'alpha');
116if ($search_accountancy_code_end == - 1) {
117 $search_accountancy_code_end =
'';
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 =
'';
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 =
'';
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');
139$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
140$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
141$optioncss =
GETPOST(
'optioncss',
'alpha');
143if (empty($page) || $page < 0) {
146$offset = $limit * $page;
147$pageprev = $page - 1;
148$pagenext = $page + 1;
149if ($sortorder ==
"") {
152if ($sortfield ==
"") {
153 $sortfield =
"t.piece_num,t.rowid";
158$hookmanager->initHooks(array(
'bookkeepingexport'));
161$form =
new Form($db);
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);
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);
179 $year_end = $year_start + 1;
180 $month_end = $month_start - 1;
181 if ($month_end < 1) {
185 $search_date_start =
dol_mktime(0, 0, 0, $month_start, 1, $year_start);
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),
211 unset($arrayfields[
't.lettering_code']);
215$listofformat = $accountancyexport->getType();
217if (empty($listofformat[$formatexportset])) {
218 $formatexportset = 1;
223if (!isModEnabled(
'accounting')) {
226if ($user->socid > 0) {
229if (!$user->hasRight(
'accounting',
'mouvements',
'lire')) {
240if (
GETPOST(
'cancel',
'alpha')) {
244if (!
GETPOST(
'confirmmassaction',
'alpha')) {
248$parameters = array(
'socid' => $socid);
249$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
254if (empty($reshook)) {
255 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
257 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
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 =
'';
314 $search_lettering_code =
'';
315 $search_not_reconciled =
'';
316 $search_import_key =
'';
322 if (!empty($search_date_start)) {
323 $filter[
't.doc_date>='] = $search_date_start;
325 $param .=
'&search_date_startmonth='.((int) $tmp[
'mon']).
'&search_date_startday='.((int) $tmp[
'mday']).
'&search_date_startyear='.((int) $tmp[
'year']);
327 if (!empty($search_date_end)) {
328 $filter[
't.doc_date<='] = $search_date_end;
330 $param .=
'&search_date_endmonth='.((int) $tmp[
'mon']).
'&search_date_endday='.((int) $tmp[
'mday']).
'&search_date_endyear='.((int) $tmp[
'year']);
332 if (!empty($search_doc_date)) {
333 $filter[
't.doc_date'] = $search_doc_date;
335 $param .=
'&doc_datemonth='.((int) $tmp[
'mon']).
'&doc_dateday='.((int) $tmp[
'mday']).
'&doc_dateyear='.((int) $tmp[
'year']);
337 if (!empty($search_doc_type)) {
338 $filter[
't.doc_type'] = $search_doc_type;
339 $param .=
'&search_doc_type='.urlencode($search_doc_type);
341 if (!empty($search_doc_ref)) {
342 $filter[
't.doc_ref'] = $search_doc_ref;
343 $param .=
'&search_doc_ref='.urlencode($search_doc_ref);
345 if ($search_account_category !=
'-1' && !empty($search_account_category)) {
346 require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountancycategory.class.php';
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']).
"'";
356 $filter[
't.search_accounting_code_in'] = implode(
',', $listofaccountsforgroup2);
357 $param .=
'&search_account_category='.urlencode((
string) ($search_account_category));
359 if (!empty($search_accountancy_code)) {
360 $filter[
't.numero_compte'] = $search_accountancy_code;
361 $param .=
'&search_accountancy_code='.urlencode($search_accountancy_code);
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);
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);
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);
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);
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);
383 if (!empty($search_mvt_label)) {
384 $filter[
't.label_operation'] = $search_mvt_label;
385 $param .=
'&search_mvt_label='.urlencode($search_mvt_label);
387 if (!empty($search_direction)) {
388 $filter[
't.sens'] = $search_direction;
389 $param .=
'&search_direction='.urlencode($search_direction);
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);
397 if (!empty($search_mvt_num)) {
398 $filter[
't.piece_num'] = $search_mvt_num;
399 $param .=
'&search_mvt_num='.urlencode((
string) ($search_mvt_num));
401 if (!empty($search_date_creation_start)) {
402 $filter[
't.date_creation>='] = $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']);
406 if (!empty($search_date_creation_end)) {
407 $filter[
't.date_creation<='] = $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']);
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']);
416 if (!empty($search_date_modification_end)) {
417 $filter[
't.tms<='] = $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']);
421 if (!empty($search_date_export_start)) {
422 $filter[
't.date_export>='] = $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']);
426 if (!empty($search_date_export_end)) {
427 $filter[
't.date_export<='] = $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']);
431 if (!empty($search_date_validation_start)) {
432 $filter[
't.date_validated>='] = $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']);
436 if (!empty($search_date_validation_end)) {
437 $filter[
't.date_validated<='] = $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']);
441 if (!empty($search_debit)) {
442 $filter[
't.debit'] = $search_debit;
443 $param .=
'&search_debit='.urlencode($search_debit);
445 if (!empty($search_credit)) {
446 $filter[
't.credit'] = $search_credit;
447 $param .=
'&search_credit='.urlencode($search_credit);
449 if (!empty($search_lettering_code)) {
450 $filter[
't.lettering_code'] = $search_lettering_code;
451 $param .=
'&search_lettering_code='.urlencode($search_lettering_code);
453 if (!empty($search_not_reconciled)) {
454 $filter[
't.reconciled_option'] = $search_not_reconciled;
455 $param .=
'&search_not_reconciled='.urlencode($search_not_reconciled);
457 if (!empty($search_import_key)) {
458 $filter[
't.import_key'] = $search_import_key;
459 $param .=
'&search_import_key='.urlencode($search_import_key);
462 if ($action ==
'setreexport' && $user->hasRight(
'accounting',
'mouvements',
'export')) {
464 if (!
dolibarr_set_const($db,
"ACCOUNTING_REEXPORT", $setreexport,
'yesno', 0,
'', $conf->entity)) {
470 setEventMessages($langs->trans(
"ExportOfPiecesAlreadyExportedIsDisable"),
null,
'mesgs');
472 setEventMessages($langs->trans(
"ExportOfPiecesAlreadyExportedIsEnable"),
null,
'warnings');
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';
495$sql .=
" t.doc_date,";
496$sql .=
" t.doc_type,";
497$sql .=
" t.doc_ref,";
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,";
508$sql .=
" t.lettering_code,";
509$sql .=
" t.date_lettering,";
510$sql .=
" t.montant as amount,";
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";
526$sql .=
' FROM '.MAIN_DB_PREFIX.$object->table_element.
' as t';
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') {
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') {
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);
581 } elseif ($key ==
't.search_accounting_code_in' && !empty($value)) {
582 $sqlwhere[] =
't.numero_compte IN ('.$db->sanitize($value, 1).
')';
588$sql .=
' WHERE t.entity IN ('.getEntity(
'accountancy').
')';
590 $sql .=
" AND t.date_export IS NULL";
592if (count($sqlwhere) > 0) {
593 $sql .=
' AND '.implode(
' AND ', $sqlwhere);
600if ($action ==
'export_fileconfirm' && $user->hasRight(
'accounting',
'mouvements',
'export')) {
605 $nbtotalofrecords = 0;
611 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords', $sql);
612 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
613 $resql = $db->query($sqlforcount);
615 $objforcount = $db->fetch_object($resql);
616 $nbtotalofrecords = $objforcount->nbtotalofrecords;
632 $result =
$object->fetchAll($sortorder, $sortfield, $limit, $offset, $filter,
'AND', (
getDolGlobalString(
'ACCOUNTING_REEXPORT') ? 1 : 0));
639 $notexportlettering =
GETPOST(
'notexportlettering',
'alpha');
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);
651 $notifiedexportdate =
GETPOST(
'notifiedexportdate',
'alpha');
652 $notifiedvalidationdate =
GETPOST(
'notifiedvalidationdate',
'alpha');
653 $withAttachment = !empty(trim(
GETPOST(
'notifiedexportfull',
'alphanohtml'))) ? 1 : 0;
657 $result = $accountancyexport->export(
$object->lines, $formatexport, $withAttachment, 1, 1, 1);
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);
667 foreach (
$object->lines as $movement) {
672 if (!empty($notifiedexportdate) && empty($movement->date_export)) {
673 $setfields .= ($setfields ?
"," :
"").
" date_export = '".$db->idate($now).
"'";
675 if (!empty($notifiedvalidationdate) && empty($movement->date_validation)) {
676 $setfields .= ($setfields ?
"," :
"").
" date_validated = '".$db->idate($now).
"'";
680 $sql =
" UPDATE ".MAIN_DB_PREFIX.
"accounting_bookkeeping";
681 $sql .=
" SET ".$setfields;
682 $sql .=
" WHERE rowid = ".((int) $movement->id);
684 $result = $db->query($sql);
693 $accountancyexport->errors[] = $langs->trans(
'NotAllExportedMovementsCouldBeRecordedAsExportedOrValidated');
703 $downloadFilePath = $accountancyexport->generatedfiledata[
'downloadFilePath'];
704 $downloadFileMimeType = $accountancyexport->generatedfiledata[
'downloadFileMimeType'];
705 $downloadFileFullName = $accountancyexport->generatedfiledata[
'downloadFileFullName'];
710 header(
'Content-Description: File Transfer');
714 header(
'Content-Disposition: attachment; filename="'.$downloadFileFullName.
'"');
716 header(
'Content-Disposition: inline; filename="'.$downloadFileFullName.
'"');
719 header(
'Cache-Control: Public, must-revalidate');
720 header(
'Pragma: public');
721 header(
'Content-Length: ' .
dol_filesize($downloadFilePath));
728 header(
'Location: '.$_SERVER[
'PHP_SELF']);
741$title_page = $langs->trans(
"Operations").
' - '.$langs->trans(
"ExportAccountancy");
744$nbtotalofrecords =
'';
747 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords', $sql);
748 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
749 $resql = $db->query($sqlforcount);
751 $objforcount = $db->fetch_object($resql);
752 $nbtotalofrecords = $objforcount->nbtotalofrecords;
757 if (($page * $limit) > $nbtotalofrecords) {
765$sql .= $db->order($sortfield, $sortorder);
767 $sql .= $db->plimit($limit + 1, $offset);
770$resql = $db->query($sql);
776$num = $db->num_rows($resql);
778$arrayofselected = is_array($toselect) ? $toselect : array();
782$help_url =
'EN:Module_Double_Entry_Accounting#Exports|FR:Module_Comptabilité_en_Partie_Double#Exports';
784llxHeader(
'', $title_page, $help_url,
'', 0, 0,
'',
'',
'',
'mod-accountancy accountancy-consultation page-export');
788if ($action ==
'export_file') {
789 $form_question = array();
791 $form_question[
'formatexport'] = array(
792 'name' =>
'formatexport',
794 'label' => $langs->trans(
'Modelcsv'),
795 'values' => $listofformat,
796 'default' => $formatexportset,
797 'morecss' =>
'minwidth200 maxwidth200'
800 $form_question[
'separator0'] = array(
'name' =>
'separator0',
'type' =>
'separator');
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'),
812 $form_question[
'separator1'] = array(
'name' =>
'separator1',
'type' =>
'separator');
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'),
824 $form_question[
'separator2'] = array(
'name' =>
'separator2',
'type' =>
'separator');
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")),
836 $form_question[
'separator3'] = array(
'name' =>
'separator3',
'type' =>
'separator');
840 $exportTypesWithDocs = array(
841 AccountancyExport::$EXPORT_TYPE_QUADRATUS,
842 AccountancyExport::$EXPORT_TYPE_FEC,
843 AccountancyExport::$EXPORT_TYPE_FEC2
846 $form_question[
'notifiedexportfull'] = array(
847 'name' =>
'notifiedexportfull',
848 'type' =>
'checkbox',
849 'label' => $langs->trans(
'NotifiedExportFull'),
853 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?'.$param, $langs->trans(
"ExportFilteredList").
'...', $langs->trans(
'ConfirmExportFile'),
'export_fileconfirm', $form_question,
'', 1, 500, 700);
855 $formconfirm .=
'<script>
856 jQuery(document).ready(function() {
857 const exportTypesWithDocs = ['.implode(
',', $exportTypesWithDocs).
'];
858 const $formatExport = jQuery("#formatexport");
860 function toggleExportFull() {
861 const $checkbox = jQuery("#notifiedexportfull");
862 const show = exportTypesWithDocs.indexOf(parseInt($formatExport.val())) !== -1;
863 $checkbox.closest(".tagtr").toggle(show);
865 $checkbox.prop("checked", false); // remove checked if hidden
869 $formatExport.on("change", toggleExportFull);
879if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
880 $param .=
'&contextpage='.urlencode($contextpage);
882if ($limit > 0 && $limit != $conf->liste_limit) {
883 $param .=
'&limit='.urlencode($limit);
887$arrayofmassactions = array();
888$massactionbutton = $form->selectMassAction($massaction, $arrayofmassactions);
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).
'">';
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.
'">';
902 $buttonLabel = $langs->trans(
"ExportFilteredList");
904 $buttonLabel = $langs->trans(
"ExportList");
907$parameters = array(
'param' => $param);
908$reshook = $hookmanager->executeHooks(
'addMoreActionsButtonsList', $parameters, $object, $action);
913$newcardbutton = empty($hookmanager->resPrint) ?
'' : $hookmanager->resPrint;
914if (empty($reshook)) {
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>';
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>';
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'));
931print_barre_liste($title_page, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'title_accountancy', 0, $newcardbutton,
'', $limit, 0, 0, 1);
935 print
info_admin($langs->trans(
"WarningDataDisappearsWhenDataIsExported"), 0, 0, 0,
'hideonsmartphone info');
942include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
944$varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
945$selectedfields = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN'));
946if ($massactionbutton && $contextpage !=
'poslist') {
947 $selectedfields .= $form->showCheckAddButtons(
'checkforselect', 1);
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>';
961$parameters = array();
962$reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
963if (empty($reshook)) {
964 $moreforfilter .= $hookmanager->resPrint;
966 $moreforfilter = $hookmanager->resPrint;
970 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
971 print $moreforfilter;
975print
'<div class="div-table-responsive">';
976print
'<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">';
979print
'<tr class="liste_titre_filter">';
982 print
'<td class="liste_titre center">';
983 $searchpicto = $form->showFilterButtons(
'left');
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>';
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');
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"));
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"));
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>';
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');
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');
1024if (!empty($arrayfields[
't.subledger_account'][
'checked'])) {
1025 print
'<td class="liste_titre">';
1029 print
'<div class="nowrap">';
1031 print $formaccounting->select_auxaccount($search_accountancy_aux_code_start,
'search_accountancy_aux_code_start', $langs->trans(
'From'),
'maxwidth150',
'subledgeraccount');
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');
1037 print
'<input type="text" class="maxwidth75" name="search_accountancy_aux_code" value="'.dol_escape_htmltag($search_accountancy_aux_code).
'">';
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).
'"/>';
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).
'">';
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).
'">';
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>';
1068$parameters = array(
'arrayfields' => $arrayfields);
1069$reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters);
1070print $hookmanager->resPrint;
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"));
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"));
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"));
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"));
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"));
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"));
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"));
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"));
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).
'">';
1123 print
'<td class="liste_titre center">';
1124 $searchpicto = $form->showFilterButtons();
1130print
'<tr class="liste_titre">';
1132 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch actioncolumn ');
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);
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 ');
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 ');
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);
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);
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);
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);
1155if (!empty($arrayfields[
't.debit'][
'checked'])) {
1156 print_liste_field_titre($arrayfields[
't.debit'][
'label'], $_SERVER[
'PHP_SELF'],
"t.debit",
"", $param,
'', $sortfield, $sortorder,
'right ');
1158if (!empty($arrayfields[
't.credit'][
'checked'])) {
1159 print_liste_field_titre($arrayfields[
't.credit'][
'label'], $_SERVER[
'PHP_SELF'],
"t.credit",
"", $param,
'', $sortfield, $sortorder,
'right ');
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 ');
1165$parameters = array(
'arrayfields' => $arrayfields,
'param' => $param,
'sortfield' => $sortfield,
'sortorder' => $sortorder);
1166$reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters);
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 ');
1171if (!empty($arrayfields[
't.tms'][
'checked'])) {
1172 print_liste_field_titre($arrayfields[
't.tms'][
'label'], $_SERVER[
'PHP_SELF'],
"t.tms",
"", $param,
'', $sortfield, $sortorder,
'center ');
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 ');
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 ');
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 ');
1184 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ');
1194$totalarray = array();
1195$totalarray[
'nbfield'] = 0;
1196$totalarray[
'val'] = array();
1197$totalarray[
'val'][
'totaldebit'] = 0;
1198$totalarray[
'val'][
'totalcredit'] = 0;
1200while ($i < min($num, $limit)) {
1201 $obj = $db->fetch_object($resql);
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;
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);
1234 print
'<tr class="oddeven">';
1237 print
'<td class="nowraponall center">';
1238 if (($massactionbutton || $massaction) && $contextpage !=
'poslist') {
1240 if (in_array($line->id, $arrayofselected)) {
1243 print
'<input id="cb'.$line->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$line->id.
'"'.($selected ?
' checked="checked"' :
'').
' />';
1247 $totalarray[
'nbfield']++;
1252 if (!empty($arrayfields[
't.piece_num'][
'checked'])) {
1255 $object->piece_num = $line->piece_num;
1256 print
$object->getNomUrl(1,
'', 0,
'', 1);
1259 $totalarray[
'nbfield']++;
1264 if (!empty($arrayfields[
't.code_journal'][
'checked'])) {
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>';
1270 $totalarray[
'nbfield']++;
1275 if (!empty($arrayfields[
't.doc_date'][
'checked'])) {
1276 print
'<td class="center">'.dol_print_date($line->doc_date,
'day').
'</td>';
1278 $totalarray[
'nbfield']++;
1284 if (!empty($arrayfields[
't.doc_ref'][
'checked'])) {
1286 $objectstatic =
null;
1287 if ($line->doc_type ==
'customer_invoice') {
1288 $langs->loadLangs(array(
'bills'));
1290 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
1291 $objectstatic =
new Facture($db);
1292 $objectstatic->fetch($line->fk_doc);
1294 if ($objectstatic->id > 0) {
1297 $urlsource = $_SERVER[
'PHP_SELF'].
'?id='.$objectstatic->id;
1298 $documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir);
1300 } elseif ($line->doc_type ==
'supplier_invoice') {
1301 $langs->loadLangs(array(
'bills'));
1303 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
1305 $objectstatic->fetch($line->fk_doc);
1307 if ($objectstatic->id > 0) {
1308 $modulepart =
'invoice_supplier';
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);
1314 } elseif ($line->doc_type ==
'expense_report') {
1315 $langs->loadLangs(array(
'trips'));
1317 require_once DOL_DOCUMENT_ROOT.
'/expensereport/class/expensereport.class.php';
1319 $objectstatic->fetch($line->fk_doc);
1321 if ($objectstatic->id > 0) {
1324 $urlsource = $_SERVER[
'PHP_SELF'].
'?id='.$objectstatic->id;
1325 $documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir);
1327 } elseif ($line->doc_type ==
'bank') {
1328 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
1330 $objectstatic->fetch($line->fk_doc);
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;
1343 $labeltoshow =
'<span class="opacitymedium">'.$langs->trans(
"Deleted").
'</span>';
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;
1352 $labeltoshow .= $line->doc_ref;
1353 $labeltoshowalt .= $line->doc_ref;
1356 print
'<td class="nowraponall tdoverflowmax200" title="'.dol_escape_htmltag($labeltoshowalt).
'">';
1360 $totalarray[
'nbfield']++;
1365 if (!empty($arrayfields[
't.numero_compte'][
'checked'])) {
1366 print
'<td>'.length_accountg($line->numero_compte).
'</td>';
1368 $totalarray[
'nbfield']++;
1373 if (!empty($arrayfields[
't.subledger_account'][
'checked'])) {
1374 print
'<td>'.length_accounta($line->subledger_account).
'</td>';
1376 $totalarray[
'nbfield']++;
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>';
1384 $totalarray[
'nbfield']++;
1389 if (!empty($arrayfields[
't.debit'][
'checked'])) {
1390 print
'<td class="right nowraponall amount">'.($line->debit != 0 ?
price($line->debit) :
'').
'</td>';
1392 $totalarray[
'nbfield']++;
1395 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'totaldebit';
1397 $totalarray[
'val'][
'totaldebit'] += $line->debit;
1401 if (!empty($arrayfields[
't.credit'][
'checked'])) {
1402 print
'<td class="right nowraponall amount">'.($line->credit != 0 ?
price($line->credit) :
'').
'</td>';
1404 $totalarray[
'nbfield']++;
1407 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'totalcredit';
1409 $totalarray[
'val'][
'totalcredit'] += $line->credit;
1413 if (!empty($arrayfields[
't.lettering_code'][
'checked'])) {
1414 print
'<td class="center">'.$line->lettering_code.
'</td>';
1416 $totalarray[
'nbfield']++;
1421 $parameters = array(
'arrayfields' => $arrayfields,
'obj' => $obj,
'i' => $i,
'totalarray' => &$totalarray);
1422 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters);
1423 print $hookmanager->resPrint;
1426 if (!empty($arrayfields[
't.date_creation'][
'checked'])) {
1427 print
'<td class="center">'.dol_print_date($line->date_creation,
'dayhour',
'tzuserrel').
'</td>';
1429 $totalarray[
'nbfield']++;
1434 if (!empty($arrayfields[
't.tms'][
'checked'])) {
1435 print
'<td class="center">'.dol_print_date($line->date_modification,
'dayhour',
'tzuserrel').
'</td>';
1437 $totalarray[
'nbfield']++;
1442 if (!empty($arrayfields[
't.date_export'][
'checked'])) {
1443 print
'<td class="center nowraponall">'.dol_print_date($line->date_export,
'dayhour',
'tzuserrel').
'</td>';
1445 $totalarray[
'nbfield']++;
1450 if (!empty($arrayfields[
't.date_validated'][
'checked'])) {
1451 print
'<td class="center nowraponall">'.dol_print_date($line->date_validation,
'dayhour',
'tzuserrel').
'</td>';
1453 $totalarray[
'nbfield']++;
1457 if (!empty($arrayfields[
't.import_key'][
'checked'])) {
1458 print
'<td class="tdoverflowmax100">'.$obj->import_key.
"</td>\n";
1460 $totalarray[
'nbfield']++;
1466 print
'<td class="nowraponall center">';
1467 if (($massactionbutton || $massaction) && $contextpage !=
'poslist') {
1469 if (in_array($line->id, $arrayofselected)) {
1472 print
'<input id="cb'.$line->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$line->id.
'"'.($selected ?
' checked="checked"' :
'').
' />';
1476 $totalarray[
'nbfield']++;
1487include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
1492 foreach ($arrayfields as $key => $val) {
1493 if (!empty($val[
'checked'])) {
1497 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
1500$parameters = array(
'arrayfields' => $arrayfields,
'sql' => $sql);
1501$reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object, $action);
1502print $hookmanager->resPrint;
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
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.
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)
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.
dol_get_last_day($year, $month=12, $gm=false)
Return GMT time for last day of a month or year.
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.