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';
53$langs->loadLangs(array(
"accountancy",
"compta"));
57$action =
GETPOST(
'action',
'aZ09');
58$massaction =
GETPOST(
'massaction',
'alpha');
59$confirm =
GETPOST(
'confirm',
'alpha');
60$toselect =
GETPOST(
'toselect',
'array');
61$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'bookkeepinglist';
62$search_mvt_num =
GETPOST(
'search_mvt_num',
'alpha');
63$search_doc_type =
GETPOST(
"search_doc_type",
'alpha');
64$search_doc_ref =
GETPOST(
"search_doc_ref",
'alpha');
65$search_date_startyear =
GETPOSTINT(
'search_date_startyear');
66$search_date_startmonth =
GETPOSTINT(
'search_date_startmonth');
67$search_date_startday =
GETPOSTINT(
'search_date_startday');
68$search_date_endyear =
GETPOSTINT(
'search_date_endyear');
69$search_date_endmonth =
GETPOSTINT(
'search_date_endmonth');
70$search_date_endday =
GETPOSTINT(
'search_date_endday');
71$search_date_start =
dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear);
72$search_date_end =
dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear);
74$search_date_creation_startyear =
GETPOSTINT(
'search_date_creation_startyear');
75$search_date_creation_startmonth =
GETPOSTINT(
'search_date_creation_startmonth');
76$search_date_creation_startday =
GETPOSTINT(
'search_date_creation_startday');
77$search_date_creation_endyear =
GETPOSTINT(
'search_date_creation_endyear');
78$search_date_creation_endmonth =
GETPOSTINT(
'search_date_creation_endmonth');
79$search_date_creation_endday =
GETPOSTINT(
'search_date_creation_endday');
80$search_date_creation_start =
dol_mktime(0, 0, 0, $search_date_creation_startmonth, $search_date_creation_startday, $search_date_creation_startyear);
81$search_date_creation_end =
dol_mktime(23, 59, 59, $search_date_creation_endmonth, $search_date_creation_endday, $search_date_creation_endyear);
82$search_date_modification_startyear =
GETPOSTINT(
'search_date_modification_startyear');
83$search_date_modification_startmonth =
GETPOSTINT(
'search_date_modification_startmonth');
84$search_date_modification_startday =
GETPOSTINT(
'search_date_modification_startday');
85$search_date_modification_endyear =
GETPOSTINT(
'search_date_modification_endyear');
86$search_date_modification_endmonth =
GETPOSTINT(
'search_date_modification_endmonth');
87$search_date_modification_endday =
GETPOSTINT(
'search_date_modification_endday');
88$search_date_modification_start =
dol_mktime(0, 0, 0, $search_date_modification_startmonth, $search_date_modification_startday, $search_date_modification_startyear);
89$search_date_modification_end =
dol_mktime(23, 59, 59, $search_date_modification_endmonth, $search_date_modification_endday, $search_date_modification_endyear);
90$search_date_export_startyear =
GETPOSTINT(
'search_date_export_startyear');
91$search_date_export_startmonth =
GETPOSTINT(
'search_date_export_startmonth');
92$search_date_export_startday =
GETPOSTINT(
'search_date_export_startday');
93$search_date_export_endyear =
GETPOSTINT(
'search_date_export_endyear');
94$search_date_export_endmonth =
GETPOSTINT(
'search_date_export_endmonth');
95$search_date_export_endday =
GETPOSTINT(
'search_date_export_endday');
96$search_date_export_start =
dol_mktime(0, 0, 0, $search_date_export_startmonth, $search_date_export_startday, $search_date_export_startyear);
97$search_date_export_end =
dol_mktime(23, 59, 59, $search_date_export_endmonth, $search_date_export_endday, $search_date_export_endyear);
98$search_date_validation_startyear =
GETPOSTINT(
'search_date_validation_startyear');
99$search_date_validation_startmonth =
GETPOSTINT(
'search_date_validation_startmonth');
100$search_date_validation_startday =
GETPOSTINT(
'search_date_validation_startday');
101$search_date_validation_endyear =
GETPOSTINT(
'search_date_validation_endyear');
102$search_date_validation_endmonth =
GETPOSTINT(
'search_date_validation_endmonth');
103$search_date_validation_endday =
GETPOSTINT(
'search_date_validation_endday');
104$search_date_validation_start =
dol_mktime(0, 0, 0, $search_date_validation_startmonth, $search_date_validation_startday, $search_date_validation_startyear);
105$search_date_validation_end =
dol_mktime(23, 59, 59, $search_date_validation_endmonth, $search_date_validation_endday, $search_date_validation_endyear);
106$search_import_key =
GETPOST(
"search_import_key",
'alpha');
110 $action =
'delbookkeepingyear';
112if (
GETPOST(
"button_export_file_x") ||
GETPOST(
"button_export_file.x") ||
GETPOST(
"button_export_file")) {
113 $action =
'export_file';
116$search_account_category =
GETPOSTINT(
'search_account_category');
118$search_accountancy_code =
GETPOST(
"search_accountancy_code",
'alpha');
119$search_accountancy_code_start =
GETPOST(
'search_accountancy_code_start',
'alpha');
120if ($search_accountancy_code_start == - 1) {
121 $search_accountancy_code_start =
'';
123$search_accountancy_code_end =
GETPOST(
'search_accountancy_code_end',
'alpha');
124if ($search_accountancy_code_end == - 1) {
125 $search_accountancy_code_end =
'';
128$search_accountancy_aux_code =
GETPOST(
"search_accountancy_aux_code",
'alpha');
129$search_accountancy_aux_code_start =
GETPOST(
'search_accountancy_aux_code_start',
'alpha');
130if ($search_accountancy_aux_code_start == - 1) {
131 $search_accountancy_aux_code_start =
'';
133$search_accountancy_aux_code_end =
GETPOST(
'search_accountancy_aux_code_end',
'alpha');
134if ($search_accountancy_aux_code_end == - 1) {
135 $search_accountancy_aux_code_end =
'';
137$search_mvt_label =
GETPOST(
'search_mvt_label',
'alpha');
138$search_direction =
GETPOST(
'search_direction',
'alpha');
139$search_debit =
GETPOST(
'search_debit',
'alpha');
140$search_credit =
GETPOST(
'search_credit',
'alpha');
141$search_ledger_code =
GETPOST(
'search_ledger_code',
'array');
142$search_lettering_code =
GETPOST(
'search_lettering_code',
'alpha');
143$search_not_reconciled =
GETPOST(
'search_not_reconciled',
'alpha');
147$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
148$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
149$optioncss =
GETPOST(
'optioncss',
'alpha');
151if (empty($page) || $page < 0) {
154$offset = $limit * $page;
155$pageprev = $page - 1;
156$pagenext = $page + 1;
157if ($sortorder ==
"") {
160if ($sortfield ==
"") {
161 $sortfield =
"t.piece_num,t.rowid";
166$hookmanager->initHooks(array(
'bookkeepingexport'));
169$form =
new Form($db);
171if (!in_array($action, array(
'export_file',
'delmouv',
'delmouvconfirm')) && !GETPOSTISSET(
'begin') && !GETPOSTISSET(
'formfilteraction') &&
GETPOSTINT(
'page') ==
'' && !
GETPOSTINT(
'noreset') && $user->hasRight(
'accounting',
'mouvements',
'export')) {
172 if (empty($search_date_start) && empty($search_date_end) && !GETPOSTISSET(
'restore_lastsearch_values') && !
GETPOST(
'search_accountancy_code_start')) {
173 $query =
"SELECT date_start, date_end from ".MAIN_DB_PREFIX.
"accounting_fiscalyear ";
174 $query .=
" where date_start < '".$db->idate(
dol_now()).
"' and date_end > '".$db->idate(
dol_now()).
"' limit 1";
175 $res = $db->query($query);
177 if ($db->num_rows($res) > 0) {
178 $fiscalYear = $db->fetch_object($res);
179 $search_date_start = strtotime($fiscalYear->date_start);
180 $search_date_end = strtotime($fiscalYear->date_end);
187 $year_end = $year_start + 1;
188 $month_end = $month_start - 1;
189 if ($month_end < 1) {
193 $search_date_start =
dol_mktime(0, 0, 0, $month_start, 1, $year_start);
201 't.piece_num' => array(
'label' => $langs->trans(
"TransactionNumShort"),
'checked' => 1),
202 't.code_journal' => array(
'label' => $langs->trans(
"Codejournal"),
'checked' => 1),
203 't.doc_date' => array(
'label' => $langs->trans(
"Docdate"),
'checked' => 1),
204 't.doc_ref' => array(
'label' => $langs->trans(
"Piece"),
'checked' => 1),
205 't.numero_compte' => array(
'label' => $langs->trans(
"AccountAccountingShort"),
'checked' => 1),
206 't.subledger_account' => array(
'label' => $langs->trans(
"SubledgerAccount"),
'checked' => 1),
207 't.label_operation' => array(
'label' => $langs->trans(
"Label"),
'checked' => 1),
208 't.debit' => array(
'label' => $langs->trans(
"AccountingDebit"),
'checked' => 1),
209 't.credit' => array(
'label' => $langs->trans(
"AccountingCredit"),
'checked' => 1),
210 't.lettering_code' => array(
'label' => $langs->trans(
"LetteringCode"),
'checked' => 1),
211 't.date_creation' => array(
'label' => $langs->trans(
"DateCreation"),
'checked' => 0),
212 't.tms' => array(
'label' => $langs->trans(
"DateModification"),
'checked' => 0),
213 't.date_export' => array(
'label' => $langs->trans(
"DateExport"),
'checked' => 1),
214 't.date_validated' => array(
'label' => $langs->trans(
"DateValidationAndLock"),
'checked' => -1,
'enabled' => !
getDolGlobalString(
"ACCOUNTANCY_DISABLE_CLOSURE_LINE_BY_LINE")),
215 't.import_key' => array(
'label' => $langs->trans(
"ImportId"),
'checked' => 0,
'position' => 1100),
219 unset($arrayfields[
't.lettering_code']);
223$listofformat = $accountancyexport->getType();
225if (empty($listofformat[$formatexportset])) {
226 $formatexportset = 1;
231if (!isModEnabled(
'accounting')) {
234if ($user->socid > 0) {
237if (!$user->hasRight(
'accounting',
'mouvements',
'lire')) {
248if (
GETPOST(
'cancel',
'alpha')) {
252if (!
GETPOST(
'confirmmassaction',
'alpha')) {
256$parameters = array(
'socid' => $socid);
257$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
262if (empty($reshook)) {
263 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
265 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
266 $search_mvt_num =
'';
267 $search_doc_type =
'';
268 $search_doc_ref =
'';
269 $search_doc_date =
'';
270 $search_account_category =
'';
271 $search_accountancy_code =
'';
272 $search_accountancy_code_start =
'';
273 $search_accountancy_code_end =
'';
274 $search_accountancy_aux_code =
'';
275 $search_accountancy_aux_code_start =
'';
276 $search_accountancy_aux_code_end =
'';
277 $search_mvt_label =
'';
278 $search_direction =
'';
279 $search_ledger_code = array();
280 $search_date_startyear =
'';
281 $search_date_startmonth =
'';
282 $search_date_startday =
'';
283 $search_date_endyear =
'';
284 $search_date_endmonth =
'';
285 $search_date_endday =
'';
286 $search_date_start =
'';
287 $search_date_end =
'';
288 $search_date_creation_startyear =
'';
289 $search_date_creation_startmonth =
'';
290 $search_date_creation_startday =
'';
291 $search_date_creation_endyear =
'';
292 $search_date_creation_endmonth =
'';
293 $search_date_creation_endday =
'';
294 $search_date_creation_start =
'';
295 $search_date_creation_end =
'';
296 $search_date_modification_startyear =
'';
297 $search_date_modification_startmonth =
'';
298 $search_date_modification_startday =
'';
299 $search_date_modification_endyear =
'';
300 $search_date_modification_endmonth =
'';
301 $search_date_modification_endday =
'';
302 $search_date_modification_start =
'';
303 $search_date_modification_end =
'';
304 $search_date_export_startyear =
'';
305 $search_date_export_startmonth =
'';
306 $search_date_export_startday =
'';
307 $search_date_export_endyear =
'';
308 $search_date_export_endmonth =
'';
309 $search_date_export_endday =
'';
310 $search_date_export_start =
'';
311 $search_date_export_end =
'';
312 $search_date_validation_startyear =
'';
313 $search_date_validation_startmonth =
'';
314 $search_date_validation_startday =
'';
315 $search_date_validation_endyear =
'';
316 $search_date_validation_endmonth =
'';
317 $search_date_validation_endday =
'';
318 $search_date_validation_start =
'';
319 $search_date_validation_end =
'';
322 $search_lettering_code =
'';
323 $search_not_reconciled =
'';
324 $search_import_key =
'';
330 if (!empty($search_date_start)) {
331 $filter[
't.doc_date>='] = $search_date_start;
333 $param .=
'&search_date_startmonth='.((int) $tmp[
'mon']).
'&search_date_startday='.((int) $tmp[
'mday']).
'&search_date_startyear='.((int) $tmp[
'year']);
335 if (!empty($search_date_end)) {
336 $filter[
't.doc_date<='] = $search_date_end;
338 $param .=
'&search_date_endmonth='.((int) $tmp[
'mon']).
'&search_date_endday='.((int) $tmp[
'mday']).
'&search_date_endyear='.((int) $tmp[
'year']);
340 if (!empty($search_doc_date)) {
341 $filter[
't.doc_date'] = $search_doc_date;
343 $param .=
'&doc_datemonth='.((int) $tmp[
'mon']).
'&doc_dateday='.((int) $tmp[
'mday']).
'&doc_dateyear='.((int) $tmp[
'year']);
345 if (!empty($search_doc_type)) {
346 $filter[
't.doc_type'] = $search_doc_type;
347 $param .=
'&search_doc_type='.urlencode($search_doc_type);
349 if (!empty($search_doc_ref)) {
350 $filter[
't.doc_ref'] = $search_doc_ref;
351 $param .=
'&search_doc_ref='.urlencode($search_doc_ref);
353 if ($search_account_category !=
'-1' && !empty($search_account_category)) {
354 require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountancycategory.class.php';
357 $listofaccountsforgroup = $accountingcategory->getCptsCat(0,
'fk_accounting_category = '.((
int) $search_account_category));
358 $listofaccountsforgroup2 = array();
359 if (is_array($listofaccountsforgroup)) {
360 foreach ($listofaccountsforgroup as $tmpval) {
361 $listofaccountsforgroup2[] =
"'".$db->escape($tmpval[
'id']).
"'";
364 $filter[
't.search_accounting_code_in'] = implode(
',', $listofaccountsforgroup2);
365 $param .=
'&search_account_category='.urlencode((
string) ($search_account_category));
367 if (!empty($search_accountancy_code)) {
368 $filter[
't.numero_compte'] = $search_accountancy_code;
369 $param .=
'&search_accountancy_code='.urlencode($search_accountancy_code);
371 if (!empty($search_accountancy_code_start)) {
372 $filter[
't.numero_compte>='] = $search_accountancy_code_start;
373 $param .=
'&search_accountancy_code_start='.urlencode($search_accountancy_code_start);
375 if (!empty($search_accountancy_code_end)) {
376 $filter[
't.numero_compte<='] = $search_accountancy_code_end;
377 $param .=
'&search_accountancy_code_end='.urlencode($search_accountancy_code_end);
379 if (!empty($search_accountancy_aux_code)) {
380 $filter[
't.subledger_account'] = $search_accountancy_aux_code;
381 $param .=
'&search_accountancy_aux_code='.urlencode($search_accountancy_aux_code);
383 if (!empty($search_accountancy_aux_code_start)) {
384 $filter[
't.subledger_account>='] = $search_accountancy_aux_code_start;
385 $param .=
'&search_accountancy_aux_code_start='.urlencode($search_accountancy_aux_code_start);
387 if (!empty($search_accountancy_aux_code_end)) {
388 $filter[
't.subledger_account<='] = $search_accountancy_aux_code_end;
389 $param .=
'&search_accountancy_aux_code_end='.urlencode($search_accountancy_aux_code_end);
391 if (!empty($search_mvt_label)) {
392 $filter[
't.label_operation'] = $search_mvt_label;
393 $param .=
'&search_mvt_label='.urlencode($search_mvt_label);
395 if (!empty($search_direction)) {
396 $filter[
't.sens'] = $search_direction;
397 $param .=
'&search_direction='.urlencode($search_direction);
399 if (!empty($search_ledger_code)) {
400 $filter[
't.code_journal'] = $search_ledger_code;
401 foreach ($search_ledger_code as $code) {
402 $param .=
'&search_ledger_code[]='.urlencode($code);
405 if (!empty($search_mvt_num)) {
406 $filter[
't.piece_num'] = $search_mvt_num;
407 $param .=
'&search_mvt_num='.urlencode((
string) ($search_mvt_num));
409 if (!empty($search_date_creation_start)) {
410 $filter[
't.date_creation>='] = $search_date_creation_start;
412 $param .=
'&search_date_creation_startmonth='.((int) $tmp[
'mon']).
'&search_date_creation_startday='.((int) $tmp[
'mday']).
'&search_date_creation_startyear='.((int) $tmp[
'year']);
414 if (!empty($search_date_creation_end)) {
415 $filter[
't.date_creation<='] = $search_date_creation_end;
417 $param .=
'&search_date_creation_endmonth='.((int) $tmp[
'mon']).
'&search_date_creation_endday='.((int) $tmp[
'mday']).
'&search_date_creation_endyear='.((int) $tmp[
'year']);
419 if (!empty($search_date_modification_start)) {
420 $filter[
't.tms>='] = $search_date_modification_start;
421 $tmp =
dol_getdate($search_date_modification_start);
422 $param .=
'&search_date_modification_startmonth='.((int) $tmp[
'mon']).
'&search_date_modification_startday='.((int) $tmp[
'mday']).
'&search_date_modification_startyear='.((int) $tmp[
'year']);
424 if (!empty($search_date_modification_end)) {
425 $filter[
't.tms<='] = $search_date_modification_end;
427 $param .=
'&search_date_modification_endmonth='.((int) $tmp[
'mon']).
'&search_date_modification_endday='.((int) $tmp[
'mday']).
'&search_date_modification_endyear='.((int) $tmp[
'year']);
429 if (!empty($search_date_export_start)) {
430 $filter[
't.date_export>='] = $search_date_export_start;
432 $param .=
'&search_date_export_startmonth='.((int) $tmp[
'mon']).
'&search_date_export_startday='.((int) $tmp[
'mday']).
'&search_date_export_startyear='.((int) $tmp[
'year']);
434 if (!empty($search_date_export_end)) {
435 $filter[
't.date_export<='] = $search_date_export_end;
437 $param .=
'&search_date_export_endmonth='.((int) $tmp[
'mon']).
'&search_date_export_endday='.((int) $tmp[
'mday']).
'&search_date_export_endyear='.((int) $tmp[
'year']);
439 if (!empty($search_date_validation_start)) {
440 $filter[
't.date_validated>='] = $search_date_validation_start;
442 $param .=
'&search_date_validation_startmonth='.((int) $tmp[
'mon']).
'&search_date_validation_startday='.((int) $tmp[
'mday']).
'&search_date_validation_startyear='.((int) $tmp[
'year']);
444 if (!empty($search_date_validation_end)) {
445 $filter[
't.date_validated<='] = $search_date_validation_end;
447 $param .=
'&search_date_validation_endmonth='.((int) $tmp[
'mon']).
'&search_date_validation_endday='.((int) $tmp[
'mday']).
'&search_date_validation_endyear='.((int) $tmp[
'year']);
449 if (!empty($search_debit)) {
450 $filter[
't.debit'] = $search_debit;
451 $param .=
'&search_debit='.urlencode($search_debit);
453 if (!empty($search_credit)) {
454 $filter[
't.credit'] = $search_credit;
455 $param .=
'&search_credit='.urlencode($search_credit);
457 if (!empty($search_lettering_code)) {
458 $filter[
't.lettering_code'] = $search_lettering_code;
459 $param .=
'&search_lettering_code='.urlencode($search_lettering_code);
461 if (!empty($search_not_reconciled)) {
462 $filter[
't.reconciled_option'] = $search_not_reconciled;
463 $param .=
'&search_not_reconciled='.urlencode($search_not_reconciled);
465 if (!empty($search_import_key)) {
466 $filter[
't.import_key'] = $search_import_key;
467 $param .=
'&search_import_key='.urlencode($search_import_key);
470 if ($action ==
'setreexport' && $user->hasRight(
'accounting',
'mouvements',
'export')) {
478 setEventMessages($langs->trans(
"ExportOfPiecesAlreadyExportedIsDisable"),
null,
'mesgs');
480 setEventMessages($langs->trans(
"ExportOfPiecesAlreadyExportedIsEnable"),
null,
'warnings');
488 $objectclass =
'Bookkeeping';
489 $objectlabel =
'Bookkeeping';
490 $permissiontoread = ($user->hasRight(
'societe',
'lire') == 1);
491 $permissiontodelete = ($user->hasRight(
'societe',
'supprimer') == 1);
492 $permissiontoadd = ($user->hasRight(
'societe',
'creer') == 1);
493 $uploaddir =
$conf->societe->dir_output;
494 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
503$sql .=
" t.doc_date,";
504$sql .=
" t.doc_type,";
505$sql .=
" t.doc_ref,";
507$sql .=
" t.fk_docdet,";
508$sql .=
" t.thirdparty_code,";
509$sql .=
" t.subledger_account,";
510$sql .=
" t.subledger_label,";
511$sql .=
" t.numero_compte,";
512$sql .=
" t.label_compte,";
513$sql .=
" t.label_operation,";
516$sql .=
" t.lettering_code,";
517$sql .=
" t.date_lettering,";
518$sql .=
" t.montant as amount,";
520$sql .=
" t.fk_user_author,";
521$sql .=
" t.import_key,";
522$sql .=
" t.code_journal,";
523$sql .=
" t.journal_label,";
524$sql .=
" t.piece_num,";
525$sql .=
" t.date_creation,";
526$sql .=
" t.date_lim_reglement,";
527$sql .=
" t.tms as date_modification,";
528$sql .=
" t.date_export,";
529$sql .=
" t.date_validated as date_validation,";
530$sql .=
" t.import_key";
534$sql .=
' FROM '.MAIN_DB_PREFIX.$object->table_element.
' as t';
537if (count($filter) > 0) {
538 foreach ($filter as $key => $value) {
539 if ($key ==
't.doc_date') {
540 $sqlwhere[] = $db->sanitize($key).
" = '".$db->idate($value).
"'";
541 } elseif ($key ==
't.doc_date>=') {
542 $sqlwhere[] =
"t.doc_date >= '".$db->idate($value).
"'";
543 } elseif ($key ==
't.doc_date<=') {
544 $sqlwhere[] =
"t.doc_date <= '".$db->idate($value).
"'";
545 } elseif ($key ==
't.doc_date>') {
546 $sqlwhere[] =
"t.doc_date > '".$db->idate($value).
"'";
547 } elseif ($key ==
't.doc_date<') {
548 $sqlwhere[] =
"t.doc_date < '".$db->idate($value).
"'";
549 } elseif ($key ==
't.numero_compte>=') {
550 $sqlwhere[] =
"t.numero_compte >= '".$db->escape($value).
"'";
551 } elseif ($key ==
't.numero_compte<=') {
552 $sqlwhere[] =
"t.numero_compte <= '".$db->escape($value).
"'";
553 } elseif ($key ==
't.subledger_account>=') {
554 $sqlwhere[] =
"t.subledger_account >= '".$db->escape($value).
"'";
555 } elseif ($key ==
't.subledger_account<=') {
556 $sqlwhere[] =
"t.subledger_account <= '".$db->escape($value).
"'";
557 } elseif ($key ==
't.fk_doc' || $key ==
't.fk_docdet' || $key ==
't.piece_num') {
558 $sqlwhere[] = $db->sanitize($key).
'='.((int) $value);
559 } elseif ($key ==
't.subledger_account' || $key ==
't.numero_compte') {
560 $sqlwhere[] = $db->sanitize($key).
" LIKE '".$db->escape($db->escapeforlike($value)).
"%'";
561 } elseif ($key ==
't.subledger_account') {
563 } elseif ($key ==
't.tms>=') {
564 $sqlwhere[] =
"t.tms >= '".$db->idate($value).
"'";
565 } elseif ($key ==
't.tms<=') {
566 $sqlwhere[] =
"t.tms <= '".$db->idate($value).
"'";
567 } elseif ($key ==
't.date_creation>=') {
568 $sqlwhere[] =
"t.date_creation >= '".$db->idate($value).
"'";
569 } elseif ($key ==
't.date_creation<=') {
570 $sqlwhere[] =
"t.date_creation <= '".$db->idate($value).
"'";
571 } elseif ($key ==
't.date_export>=') {
572 $sqlwhere[] =
"t.date_export >= '".$db->idate($value).
"'";
573 } elseif ($key ==
't.date_export<=') {
574 $sqlwhere[] =
"t.date_export <= '".$db->idate($value).
"'";
575 } elseif ($key ==
't.date_validated>=') {
576 $sqlwhere[] =
"t.date_validated >= '".$db->idate($value).
"'";
577 } elseif ($key ==
't.date_validated<=') {
578 $sqlwhere[] =
"t.date_validated <= '".$db->idate($value).
"'";
579 } elseif ($key ==
't.credit' || $key ==
't.debit') {
581 } elseif ($key ==
't.reconciled_option') {
582 $sqlwhere[] =
't.lettering_code IS NULL';
583 } elseif ($key ==
't.code_journal' && !empty($value)) {
584 if (is_array($value)) {
585 $sqlwhere[] =
natural_search(
"t.code_journal", implode(
',', $value), 3, 1);
589 } elseif ($key ==
't.search_accounting_code_in' && !empty($value)) {
590 $sqlwhere[] =
't.numero_compte IN ('.$db->sanitize($value, 1).
')';
596$sql .=
' WHERE t.entity IN ('.getEntity(
'accountancy').
')';
598 $sql .=
" AND t.date_export IS NULL";
600if (count($sqlwhere) > 0) {
601 $sql .=
' AND '.implode(
' AND ', $sqlwhere);
608if ($action ==
'export_fileconfirm' && $user->hasRight(
'accounting',
'mouvements',
'export')) {
613 $nbtotalofrecords = 0;
619 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords', $sql);
620 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
621 $resql = $db->query($sqlforcount);
623 $objforcount = $db->fetch_object($resql);
624 $nbtotalofrecords = $objforcount->nbtotalofrecords;
640 $result =
$object->fetchAll($sortorder, $sortfield, $limit, $offset, $filter,
'AND', (
getDolGlobalString(
'ACCOUNTING_REEXPORT') ? 1 : 0));
647 $notexportlettering =
GETPOST(
'notexportlettering',
'alpha');
650 if (!empty($notexportlettering)) {
651 if (is_array(
$object->lines)) {
652 foreach (
$object->lines as $k => $movement) {
653 unset(
$object->lines[$k]->lettering_code);
654 unset(
$object->lines[$k]->date_lettering);
659 $notifiedexportdate =
GETPOST(
'notifiedexportdate',
'alpha');
660 $notifiedvalidationdate =
GETPOST(
'notifiedvalidationdate',
'alpha');
661 $withAttachment = !empty(trim(
GETPOST(
'notifiedexportfull',
'alphanohtml'))) ? 1 : 0;
665 $result = $accountancyexport->export(
$object->lines, $formatexport, $withAttachment, 1, 1, 1);
670 if (!empty($notifiedexportdate) || !empty($notifiedvalidationdate)) {
671 if (is_array(
$object->lines)) {
672 dol_syslog(
"/accountancy/bookkeeping/list.php Function export_file set movements as exported", LOG_DEBUG);
675 foreach (
$object->lines as $movement) {
680 if (!empty($notifiedexportdate) && empty($movement->date_export)) {
681 $setfields .= ($setfields ?
"," :
"").
" date_export = '".$db->idate($now).
"'";
683 if (!empty($notifiedvalidationdate) && empty($movement->date_validation)) {
684 $setfields .= ($setfields ?
"," :
"").
" date_validated = '".$db->idate($now).
"'";
688 $sql =
" UPDATE ".MAIN_DB_PREFIX.
"accounting_bookkeeping";
689 $sql .=
" SET ".$setfields;
690 $sql .=
" WHERE rowid = ".((int) $movement->id);
692 $result = $db->query($sql);
701 $accountancyexport->errors[] = $langs->trans(
'NotAllExportedMovementsCouldBeRecordedAsExportedOrValidated');
711 $downloadFilePath = $accountancyexport->generatedfiledata[
'downloadFilePath'];
712 $downloadFileMimeType = $accountancyexport->generatedfiledata[
'downloadFileMimeType'];
713 $downloadFileFullName = $accountancyexport->generatedfiledata[
'downloadFileFullName'];
718 header(
'Content-Description: File Transfer');
722 header(
'Content-Disposition: attachment; filename="'.$downloadFileFullName.
'"');
724 header(
'Content-Disposition: inline; filename="'.$downloadFileFullName.
'"');
727 header(
'Cache-Control: Public, must-revalidate');
728 header(
'Pragma: public');
729 header(
'Content-Length: ' .
dol_filesize($downloadFilePath));
736 header(
'Location: '.$_SERVER[
'PHP_SELF']);
749$title_page = $langs->trans(
"Operations").
' - '.$langs->trans(
"ExportAccountancy");
752$nbtotalofrecords =
'';
755 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords', $sql);
756 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
757 $resql = $db->query($sqlforcount);
759 $objforcount = $db->fetch_object($resql);
760 $nbtotalofrecords = $objforcount->nbtotalofrecords;
765 if (($page * $limit) > $nbtotalofrecords) {
773$sql .= $db->order($sortfield, $sortorder);
775 $sql .= $db->plimit($limit + 1, $offset);
778$resql = $db->query($sql);
784$num = $db->num_rows($resql);
786$arrayofselected = is_array($toselect) ? $toselect : array();
790$help_url =
'EN:Module_Double_Entry_Accounting#Exports|FR:Module_Comptabilité_en_Partie_Double#Exports';
792llxHeader(
'', $title_page, $help_url,
'', 0, 0,
'',
'',
'',
'mod-accountancy accountancy-consultation page-export');
796if ($action ==
'export_file') {
797 $form_question = array();
799 $form_question[
'formatexport'] = array(
800 'name' =>
'formatexport',
802 'label' => $langs->trans(
'Modelcsv'),
803 'values' => $listofformat,
804 'default' => $formatexportset,
805 'morecss' =>
'minwidth200 maxwidth200'
808 $form_question[
'separator0'] = array(
'name' =>
'separator0',
'type' =>
'separator');
812 $checked =
getDolGlobalString(
'ACCOUNTING_DEFAULT_NOT_EXPORT_LETTERING') ?
'true' :
'false';
813 $form_question[
'notexportlettering'] = array(
814 'name' =>
'notexportlettering',
815 'type' =>
'checkbox',
816 'label' => $langs->trans(
'NotExportLettering'),
820 $form_question[
'separator1'] = array(
'name' =>
'separator1',
'type' =>
'separator');
824 $checked = (!isset(
$conf->global->ACCOUNTING_DEFAULT_NOT_NOTIFIED_EXPORT_DATE) ||
getDolGlobalString(
'ACCOUNTING_DEFAULT_NOT_NOTIFIED_EXPORT_DATE'));
825 $form_question[
'notifiedexportdate'] = array(
826 'name' =>
'notifiedexportdate',
827 'type' =>
'checkbox',
828 'label' => $langs->trans(
'NotifiedExportDate'),
829 'value' => (
getDolGlobalString(
'ACCOUNTING_DEFAULT_NOT_NOTIFIED_EXPORT_DATE') ?
'false' :
'true'),
832 $form_question[
'separator2'] = array(
'name' =>
'separator2',
'type' =>
'separator');
837 $form_question[
'notifiedvalidationdate'] = array(
838 'name' =>
'notifiedvalidationdate',
839 'type' =>
'checkbox',
840 'label' => $langs->trans(
'NotifiedValidationDate', $langs->transnoentitiesnoconv(
"MenuAccountancyClosure")),
844 $form_question[
'separator3'] = array(
'name' =>
'separator3',
'type' =>
'separator');
848 if (
getDolGlobalString(
'ACCOUNTING_EXPORT_MODELCSV') == AccountancyExport::$EXPORT_TYPE_QUADRATUS
849 ||
getDolGlobalString(
'ACCOUNTING_EXPORT_MODELCSV') == AccountancyExport::$EXPORT_TYPE_FEC
850 ||
getDolGlobalString(
'ACCOUNTING_EXPORT_MODELCSV') == AccountancyExport::$EXPORT_TYPE_FEC2
852 $form_question[
'notifiedexportfull'] = array(
853 'name' =>
'notifiedexportfull',
854 'type' =>
'checkbox',
855 'label' => $langs->trans(
'NotifiedExportFull'),
860 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?'.$param, $langs->trans(
"ExportFilteredList").
'...', $langs->trans(
'ConfirmExportFile'),
'export_fileconfirm', $form_question,
'', 1, 390, 700);
867if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
868 $param .=
'&contextpage='.urlencode($contextpage);
870if ($limit > 0 && $limit !=
$conf->liste_limit) {
871 $param .=
'&limit='.urlencode($limit);
875$arrayofmassactions = array();
876$massactionbutton = $form->selectMassAction($massaction, $arrayofmassactions);
878print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">';
879print
'<input type="hidden" name="token" value="'.newToken().
'">';
880print
'<input type="hidden" name="action" value="list">';
881if ($optioncss !=
'') {
882 print
'<input type="hidden" name="optioncss" value="'.urlencode($optioncss).
'">';
884print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
885print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
886print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
887print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
890 $buttonLabel = $langs->trans(
"ExportFilteredList");
892 $buttonLabel = $langs->trans(
"ExportList");
895$parameters = array(
'param' => $param);
896$reshook = $hookmanager->executeHooks(
'addMoreActionsButtonsList', $parameters, $object, $action);
901$newcardbutton = empty($hookmanager->resPrint) ?
'' : $hookmanager->resPrint;
902if (empty($reshook)) {
905 $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"');
906 $newcardbutton .=
'<span class="valignmiddle marginrightonly paddingleft">'.$langs->trans(
"ClickToShowAlreadyExportedLines").
'</span>';
907 $newcardbutton .=
'</a>';
909 $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"');
910 $newcardbutton .=
'<span class="valignmiddle marginrightonly paddingleft">'.$langs->trans(
"DocsAlreadyExportedAreIncluded").
'</span>';
911 $newcardbutton .=
'</a>';
914 if ($user->hasRight(
'accounting',
'mouvements',
'export')) {
915 $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'));
919print_barre_liste($title_page, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'title_accountancy', 0, $newcardbutton,
'', $limit, 0, 0, 1);
923 print
info_admin($langs->trans(
"WarningDataDisappearsWhenDataIsExported"), 0, 0,
'0',
'hideonsmartphone info');
930include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
932$varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
933$selectedfields = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN'));
934if ($massactionbutton && $contextpage !=
'poslist') {
935 $selectedfields .= $form->showCheckAddButtons(
'checkforselect', 1);
940if (!empty($search_account_category)) {
941 $moreforfilter .=
'<div class="divsearchfield">';
942 $moreforfilter .= $langs->trans(
'AccountingCategory').
': ';
943 $moreforfilter .=
'<div class="nowrap inline-block">';
944 $moreforfilter .= $formaccounting->select_accounting_category($search_account_category,
'search_account_category', 1, 0, 0, 0);
945 $moreforfilter .=
'</div>';
946 $moreforfilter .=
'</div>';
949$parameters = array();
950$reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
951if (empty($reshook)) {
952 $moreforfilter .= $hookmanager->resPrint;
954 $moreforfilter = $hookmanager->resPrint;
958 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
959 print $moreforfilter;
963print
'<div class="div-table-responsive">';
964print
'<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">';
967print
'<tr class="liste_titre_filter">';
970 print
'<td class="liste_titre center">';
971 $searchpicto = $form->showFilterButtons(
'left');
976if (!empty($arrayfields[
't.piece_num'][
'checked'])) {
977 print
'<td class="liste_titre"><input type="text" class="width50" name="search_mvt_num" value="'.dol_escape_htmltag($search_mvt_num).
'"></td>';
980if (!empty($arrayfields[
't.code_journal'][
'checked'])) {
981 print
'<td class="liste_titre center">';
982 print $formaccounting->multi_select_journal($search_ledger_code,
'search_ledger_code', 0, 1, 1, 1,
'small maxwidth75');
986if (!empty($arrayfields[
't.doc_date'][
'checked'])) {
987 print
'<td class="liste_titre center">';
988 print
'<div class="nowrapfordate">';
989 print $form->selectDate($search_date_start ? $search_date_start : -1,
'search_date_start', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"From"));
991 print
'<div class="nowrapfordate">';
992 print $form->selectDate($search_date_end ? $search_date_end : -1,
'search_date_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"to"));
997if (!empty($arrayfields[
't.doc_ref'][
'checked'])) {
998 print
'<td class="liste_titre"><input type="text" name="search_doc_ref" class="width75" value="'.dol_escape_htmltag($search_doc_ref).
'"></td>';
1001if (!empty($arrayfields[
't.numero_compte'][
'checked'])) {
1002 print
'<td class="liste_titre">';
1003 print
'<div class="nowrap">';
1004 print $formaccounting->select_account($search_accountancy_code_start,
'search_accountancy_code_start', $langs->trans(
'From'), array(), 1, 1,
'maxwidth150',
'account');
1006 print
'<div class="nowrap">';
1007 print $formaccounting->select_account($search_accountancy_code_end,
'search_accountancy_code_end', $langs->trans(
'to'), array(), 1, 1,
'maxwidth150',
'account');
1012if (!empty($arrayfields[
't.subledger_account'][
'checked'])) {
1013 print
'<td class="liste_titre">';
1017 print
'<div class="nowrap">';
1019 print $formaccounting->select_auxaccount($search_accountancy_aux_code_start,
'search_accountancy_aux_code_start', $langs->trans(
'From'),
'maxwidth150',
'subledgeraccount');
1021 print
'<div class="nowrap">';
1022 print $formaccounting->select_auxaccount($search_accountancy_aux_code_end,
'search_accountancy_aux_code_end', $langs->trans(
'to'),
'maxwidth150',
'subledgeraccount');
1025 print
'<input type="text" class="maxwidth75" name="search_accountancy_aux_code" value="'.dol_escape_htmltag($search_accountancy_aux_code).
'">';
1030if (!empty($arrayfields[
't.label_operation'][
'checked'])) {
1031 print
'<td class="liste_titre">';
1032 print
'<input type="text" size="7" class="flat" name="search_mvt_label" value="'.dol_escape_htmltag($search_mvt_label).
'"/>';
1036if (!empty($arrayfields[
't.debit'][
'checked'])) {
1037 print
'<td class="liste_titre right">';
1038 print
'<input type="text" class="flat" name="search_debit" size="4" value="'.dol_escape_htmltag($search_debit).
'">';
1042if (!empty($arrayfields[
't.credit'][
'checked'])) {
1043 print
'<td class="liste_titre right">';
1044 print
'<input type="text" class="flat" name="search_credit" size="4" value="'.dol_escape_htmltag($search_credit).
'">';
1048if (!empty($arrayfields[
't.lettering_code'][
'checked'])) {
1049 print
'<td class="liste_titre center">';
1050 print
'<input type="text" size="3" class="flat" name="search_lettering_code" value="'.dol_escape_htmltag($search_lettering_code).
'"/>';
1051 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>';
1056$parameters = array(
'arrayfields' => $arrayfields);
1057$reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters);
1058print $hookmanager->resPrint;
1061if (!empty($arrayfields[
't.date_creation'][
'checked'])) {
1062 print
'<td class="liste_titre center">';
1063 print
'<div class="nowrapfordate">';
1064 print $form->selectDate($search_date_creation_start,
'search_date_creation_start', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"From"));
1066 print
'<div class="nowrapfordate">';
1067 print $form->selectDate($search_date_creation_end,
'search_date_creation_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"to"));
1072if (!empty($arrayfields[
't.tms'][
'checked'])) {
1073 print
'<td class="liste_titre center">';
1074 print
'<div class="nowrapfordate">';
1075 print $form->selectDate($search_date_modification_start,
'search_date_modification_start', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"From"));
1077 print
'<div class="nowrapfordate">';
1078 print $form->selectDate($search_date_modification_end,
'search_date_modification_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"From"));
1083if (!empty($arrayfields[
't.date_export'][
'checked'])) {
1084 print
'<td class="liste_titre center">';
1085 print
'<div class="nowrapfordate">';
1086 print $form->selectDate($search_date_export_start,
'search_date_export_start', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"From"));
1088 print
'<div class="nowrapfordate">';
1089 print $form->selectDate($search_date_export_end,
'search_date_export_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"to"));
1094if (!empty($arrayfields[
't.date_validated'][
'checked'])) {
1095 print
'<td class="liste_titre center">';
1096 print
'<div class="nowrapfordate">';
1097 print $form->selectDate($search_date_validation_start,
'search_date_validation_start', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"From"));
1099 print
'<div class="nowrapfordate">';
1100 print $form->selectDate($search_date_validation_end,
'search_date_validation_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"to"));
1104if (!empty($arrayfields[
't.import_key'][
'checked'])) {
1105 print
'<td class="liste_titre center">';
1106 print
'<input class="flat searchstring maxwidth50" type="text" name="search_import_key" value="'.dol_escape_htmltag($search_import_key).
'">';
1111 print
'<td class="liste_titre center">';
1112 $searchpicto = $form->showFilterButtons();
1118print
'<tr class="liste_titre">';
1120 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch actioncolumn ');
1122if (!empty($arrayfields[
't.piece_num'][
'checked'])) {
1123 print_liste_field_titre($arrayfields[
't.piece_num'][
'label'], $_SERVER[
'PHP_SELF'],
"t.piece_num",
"", $param,
"", $sortfield, $sortorder);
1125if (!empty($arrayfields[
't.code_journal'][
'checked'])) {
1126 print_liste_field_titre($arrayfields[
't.code_journal'][
'label'], $_SERVER[
'PHP_SELF'],
"t.code_journal",
"", $param,
'', $sortfield, $sortorder,
'center ');
1128if (!empty($arrayfields[
't.doc_date'][
'checked'])) {
1129 print_liste_field_titre($arrayfields[
't.doc_date'][
'label'], $_SERVER[
'PHP_SELF'],
"t.doc_date",
"", $param,
'', $sortfield, $sortorder,
'center ');
1131if (!empty($arrayfields[
't.doc_ref'][
'checked'])) {
1132 print_liste_field_titre($arrayfields[
't.doc_ref'][
'label'], $_SERVER[
'PHP_SELF'],
"t.doc_ref",
"", $param,
"", $sortfield, $sortorder);
1134if (!empty($arrayfields[
't.numero_compte'][
'checked'])) {
1135 print_liste_field_titre($arrayfields[
't.numero_compte'][
'label'], $_SERVER[
'PHP_SELF'],
"t.numero_compte",
"", $param,
"", $sortfield, $sortorder);
1137if (!empty($arrayfields[
't.subledger_account'][
'checked'])) {
1138 print_liste_field_titre($arrayfields[
't.subledger_account'][
'label'], $_SERVER[
'PHP_SELF'],
"t.subledger_account",
"", $param,
"", $sortfield, $sortorder);
1140if (!empty($arrayfields[
't.label_operation'][
'checked'])) {
1141 print_liste_field_titre($arrayfields[
't.label_operation'][
'label'], $_SERVER[
'PHP_SELF'],
"t.label_operation",
"", $param,
"", $sortfield, $sortorder);
1143if (!empty($arrayfields[
't.debit'][
'checked'])) {
1144 print_liste_field_titre($arrayfields[
't.debit'][
'label'], $_SERVER[
'PHP_SELF'],
"t.debit",
"", $param,
'', $sortfield, $sortorder,
'right ');
1146if (!empty($arrayfields[
't.credit'][
'checked'])) {
1147 print_liste_field_titre($arrayfields[
't.credit'][
'label'], $_SERVER[
'PHP_SELF'],
"t.credit",
"", $param,
'', $sortfield, $sortorder,
'right ');
1149if (!empty($arrayfields[
't.lettering_code'][
'checked'])) {
1150 print_liste_field_titre($arrayfields[
't.lettering_code'][
'label'], $_SERVER[
'PHP_SELF'],
"t.lettering_code",
"", $param,
'', $sortfield, $sortorder,
'center ');
1153$parameters = array(
'arrayfields' => $arrayfields,
'param' => $param,
'sortfield' => $sortfield,
'sortorder' => $sortorder);
1154$reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters);
1155print $hookmanager->resPrint;
1156if (!empty($arrayfields[
't.date_creation'][
'checked'])) {
1157 print_liste_field_titre($arrayfields[
't.date_creation'][
'label'], $_SERVER[
'PHP_SELF'],
"t.date_creation",
"", $param,
'', $sortfield, $sortorder,
'center ');
1159if (!empty($arrayfields[
't.tms'][
'checked'])) {
1160 print_liste_field_titre($arrayfields[
't.tms'][
'label'], $_SERVER[
'PHP_SELF'],
"t.tms",
"", $param,
'', $sortfield, $sortorder,
'center ');
1162if (!empty($arrayfields[
't.date_export'][
'checked'])) {
1163 print_liste_field_titre($arrayfields[
't.date_export'][
'label'], $_SERVER[
'PHP_SELF'],
"t.date_export,t.doc_date",
"", $param,
'', $sortfield, $sortorder,
'center ');
1165if (!empty($arrayfields[
't.date_validated'][
'checked'])) {
1166 print_liste_field_titre($arrayfields[
't.date_validated'][
'label'], $_SERVER[
'PHP_SELF'],
"t.date_validated,t.doc_date",
"", $param,
'', $sortfield, $sortorder,
'center ');
1168if (!empty($arrayfields[
't.import_key'][
'checked'])) {
1169 print_liste_field_titre($arrayfields[
't.import_key'][
'label'], $_SERVER[
"PHP_SELF"],
"t.import_key",
"", $param,
'', $sortfield, $sortorder,
'center ');
1172 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ');
1182$totalarray = array();
1183$totalarray[
'nbfield'] = 0;
1184$totalarray[
'val'] = array();
1185$totalarray[
'val'][
'totaldebit'] = 0;
1186$totalarray[
'val'][
'totalcredit'] = 0;
1188while ($i < min($num, $limit)) {
1189 $obj = $db->fetch_object($resql);
1194 $line->id = $obj->rowid;
1195 $line->doc_date = $db->jdate($obj->doc_date);
1196 $line->doc_type = $obj->doc_type;
1197 $line->doc_ref = $obj->doc_ref;
1198 $line->fk_doc = $obj->fk_doc;
1199 $line->fk_docdet = $obj->fk_docdet;
1200 $line->thirdparty_code = $obj->thirdparty_code;
1201 $line->subledger_account = $obj->subledger_account;
1202 $line->subledger_label = $obj->subledger_label;
1203 $line->numero_compte = $obj->numero_compte;
1204 $line->label_compte = $obj->label_compte;
1205 $line->label_operation = $obj->label_operation;
1206 $line->debit = $obj->debit;
1207 $line->credit = $obj->credit;
1208 $line->montant = $obj->amount;
1209 $line->amount = $obj->amount;
1210 $line->sens = $obj->sens;
1211 $line->lettering_code = $obj->lettering_code;
1212 $line->fk_user_author = $obj->fk_user_author;
1213 $line->import_key = $obj->import_key;
1214 $line->code_journal = $obj->code_journal;
1215 $line->journal_label = $obj->journal_label;
1216 $line->piece_num = $obj->piece_num;
1217 $line->date_creation = $db->jdate($obj->date_creation);
1218 $line->date_modification = $db->jdate($obj->date_modification);
1219 $line->date_export = $db->jdate($obj->date_export);
1220 $line->date_validation = $db->jdate($obj->date_validation);
1222 print
'<tr class="oddeven">';
1225 print
'<td class="nowraponall center">';
1226 if (($massactionbutton || $massaction) && $contextpage !=
'poslist') {
1228 if (in_array($line->id, $arrayofselected)) {
1231 print
'<input id="cb'.$line->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$line->id.
'"'.($selected ?
' checked="checked"' :
'').
' />';
1235 $totalarray[
'nbfield']++;
1240 if (!empty($arrayfields[
't.piece_num'][
'checked'])) {
1243 $object->piece_num = $line->piece_num;
1244 print
$object->getNomUrl(1,
'', 0,
'', 1);
1247 $totalarray[
'nbfield']++;
1252 if (!empty($arrayfields[
't.code_journal'][
'checked'])) {
1254 $result = $accountingjournal->fetch(0, $line->code_journal);
1255 $journaltoshow = (($result > 0) ? $accountingjournal->getNomUrl(0, 0, 0,
'', 0) : $line->code_journal);
1256 print
'<td class="center tdoverflowmax150">'.$journaltoshow.
'</td>';
1258 $totalarray[
'nbfield']++;
1263 if (!empty($arrayfields[
't.doc_date'][
'checked'])) {
1264 print
'<td class="center">'.dol_print_date($line->doc_date,
'day').
'</td>';
1266 $totalarray[
'nbfield']++;
1272 if (!empty($arrayfields[
't.doc_ref'][
'checked'])) {
1274 $objectstatic =
null;
1275 if ($line->doc_type ==
'customer_invoice') {
1276 $langs->loadLangs(array(
'bills'));
1278 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
1279 $objectstatic =
new Facture($db);
1280 $objectstatic->fetch($line->fk_doc);
1282 if ($objectstatic->id > 0) {
1285 $urlsource = $_SERVER[
'PHP_SELF'].
'?id='.$objectstatic->id;
1286 $documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir);
1288 } elseif ($line->doc_type ==
'supplier_invoice') {
1289 $langs->loadLangs(array(
'bills'));
1291 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
1293 $objectstatic->fetch($line->fk_doc);
1295 if ($objectstatic->id > 0) {
1296 $modulepart =
'invoice_supplier';
1298 $filedir =
$conf->fournisseur->facture->dir_output.
'/'.
get_exdir($line->fk_doc, 2, 0, 0, $objectstatic, $objectstatic->element).dol_sanitizeFileName($line->doc_ref);
1299 $subdir =
get_exdir($objectstatic->id, 2, 0, 0, $objectstatic, $objectstatic->element).dol_sanitizeFileName($line->doc_ref);
1300 $documentlink = $formfile->getDocumentsLink($objectstatic->element, $subdir, $filedir);
1302 } elseif ($line->doc_type ==
'expense_report') {
1303 $langs->loadLangs(array(
'trips'));
1305 require_once DOL_DOCUMENT_ROOT.
'/expensereport/class/expensereport.class.php';
1307 $objectstatic->fetch($line->fk_doc);
1309 if ($objectstatic->id > 0) {
1312 $urlsource = $_SERVER[
'PHP_SELF'].
'?id='.$objectstatic->id;
1313 $documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir);
1315 } elseif ($line->doc_type ==
'bank') {
1316 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
1318 $objectstatic->fetch($line->fk_doc);
1323 $labeltoshowhtml =
'';
1324 $labeltoshowalt =
'';
1325 if (($objectstatic instanceof
CommonObject) && in_array($line->doc_type, array(
'customer_invoice',
'supplier_invoice',
'expense_report'))) {
1326 if ($objectstatic->id > 0) {
1327 $labeltoshowhtml .= $objectstatic->getNomUrl(1,
'', 0, 0,
'', 0, -1, 1);
1328 $labeltoshowhtml .= $documentlink;
1329 $labeltoshowalt .= $objectstatic->ref;
1331 $labeltoshowhtml =
'<span class="opacitymedium">'.$langs->trans(
"Deleted").
'</span>';
1333 } elseif ($line->doc_type ==
'bank') {
1334 $labeltoshowhtml .= $objectstatic->getNomUrl(1);
1335 $labeltoshowalt .= $objectstatic->ref;
1336 $bank_ref = strstr($line->doc_ref,
'-');
1337 $labeltoshowhtml .=
" " . $bank_ref;
1338 $labeltoshowalt .=
" " . $bank_ref;
1340 $labeltoshowhtml .= $line->doc_ref;
1341 $labeltoshowalt .= $line->doc_ref;
1344 print
'<td class="nowraponall tdoverflowmax150" title="'.dolPrintHTMLForAttribute($labeltoshowalt).
'">';
1345 print $labeltoshowhtml;
1348 $totalarray[
'nbfield']++;
1353 if (!empty($arrayfields[
't.numero_compte'][
'checked'])) {
1354 print
'<td>'.length_accountg($line->numero_compte).
'</td>';
1356 $totalarray[
'nbfield']++;
1361 if (!empty($arrayfields[
't.subledger_account'][
'checked'])) {
1362 print
'<td>'.length_accounta($line->subledger_account).
'</td>';
1364 $totalarray[
'nbfield']++;
1369 if (!empty($arrayfields[
't.label_operation'][
'checked'])) {
1370 print
'<td class="small tdoverflowmax200" title="'.dol_escape_htmltag($line->label_operation).
'">'.
dol_escape_htmltag($line->label_operation).
'</td>';
1372 $totalarray[
'nbfield']++;
1377 if (!empty($arrayfields[
't.debit'][
'checked'])) {
1378 print
'<td class="right nowraponall amount">'.($line->debit != 0 ?
price($line->debit) :
'').
'</td>';
1380 $totalarray[
'nbfield']++;
1383 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'totaldebit';
1385 $totalarray[
'val'][
'totaldebit'] += $line->debit;
1389 if (!empty($arrayfields[
't.credit'][
'checked'])) {
1390 print
'<td class="right nowraponall amount">'.($line->credit != 0 ?
price($line->credit) :
'').
'</td>';
1392 $totalarray[
'nbfield']++;
1395 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'totalcredit';
1397 $totalarray[
'val'][
'totalcredit'] += $line->credit;
1401 if (!empty($arrayfields[
't.lettering_code'][
'checked'])) {
1402 print
'<td class="center">'.$line->lettering_code.
'</td>';
1404 $totalarray[
'nbfield']++;
1409 $parameters = array(
'arrayfields' => $arrayfields,
'obj' => $obj,
'i' => $i,
'totalarray' => &$totalarray);
1410 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters);
1411 print $hookmanager->resPrint;
1414 if (!empty($arrayfields[
't.date_creation'][
'checked'])) {
1415 print
'<td class="center">'.dol_print_date($line->date_creation,
'dayhour',
'tzuserrel').
'</td>';
1417 $totalarray[
'nbfield']++;
1422 if (!empty($arrayfields[
't.tms'][
'checked'])) {
1423 print
'<td class="center">'.dol_print_date($line->date_modification,
'dayhour',
'tzuserrel').
'</td>';
1425 $totalarray[
'nbfield']++;
1430 if (!empty($arrayfields[
't.date_export'][
'checked'])) {
1431 print
'<td class="center nowraponall">'.dol_print_date($line->date_export,
'dayhour',
'tzuserrel').
'</td>';
1433 $totalarray[
'nbfield']++;
1438 if (!empty($arrayfields[
't.date_validated'][
'checked'])) {
1439 print
'<td class="center nowraponall">'.dol_print_date($line->date_validation,
'dayhour',
'tzuserrel').
'</td>';
1441 $totalarray[
'nbfield']++;
1445 if (!empty($arrayfields[
't.import_key'][
'checked'])) {
1446 print
'<td class="tdoverflowmax100">'.$obj->import_key.
"</td>\n";
1448 $totalarray[
'nbfield']++;
1454 print
'<td class="nowraponall center">';
1455 if (($massactionbutton || $massaction) && $contextpage !=
'poslist') {
1457 if (in_array($line->id, $arrayofselected)) {
1460 print
'<input id="cb'.$line->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$line->id.
'"'.($selected ?
' checked="checked"' :
'').
' />';
1464 $totalarray[
'nbfield']++;
1475include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
1480 foreach ($arrayfields as $key => $val) {
1481 if (!empty($val[
'checked'])) {
1485 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
1488$parameters = array(
'arrayfields' => $arrayfields,
'sql' => $sql);
1489$reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object, $action);
1490print $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.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.