29 require
'../../main.inc.php';
30 require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountancyexport.class.php';
31 require_once DOL_DOCUMENT_ROOT.
'/core/lib/accounting.lib.php';
32 require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/lettering.class.php';
33 require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/bookkeeping.class.php';
34 require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountingjournal.class.php';
35 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
36 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
37 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formaccounting.class.php';
38 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
39 require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
42 $langs->loadLangs(array(
"accountancy",
"compta"));
44 $socid =
GETPOST(
'socid',
'int');
46 $action =
GETPOST(
'action',
'aZ09');
47 $massaction =
GETPOST(
'massaction',
'alpha');
48 $confirm =
GETPOST(
'confirm',
'alpha');
49 $toselect =
GETPOST(
'toselect',
'array');
50 $contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'bookkeepinglist';
51 $search_mvt_num =
GETPOST(
'search_mvt_num',
'int');
52 $search_doc_type =
GETPOST(
"search_doc_type",
'alpha');
53 $search_doc_ref =
GETPOST(
"search_doc_ref",
'alpha');
54 $search_date_startyear =
GETPOST(
'search_date_startyear',
'int');
55 $search_date_startmonth =
GETPOST(
'search_date_startmonth',
'int');
56 $search_date_startday =
GETPOST(
'search_date_startday',
'int');
57 $search_date_endyear =
GETPOST(
'search_date_endyear',
'int');
58 $search_date_endmonth =
GETPOST(
'search_date_endmonth',
'int');
59 $search_date_endday =
GETPOST(
'search_date_endday',
'int');
60 $search_date_start =
dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear);
61 $search_date_end =
dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear);
63 $search_date_creation_startyear =
GETPOST(
'search_date_creation_startyear',
'int');
64 $search_date_creation_startmonth =
GETPOST(
'search_date_creation_startmonth',
'int');
65 $search_date_creation_startday =
GETPOST(
'search_date_creation_startday',
'int');
66 $search_date_creation_endyear =
GETPOST(
'search_date_creation_endyear',
'int');
67 $search_date_creation_endmonth =
GETPOST(
'search_date_creation_endmonth',
'int');
68 $search_date_creation_endday =
GETPOST(
'search_date_creation_endday',
'int');
69 $search_date_creation_start =
dol_mktime(0, 0, 0, $search_date_creation_startmonth, $search_date_creation_startday, $search_date_creation_startyear);
70 $search_date_creation_end =
dol_mktime(23, 59, 59, $search_date_creation_endmonth, $search_date_creation_endday, $search_date_creation_endyear);
71 $search_date_modification_startyear =
GETPOST(
'search_date_modification_startyear',
'int');
72 $search_date_modification_startmonth =
GETPOST(
'search_date_modification_startmonth',
'int');
73 $search_date_modification_startday =
GETPOST(
'search_date_modification_startday',
'int');
74 $search_date_modification_endyear =
GETPOST(
'search_date_modification_endyear',
'int');
75 $search_date_modification_endmonth =
GETPOST(
'search_date_modification_endmonth',
'int');
76 $search_date_modification_endday =
GETPOST(
'search_date_modification_endday',
'int');
77 $search_date_modification_start =
dol_mktime(0, 0, 0, $search_date_modification_startmonth, $search_date_modification_startday, $search_date_modification_startyear);
78 $search_date_modification_end =
dol_mktime(23, 59, 59, $search_date_modification_endmonth, $search_date_modification_endday, $search_date_modification_endyear);
79 $search_date_export_startyear =
GETPOST(
'search_date_export_startyear',
'int');
80 $search_date_export_startmonth =
GETPOST(
'search_date_export_startmonth',
'int');
81 $search_date_export_startday =
GETPOST(
'search_date_export_startday',
'int');
82 $search_date_export_endyear =
GETPOST(
'search_date_export_endyear',
'int');
83 $search_date_export_endmonth =
GETPOST(
'search_date_export_endmonth',
'int');
84 $search_date_export_endday =
GETPOST(
'search_date_export_endday',
'int');
85 $search_date_export_start =
dol_mktime(0, 0, 0, $search_date_export_startmonth, $search_date_export_startday, $search_date_export_startyear);
86 $search_date_export_end =
dol_mktime(23, 59, 59, $search_date_export_endmonth, $search_date_export_endday, $search_date_export_endyear);
87 $search_date_validation_startyear =
GETPOST(
'search_date_validation_startyear',
'int');
88 $search_date_validation_startmonth =
GETPOST(
'search_date_validation_startmonth',
'int');
89 $search_date_validation_startday =
GETPOST(
'search_date_validation_startday',
'int');
90 $search_date_validation_endyear =
GETPOST(
'search_date_validation_endyear',
'int');
91 $search_date_validation_endmonth =
GETPOST(
'search_date_validation_endmonth',
'int');
92 $search_date_validation_endday =
GETPOST(
'search_date_validation_endday',
'int');
93 $search_date_validation_start =
dol_mktime(0, 0, 0, $search_date_validation_startmonth, $search_date_validation_startday, $search_date_validation_startyear);
94 $search_date_validation_end =
dol_mktime(23, 59, 59, $search_date_validation_endmonth, $search_date_validation_endday, $search_date_validation_endyear);
95 $search_import_key =
GETPOST(
"search_import_key",
'alpha');
99 $action =
'delbookkeepingyear';
101 if (
GETPOST(
"button_export_file_x") ||
GETPOST(
"button_export_file.x") ||
GETPOST(
"button_export_file")) {
102 $action =
'export_file';
105 $search_accountancy_code =
GETPOST(
"search_accountancy_code");
106 $search_accountancy_code_start =
GETPOST(
'search_accountancy_code_start',
'alpha');
107 if ($search_accountancy_code_start == - 1) {
108 $search_accountancy_code_start =
'';
110 $search_accountancy_code_end =
GETPOST(
'search_accountancy_code_end',
'alpha');
111 if ($search_accountancy_code_end == - 1) {
112 $search_accountancy_code_end =
'';
115 $search_accountancy_aux_code =
GETPOST(
"search_accountancy_aux_code",
'alpha');
116 $search_accountancy_aux_code_start =
GETPOST(
'search_accountancy_aux_code_start',
'alpha');
117 if ($search_accountancy_aux_code_start == - 1) {
118 $search_accountancy_aux_code_start =
'';
120 $search_accountancy_aux_code_end =
GETPOST(
'search_accountancy_aux_code_end',
'alpha');
121 if ($search_accountancy_aux_code_end == - 1) {
122 $search_accountancy_aux_code_end =
'';
124 $search_mvt_label =
GETPOST(
'search_mvt_label',
'alpha');
125 $search_direction =
GETPOST(
'search_direction',
'alpha');
126 $search_debit =
GETPOST(
'search_debit',
'alpha');
127 $search_credit =
GETPOST(
'search_credit',
'alpha');
128 $search_ledger_code =
GETPOST(
'search_ledger_code',
'array');
129 $search_lettering_code =
GETPOST(
'search_lettering_code',
'alpha');
130 $search_not_reconciled =
GETPOST(
'search_not_reconciled',
'alpha');
133 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : (empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION) ? $conf->liste_limit : $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION);
134 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
135 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
136 $optioncss =
GETPOST(
'optioncss',
'alpha');
138 if (empty($page) || $page < 0) {
141 $offset = $limit * $page;
142 $pageprev = $page - 1;
143 $pagenext = $page + 1;
144 if ($sortorder ==
"") {
147 if ($sortfield ==
"") {
148 $sortfield =
"t.piece_num,t.rowid";
153 $hookmanager->initHooks(array(
'bookkeepinglist'));
158 if (!in_array($action, array(
'export_file',
'delmouv',
'delmouvconfirm')) && !
GETPOSTISSET(
'begin') && !
GETPOSTISSET(
'formfilteraction') &&
GETPOST(
'page',
'int') ==
'' && !
GETPOST(
'noreset',
'int') && $user->hasRight(
'accounting',
'mouvements',
'export')) {
159 if (empty($search_date_start) && empty($search_date_end) && !
GETPOSTISSET(
'restore_lastsearch_values') && !
GETPOST(
'search_accountancy_code_start')) {
160 $query =
"SELECT date_start, date_end from ".MAIN_DB_PREFIX.
"accounting_fiscalyear ";
161 $query .=
" where date_start < '".$db->idate(
dol_now()).
"' and date_end > '".$db->idate(
dol_now()).
"' limit 1";
162 $res = $db->query($query);
164 if ($res->num_rows > 0) {
165 $fiscalYear = $db->fetch_object($res);
166 $search_date_start = strtotime($fiscalYear->date_start);
167 $search_date_end = strtotime($fiscalYear->date_end);
169 $month_start = ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1);
174 $year_end = $year_start + 1;
175 $month_end = $month_start - 1;
176 if ($month_end < 1) {
180 $search_date_start =
dol_mktime(0, 0, 0, $month_start, 1, $year_start);
187 $arrayfields = array(
188 't.piece_num'=>array(
'label'=>$langs->trans(
"TransactionNumShort"),
'checked'=>1),
189 't.code_journal'=>array(
'label'=>$langs->trans(
"Codejournal"),
'checked'=>1),
190 't.doc_date'=>array(
'label'=>$langs->trans(
"Docdate"),
'checked'=>1),
191 't.doc_ref'=>array(
'label'=>$langs->trans(
"Piece"),
'checked'=>1),
192 't.numero_compte'=>array(
'label'=>$langs->trans(
"AccountAccountingShort"),
'checked'=>1),
193 't.subledger_account'=>array(
'label'=>$langs->trans(
"SubledgerAccount"),
'checked'=>1),
194 't.label_operation'=>array(
'label'=>$langs->trans(
"Label"),
'checked'=>1),
195 't.debit'=>array(
'label'=>$langs->trans(
"AccountingDebit"),
'checked'=>1),
196 't.credit'=>array(
'label'=>$langs->trans(
"AccountingCredit"),
'checked'=>1),
197 't.lettering_code'=>array(
'label'=>$langs->trans(
"LetteringCode"),
'checked'=>1),
198 't.date_creation'=>array(
'label'=>$langs->trans(
"DateCreation"),
'checked'=>0),
199 't.tms'=>array(
'label'=>$langs->trans(
"DateModification"),
'checked'=>0),
200 't.date_export'=>array(
'label'=>$langs->trans(
"DateExport"),
'checked'=>1),
201 't.date_validated'=>array(
'label'=>$langs->trans(
"DateValidationAndLock"),
'checked'=>1,
'enabled'=>!
getDolGlobalString(
"ACCOUNTANCY_DISABLE_CLOSURE_LINE_BY_LINE")),
202 't.import_key'=>array(
'label'=>$langs->trans(
"ImportId"),
'checked'=>0,
'position'=>1100),
205 if (empty($conf->global->ACCOUNTING_ENABLE_LETTERING)) {
206 unset($arrayfields[
't.lettering_code']);
210 $listofformat = $accountancyexport->getType();
212 if (empty($listofformat[$formatexportset])) {
213 $formatexportset = 1;
221 if ($user->socid > 0) {
224 if (!$user->hasRight(
'accounting',
'mouvements',
'lire')) {
235 if (
GETPOST(
'cancel',
'alpha')) {
236 $action =
'list'; $massaction =
'';
238 if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'preunletteringauto' && $massaction !=
'preunletteringmanual' && $massaction !=
'predeletebookkeepingwriting') {
242 $parameters = array(
'socid'=>$socid);
243 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
248 if (empty($reshook)) {
249 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
251 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
252 $search_mvt_num =
'';
253 $search_doc_type =
'';
254 $search_doc_ref =
'';
255 $search_doc_date =
'';
256 $search_accountancy_code =
'';
257 $search_accountancy_code_start =
'';
258 $search_accountancy_code_end =
'';
259 $search_accountancy_aux_code =
'';
260 $search_accountancy_aux_code_start =
'';
261 $search_accountancy_aux_code_end =
'';
262 $search_mvt_label =
'';
263 $search_direction =
'';
264 $search_ledger_code = array();
265 $search_date_startyear =
'';
266 $search_date_startmonth =
'';
267 $search_date_startday =
'';
268 $search_date_endyear =
'';
269 $search_date_endmonth =
'';
270 $search_date_endday =
'';
271 $search_date_start =
'';
272 $search_date_end =
'';
273 $search_date_creation_startyear =
'';
274 $search_date_creation_startmonth =
'';
275 $search_date_creation_startday =
'';
276 $search_date_creation_endyear =
'';
277 $search_date_creation_endmonth =
'';
278 $search_date_creation_endday =
'';
279 $search_date_creation_start =
'';
280 $search_date_creation_end =
'';
281 $search_date_modification_startyear =
'';
282 $search_date_modification_startmonth =
'';
283 $search_date_modification_startday =
'';
284 $search_date_modification_endyear =
'';
285 $search_date_modification_endmonth =
'';
286 $search_date_modification_endday =
'';
287 $search_date_modification_start =
'';
288 $search_date_modification_end =
'';
289 $search_date_export_startyear =
'';
290 $search_date_export_startmonth =
'';
291 $search_date_export_startday =
'';
292 $search_date_export_endyear =
'';
293 $search_date_export_endmonth =
'';
294 $search_date_export_endday =
'';
295 $search_date_export_start =
'';
296 $search_date_export_end =
'';
297 $search_date_validation_startyear =
'';
298 $search_date_validation_startmonth =
'';
299 $search_date_validation_startday =
'';
300 $search_date_validation_endyear =
'';
301 $search_date_validation_endmonth =
'';
302 $search_date_validation_endday =
'';
303 $search_date_validation_start =
'';
304 $search_date_validation_end =
'';
307 $search_lettering_code =
'';
308 $search_not_reconciled =
'';
309 $search_import_key =
'';
315 if (!empty($search_date_start)) {
316 $filter[
't.doc_date>='] = $search_date_start;
318 $param .=
'&search_date_startmonth='.urlencode($tmp[
'mon']).
'&search_date_startday='.urlencode($tmp[
'mday']).
'&search_date_startyear='.urlencode($tmp[
'year']);
320 if (!empty($search_date_end)) {
321 $filter[
't.doc_date<='] = $search_date_end;
323 $param .=
'&search_date_endmonth='.urlencode($tmp[
'mon']).
'&search_date_endday='.urlencode($tmp[
'mday']).
'&search_date_endyear='.urlencode($tmp[
'year']);
325 if (!empty($search_doc_date)) {
326 $filter[
't.doc_date'] = $search_doc_date;
328 $param .=
'&doc_datemonth='.urlencode($tmp[
'mon']).
'&doc_dateday='.urlencode($tmp[
'mday']).
'&doc_dateyear='.urlencode($tmp[
'year']);
330 if (!empty($search_doc_type)) {
331 $filter[
't.doc_type'] = $search_doc_type;
332 $param .=
'&search_doc_type='.urlencode($search_doc_type);
334 if (!empty($search_doc_ref)) {
335 $filter[
't.doc_ref'] = $search_doc_ref;
336 $param .=
'&search_doc_ref='.urlencode($search_doc_ref);
338 if (!empty($search_accountancy_code)) {
339 $filter[
't.numero_compte'] = $search_accountancy_code;
340 $param .=
'&search_accountancy_code='.urlencode($search_accountancy_code);
342 if (!empty($search_accountancy_code_start)) {
343 $filter[
't.numero_compte>='] = $search_accountancy_code_start;
344 $param .=
'&search_accountancy_code_start='.urlencode($search_accountancy_code_start);
346 if (!empty($search_accountancy_code_end)) {
347 $filter[
't.numero_compte<='] = $search_accountancy_code_end;
348 $param .=
'&search_accountancy_code_end='.urlencode($search_accountancy_code_end);
350 if (!empty($search_accountancy_aux_code)) {
351 $filter[
't.subledger_account'] = $search_accountancy_aux_code;
352 $param .=
'&search_accountancy_aux_code='.urlencode($search_accountancy_aux_code);
354 if (!empty($search_accountancy_aux_code_start)) {
355 $filter[
't.subledger_account>='] = $search_accountancy_aux_code_start;
356 $param .=
'&search_accountancy_aux_code_start='.urlencode($search_accountancy_aux_code_start);
358 if (!empty($search_accountancy_aux_code_end)) {
359 $filter[
't.subledger_account<='] = $search_accountancy_aux_code_end;
360 $param .=
'&search_accountancy_aux_code_end='.urlencode($search_accountancy_aux_code_end);
362 if (!empty($search_mvt_label)) {
363 $filter[
't.label_operation'] = $search_mvt_label;
364 $param .=
'&search_mvt_label='.urlencode($search_mvt_label);
366 if (!empty($search_direction)) {
367 $filter[
't.sens'] = $search_direction;
368 $param .=
'&search_direction='.urlencode($search_direction);
370 if (!empty($search_ledger_code)) {
371 $filter[
't.code_journal'] = $search_ledger_code;
372 foreach ($search_ledger_code as $code) {
373 $param .=
'&search_ledger_code[]='.urlencode($code);
376 if (!empty($search_mvt_num)) {
377 $filter[
't.piece_num'] = $search_mvt_num;
378 $param .=
'&search_mvt_num='.urlencode($search_mvt_num);
380 if (!empty($search_date_creation_start)) {
381 $filter[
't.date_creation>='] = $search_date_creation_start;
383 $param .=
'&search_date_creation_startmonth='.urlencode($tmp[
'mon']).
'&search_date_creation_startday='.urlencode($tmp[
'mday']).
'&search_date_creation_startyear='.urlencode($tmp[
'year']);
385 if (!empty($search_date_creation_end)) {
386 $filter[
't.date_creation<='] = $search_date_creation_end;
388 $param .=
'&search_date_creation_endmonth='.urlencode($tmp[
'mon']).
'&search_date_creation_endday='.urlencode($tmp[
'mday']).
'&search_date_creation_endyear='.urlencode($tmp[
'year']);
390 if (!empty($search_date_modification_start)) {
391 $filter[
't.tms>='] = $search_date_modification_start;
392 $tmp =
dol_getdate($search_date_modification_start);
393 $param .=
'&search_date_modification_startmonth='.urlencode($tmp[
'mon']).
'&search_date_modification_startday='.urlencode($tmp[
'mday']).
'&search_date_modification_startyear='.urlencode($tmp[
'year']);
395 if (!empty($search_date_modification_end)) {
396 $filter[
't.tms<='] = $search_date_modification_end;
398 $param .=
'&search_date_modification_endmonth='.urlencode($tmp[
'mon']).
'&search_date_modification_endday='.urlencode($tmp[
'mday']).
'&search_date_modification_endyear='.urlencode($tmp[
'year']);
400 if (!empty($search_date_export_start)) {
401 $filter[
't.date_export>='] = $search_date_export_start;
403 $param .=
'&search_date_export_startmonth='.urlencode($tmp[
'mon']).
'&search_date_export_startday='.urlencode($tmp[
'mday']).
'&search_date_export_startyear='.urlencode($tmp[
'year']);
405 if (!empty($search_date_export_end)) {
406 $filter[
't.date_export<='] = $search_date_export_end;
408 $param .=
'&search_date_export_endmonth='.urlencode($tmp[
'mon']).
'&search_date_export_endday='.urlencode($tmp[
'mday']).
'&search_date_export_endyear='.urlencode($tmp[
'year']);
410 if (!empty($search_date_validation_start)) {
411 $filter[
't.date_validated>='] = $search_date_validation_start;
413 $param .=
'&search_date_validation_startmonth='.urlencode($tmp[
'mon']).
'&search_date_validation_startday='.urlencode($tmp[
'mday']).
'&search_date_validation_startyear='.urlencode($tmp[
'year']);
415 if (!empty($search_date_validation_end)) {
416 $filter[
't.date_validated<='] = $search_date_validation_end;
418 $param .=
'&search_date_validation_endmonth='.urlencode($tmp[
'mon']).
'&search_date_validation_endday='.urlencode($tmp[
'mday']).
'&search_date_validation_endyear='.urlencode($tmp[
'year']);
420 if (!empty($search_debit)) {
421 $filter[
't.debit'] = $search_debit;
422 $param .=
'&search_debit='.urlencode($search_debit);
424 if (!empty($search_credit)) {
425 $filter[
't.credit'] = $search_credit;
426 $param .=
'&search_credit='.urlencode($search_credit);
428 if (!empty($search_lettering_code)) {
429 $filter[
't.lettering_code'] = $search_lettering_code;
430 $param .=
'&search_lettering_code='.urlencode($search_lettering_code);
432 if (!empty($search_not_reconciled)) {
433 $filter[
't.reconciled_option'] = $search_not_reconciled;
434 $param .=
'&search_not_reconciled='.urlencode($search_not_reconciled);
436 if (!empty($search_import_key)) {
437 $filter[
't.import_key'] = $search_import_key;
438 $param .=
'&search_import_key='.urlencode($search_import_key);
467 if ($action ==
'setreexport') {
468 $setreexport =
GETPOST(
'value',
'int');
469 if (!
dolibarr_set_const($db,
"ACCOUNTING_REEXPORT", $setreexport,
'yesno', 0,
'', $conf->entity)) {
474 if ($conf->global->ACCOUNTING_REEXPORT == 1) {
475 setEventMessages($langs->trans(
"ExportOfPiecesAlreadyExportedIsEnable"),
null,
'mesgs');
477 setEventMessages($langs->trans(
"ExportOfPiecesAlreadyExportedIsDisable"),
null,
'warnings');
485 $objectclass =
'Bookkeeping';
486 $objectlabel =
'Bookkeeping';
487 $permissiontoread = $user->hasRight(
'societe',
'lire');
488 $permissiontodelete = $user->hasRight(
'societe',
'supprimer');
489 $permissiontoadd = $user->rights->societe->creer;
490 $uploaddir = $conf->societe->dir_output;
491 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
493 if (!$error && $action ==
'deletebookkeepingwriting' && $confirm ==
"yes" && $user->hasRight(
'accounting',
'mouvements',
'supprimer')) {
498 $nb_lettering = $lettering->bookkeepingLetteringAll($toselect,
true);
499 if ($nb_lettering < 0) {
507 foreach ($toselect as $toselectid) {
508 $result = $object->fetch($toselectid);
509 if ($result > 0 && (!isset($object->date_validation) || $object->date_validation ===
'')) {
510 $result = $object->deleteMvtNum($object->piece_num);
518 } elseif ($result < 0) {
522 } elseif (isset($object->date_validation) || $object->date_validation !=
'') {
523 setEventMessages($langs->trans(
"ValidatedRecordWhereFound"),
null,
'errors');
536 } elseif ($nbok > 0) {
542 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?noreset=1".($param ?
'&'.$param :
''));
550 if (!$error &&
getDolGlobalInt(
'ACCOUNTING_ENABLE_LETTERING') && $user->hasRight(
'accounting',
'mouvements',
'creer')) {
551 if ($massaction ==
'letteringauto') {
553 $nb_lettering = $lettering->bookkeepingLetteringAll($toselect);
554 if ($nb_lettering < 0) {
557 $nb_lettering = max(0, abs($nb_lettering) - 2);
558 } elseif ($nb_lettering == 0) {
560 setEventMessages($langs->trans(
'AccountancyNoLetteringModified'), array(),
'mesgs');
562 if ($nb_lettering == 1) {
563 setEventMessages($langs->trans(
'AccountancyOneLetteringModifiedSuccessfully'), array(),
'mesgs');
564 } elseif ($nb_lettering > 1) {
565 setEventMessages($langs->trans(
'AccountancyLetteringModifiedSuccessfully', $nb_lettering), array(),
'mesgs');
569 header(
'Location: ' . $_SERVER[
'PHP_SELF'] .
'?noreset=1' . $param);
572 } elseif ($massaction ==
'letteringmanual') {
574 $result = $lettering->updateLettering($toselect);
578 setEventMessages($langs->trans(
'AccountancyOneLetteringModifiedSuccessfully'), array(),
'mesgs');
579 header(
'Location: ' . $_SERVER[
'PHP_SELF'] .
'?noreset=1' . $param);
582 } elseif ($action ==
'unletteringauto' && $confirm ==
"yes") {
584 $nb_lettering = $lettering->bookkeepingLetteringAll($toselect,
true);
585 if ($nb_lettering < 0) {
588 $nb_lettering = max(0, abs($nb_lettering) - 2);
589 } elseif ($nb_lettering == 0) {
591 setEventMessages($langs->trans(
'AccountancyNoUnletteringModified'), array(),
'mesgs');
593 if ($nb_lettering == 1) {
594 setEventMessages($langs->trans(
'AccountancyOneUnletteringModifiedSuccessfully'), array(),
'mesgs');
595 } elseif ($nb_lettering > 1) {
596 setEventMessages($langs->trans(
'AccountancyUnletteringModifiedSuccessfully', $nb_lettering), array(),
'mesgs');
600 header(
'Location: ' . $_SERVER[
'PHP_SELF'] .
'?noreset=1' . $param);
603 } elseif ($action ==
'unletteringmanual' && $confirm ==
"yes") {
605 $nb_lettering = $lettering->deleteLettering($toselect);
609 setEventMessages($langs->trans(
'AccountancyOneUnletteringModifiedSuccessfully'), array(),
'mesgs');
610 header(
'Location: ' . $_SERVER[
'PHP_SELF'] .
'?noreset=1' . $param);
623 $sql .=
" t.doc_date,";
624 $sql .=
" t.doc_type,";
625 $sql .=
" t.doc_ref,";
626 $sql .=
" t.fk_doc,";
627 $sql .=
" t.fk_docdet,";
628 $sql .=
" t.thirdparty_code,";
629 $sql .=
" t.subledger_account,";
630 $sql .=
" t.subledger_label,";
631 $sql .=
" t.numero_compte,";
632 $sql .=
" t.label_compte,";
633 $sql .=
" t.label_operation,";
635 $sql .=
" t.credit,";
636 $sql .=
" t.lettering_code,";
637 $sql .=
" t.montant as amount,";
639 $sql .=
" t.fk_user_author,";
640 $sql .=
" t.import_key,";
641 $sql .=
" t.code_journal,";
642 $sql .=
" t.journal_label,";
643 $sql .=
" t.piece_num,";
644 $sql .=
" t.date_creation,";
645 $sql .=
" t.tms as date_modification,";
646 $sql .=
" t.date_export,";
647 $sql .=
" t.date_validated as date_validation,";
648 $sql .=
" t.import_key";
649 $sql .=
' FROM '.MAIN_DB_PREFIX.$object->table_element.
' as t';
652 if (count($filter) > 0) {
653 foreach ($filter as $key => $value) {
654 if ($key ==
't.doc_date') {
655 $sqlwhere[] = $key.
"='".$db->idate($value).
"'";
656 } elseif ($key ==
't.doc_date>=' || $key ==
't.doc_date<=') {
657 $sqlwhere[] = $key.
"'".$db->idate($value).
"'";
658 } elseif ($key ==
't.numero_compte>=' || $key ==
't.numero_compte<=' || $key ==
't.subledger_account>=' || $key ==
't.subledger_account<=') {
659 $sqlwhere[] = $key.
"'".$db->escape($value).
"'";
660 } elseif ($key ==
't.fk_doc' || $key ==
't.fk_docdet' || $key ==
't.piece_num') {
661 $sqlwhere[] = $key.
'='.((int) $value);
662 } elseif ($key ==
't.subledger_account' || $key ==
't.numero_compte') {
663 $sqlwhere[] = $key.
" LIKE '".$db->escape($value).
"%'";
664 } elseif ($key ==
't.subledger_account') {
666 } elseif ($key ==
't.date_creation>=' || $key ==
't.date_creation<=') {
667 $sqlwhere[] = $key.
"'".$db->idate($value).
"'";
668 } elseif ($key ==
't.tms>=' || $key ==
't.tms<=') {
669 $sqlwhere[] = $key.
"'".$db->idate($value).
"'";
670 } elseif ($key ==
't.date_export>=' || $key ==
't.date_export<=') {
671 $sqlwhere[] = $key.
"'".$db->idate($value).
"'";
672 } elseif ($key ==
't.date_validated>=' || $key ==
't.date_validated<=') {
673 $sqlwhere[] = $key.
"'".$db->idate($value).
"'";
674 } elseif ($key ==
't.credit' || $key ==
't.debit') {
676 } elseif ($key ==
't.reconciled_option') {
677 $sqlwhere[] =
't.lettering_code IS NULL';
678 } elseif ($key ==
't.code_journal' && !empty($value)) {
679 $sqlwhere[] =
natural_search(
"t.code_journal", join(
',', $value), 3, 1);
685 $sql .=
' WHERE t.entity IN ('.getEntity(
'accountancy').
')';
686 if (empty($conf->global->ACCOUNTING_REEXPORT)) {
687 $sql .=
" AND t.date_export IS NULL";
689 if (count($sqlwhere) > 0) {
690 $sql .=
' AND '.implode(
' AND ', $sqlwhere);
692 if (!empty($sortfield)) {
693 $sql .= $db->order($sortfield, $sortorder);
700 if ($action ==
'export_fileconfirm' && $user->hasRight(
'accounting',
'mouvements',
'export')) {
703 $result = $object->fetchAll($sortorder, $sortfield, 0, 0, $filter,
'AND', (empty($conf->global->ACCOUNTING_REEXPORT) ? 0 : 1));
711 $notexportlettering =
GETPOST(
'notexportlettering',
'alpha');
713 if (!empty($notexportlettering)) {
714 if (is_array($object->lines)) {
715 foreach ($object->lines as $k => $movement) {
716 unset($object->lines[$k]->lettering_code);
717 unset($object->lines[$k]->date_lettering);
722 $mimetype = $accountancyexport->getMimeType($formatexportset);
727 $accountancyexport->export($object->lines, $formatexportset);
729 $notifiedexportdate =
GETPOST(
'notifiedexportdate',
'alpha');
730 $notifiedvalidationdate =
GETPOST(
'notifiedvalidationdate',
'alpha');
732 if (!empty($accountancyexport->errors)) {
734 } elseif (!empty($notifiedexportdate) || !empty($notifiedvalidationdate)) {
739 if (is_array($object->lines)) {
740 foreach ($object->lines as $movement) {
743 $sql =
" UPDATE ".MAIN_DB_PREFIX.
"accounting_bookkeeping";
745 if (!empty($notifiedexportdate) && !empty($notifiedvalidationdate)) {
746 $sql .=
" date_export = '".$db->idate($now).
"'";
747 $sql .=
", date_validated = '".$db->idate($now).
"'";
748 } elseif (!empty($notifiedexportdate)) {
749 $sql .=
" date_export = '".$db->idate($now).
"'";
750 } elseif (!empty($notifiedvalidationdate)) {
751 $sql .=
" date_validated = '".$db->idate($now).
"'";
753 $sql .=
" WHERE rowid = ".((int) $movement->id);
755 dol_syslog(
"/accountancy/bookkeeping/list.php Function export_file Specify movements as exported", LOG_DEBUG);
757 $result = $db->query($sql);
770 dol_print_error(
'', $langs->trans(
"NotAllExportedMovementsCouldBeRecordedAsExportedOrValidated"));
785 $title_page = $langs->trans(
"Operations").
' - '.$langs->trans(
"Journals");
789 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
790 $resql = $db->query($sql);
801 $sql .= $db->plimit($limit + 1, $offset);
803 $resql = $db->query($sql);
809 $num = $db->num_rows(
$resql);
812 $arrayofselected = is_array($toselect) ? $toselect : array();
821 if ($action ==
'export_file') {
822 $form_question = array();
824 $form_question[
'notexportlettering'] = array(
825 'name' =>
'notexportlettering',
828 'value' => $langs->trans(
'Modelcsv').
' : <b>'.$listofformat[$formatexportset].
'</b>'
831 $form_question[
'separator0'] = array(
'name'=>
'separator0',
'type'=>
'separator');
835 $checked = !empty($conf->global->ACCOUNTING_DEFAULT_NOT_EXPORT_LETTERING) ?
'true' :
'false';
836 $form_question[
'notexportlettering'] = array(
837 'name' =>
'notexportlettering',
838 'type' =>
'checkbox',
839 'label' => $langs->trans(
'NotExportLettering'),
843 $form_question[
'separator1'] = array(
'name'=>
'separator1',
'type'=>
'separator');
847 $checked = (!isset($conf->global->ACCOUNTING_DEFAULT_NOT_NOTIFIED_EXPORT_DATE) || !empty($conf->global->ACCOUNTING_DEFAULT_NOT_NOTIFIED_EXPORT_DATE));
848 $form_question[
'notifiedexportdate'] = array(
849 'name' =>
'notifiedexportdate',
850 'type' =>
'checkbox',
851 'label' => $langs->trans(
'NotifiedExportDate'),
852 'value' => (!empty($conf->global->ACCOUNTING_DEFAULT_NOT_NOTIFIED_EXPORT_DATE) ?
'false' :
'true'),
855 $form_question[
'separator2'] = array(
'name'=>
'separator2',
'type'=>
'separator');
859 $checked = (isset($conf->global->ACCOUNTING_DEFAULT_NOT_NOTIFIED_VALIDATION_DATE) || !empty($conf->global->ACCOUNTING_DEFAULT_NOT_NOTIFIED_VALIDATION_DATE));
860 $form_question[
'notifiedvalidationdate'] = array(
861 'name' =>
'notifiedvalidationdate',
862 'type' =>
'checkbox',
863 'label' => $langs->trans(
'NotifiedValidationDate', $langs->transnoentitiesnoconv(
"MenuAccountancyClosure")),
867 $form_question[
'separator3'] = array(
'name'=>
'separator3',
'type'=>
'separator');
870 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?'.$param, $langs->trans(
"ExportFilteredList").
'...', $langs->trans(
'ConfirmExportFile'),
'export_fileconfirm', $form_question,
'', 1, 350, 600);
918 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
919 $param .=
'&contextpage='.urlencode($contextpage);
921 if ($limit > 0 && $limit != $conf->liste_limit) {
922 $param .=
'&limit='.urlencode($limit);
926 $arrayofmassactions = array();
927 if (
getDolGlobalInt(
'ACCOUNTING_ENABLE_LETTERING') && $user->rights->accounting->mouvements->creer) {
928 $arrayofmassactions[
'letteringauto'] =
img_picto(
'',
'check',
'class="pictofixedwidth"') . $langs->trans(
'LetteringAuto');
929 $arrayofmassactions[
'preunletteringauto'] =
img_picto(
'',
'uncheck',
'class="pictofixedwidth"') . $langs->trans(
'UnletteringAuto');
930 $arrayofmassactions[
'letteringmanual'] =
img_picto(
'',
'check',
'class="pictofixedwidth"') . $langs->trans(
'LetteringManual');
931 $arrayofmassactions[
'preunletteringmanual'] =
img_picto(
'',
'uncheck',
'class="pictofixedwidth"') . $langs->trans(
'UnletteringManual');
933 if ($user->hasRight(
'accounting',
'mouvements',
'supprimer')) {
934 $arrayofmassactions[
'predeletebookkeepingwriting'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
936 if (
GETPOST(
'nomassaction',
'int') || in_array($massaction, array(
'preunletteringauto',
'preunletteringmanual',
'predeletebookkeepingwriting'))) {
937 $arrayofmassactions = array();
939 $massactionbutton =
$form->selectMassAction($massaction, $arrayofmassactions);
941 print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">';
942 print
'<input type="hidden" name="token" value="'.newToken().
'">';
943 print
'<input type="hidden" name="action" value="list">';
944 if ($optioncss !=
'') {
945 print
'<input type="hidden" name="optioncss" value="'.urlencode($optioncss).
'">';
947 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
948 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
949 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
950 print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
952 if (count($filter)) {
953 $buttonLabel = $langs->trans(
"ExportFilteredList");
955 $buttonLabel = $langs->trans(
"ExportList");
958 $parameters = array(
'param' => $param);
959 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtonsList', $parameters, $object, $action);
964 $newcardbutton = empty($hookmanager->resPrint) ?
'' : $hookmanager->resPrint;
966 if (empty($reshook)) {
968 if (!empty($conf->global->ACCOUNTING_REEXPORT)) {
969 $newcardbutton .=
'<a class="valignmiddle" href="'.$_SERVER[
'PHP_SELF'].
'?action=setreexport&token='.
newToken().
'&value=0'.($param ?
'&'.$param :
'').
'">'.
img_picto($langs->trans(
"ClickToHideAlreadyExportedLines"),
'switch_off',
'class="small size15x valignmiddle"');
970 $newcardbutton .=
'<span class="valignmiddle marginrightonly paddingleft">'.$langs->trans(
"ClickToHideAlreadyExportedLines").
'</span>';
971 $newcardbutton .=
'</a>';
973 $newcardbutton .=
'<a class="valignmiddle" href="'.$_SERVER[
'PHP_SELF'].
'?action=setreexport&token='.
newToken().
'&value=1'.($param ?
'&'.$param :
'').
'">'.
img_picto($langs->trans(
"DocsAlreadyExportedAreExcluded"),
'switch_on',
'class="warning size15x valignmiddle"');
974 $newcardbutton .=
'<span class="valignmiddle marginrightonly paddingleft">'.$langs->trans(
"DocsAlreadyExportedAreExcluded").
'</span>';
975 $newcardbutton .=
'</a>';
978 if ($user->hasRight(
'accounting',
'mouvements',
'export')) {
979 $newcardbutton .=
dolGetButtonTitle($buttonLabel, $langs->trans(
"ExportFilteredList").
' ('.$listofformat[$formatexportset].
')',
'fa fa-file-export paddingleft', $_SERVER[
"PHP_SELF"].
'?action=export_file&token='.
newToken().($param ?
'&'.$param :
''), $user->hasRight(
'accounting',
'mouvements',
'export'));
982 $newcardbutton .=
dolGetButtonTitle($langs->trans(
'ViewFlatList'),
'',
'fa fa-list paddingleft imgforviewmode', DOL_URL_ROOT.
'/accountancy/bookkeeping/list.php?'.$param,
'', 1, array(
'morecss' =>
'marginleftonly btnTitleSelected'));
983 $newcardbutton .=
dolGetButtonTitle($langs->trans(
'GroupByAccountAccounting'),
'',
'fa fa-stream paddingleft imgforviewmode', DOL_URL_ROOT.
'/accountancy/bookkeeping/listbyaccount.php?'.$param,
'', 1, array(
'morecss' =>
'marginleftonly'));
984 $newcardbutton .=
dolGetButtonTitle($langs->trans(
'GroupBySubAccountAccounting'),
'',
'fa fa-align-left vmirror paddingleft imgforviewmode', DOL_URL_ROOT.
'/accountancy/bookkeeping/listbyaccount.php?type=sub'.$param,
'', 1, array(
'morecss' =>
'marginleftonly'));
986 $url =
'./card.php?action=create';
987 if (!empty($socid)) {
988 $url .=
'&socid='.$socid;
990 $newcardbutton .=
dolGetButtonTitle($langs->trans(
'NewAccountingMvt'),
'',
'fa fa-plus-circle paddingleft', $url,
'', $user->hasRight(
'accounting',
'mouvements',
'creer'));
993 print_barre_liste($title_page, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num,
$nbtotalofrecords,
'title_accountancy', 0, $newcardbutton,
'', $limit, 0, 0, 1);
995 if ($massaction ==
'preunletteringauto') {
996 print
$form->formconfirm($_SERVER[
"PHP_SELF"], $langs->trans(
"ConfirmMassUnletteringAuto"), $langs->trans(
"ConfirmMassUnletteringQuestion", count($toselect)),
"unletteringauto",
null,
'', 0, 200, 500, 1);
997 } elseif ($massaction ==
'preunletteringmanual') {
998 print
$form->formconfirm($_SERVER[
"PHP_SELF"], $langs->trans(
"ConfirmMassUnletteringManual"), $langs->trans(
"ConfirmMassUnletteringQuestion", count($toselect)),
"unletteringmanual",
null,
'', 0, 200, 500, 1);
999 } elseif ($massaction ==
'predeletebookkeepingwriting') {
1000 print
$form->formconfirm($_SERVER[
"PHP_SELF"], $langs->trans(
"ConfirmMassDeleteBookkeepingWriting"), $langs->trans(
"ConfirmMassDeleteBookkeepingWritingQuestion", count($toselect)),
"deletebookkeepingwriting",
null,
'', 0, 200, 500, 1);
1007 include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
1009 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
1010 $selectedfields =
$form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN',
''));
1011 if ($massactionbutton && $contextpage !=
'poslist') {
1012 $selectedfields .=
$form->showCheckAddButtons(
'checkforselect', 1);
1015 $moreforfilter =
'';
1017 $parameters = array();
1018 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN'));
1019 if (empty($reshook)) {
1020 $moreforfilter .= $hookmanager->resPrint;
1022 $moreforfilter = $hookmanager->resPrint;
1025 print
'<div class="div-table-responsive">';
1026 print
'<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">';
1029 print
'<tr class="liste_titre_filter">';
1032 print
'<td class="liste_titre center">';
1033 $searchpicto =
$form->showFilterButtons(
'left');
1038 if (!empty($arrayfields[
't.piece_num'][
'checked'])) {
1039 print
'<td class="liste_titre"><input type="text" name="search_mvt_num" size="6" value="'.dol_escape_htmltag($search_mvt_num).
'"></td>';
1042 if (!empty($arrayfields[
't.code_journal'][
'checked'])) {
1043 print
'<td class="liste_titre center">';
1044 print $formaccounting->multi_select_journal($search_ledger_code,
'search_ledger_code', 0, 1, 1, 1,
'small maxwidth75');
1048 if (!empty($arrayfields[
't.doc_date'][
'checked'])) {
1049 print
'<td class="liste_titre center">';
1050 print
'<div class="nowrap">';
1051 print
$form->selectDate($search_date_start ? $search_date_start : -1,
'search_date_start', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"From"));
1053 print
'<div class="nowrap">';
1054 print
$form->selectDate($search_date_end ? $search_date_end : -1,
'search_date_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"to"));
1059 if (!empty($arrayfields[
't.doc_ref'][
'checked'])) {
1060 print
'<td class="liste_titre"><input type="text" name="search_doc_ref" size="8" value="'.dol_escape_htmltag($search_doc_ref).
'"></td>';
1063 if (!empty($arrayfields[
't.numero_compte'][
'checked'])) {
1064 print
'<td class="liste_titre">';
1065 print
'<div class="nowrap">';
1066 print $formaccounting->select_account($search_accountancy_code_start,
'search_accountancy_code_start', $langs->trans(
'From'), array(), 1, 1,
'maxwidth150',
'account');
1068 print
'<div class="nowrap">';
1069 print $formaccounting->select_account($search_accountancy_code_end,
'search_accountancy_code_end', $langs->trans(
'to'), array(), 1, 1,
'maxwidth150',
'account');
1074 if (!empty($arrayfields[
't.subledger_account'][
'checked'])) {
1075 print
'<td class="liste_titre">';
1078 if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) {
1079 print
'<div class="nowrap">';
1081 print $formaccounting->select_auxaccount($search_accountancy_aux_code_start,
'search_accountancy_aux_code_start', $langs->trans(
'From'),
'maxwidth250',
'subledgeraccount');
1083 print
'<div class="nowrap">';
1084 print $formaccounting->select_auxaccount($search_accountancy_aux_code_end,
'search_accountancy_aux_code_end', $langs->trans(
'to'),
'maxwidth250',
'subledgeraccount');
1087 print
'<input type="text" class="maxwidth75" name="search_accountancy_aux_code" value="'.dol_escape_htmltag($search_accountancy_aux_code).
'">';
1092 if (!empty($arrayfields[
't.label_operation'][
'checked'])) {
1093 print
'<td class="liste_titre">';
1094 print
'<input type="text" size="7" class="flat" name="search_mvt_label" value="'.dol_escape_htmltag($search_mvt_label).
'"/>';
1098 if (!empty($arrayfields[
't.debit'][
'checked'])) {
1099 print
'<td class="liste_titre right">';
1100 print
'<input type="text" class="flat" name="search_debit" size="4" value="'.dol_escape_htmltag($search_debit).
'">';
1104 if (!empty($arrayfields[
't.credit'][
'checked'])) {
1105 print
'<td class="liste_titre right">';
1106 print
'<input type="text" class="flat" name="search_credit" size="4" value="'.dol_escape_htmltag($search_credit).
'">';
1110 if (!empty($arrayfields[
't.lettering_code'][
'checked'])) {
1111 print
'<td class="liste_titre center">';
1112 print
'<input type="text" size="3" class="flat" name="search_lettering_code" value="'.dol_escape_htmltag($search_lettering_code).
'"/>';
1113 print
'<br><span class="nowrap"><input type="checkbox" name="search_not_reconciled" value="notreconciled"'.($search_not_reconciled ==
'notreconciled' ?
' checked' :
'').
'>'.$langs->trans(
"NotReconciled").
'</span>';
1118 $parameters = array(
'arrayfields'=>$arrayfields);
1119 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters);
1120 print $hookmanager->resPrint;
1123 if (!empty($arrayfields[
't.date_creation'][
'checked'])) {
1124 print
'<td class="liste_titre center">';
1125 print
'<div class="nowrap">';
1126 print
$form->selectDate($search_date_creation_start,
'search_date_creation_start', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"From"));
1128 print
'<div class="nowrap">';
1129 print
$form->selectDate($search_date_creation_end,
'search_date_creation_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"to"));
1134 if (!empty($arrayfields[
't.tms'][
'checked'])) {
1135 print
'<td class="liste_titre center">';
1136 print
'<div class="nowrap">';
1137 print
$form->selectDate($search_date_modification_start,
'search_date_modification_start', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"From"));
1139 print
'<div class="nowrap">';
1140 print
$form->selectDate($search_date_modification_end,
'search_date_modification_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"From"));
1145 if (!empty($arrayfields[
't.date_export'][
'checked'])) {
1146 print
'<td class="liste_titre center">';
1147 print
'<div class="nowrap">';
1148 print
$form->selectDate($search_date_export_start,
'search_date_export_start', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"From"));
1150 print
'<div class="nowrap">';
1151 print
$form->selectDate($search_date_export_end,
'search_date_export_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"to"));
1156 if (!empty($arrayfields[
't.date_validated'][
'checked'])) {
1157 print
'<td class="liste_titre center">';
1158 print
'<div class="nowrap">';
1159 print
$form->selectDate($search_date_validation_start,
'search_date_validation_start', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"From"));
1161 print
'<div class="nowrap">';
1162 print
$form->selectDate($search_date_validation_end,
'search_date_validation_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"to"));
1166 if (!empty($arrayfields[
't.import_key'][
'checked'])) {
1167 print
'<td class="liste_titre center">';
1168 print
'<input class="flat searchstring maxwidth50" type="text" name="search_import_key" value="'.dol_escape_htmltag($search_import_key).
'">';
1173 print
'<td class="liste_titre center">';
1174 $searchpicto =
$form->showFilterButtons();
1180 print
'<tr class="liste_titre">';
1182 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch actioncolumn ');}
1183 if (!empty($arrayfields[
't.piece_num'][
'checked'])) {
1184 print_liste_field_titre($arrayfields[
't.piece_num'][
'label'], $_SERVER[
'PHP_SELF'],
"t.piece_num",
"", $param,
"", $sortfield, $sortorder);
1186 if (!empty($arrayfields[
't.code_journal'][
'checked'])) {
1187 print_liste_field_titre($arrayfields[
't.code_journal'][
'label'], $_SERVER[
'PHP_SELF'],
"t.code_journal",
"", $param,
'', $sortfield, $sortorder,
'center ');
1189 if (!empty($arrayfields[
't.doc_date'][
'checked'])) {
1190 print_liste_field_titre($arrayfields[
't.doc_date'][
'label'], $_SERVER[
'PHP_SELF'],
"t.doc_date",
"", $param,
'', $sortfield, $sortorder,
'center ');
1192 if (!empty($arrayfields[
't.doc_ref'][
'checked'])) {
1193 print_liste_field_titre($arrayfields[
't.doc_ref'][
'label'], $_SERVER[
'PHP_SELF'],
"t.doc_ref",
"", $param,
"", $sortfield, $sortorder);
1195 if (!empty($arrayfields[
't.numero_compte'][
'checked'])) {
1196 print_liste_field_titre($arrayfields[
't.numero_compte'][
'label'], $_SERVER[
'PHP_SELF'],
"t.numero_compte",
"", $param,
"", $sortfield, $sortorder);
1198 if (!empty($arrayfields[
't.subledger_account'][
'checked'])) {
1199 print_liste_field_titre($arrayfields[
't.subledger_account'][
'label'], $_SERVER[
'PHP_SELF'],
"t.subledger_account",
"", $param,
"", $sortfield, $sortorder);
1201 if (!empty($arrayfields[
't.label_operation'][
'checked'])) {
1202 print_liste_field_titre($arrayfields[
't.label_operation'][
'label'], $_SERVER[
'PHP_SELF'],
"t.label_operation",
"", $param,
"", $sortfield, $sortorder);
1204 if (!empty($arrayfields[
't.debit'][
'checked'])) {
1205 print_liste_field_titre($arrayfields[
't.debit'][
'label'], $_SERVER[
'PHP_SELF'],
"t.debit",
"", $param,
'', $sortfield, $sortorder,
'right ');
1207 if (!empty($arrayfields[
't.credit'][
'checked'])) {
1208 print_liste_field_titre($arrayfields[
't.credit'][
'label'], $_SERVER[
'PHP_SELF'],
"t.credit",
"", $param,
'', $sortfield, $sortorder,
'right ');
1210 if (!empty($arrayfields[
't.lettering_code'][
'checked'])) {
1211 print_liste_field_titre($arrayfields[
't.lettering_code'][
'label'], $_SERVER[
'PHP_SELF'],
"t.lettering_code",
"", $param,
'', $sortfield, $sortorder,
'center ');
1214 $parameters = array(
'arrayfields'=>$arrayfields,
'param'=>$param,
'sortfield'=>$sortfield,
'sortorder'=>$sortorder);
1215 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters);
1216 print $hookmanager->resPrint;
1217 if (!empty($arrayfields[
't.date_creation'][
'checked'])) {
1218 print_liste_field_titre($arrayfields[
't.date_creation'][
'label'], $_SERVER[
'PHP_SELF'],
"t.date_creation",
"", $param,
'', $sortfield, $sortorder,
'center ');
1220 if (!empty($arrayfields[
't.tms'][
'checked'])) {
1221 print_liste_field_titre($arrayfields[
't.tms'][
'label'], $_SERVER[
'PHP_SELF'],
"t.tms",
"", $param,
'', $sortfield, $sortorder,
'center ');
1223 if (!empty($arrayfields[
't.date_export'][
'checked'])) {
1224 print_liste_field_titre($arrayfields[
't.date_export'][
'label'], $_SERVER[
'PHP_SELF'],
"t.date_export,t.doc_date",
"", $param,
'', $sortfield, $sortorder,
'center ');
1226 if (!empty($arrayfields[
't.date_validated'][
'checked'])) {
1227 print_liste_field_titre($arrayfields[
't.date_validated'][
'label'], $_SERVER[
'PHP_SELF'],
"t.date_validated,t.doc_date",
"", $param,
'', $sortfield, $sortorder,
'center ');
1229 if (!empty($arrayfields[
't.import_key'][
'checked'])) {
1230 print_liste_field_titre($arrayfields[
't.import_key'][
'label'], $_SERVER[
"PHP_SELF"],
"t.import_key",
"", $param,
'', $sortfield, $sortorder,
'center ');
1233 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ');
1243 $totalarray = array();
1244 $totalarray[
'nbfield'] = 0;
1247 $totalarray[
'val'] = array ();
1248 $totalarray[
'val'][
'totaldebit'] = 0;
1249 $totalarray[
'val'][
'totalcredit'] = 0;
1251 while ($i < min($num, $limit)) {
1252 $obj = $db->fetch_object(
$resql);
1257 $line->id = $obj->rowid;
1258 $line->doc_date = $db->jdate($obj->doc_date);
1259 $line->doc_type = $obj->doc_type;
1260 $line->doc_ref = $obj->doc_ref;
1261 $line->fk_doc = $obj->fk_doc;
1262 $line->fk_docdet = $obj->fk_docdet;
1263 $line->thirdparty_code = $obj->thirdparty_code;
1264 $line->subledger_account = $obj->subledger_account;
1265 $line->subledger_label = $obj->subledger_label;
1266 $line->numero_compte = $obj->numero_compte;
1267 $line->label_compte = $obj->label_compte;
1268 $line->label_operation = $obj->label_operation;
1269 $line->debit = $obj->debit;
1270 $line->credit = $obj->credit;
1271 $line->montant = $obj->amount;
1272 $line->amount = $obj->amount;
1273 $line->sens = $obj->sens;
1274 $line->lettering_code = $obj->lettering_code;
1275 $line->fk_user_author = $obj->fk_user_author;
1276 $line->import_key = $obj->import_key;
1277 $line->code_journal = $obj->code_journal;
1278 $line->journal_label = $obj->journal_label;
1279 $line->piece_num = $obj->piece_num;
1280 $line->date_creation = $db->jdate($obj->date_creation);
1281 $line->date_modification = $db->jdate($obj->date_modification);
1282 $line->date_export = $db->jdate($obj->date_export);
1283 $line->date_validation = $db->jdate($obj->date_validation);
1285 $total_debit += $line->debit;
1286 $total_credit += $line->credit;
1288 print
'<tr class="oddeven">';
1291 print
'<td class="nowraponall center">';
1292 if (($massactionbutton || $massaction) && $contextpage !=
'poslist') {
1294 if (in_array($line->id, $arrayofselected)) {
1297 print
'<input id="cb'.$line->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$line->id.
'"'.($selected ?
' checked="checked"' :
'').
' />';
1303 if (!empty($arrayfields[
't.piece_num'][
'checked'])) {
1305 $object->id = $line->id;
1306 $object->piece_num = $line->piece_num;
1307 print $object->getNomUrl(1,
'', 0,
'', 1);
1310 $totalarray[
'nbfield']++;
1315 if (!empty($arrayfields[
't.code_journal'][
'checked'])) {
1317 $result = $accountingjournal->fetch(
'', $line->code_journal);
1318 $journaltoshow = (($result > 0) ? $accountingjournal->getNomUrl(0, 0, 0,
'', 0) : $line->code_journal);
1319 print
'<td class="center tdoverflowmax150">'.$journaltoshow.
'</td>';
1321 $totalarray[
'nbfield']++;
1326 if (!empty($arrayfields[
't.doc_date'][
'checked'])) {
1327 print
'<td class="center">'.dol_print_date($line->doc_date,
'day').
'</td>';
1329 $totalarray[
'nbfield']++;
1334 if (!empty($arrayfields[
't.doc_ref'][
'checked'])) {
1335 if ($line->doc_type ==
'customer_invoice') {
1336 $langs->loadLangs(array(
'bills'));
1338 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
1339 $objectstatic =
new Facture($db);
1340 $objectstatic->fetch($line->fk_doc);
1345 $urlsource = $_SERVER[
'PHP_SELF'].
'?id='.$objectstatic->id;
1346 $documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir);
1347 } elseif ($line->doc_type ==
'supplier_invoice') {
1348 $langs->loadLangs(array(
'bills'));
1350 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
1352 $objectstatic->fetch($line->fk_doc);
1356 $filedir = $conf->fournisseur->facture->dir_output.
'/'.
get_exdir($line->fk_doc, 2, 0, 0, $objectstatic, $modulepart).dol_sanitizeFileName($line->doc_ref);
1357 $subdir =
get_exdir($objectstatic->id, 2, 0, 0, $objectstatic, $modulepart).dol_sanitizeFileName($line->doc_ref);
1358 $documentlink = $formfile->getDocumentsLink($objectstatic->element, $subdir, $filedir);
1359 } elseif ($line->doc_type ==
'expense_report') {
1360 $langs->loadLangs(array(
'trips'));
1362 require_once DOL_DOCUMENT_ROOT.
'/expensereport/class/expensereport.class.php';
1364 $objectstatic->fetch($line->fk_doc);
1369 $urlsource = $_SERVER[
'PHP_SELF'].
'?id='.$objectstatic->id;
1370 $documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir);
1371 } elseif ($line->doc_type ==
'bank') {
1372 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
1374 $objectstatic->fetch($line->fk_doc);
1380 $labeltoshowalt =
'';
1381 if ($line->doc_type ==
'customer_invoice' || $line->doc_type ==
'supplier_invoice' || $line->doc_type ==
'expense_report') {
1382 $labeltoshow .= $objectstatic->getNomUrl(1,
'', 0, 0,
'', 0, -1, 1);
1383 $labeltoshow .= $documentlink;
1384 $labeltoshowalt .= $objectstatic->ref;
1385 } elseif ($line->doc_type ==
'bank') {
1386 $labeltoshow .= $objectstatic->getNomUrl(1);
1387 $labeltoshowalt .= $objectstatic->ref;
1388 $bank_ref = strstr($line->doc_ref,
'-');
1389 $labeltoshow .=
" " . $bank_ref;
1390 $labeltoshowalt .=
" " . $bank_ref;
1392 $labeltoshow .= $line->doc_ref;
1393 $labeltoshowalt .= $line->doc_ref;
1396 print
'<td class="nowraponall tdoverflowmax200" title="'.dol_escape_htmltag($labeltoshowalt).
'">';
1400 $totalarray[
'nbfield']++;
1405 if (!empty($arrayfields[
't.numero_compte'][
'checked'])) {
1406 print
'<td>'.length_accountg($line->numero_compte).
'</td>';
1408 $totalarray[
'nbfield']++;
1413 if (!empty($arrayfields[
't.subledger_account'][
'checked'])) {
1414 print
'<td>'.length_accounta($line->subledger_account).
'</td>';
1416 $totalarray[
'nbfield']++;
1421 if (!empty($arrayfields[
't.label_operation'][
'checked'])) {
1422 print
'<td class="small tdoverflowmax200" title="'.dol_escape_htmltag($line->label_operation).
'">'.
dol_escape_htmltag($line->label_operation).
'</td>';
1424 $totalarray[
'nbfield']++;
1429 if (!empty($arrayfields[
't.debit'][
'checked'])) {
1430 print
'<td class="right nowraponall amount">'.($line->debit != 0 ?
price($line->debit) :
'').
'</td>';
1432 $totalarray[
'nbfield']++;
1435 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'totaldebit';
1437 $totalarray[
'val'][
'totaldebit'] += $line->debit;
1441 if (!empty($arrayfields[
't.credit'][
'checked'])) {
1442 print
'<td class="right nowraponall amount">'.($line->credit != 0 ?
price($line->credit) :
'').
'</td>';
1444 $totalarray[
'nbfield']++;
1447 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'totalcredit';
1449 $totalarray[
'val'][
'totalcredit'] += $line->credit;
1453 if (!empty($arrayfields[
't.lettering_code'][
'checked'])) {
1454 print
'<td class="center">'.$line->lettering_code.
'</td>';
1456 $totalarray[
'nbfield']++;
1461 $parameters = array(
'arrayfields'=>$arrayfields,
'obj'=>$obj,
'i'=>$i,
'totalarray'=>&$totalarray);
1462 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters);
1463 print $hookmanager->resPrint;
1466 if (!empty($arrayfields[
't.date_creation'][
'checked'])) {
1467 print
'<td class="center">'.dol_print_date($line->date_creation,
'dayhour',
'tzuserrel').
'</td>';
1469 $totalarray[
'nbfield']++;
1474 if (!empty($arrayfields[
't.tms'][
'checked'])) {
1475 print
'<td class="center">'.dol_print_date($line->date_modification,
'dayhour',
'tzuserrel').
'</td>';
1477 $totalarray[
'nbfield']++;
1482 if (!empty($arrayfields[
't.date_export'][
'checked'])) {
1483 print
'<td class="center nowraponall">'.dol_print_date($line->date_export,
'dayhour',
'tzuserrel').
'</td>';
1485 $totalarray[
'nbfield']++;
1490 if (!empty($arrayfields[
't.date_validated'][
'checked'])) {
1491 print
'<td class="center nowraponall">'.dol_print_date($line->date_validation,
'dayhour',
'tzuserrel').
'</td>';
1493 $totalarray[
'nbfield']++;
1497 if (!empty($arrayfields[
't.import_key'][
'checked'])) {
1498 print
'<td class="tdoverflowmax100">'.$obj->import_key.
"</td>\n";
1500 $totalarray[
'nbfield']++;
1506 print
'<td class="nowraponall center">';
1507 if (($massactionbutton || $massaction) && $contextpage !=
'poslist') {
1509 if (in_array($line->id, $arrayofselected)) {
1512 print
'<input id="cb'.$line->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$line->id.
'"'.($selected ?
' checked="checked"' :
'').
' />';
1518 $totalarray[
'nbfield']++;
1527 include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
1532 foreach ($arrayfields as $key => $val) {
1533 if (!empty($val[
'checked'])) {
1537 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
1540 $parameters = array(
'arrayfields'=>$arrayfields,
'sql'=>$sql);
1541 $reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object, $action);
1542 print $hookmanager->resPrint;
dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $note='', $entity=1)
Insert a parameter (key,value) into database (delete old key then insert it again).
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage bank transaction lines.
Manage the different format accountancy export.
Class to manage accounting accounts.
Class to manage Ledger (General Ledger and Subledger)
Class to manage Trips and Expenses.
Class to manage suppliers invoices.
Class to manage invoices.
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
dol_get_last_day($year, $month=12, $gm=false)
Return GMT time for last day of a month or year.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
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_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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.
print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
if(!function_exists('utf8_encode')) if(!function_exists('utf8_decode')) getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
isModEnabled($module)
Is Dolibarr module enabled.
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.
$formconfirm
if ($action == 'delbookkeepingyear') {
if(!defined('NOREQUIREMENU')) if(!function_exists("llxHeader")) top_httphead($contenttype='text/html', $forcenocache=0)
Show HTTP header.
$nbtotalofrecords
Count total nb of records.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.