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[
'id']).
"'";
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');
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 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
844 $form_question[
'notifiedexportfull'] = array(
845 'name' =>
'notifiedexportfull',
846 'type' =>
'checkbox',
847 'label' => $langs->trans(
'NotifiedExportFull'),
852 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?'.$param, $langs->trans(
"ExportFilteredList").
'...', $langs->trans(
'ConfirmExportFile'),
'export_fileconfirm', $form_question,
'', 1, 390, 700);
859if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
860 $param .=
'&contextpage='.urlencode($contextpage);
862if ($limit > 0 && $limit != $conf->liste_limit) {
863 $param .=
'&limit='.urlencode($limit);
867$arrayofmassactions = array();
868$massactionbutton = $form->selectMassAction($massaction, $arrayofmassactions);
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).
'">';
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.
'">';
882 $buttonLabel = $langs->trans(
"ExportFilteredList");
884 $buttonLabel = $langs->trans(
"ExportList");
887$parameters = array(
'param' => $param);
888$reshook = $hookmanager->executeHooks(
'addMoreActionsButtonsList', $parameters, $object, $action);
893$newcardbutton = empty($hookmanager->resPrint) ?
'' : $hookmanager->resPrint;
894if (empty($reshook)) {
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>';
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>';
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'));
911print_barre_liste($title_page, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'title_accountancy', 0, $newcardbutton,
'', $limit, 0, 0, 1);
915 print
info_admin($langs->trans(
"WarningDataDisappearsWhenDataIsExported"), 0, 0,
'0',
'hideonsmartphone info');
922include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
924$varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
925$selectedfields = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN'));
926if ($massactionbutton && $contextpage !=
'poslist') {
927 $selectedfields .= $form->showCheckAddButtons(
'checkforselect', 1);
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>';
941$parameters = array();
942$reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
943if (empty($reshook)) {
944 $moreforfilter .= $hookmanager->resPrint;
946 $moreforfilter = $hookmanager->resPrint;
950 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
951 print $moreforfilter;
955print
'<div class="div-table-responsive">';
956print
'<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">';
959print
'<tr class="liste_titre_filter">';
962 print
'<td class="liste_titre center">';
963 $searchpicto = $form->showFilterButtons(
'left');
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>';
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');
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"));
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"));
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>';
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');
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');
1004if (!empty($arrayfields[
't.subledger_account'][
'checked'])) {
1005 print
'<td class="liste_titre">';
1009 print
'<div class="nowrap">';
1011 print $formaccounting->select_auxaccount($search_accountancy_aux_code_start,
'search_accountancy_aux_code_start', $langs->trans(
'From'),
'maxwidth150',
'subledgeraccount');
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');
1017 print
'<input type="text" class="maxwidth75" name="search_accountancy_aux_code" value="'.dol_escape_htmltag($search_accountancy_aux_code).
'">';
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).
'"/>';
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).
'">';
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).
'">';
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>';
1048$parameters = array(
'arrayfields' => $arrayfields);
1049$reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters);
1050print $hookmanager->resPrint;
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"));
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"));
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"));
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"));
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"));
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"));
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"));
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"));
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).
'">';
1103 print
'<td class="liste_titre center">';
1104 $searchpicto = $form->showFilterButtons();
1110print
'<tr class="liste_titre">';
1112 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch actioncolumn ');
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);
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 ');
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 ');
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);
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);
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);
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);
1135if (!empty($arrayfields[
't.debit'][
'checked'])) {
1136 print_liste_field_titre($arrayfields[
't.debit'][
'label'], $_SERVER[
'PHP_SELF'],
"t.debit",
"", $param,
'', $sortfield, $sortorder,
'right ');
1138if (!empty($arrayfields[
't.credit'][
'checked'])) {
1139 print_liste_field_titre($arrayfields[
't.credit'][
'label'], $_SERVER[
'PHP_SELF'],
"t.credit",
"", $param,
'', $sortfield, $sortorder,
'right ');
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 ');
1145$parameters = array(
'arrayfields' => $arrayfields,
'param' => $param,
'sortfield' => $sortfield,
'sortorder' => $sortorder);
1146$reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters);
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 ');
1151if (!empty($arrayfields[
't.tms'][
'checked'])) {
1152 print_liste_field_titre($arrayfields[
't.tms'][
'label'], $_SERVER[
'PHP_SELF'],
"t.tms",
"", $param,
'', $sortfield, $sortorder,
'center ');
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 ');
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 ');
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 ');
1164 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ');
1174$totalarray = array();
1175$totalarray[
'nbfield'] = 0;
1176$totalarray[
'val'] = array();
1177$totalarray[
'val'][
'totaldebit'] = 0;
1178$totalarray[
'val'][
'totalcredit'] = 0;
1180while ($i < min($num, $limit)) {
1181 $obj = $db->fetch_object($resql);
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;
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);
1214 print
'<tr class="oddeven">';
1217 print
'<td class="nowraponall center">';
1218 if (($massactionbutton || $massaction) && $contextpage !=
'poslist') {
1220 if (in_array($line->id, $arrayofselected)) {
1223 print
'<input id="cb'.$line->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$line->id.
'"'.($selected ?
' checked="checked"' :
'').
' />';
1227 $totalarray[
'nbfield']++;
1232 if (!empty($arrayfields[
't.piece_num'][
'checked'])) {
1235 $object->piece_num = $line->piece_num;
1236 print
$object->getNomUrl(1,
'', 0,
'', 1);
1239 $totalarray[
'nbfield']++;
1244 if (!empty($arrayfields[
't.code_journal'][
'checked'])) {
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>';
1250 $totalarray[
'nbfield']++;
1255 if (!empty($arrayfields[
't.doc_date'][
'checked'])) {
1256 print
'<td class="center">'.dol_print_date($line->doc_date,
'day').
'</td>';
1258 $totalarray[
'nbfield']++;
1264 if (!empty($arrayfields[
't.doc_ref'][
'checked'])) {
1266 $objectstatic =
null;
1267 if ($line->doc_type ==
'customer_invoice') {
1268 $langs->loadLangs(array(
'bills'));
1270 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
1271 $objectstatic =
new Facture($db);
1272 $objectstatic->fetch($line->fk_doc);
1274 if ($objectstatic->id > 0) {
1277 $urlsource = $_SERVER[
'PHP_SELF'].
'?id='.$objectstatic->id;
1278 $documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir);
1280 } elseif ($line->doc_type ==
'supplier_invoice') {
1281 $langs->loadLangs(array(
'bills'));
1283 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
1285 $objectstatic->fetch($line->fk_doc);
1287 if ($objectstatic->id > 0) {
1288 $modulepart =
'invoice_supplier';
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);
1294 } elseif ($line->doc_type ==
'expense_report') {
1295 $langs->loadLangs(array(
'trips'));
1297 require_once DOL_DOCUMENT_ROOT.
'/expensereport/class/expensereport.class.php';
1299 $objectstatic->fetch($line->fk_doc);
1301 if ($objectstatic->id > 0) {
1304 $urlsource = $_SERVER[
'PHP_SELF'].
'?id='.$objectstatic->id;
1305 $documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir);
1307 } elseif ($line->doc_type ==
'bank') {
1308 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
1310 $objectstatic->fetch($line->fk_doc);
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;
1323 $labeltoshowhtml =
'<span class="opacitymedium">'.$langs->trans(
"Deleted").
'</span>';
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;
1332 $labeltoshowhtml .= $line->doc_ref;
1333 $labeltoshowalt .= $line->doc_ref;
1336 print
'<td class="nowraponall tdoverflowmax150" title="'.dolPrintHTMLForAttribute($labeltoshowalt).
'">';
1337 print $labeltoshowhtml;
1340 $totalarray[
'nbfield']++;
1345 if (!empty($arrayfields[
't.numero_compte'][
'checked'])) {
1346 print
'<td>'.length_accountg($line->numero_compte).
'</td>';
1348 $totalarray[
'nbfield']++;
1353 if (!empty($arrayfields[
't.subledger_account'][
'checked'])) {
1354 print
'<td>'.length_accounta($line->subledger_account).
'</td>';
1356 $totalarray[
'nbfield']++;
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>';
1364 $totalarray[
'nbfield']++;
1369 if (!empty($arrayfields[
't.debit'][
'checked'])) {
1370 print
'<td class="right nowraponall amount">'.($line->debit != 0 ?
price($line->debit) :
'').
'</td>';
1372 $totalarray[
'nbfield']++;
1375 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'totaldebit';
1377 $totalarray[
'val'][
'totaldebit'] += $line->debit;
1381 if (!empty($arrayfields[
't.credit'][
'checked'])) {
1382 print
'<td class="right nowraponall amount">'.($line->credit != 0 ?
price($line->credit) :
'').
'</td>';
1384 $totalarray[
'nbfield']++;
1387 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'totalcredit';
1389 $totalarray[
'val'][
'totalcredit'] += $line->credit;
1393 if (!empty($arrayfields[
't.lettering_code'][
'checked'])) {
1394 print
'<td class="center">'.$line->lettering_code.
'</td>';
1396 $totalarray[
'nbfield']++;
1401 $parameters = array(
'arrayfields' => $arrayfields,
'obj' => $obj,
'i' => $i,
'totalarray' => &$totalarray);
1402 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters);
1403 print $hookmanager->resPrint;
1406 if (!empty($arrayfields[
't.date_creation'][
'checked'])) {
1407 print
'<td class="center">'.dol_print_date($line->date_creation,
'dayhour',
'tzuserrel').
'</td>';
1409 $totalarray[
'nbfield']++;
1414 if (!empty($arrayfields[
't.tms'][
'checked'])) {
1415 print
'<td class="center">'.dol_print_date($line->date_modification,
'dayhour',
'tzuserrel').
'</td>';
1417 $totalarray[
'nbfield']++;
1422 if (!empty($arrayfields[
't.date_export'][
'checked'])) {
1423 print
'<td class="center nowraponall">'.dol_print_date($line->date_export,
'dayhour',
'tzuserrel').
'</td>';
1425 $totalarray[
'nbfield']++;
1430 if (!empty($arrayfields[
't.date_validated'][
'checked'])) {
1431 print
'<td class="center nowraponall">'.dol_print_date($line->date_validation,
'dayhour',
'tzuserrel').
'</td>';
1433 $totalarray[
'nbfield']++;
1437 if (!empty($arrayfields[
't.import_key'][
'checked'])) {
1438 print
'<td class="tdoverflowmax100">'.$obj->import_key.
"</td>\n";
1440 $totalarray[
'nbfield']++;
1446 print
'<td class="nowraponall center">';
1447 if (($massactionbutton || $massaction) && $contextpage !=
'poslist') {
1449 if (in_array($line->id, $arrayofselected)) {
1452 print
'<input id="cb'.$line->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$line->id.
'"'.($selected ?
' checked="checked"' :
'').
' />';
1456 $totalarray[
'nbfield']++;
1467include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
1472 foreach ($arrayfields as $key => $val) {
1473 if (!empty($val[
'checked'])) {
1477 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
1480$parameters = array(
'arrayfields' => $arrayfields,
'sql' => $sql);
1481$reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object, $action);
1482print $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($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
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...
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.