28 require
'../../main.inc.php';
29 require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountancyexport.class.php';
30 require_once DOL_DOCUMENT_ROOT.
'/core/lib/accounting.lib.php';
31 require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/lettering.class.php';
32 require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/bookkeeping.class.php';
33 require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountingjournal.class.php';
34 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
35 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
36 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formaccounting.class.php';
37 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
38 require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
41 $langs->loadLangs(array(
"accountancy",
"compta"));
43 $socid =
GETPOST(
'socid',
'int');
45 $action =
GETPOST(
'action',
'aZ09');
46 $massaction =
GETPOST(
'massaction',
'alpha');
47 $confirm =
GETPOST(
'confirm',
'alpha');
48 $toselect =
GETPOST(
'toselect',
'array');
49 $contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'bookkeepinglist';
50 $search_mvt_num =
GETPOST(
'search_mvt_num',
'int');
51 $search_doc_type =
GETPOST(
"search_doc_type",
'alpha');
52 $search_doc_ref =
GETPOST(
"search_doc_ref",
'alpha');
53 $search_date_startyear =
GETPOST(
'search_date_startyear',
'int');
54 $search_date_startmonth =
GETPOST(
'search_date_startmonth',
'int');
55 $search_date_startday =
GETPOST(
'search_date_startday',
'int');
56 $search_date_endyear =
GETPOST(
'search_date_endyear',
'int');
57 $search_date_endmonth =
GETPOST(
'search_date_endmonth',
'int');
58 $search_date_endday =
GETPOST(
'search_date_endday',
'int');
59 $search_date_start =
dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear);
60 $search_date_end =
dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear);
62 $search_date_creation_startyear =
GETPOST(
'search_date_creation_startyear',
'int');
63 $search_date_creation_startmonth =
GETPOST(
'search_date_creation_startmonth',
'int');
64 $search_date_creation_startday =
GETPOST(
'search_date_creation_startday',
'int');
65 $search_date_creation_endyear =
GETPOST(
'search_date_creation_endyear',
'int');
66 $search_date_creation_endmonth =
GETPOST(
'search_date_creation_endmonth',
'int');
67 $search_date_creation_endday =
GETPOST(
'search_date_creation_endday',
'int');
68 $search_date_creation_start =
dol_mktime(0, 0, 0, $search_date_creation_startmonth, $search_date_creation_startday, $search_date_creation_startyear);
69 $search_date_creation_end =
dol_mktime(23, 59, 59, $search_date_creation_endmonth, $search_date_creation_endday, $search_date_creation_endyear);
70 $search_date_modification_startyear =
GETPOST(
'search_date_modification_startyear',
'int');
71 $search_date_modification_startmonth =
GETPOST(
'search_date_modification_startmonth',
'int');
72 $search_date_modification_startday =
GETPOST(
'search_date_modification_startday',
'int');
73 $search_date_modification_endyear =
GETPOST(
'search_date_modification_endyear',
'int');
74 $search_date_modification_endmonth =
GETPOST(
'search_date_modification_endmonth',
'int');
75 $search_date_modification_endday =
GETPOST(
'search_date_modification_endday',
'int');
76 $search_date_modification_start =
dol_mktime(0, 0, 0, $search_date_modification_startmonth, $search_date_modification_startday, $search_date_modification_startyear);
77 $search_date_modification_end =
dol_mktime(23, 59, 59, $search_date_modification_endmonth, $search_date_modification_endday, $search_date_modification_endyear);
78 $search_date_export_startyear =
GETPOST(
'search_date_export_startyear',
'int');
79 $search_date_export_startmonth =
GETPOST(
'search_date_export_startmonth',
'int');
80 $search_date_export_startday =
GETPOST(
'search_date_export_startday',
'int');
81 $search_date_export_endyear =
GETPOST(
'search_date_export_endyear',
'int');
82 $search_date_export_endmonth =
GETPOST(
'search_date_export_endmonth',
'int');
83 $search_date_export_endday =
GETPOST(
'search_date_export_endday',
'int');
84 $search_date_export_start =
dol_mktime(0, 0, 0, $search_date_export_startmonth, $search_date_export_startday, $search_date_export_startyear);
85 $search_date_export_end =
dol_mktime(23, 59, 59, $search_date_export_endmonth, $search_date_export_endday, $search_date_export_endyear);
86 $search_date_validation_startyear =
GETPOST(
'search_date_validation_startyear',
'int');
87 $search_date_validation_startmonth =
GETPOST(
'search_date_validation_startmonth',
'int');
88 $search_date_validation_startday =
GETPOST(
'search_date_validation_startday',
'int');
89 $search_date_validation_endyear =
GETPOST(
'search_date_validation_endyear',
'int');
90 $search_date_validation_endmonth =
GETPOST(
'search_date_validation_endmonth',
'int');
91 $search_date_validation_endday =
GETPOST(
'search_date_validation_endday',
'int');
92 $search_date_validation_start =
dol_mktime(0, 0, 0, $search_date_validation_startmonth, $search_date_validation_startday, $search_date_validation_startyear);
93 $search_date_validation_end =
dol_mktime(23, 59, 59, $search_date_validation_endmonth, $search_date_validation_endday, $search_date_validation_endyear);
94 $search_import_key =
GETPOST(
"search_import_key",
'alpha');
98 $action =
'delbookkeepingyear';
100 if (
GETPOST(
"button_export_file_x") ||
GETPOST(
"button_export_file.x") ||
GETPOST(
"button_export_file")) {
101 $action =
'export_file';
104 $search_accountancy_code =
GETPOST(
"search_accountancy_code");
105 $search_accountancy_code_start =
GETPOST(
'search_accountancy_code_start',
'alpha');
106 if ($search_accountancy_code_start == - 1) {
107 $search_accountancy_code_start =
'';
109 $search_accountancy_code_end =
GETPOST(
'search_accountancy_code_end',
'alpha');
110 if ($search_accountancy_code_end == - 1) {
111 $search_accountancy_code_end =
'';
114 $search_accountancy_aux_code =
GETPOST(
"search_accountancy_aux_code",
'alpha');
115 $search_accountancy_aux_code_start =
GETPOST(
'search_accountancy_aux_code_start',
'alpha');
116 if ($search_accountancy_aux_code_start == - 1) {
117 $search_accountancy_aux_code_start =
'';
119 $search_accountancy_aux_code_end =
GETPOST(
'search_accountancy_aux_code_end',
'alpha');
120 if ($search_accountancy_aux_code_end == - 1) {
121 $search_accountancy_aux_code_end =
'';
123 $search_mvt_label =
GETPOST(
'search_mvt_label',
'alpha');
124 $search_direction =
GETPOST(
'search_direction',
'alpha');
125 $search_debit =
GETPOST(
'search_debit',
'alpha');
126 $search_credit =
GETPOST(
'search_credit',
'alpha');
127 $search_ledger_code =
GETPOST(
'search_ledger_code',
'array');
128 $search_lettering_code =
GETPOST(
'search_lettering_code',
'alpha');
129 $search_not_reconciled =
GETPOST(
'search_not_reconciled',
'alpha');
132 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : (empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION) ? $conf->liste_limit : $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION);
133 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
134 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
135 $optioncss =
GETPOST(
'optioncss',
'alpha');
137 if (empty($page) || $page < 0) {
140 $offset = $limit * $page;
141 $pageprev = $page - 1;
142 $pagenext = $page + 1;
143 if ($sortorder ==
"") {
146 if ($sortfield ==
"") {
147 $sortfield =
"t.piece_num,t.rowid";
152 $hookmanager->initHooks(array(
'bookkeepinglist'));
157 if (!in_array($action, array(
'export_file',
'delmouv',
'delmouvconfirm')) && !
GETPOSTISSET(
'begin') && !
GETPOSTISSET(
'formfilteraction') &&
GETPOST(
'page',
'int') ==
'' && !
GETPOST(
'noreset',
'int') && $user->rights->accounting->mouvements->export) {
158 if (empty($search_date_start) && empty($search_date_end) && !
GETPOSTISSET(
'restore_lastsearch_values') && !
GETPOST(
'search_accountancy_code_start')) {
159 $query =
"SELECT date_start, date_end from ".MAIN_DB_PREFIX.
"accounting_fiscalyear ";
160 $query .=
" where date_start < '".$db->idate(
dol_now()).
"' and date_end > '".$db->idate(
dol_now()).
"' limit 1";
161 $res = $db->query($query);
163 if ($res->num_rows > 0) {
164 $fiscalYear = $db->fetch_object($res);
165 $search_date_start = strtotime($fiscalYear->date_start);
166 $search_date_end = strtotime($fiscalYear->date_end);
168 $month_start = ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1);
173 $year_end = $year_start + 1;
174 $month_end = $month_start - 1;
175 if ($month_end < 1) {
179 $search_date_start =
dol_mktime(0, 0, 0, $month_start, 1, $year_start);
186 $arrayfields = array(
187 't.piece_num'=>array(
'label'=>$langs->trans(
"TransactionNumShort"),
'checked'=>1),
188 't.code_journal'=>array(
'label'=>$langs->trans(
"Codejournal"),
'checked'=>1),
189 't.doc_date'=>array(
'label'=>$langs->trans(
"Docdate"),
'checked'=>1),
190 't.doc_ref'=>array(
'label'=>$langs->trans(
"Piece"),
'checked'=>1),
191 't.numero_compte'=>array(
'label'=>$langs->trans(
"AccountAccountingShort"),
'checked'=>1),
192 't.subledger_account'=>array(
'label'=>$langs->trans(
"SubledgerAccount"),
'checked'=>1),
193 't.label_operation'=>array(
'label'=>$langs->trans(
"Label"),
'checked'=>1),
194 't.debit'=>array(
'label'=>$langs->trans(
"Debit"),
'checked'=>1),
195 't.credit'=>array(
'label'=>$langs->trans(
"Credit"),
'checked'=>1),
196 't.lettering_code'=>array(
'label'=>$langs->trans(
"LetteringCode"),
'checked'=>1),
197 't.date_creation'=>array(
'label'=>$langs->trans(
"DateCreation"),
'checked'=>0),
198 't.tms'=>array(
'label'=>$langs->trans(
"DateModification"),
'checked'=>0),
199 't.date_export'=>array(
'label'=>$langs->trans(
"DateExport"),
'checked'=>1),
200 't.date_validated'=>array(
'label'=>$langs->trans(
"DateValidationAndLock"),
'checked'=>1,
'enabled'=>!
getDolGlobalString(
"ACCOUNTANCY_DISABLE_CLOSURE_LINE_BY_LINE")),
201 't.import_key'=>array(
'label'=>$langs->trans(
"ImportId"),
'checked'=>0,
'position'=>1100),
204 if (empty($conf->global->ACCOUNTING_ENABLE_LETTERING)) {
205 unset($arrayfields[
't.lettering_code']);
209 $listofformat = $accountancyexport->getType();
211 if (empty($listofformat[$formatexportset])) {
212 $formatexportset = 1;
220 if ($user->socid > 0) {
223 if (empty($user->rights->accounting->mouvements->lire)) {
234 if (
GETPOST(
'cancel',
'alpha')) {
235 $action =
'list'; $massaction =
'';
237 if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'preunlettering' && $massaction !=
'predeletebookkeepingwriting') {
241 $parameters = array(
'socid'=>$socid);
242 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
247 if (empty($reshook)) {
248 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
250 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
251 $search_mvt_num =
'';
252 $search_doc_type =
'';
253 $search_doc_ref =
'';
254 $search_doc_date =
'';
255 $search_accountancy_code =
'';
256 $search_accountancy_code_start =
'';
257 $search_accountancy_code_end =
'';
258 $search_accountancy_aux_code =
'';
259 $search_accountancy_aux_code_start =
'';
260 $search_accountancy_aux_code_end =
'';
261 $search_mvt_label =
'';
262 $search_direction =
'';
263 $search_ledger_code = array();
264 $search_date_startyear =
'';
265 $search_date_startmonth =
'';
266 $search_date_startday =
'';
267 $search_date_endyear =
'';
268 $search_date_endmonth =
'';
269 $search_date_endday =
'';
270 $search_date_start =
'';
271 $search_date_end =
'';
272 $search_date_creation_startyear =
'';
273 $search_date_creation_startmonth =
'';
274 $search_date_creation_startday =
'';
275 $search_date_creation_endyear =
'';
276 $search_date_creation_endmonth =
'';
277 $search_date_creation_endday =
'';
278 $search_date_creation_start =
'';
279 $search_date_creation_end =
'';
280 $search_date_modification_startyear =
'';
281 $search_date_modification_startmonth =
'';
282 $search_date_modification_startday =
'';
283 $search_date_modification_endyear =
'';
284 $search_date_modification_endmonth =
'';
285 $search_date_modification_endday =
'';
286 $search_date_modification_start =
'';
287 $search_date_modification_end =
'';
288 $search_date_export_startyear =
'';
289 $search_date_export_startmonth =
'';
290 $search_date_export_startday =
'';
291 $search_date_export_endyear =
'';
292 $search_date_export_endmonth =
'';
293 $search_date_export_endday =
'';
294 $search_date_export_start =
'';
295 $search_date_export_end =
'';
296 $search_date_validation_startyear =
'';
297 $search_date_validation_startmonth =
'';
298 $search_date_validation_startday =
'';
299 $search_date_validation_endyear =
'';
300 $search_date_validation_endmonth =
'';
301 $search_date_validation_endday =
'';
302 $search_date_validation_start =
'';
303 $search_date_validation_end =
'';
306 $search_lettering_code =
'';
307 $search_not_reconciled =
'';
308 $search_import_key =
'';
314 if (!empty($search_date_start)) {
315 $filter[
't.doc_date>='] = $search_date_start;
317 $param .=
'&search_date_startmonth='.urlencode($tmp[
'mon']).
'&search_date_startday='.urlencode($tmp[
'mday']).
'&search_date_startyear='.urlencode($tmp[
'year']);
319 if (!empty($search_date_end)) {
320 $filter[
't.doc_date<='] = $search_date_end;
322 $param .=
'&search_date_endmonth='.urlencode($tmp[
'mon']).
'&search_date_endday='.urlencode($tmp[
'mday']).
'&search_date_endyear='.urlencode($tmp[
'year']);
324 if (!empty($search_doc_date)) {
325 $filter[
't.doc_date'] = $search_doc_date;
327 $param .=
'&doc_datemonth='.urlencode($tmp[
'mon']).
'&doc_dateday='.urlencode($tmp[
'mday']).
'&doc_dateyear='.urlencode($tmp[
'year']);
329 if (!empty($search_doc_type)) {
330 $filter[
't.doc_type'] = $search_doc_type;
331 $param .=
'&search_doc_type='.urlencode($search_doc_type);
333 if (!empty($search_doc_ref)) {
334 $filter[
't.doc_ref'] = $search_doc_ref;
335 $param .=
'&search_doc_ref='.urlencode($search_doc_ref);
337 if (!empty($search_accountancy_code)) {
338 $filter[
't.numero_compte'] = $search_accountancy_code;
339 $param .=
'&search_accountancy_code='.urlencode($search_accountancy_code);
341 if (!empty($search_accountancy_code_start)) {
342 $filter[
't.numero_compte>='] = $search_accountancy_code_start;
343 $param .=
'&search_accountancy_code_start='.urlencode($search_accountancy_code_start);
345 if (!empty($search_accountancy_code_end)) {
346 $filter[
't.numero_compte<='] = $search_accountancy_code_end;
347 $param .=
'&search_accountancy_code_end='.urlencode($search_accountancy_code_end);
349 if (!empty($search_accountancy_aux_code)) {
350 $filter[
't.subledger_account'] = $search_accountancy_aux_code;
351 $param .=
'&search_accountancy_aux_code='.urlencode($search_accountancy_aux_code);
353 if (!empty($search_accountancy_aux_code_start)) {
354 $filter[
't.subledger_account>='] = $search_accountancy_aux_code_start;
355 $param .=
'&search_accountancy_aux_code_start='.urlencode($search_accountancy_aux_code_start);
357 if (!empty($search_accountancy_aux_code_end)) {
358 $filter[
't.subledger_account<='] = $search_accountancy_aux_code_end;
359 $param .=
'&search_accountancy_aux_code_end='.urlencode($search_accountancy_aux_code_end);
361 if (!empty($search_mvt_label)) {
362 $filter[
't.label_operation'] = $search_mvt_label;
363 $param .=
'&search_mvt_label='.urlencode($search_mvt_label);
365 if (!empty($search_direction)) {
366 $filter[
't.sens'] = $search_direction;
367 $param .=
'&search_direction='.urlencode($search_direction);
369 if (!empty($search_ledger_code)) {
370 $filter[
't.code_journal'] = $search_ledger_code;
371 foreach ($search_ledger_code as $code) {
372 $param .=
'&search_ledger_code[]='.urlencode($code);
375 if (!empty($search_mvt_num)) {
376 $filter[
't.piece_num'] = $search_mvt_num;
377 $param .=
'&search_mvt_num='.urlencode($search_mvt_num);
379 if (!empty($search_date_creation_start)) {
380 $filter[
't.date_creation>='] = $search_date_creation_start;
382 $param .=
'&search_date_creation_startmonth='.urlencode($tmp[
'mon']).
'&search_date_creation_startday='.urlencode($tmp[
'mday']).
'&search_date_creation_startyear='.urlencode($tmp[
'year']);
384 if (!empty($search_date_creation_end)) {
385 $filter[
't.date_creation<='] = $search_date_creation_end;
387 $param .=
'&search_date_creation_endmonth='.urlencode($tmp[
'mon']).
'&search_date_creation_endday='.urlencode($tmp[
'mday']).
'&search_date_creation_endyear='.urlencode($tmp[
'year']);
389 if (!empty($search_date_modification_start)) {
390 $filter[
't.tms>='] = $search_date_modification_start;
391 $tmp =
dol_getdate($search_date_modification_start);
392 $param .=
'&search_date_modification_startmonth='.urlencode($tmp[
'mon']).
'&search_date_modification_startday='.urlencode($tmp[
'mday']).
'&search_date_modification_startyear='.urlencode($tmp[
'year']);
394 if (!empty($search_date_modification_end)) {
395 $filter[
't.tms<='] = $search_date_modification_end;
397 $param .=
'&search_date_modification_endmonth='.urlencode($tmp[
'mon']).
'&search_date_modification_endday='.urlencode($tmp[
'mday']).
'&search_date_modification_endyear='.urlencode($tmp[
'year']);
399 if (!empty($search_date_export_start)) {
400 $filter[
't.date_export>='] = $search_date_export_start;
402 $param .=
'&search_date_export_startmonth='.urlencode($tmp[
'mon']).
'&search_date_export_startday='.urlencode($tmp[
'mday']).
'&search_date_export_startyear='.urlencode($tmp[
'year']);
404 if (!empty($search_date_export_end)) {
405 $filter[
't.date_export<='] = $search_date_export_end;
407 $param .=
'&search_date_export_endmonth='.urlencode($tmp[
'mon']).
'&search_date_export_endday='.urlencode($tmp[
'mday']).
'&search_date_export_endyear='.urlencode($tmp[
'year']);
409 if (!empty($search_date_validation_start)) {
410 $filter[
't.date_validated>='] = $search_date_validation_start;
412 $param .=
'&search_date_validation_startmonth='.urlencode($tmp[
'mon']).
'&search_date_validation_startday='.urlencode($tmp[
'mday']).
'&search_date_validation_startyear='.urlencode($tmp[
'year']);
414 if (!empty($search_date_validation_end)) {
415 $filter[
't.date_validated<='] = $search_date_validation_end;
417 $param .=
'&search_date_validation_endmonth='.urlencode($tmp[
'mon']).
'&search_date_validation_endday='.urlencode($tmp[
'mday']).
'&search_date_validation_endyear='.urlencode($tmp[
'year']);
419 if (!empty($search_debit)) {
420 $filter[
't.debit'] = $search_debit;
421 $param .=
'&search_debit='.urlencode($search_debit);
423 if (!empty($search_credit)) {
424 $filter[
't.credit'] = $search_credit;
425 $param .=
'&search_credit='.urlencode($search_credit);
427 if (!empty($search_lettering_code)) {
428 $filter[
't.lettering_code'] = $search_lettering_code;
429 $param .=
'&search_lettering_code='.urlencode($search_lettering_code);
431 if (!empty($search_not_reconciled)) {
432 $filter[
't.reconciled_option'] = $search_not_reconciled;
433 $param .=
'&search_not_reconciled='.urlencode($search_not_reconciled);
435 if (!empty($search_import_key)) {
436 $filter[
't.import_key'] = $search_import_key;
437 $param .=
'&search_import_key='.urlencode($search_import_key);
466 if ($action ==
'setreexport') {
467 $setreexport =
GETPOST(
'value',
'int');
468 if (!
dolibarr_set_const($db,
"ACCOUNTING_REEXPORT", $setreexport,
'yesno', 0,
'', $conf->entity)) {
473 if ($conf->global->ACCOUNTING_REEXPORT == 1) {
474 setEventMessages($langs->trans(
"ExportOfPiecesAlreadyExportedIsEnable"),
null,
'mesgs');
476 setEventMessages($langs->trans(
"ExportOfPiecesAlreadyExportedIsDisable"),
null,
'mesgs');
484 $objectclass =
'Bookkeeping';
485 $objectlabel =
'Bookkeeping';
486 $permissiontoread = $user->rights->societe->lire;
487 $permissiontodelete = $user->rights->societe->supprimer;
488 $permissiontoadd = $user->rights->societe->creer;
489 $uploaddir = $conf->societe->dir_output;
490 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
492 if (!$error && $action ==
'deletebookkeepingwriting' && $confirm ==
"yes" && $user->rights->accounting->mouvements->supprimer) {
494 foreach ($toselect as $toselectid) {
495 $result = $object->fetch($toselectid);
496 if ($result > 0 && (!isset($object->date_validation) || $object->date_validation ===
'')) {
497 $result = $object->deleteMvtNum($object->piece_num);
505 } elseif ($result < 0) {
515 } elseif ($nbok > 0) {
522 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?noreset=1".($param ?
'&'.$param :
''));
528 if (!$error &&
getDolGlobalInt(
'ACCOUNTING_ENABLE_LETTERING') && $user->rights->accounting->mouvements->creer) {
529 if ($massaction ==
'lettering') {
531 $nb_lettering = $lettering->bookkeepingLetteringAll($toselect);
532 if ($nb_lettering < 0) {
535 $nb_lettering = max(0, abs($nb_lettering) - 2);
536 } elseif ($nb_lettering == 0) {
538 setEventMessages($langs->trans(
'AccountancyNoLetteringModified'), array(),
'mesgs');
540 if ($nb_lettering == 1) {
541 setEventMessages($langs->trans(
'AccountancyOneLetteringModifiedSuccessfully'), array(),
'mesgs');
542 } elseif ($nb_lettering > 1) {
543 setEventMessages($langs->trans(
'AccountancyLetteringModifiedSuccessfully', $nb_lettering), array(),
'mesgs');
547 header(
'Location: ' . $_SERVER[
'PHP_SELF'] .
'?noreset=1' . $param);
550 } elseif ($action ==
'unlettering' && $confirm ==
"yes") {
552 $nb_lettering = $lettering->bookkeepingLetteringAll($toselect,
true);
553 if ($nb_lettering < 0) {
556 $nb_lettering = max(0, abs($nb_lettering) - 2);
557 } elseif ($nb_lettering == 0) {
559 setEventMessages($langs->trans(
'AccountancyNoUnletteringModified'), array(),
'mesgs');
561 if ($nb_lettering == 1) {
562 setEventMessages($langs->trans(
'AccountancyOneUnletteringModifiedSuccessfully'), array(),
'mesgs');
563 } elseif ($nb_lettering > 1) {
564 setEventMessages($langs->trans(
'AccountancyUnletteringModifiedSuccessfully', $nb_lettering), array(),
'mesgs');
568 header(
'Location: ' . $_SERVER[
'PHP_SELF'] .
'?noreset=1' . $param);
581 $sql .=
" t.doc_date,";
582 $sql .=
" t.doc_type,";
583 $sql .=
" t.doc_ref,";
584 $sql .=
" t.fk_doc,";
585 $sql .=
" t.fk_docdet,";
586 $sql .=
" t.thirdparty_code,";
587 $sql .=
" t.subledger_account,";
588 $sql .=
" t.subledger_label,";
589 $sql .=
" t.numero_compte,";
590 $sql .=
" t.label_compte,";
591 $sql .=
" t.label_operation,";
593 $sql .=
" t.credit,";
594 $sql .=
" t.lettering_code,";
595 $sql .=
" t.montant as amount,";
597 $sql .=
" t.fk_user_author,";
598 $sql .=
" t.import_key,";
599 $sql .=
" t.code_journal,";
600 $sql .=
" t.journal_label,";
601 $sql .=
" t.piece_num,";
602 $sql .=
" t.date_creation,";
603 $sql .=
" t.tms as date_modification,";
604 $sql .=
" t.date_export,";
605 $sql .=
" t.date_validated as date_validation,";
606 $sql .=
" t.import_key";
607 $sql .=
' FROM '.MAIN_DB_PREFIX.$object->table_element.
' as t';
610 if (count($filter) > 0) {
611 foreach ($filter as $key => $value) {
612 if ($key ==
't.doc_date') {
613 $sqlwhere[] = $key.
"='".$db->idate($value).
"'";
614 } elseif ($key ==
't.doc_date>=' || $key ==
't.doc_date<=') {
615 $sqlwhere[] = $key.
"'".$db->idate($value).
"'";
616 } elseif ($key ==
't.numero_compte>=' || $key ==
't.numero_compte<=' || $key ==
't.subledger_account>=' || $key ==
't.subledger_account<=') {
617 $sqlwhere[] = $key.
"'".$db->escape($value).
"'";
618 } elseif ($key ==
't.fk_doc' || $key ==
't.fk_docdet' || $key ==
't.piece_num') {
619 $sqlwhere[] = $key.
'='.((int) $value);
620 } elseif ($key ==
't.subledger_account' || $key ==
't.numero_compte') {
621 $sqlwhere[] = $key.
" LIKE '".$db->escape($value).
"%'";
622 } elseif ($key ==
't.subledger_account') {
624 } elseif ($key ==
't.date_creation>=' || $key ==
't.date_creation<=') {
625 $sqlwhere[] = $key.
"'".$db->idate($value).
"'";
626 } elseif ($key ==
't.tms>=' || $key ==
't.tms<=') {
627 $sqlwhere[] = $key.
"'".$db->idate($value).
"'";
628 } elseif ($key ==
't.date_export>=' || $key ==
't.date_export<=') {
629 $sqlwhere[] = $key.
"'".$db->idate($value).
"'";
630 } elseif ($key ==
't.date_validated>=' || $key ==
't.date_validated<=') {
631 $sqlwhere[] = $key.
"'".$db->idate($value).
"'";
632 } elseif ($key ==
't.credit' || $key ==
't.debit') {
634 } elseif ($key ==
't.reconciled_option') {
635 $sqlwhere[] =
't.lettering_code IS NULL';
636 } elseif ($key ==
't.code_journal' && !empty($value)) {
637 $sqlwhere[] =
natural_search(
"t.code_journal", join(
',', $value), 3, 1);
643 $sql .=
' WHERE t.entity IN ('.getEntity(
'accountancy').
')';
644 if (empty($conf->global->ACCOUNTING_REEXPORT)) {
645 $sql .=
" AND t.date_export IS NULL";
647 if (count($sqlwhere) > 0) {
648 $sql .=
' AND '.implode(
' AND ', $sqlwhere);
650 if (!empty($sortfield)) {
651 $sql .= $db->order($sortfield, $sortorder);
658 if ($action ==
'export_fileconfirm' && $user->rights->accounting->mouvements->export) {
660 $result = $object->fetchAll($sortorder, $sortfield, 0, 0, $filter,
'AND', (empty($conf->global->ACCOUNTING_REEXPORT) ? 0 : 1));
667 $accountancyexport->export($object->lines, $formatexportset);
669 $notifiedexportdate =
GETPOST(
'notifiedexportdate',
'alpha');
670 $notifiedvalidationdate =
GETPOST(
'notifiedvalidationdate',
'alpha');
672 if (!empty($accountancyexport->errors)) {
674 } elseif (!empty($notifiedexportdate) || !empty($notifiedvalidationdate)) {
679 if (is_array($object->lines)) {
680 foreach ($object->lines as $movement) {
683 $sql =
" UPDATE ".MAIN_DB_PREFIX.
"accounting_bookkeeping";
685 if (!empty($notifiedexportdate) && !empty($notifiedvalidationdate)) {
686 $sql .=
" date_export = '".$db->idate($now).
"'";
687 $sql .=
", date_validated = '".$db->idate($now).
"'";
688 } elseif (!empty($notifiedexportdate)) {
689 $sql .=
" date_export = '".$db->idate($now).
"'";
690 } elseif (!empty($notifiedvalidationdate)) {
691 $sql .=
" date_validated = '".$db->idate($now).
"'";
693 $sql .=
" WHERE rowid = ".((int) $movement->id);
695 dol_syslog(
"/accountancy/bookkeeping/list.php Function export_file Specify movements as exported", LOG_DEBUG);
697 $result = $db->query($sql);
711 setEventMessages($langs->trans(
"NotAllExportedMovementsCouldBeRecordedAsExportedOrValidated"),
null,
'errors');
726 $title_page = $langs->trans(
"Operations").
' - '.$langs->trans(
"Journals");
729 $nbtotalofrecords =
'';
730 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
731 $resql = $db->query($sql);
732 $nbtotalofrecords = $db->num_rows(
$resql);
733 if (($page * $limit) > $nbtotalofrecords) {
739 if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords) {
740 $num = $nbtotalofrecords;
742 $sql .= $db->plimit($limit + 1, $offset);
744 $resql = $db->query($sql);
750 $num = $db->num_rows(
$resql);
753 $arrayofselected = is_array($toselect) ? $toselect : array();
762 if ($action ==
'export_file') {
763 $form_question = array();
766 $checked = (!isset($conf->global->ACCOUNTING_DEFAULT_NOT_NOTIFIED_EXPORT_DATE) || !empty($conf->global->ACCOUNTING_DEFAULT_NOT_NOTIFIED_EXPORT_DATE));
767 $form_question[
'notifiedexportdate'] = array(
768 'name' =>
'notifiedexportdate',
769 'type' =>
'checkbox',
770 'label' => $langs->trans(
'NotifiedExportDate'),
771 'value' => (!empty($conf->global->ACCOUNTING_DEFAULT_NOT_NOTIFIED_EXPORT_DATE) ?
'false' :
'true'),
774 $form_question[
'separator'] = array(
'name'=>
'separator',
'type'=>
'separator');
778 $checked = (isset($conf->global->ACCOUNTING_DEFAULT_NOT_NOTIFIED_VALIDATION_DATE) || !empty($conf->global->ACCOUNTING_DEFAULT_NOT_NOTIFIED_VALIDATION_DATE));
779 $form_question[
'notifiedvalidationdate'] = array(
780 'name' =>
'notifiedvalidationdate',
781 'type' =>
'checkbox',
782 'label' => $langs->trans(
'NotifiedValidationDate', $langs->transnoentitiesnoconv(
"MenuAccountancyClosure")),
786 $form_question[
'separator2'] = array(
'name'=>
'separator2',
'type'=>
'separator');
789 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?'.$param, $langs->trans(
"ExportFilteredList").
' ('.$listofformat[$formatexportset].
')', $langs->trans(
'ConfirmExportFile'),
'export_fileconfirm', $form_question,
'', 1, 300, 600);
837 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
838 $param .=
'&contextpage='.urlencode($contextpage);
840 if ($limit > 0 && $limit != $conf->liste_limit) {
841 $param .=
'&limit='.urlencode($limit);
845 $arrayofmassactions = array();
852 if ($user->rights->accounting->mouvements->supprimer) {
853 $arrayofmassactions[
'predeletebookkeepingwriting'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
855 if (
GETPOST(
'nomassaction',
'int') || in_array($massaction, array(
'preunlettering',
'predeletebookkeepingwriting'))) {
856 $arrayofmassactions = array();
858 $massactionbutton =
$form->selectMassAction($massaction, $arrayofmassactions);
860 print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">';
861 print
'<input type="hidden" name="token" value="'.newToken().
'">';
862 print
'<input type="hidden" name="action" value="list">';
863 if ($optioncss !=
'') {
864 print
'<input type="hidden" name="optioncss" value="'.urlencode($optioncss).
'">';
866 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
867 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
868 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
869 print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
871 if (count($filter)) {
872 $buttonLabel = $langs->trans(
"ExportFilteredList");
874 $buttonLabel = $langs->trans(
"ExportList");
877 $parameters = array(
'param' => $param);
878 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtonsList', $parameters, $object, $action);
883 $newcardbutton = empty($hookmanager->resPrint) ?
'' : $hookmanager->resPrint;
885 if (empty($reshook)) {
887 if (!empty($conf->global->ACCOUNTING_REEXPORT)) {
888 $newcardbutton .=
'<a class="valignmiddle" href="'.$_SERVER[
'PHP_SELF'].
'?action=setreexport&token='.
newToken().
'&value=0'.($param ?
'&'.$param :
'').
'">'.
img_picto($langs->trans(
"Activated"),
'switch_on').
'</a> ';
890 $newcardbutton .=
'<a class="valignmiddle" href="'.$_SERVER[
'PHP_SELF'].
'?action=setreexport&token='.
newToken().
'&value=1'.($param ?
'&'.$param :
'').
'">'.
img_picto($langs->trans(
"Disabled"),
'switch_off').
'</a> ';
892 $newcardbutton .=
'<span class="valignmiddle marginrightonly">'.$langs->trans(
"IncludeDocsAlreadyExported").
'</span>';
894 if (!empty($user->rights->accounting->mouvements->export)) {
895 $newcardbutton .=
dolGetButtonTitle($buttonLabel, $langs->trans(
"ExportFilteredList").
' ('.$listofformat[$formatexportset].
')',
'fa fa-file-export paddingleft', $_SERVER[
"PHP_SELF"].
'?action=export_file'.($param ?
'&'.$param :
''), $user->rights->accounting->mouvements->export);
898 $newcardbutton .=
dolGetButtonTitle($langs->trans(
'ViewFlatList'),
'',
'fa fa-list paddingleft imgforviewmode', DOL_URL_ROOT.
'/accountancy/bookkeeping/list.php?'.$param,
'', 1, array(
'morecss' =>
'marginleftonly btnTitleSelected'));
899 $newcardbutton .=
dolGetButtonTitle($langs->trans(
'GroupByAccountAccounting'),
'',
'fa fa-stream paddingleft imgforviewmode', DOL_URL_ROOT.
'/accountancy/bookkeeping/listbyaccount.php?'.$param,
'', 1, array(
'morecss' =>
'marginleftonly'));
900 $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'));
902 $url =
'./card.php?action=create';
903 if (!empty($socid)) {
904 $url .=
'&socid='.$socid;
906 $newcardbutton .=
dolGetButtonTitle($langs->trans(
'NewAccountingMvt'),
'',
'fa fa-plus-circle paddingleft', $url,
'', $user->rights->accounting->mouvements->creer);
909 print_barre_liste($title_page, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'title_accountancy', 0, $newcardbutton,
'', $limit, 0, 0, 1);
911 if ($massaction ==
'preunlettering') {
912 print
$form->formconfirm($_SERVER[
"PHP_SELF"], $langs->trans(
"ConfirmMassUnlettering"), $langs->trans(
"ConfirmMassUnletteringQuestion", count($toselect)),
"unlettering",
null,
'', 0, 200, 500, 1);
913 } elseif ($massaction ==
'predeletebookkeepingwriting') {
914 print
$form->formconfirm($_SERVER[
"PHP_SELF"], $langs->trans(
"ConfirmMassDeleteBookkeepingWriting"), $langs->trans(
"ConfirmMassDeleteBookkeepingWritingQuestion", count($toselect)),
"deletebookkeepingwriting",
null,
'', 0, 200, 500, 1);
921 include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
923 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
924 $selectedfields =
$form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage);
925 if ($massactionbutton && $contextpage !=
'poslist') {
926 $selectedfields .=
$form->showCheckAddButtons(
'checkforselect', 1);
931 $parameters = array();
932 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters);
933 if (empty($reshook)) {
934 $moreforfilter .= $hookmanager->resPrint;
936 $moreforfilter = $hookmanager->resPrint;
939 print
'<div class="div-table-responsive">';
940 print
'<table class="tagtable liste centpercent">';
943 print
'<tr class="liste_titre_filter">';
946 if (!empty($arrayfields[
't.piece_num'][
'checked'])) {
947 print
'<td class="liste_titre"><input type="text" name="search_mvt_num" size="6" value="'.dol_escape_htmltag($search_mvt_num).
'"></td>';
950 if (!empty($arrayfields[
't.code_journal'][
'checked'])) {
951 print
'<td class="liste_titre center">';
952 print $formaccounting->multi_select_journal($search_ledger_code,
'search_ledger_code', 0, 1, 1, 1,
'small maxwidth150');
956 if (!empty($arrayfields[
't.doc_date'][
'checked'])) {
957 print
'<td class="liste_titre center">';
958 print
'<div class="nowrap">';
959 print
$form->selectDate($search_date_start ? $search_date_start : -1,
'search_date_start', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"From"));
961 print
'<div class="nowrap">';
962 print
$form->selectDate($search_date_end ? $search_date_end : -1,
'search_date_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"to"));
967 if (!empty($arrayfields[
't.doc_ref'][
'checked'])) {
968 print
'<td class="liste_titre"><input type="text" name="search_doc_ref" size="8" value="'.dol_escape_htmltag($search_doc_ref).
'"></td>';
971 if (!empty($arrayfields[
't.numero_compte'][
'checked'])) {
972 print
'<td class="liste_titre">';
973 print
'<div class="nowrap">';
974 print $formaccounting->select_account($search_accountancy_code_start,
'search_accountancy_code_start', $langs->trans(
'From'), array(), 1, 1,
'maxwidth150',
'account');
976 print
'<div class="nowrap">';
977 print $formaccounting->select_account($search_accountancy_code_end,
'search_accountancy_code_end', $langs->trans(
'to'), array(), 1, 1,
'maxwidth150',
'account');
982 if (!empty($arrayfields[
't.subledger_account'][
'checked'])) {
983 print
'<td class="liste_titre">';
986 if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) {
987 print
'<div class="nowrap">';
989 print $formaccounting->select_auxaccount($search_accountancy_aux_code_start,
'search_accountancy_aux_code_start', $langs->trans(
'From'),
'maxwidth250',
'subledgeraccount');
991 print
'<div class="nowrap">';
992 print $formaccounting->select_auxaccount($search_accountancy_aux_code_end,
'search_accountancy_aux_code_end', $langs->trans(
'to'),
'maxwidth250',
'subledgeraccount');
995 print
'<input type="text" class="maxwidth75" name="search_accountancy_aux_code" value="'.$search_accountancy_aux_code.
'">';
1000 if (!empty($arrayfields[
't.label_operation'][
'checked'])) {
1001 print
'<td class="liste_titre">';
1002 print
'<input type="text" size="7" class="flat" name="search_mvt_label" value="'.$search_mvt_label.
'"/>';
1006 if (!empty($arrayfields[
't.debit'][
'checked'])) {
1007 print
'<td class="liste_titre right">';
1008 print
'<input type="text" class="flat" name="search_debit" size="4" value="'.dol_escape_htmltag($search_debit).
'">';
1012 if (!empty($arrayfields[
't.credit'][
'checked'])) {
1013 print
'<td class="liste_titre right">';
1014 print
'<input type="text" class="flat" name="search_credit" size="4" value="'.dol_escape_htmltag($search_credit).
'">';
1018 if (!empty($arrayfields[
't.lettering_code'][
'checked'])) {
1019 print
'<td class="liste_titre center">';
1020 print
'<input type="text" size="3" class="flat" name="search_lettering_code" value="'.$search_lettering_code.
'"/>';
1021 print
'<br><span class="nowrap"><input type="checkbox" name="search_not_reconciled" value="notreconciled"'.($search_not_reconciled ==
'notreconciled' ?
' checked' :
'').
'>'.$langs->trans(
"NotReconciled").
'</span>';
1026 $parameters = array(
'arrayfields'=>$arrayfields);
1027 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters);
1028 print $hookmanager->resPrint;
1031 if (!empty($arrayfields[
't.date_creation'][
'checked'])) {
1032 print
'<td class="liste_titre center">';
1033 print
'<div class="nowrap">';
1034 print
$form->selectDate($search_date_creation_start,
'search_date_creation_start', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"From"));
1036 print
'<div class="nowrap">';
1037 print
$form->selectDate($search_date_creation_end,
'search_date_creation_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"to"));
1042 if (!empty($arrayfields[
't.tms'][
'checked'])) {
1043 print
'<td class="liste_titre center">';
1044 print
'<div class="nowrap">';
1045 print
$form->selectDate($search_date_modification_start,
'search_date_modification_start', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"From"));
1047 print
'<div class="nowrap">';
1048 print
$form->selectDate($search_date_modification_end,
'search_date_modification_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"From"));
1053 if (!empty($arrayfields[
't.date_export'][
'checked'])) {
1054 print
'<td class="liste_titre center">';
1055 print
'<div class="nowrap">';
1056 print
$form->selectDate($search_date_export_start,
'search_date_export_start', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"From"));
1058 print
'<div class="nowrap">';
1059 print
$form->selectDate($search_date_export_end,
'search_date_export_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"to"));
1064 if (!empty($arrayfields[
't.date_validated'][
'checked'])) {
1065 print
'<td class="liste_titre center">';
1066 print
'<div class="nowrap">';
1067 print
$form->selectDate($search_date_validation_start,
'search_date_validation_start', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"From"));
1069 print
'<div class="nowrap">';
1070 print
$form->selectDate($search_date_validation_end,
'search_date_validation_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"to"));
1074 if (!empty($arrayfields[
't.import_key'][
'checked'])) {
1075 print
'<td class="liste_titre center">';
1076 print
'<input class="flat searchstring maxwidth50" type="text" name="search_import_key" value="'.dol_escape_htmltag($search_import_key).
'">';
1080 print
'<td class="liste_titre center">';
1081 $searchpicto =
$form->showFilterButtons();
1086 print
'<tr class="liste_titre">';
1087 if (!empty($arrayfields[
't.piece_num'][
'checked'])) {
1088 print_liste_field_titre($arrayfields[
't.piece_num'][
'label'], $_SERVER[
'PHP_SELF'],
"t.piece_num",
"", $param,
"", $sortfield, $sortorder);
1090 if (!empty($arrayfields[
't.code_journal'][
'checked'])) {
1091 print_liste_field_titre($arrayfields[
't.code_journal'][
'label'], $_SERVER[
'PHP_SELF'],
"t.code_journal",
"", $param,
'', $sortfield, $sortorder,
'center ');
1093 if (!empty($arrayfields[
't.doc_date'][
'checked'])) {
1094 print_liste_field_titre($arrayfields[
't.doc_date'][
'label'], $_SERVER[
'PHP_SELF'],
"t.doc_date",
"", $param,
'', $sortfield, $sortorder,
'center ');
1096 if (!empty($arrayfields[
't.doc_ref'][
'checked'])) {
1097 print_liste_field_titre($arrayfields[
't.doc_ref'][
'label'], $_SERVER[
'PHP_SELF'],
"t.doc_ref",
"", $param,
"", $sortfield, $sortorder);
1099 if (!empty($arrayfields[
't.numero_compte'][
'checked'])) {
1100 print_liste_field_titre($arrayfields[
't.numero_compte'][
'label'], $_SERVER[
'PHP_SELF'],
"t.numero_compte",
"", $param,
"", $sortfield, $sortorder);
1102 if (!empty($arrayfields[
't.subledger_account'][
'checked'])) {
1103 print_liste_field_titre($arrayfields[
't.subledger_account'][
'label'], $_SERVER[
'PHP_SELF'],
"t.subledger_account",
"", $param,
"", $sortfield, $sortorder);
1105 if (!empty($arrayfields[
't.label_operation'][
'checked'])) {
1106 print_liste_field_titre($arrayfields[
't.label_operation'][
'label'], $_SERVER[
'PHP_SELF'],
"t.label_operation",
"", $param,
"", $sortfield, $sortorder);
1108 if (!empty($arrayfields[
't.debit'][
'checked'])) {
1109 print_liste_field_titre($arrayfields[
't.debit'][
'label'], $_SERVER[
'PHP_SELF'],
"t.debit",
"", $param,
'', $sortfield, $sortorder,
'right ');
1111 if (!empty($arrayfields[
't.credit'][
'checked'])) {
1112 print_liste_field_titre($arrayfields[
't.credit'][
'label'], $_SERVER[
'PHP_SELF'],
"t.credit",
"", $param,
'', $sortfield, $sortorder,
'right ');
1114 if (!empty($arrayfields[
't.lettering_code'][
'checked'])) {
1115 print_liste_field_titre($arrayfields[
't.lettering_code'][
'label'], $_SERVER[
'PHP_SELF'],
"t.lettering_code",
"", $param,
'', $sortfield, $sortorder,
'center ');
1118 $parameters = array(
'arrayfields'=>$arrayfields,
'param'=>$param,
'sortfield'=>$sortfield,
'sortorder'=>$sortorder);
1119 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters);
1120 print $hookmanager->resPrint;
1121 if (!empty($arrayfields[
't.date_creation'][
'checked'])) {
1122 print_liste_field_titre($arrayfields[
't.date_creation'][
'label'], $_SERVER[
'PHP_SELF'],
"t.date_creation",
"", $param,
'', $sortfield, $sortorder,
'center ');
1124 if (!empty($arrayfields[
't.tms'][
'checked'])) {
1125 print_liste_field_titre($arrayfields[
't.tms'][
'label'], $_SERVER[
'PHP_SELF'],
"t.tms",
"", $param,
'', $sortfield, $sortorder,
'center ');
1127 if (!empty($arrayfields[
't.date_export'][
'checked'])) {
1128 print_liste_field_titre($arrayfields[
't.date_export'][
'label'], $_SERVER[
'PHP_SELF'],
"t.date_export",
"", $param,
'', $sortfield, $sortorder,
'center ');
1130 if (!empty($arrayfields[
't.date_validated'][
'checked'])) {
1131 print_liste_field_titre($arrayfields[
't.date_validated'][
'label'], $_SERVER[
'PHP_SELF'],
"t.date_validated",
"", $param,
'', $sortfield, $sortorder,
'center ');
1133 if (!empty($arrayfields[
't.import_key'][
'checked'])) {
1134 print_liste_field_titre($arrayfields[
't.import_key'][
'label'], $_SERVER[
"PHP_SELF"],
"t.import_key",
"", $param,
'', $sortfield, $sortorder,
'center ');
1136 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ');
1145 $totalarray = array();
1146 $totalarray[
'val'] = array ();
1147 $totalarray[
'nbfield'] = 0;
1150 $totalarray[
'val'][
'totaldebit'] = 0;
1151 $totalarray[
'val'][
'totalcredit'] = 0;
1153 while ($i < min($num, $limit)) {
1154 $obj = $db->fetch_object(
$resql);
1159 $line->id = $obj->rowid;
1160 $line->doc_date = $db->jdate($obj->doc_date);
1161 $line->doc_type = $obj->doc_type;
1162 $line->doc_ref = $obj->doc_ref;
1163 $line->fk_doc = $obj->fk_doc;
1164 $line->fk_docdet = $obj->fk_docdet;
1165 $line->thirdparty_code = $obj->thirdparty_code;
1166 $line->subledger_account = $obj->subledger_account;
1167 $line->subledger_label = $obj->subledger_label;
1168 $line->numero_compte = $obj->numero_compte;
1169 $line->label_compte = $obj->label_compte;
1170 $line->label_operation = $obj->label_operation;
1171 $line->debit = $obj->debit;
1172 $line->credit = $obj->credit;
1173 $line->montant = $obj->amount;
1174 $line->amount = $obj->amount;
1175 $line->sens = $obj->sens;
1176 $line->lettering_code = $obj->lettering_code;
1177 $line->fk_user_author = $obj->fk_user_author;
1178 $line->import_key = $obj->import_key;
1179 $line->code_journal = $obj->code_journal;
1180 $line->journal_label = $obj->journal_label;
1181 $line->piece_num = $obj->piece_num;
1182 $line->date_creation = $db->jdate($obj->date_creation);
1183 $line->date_modification = $db->jdate($obj->date_modification);
1184 $line->date_export = $db->jdate($obj->date_export);
1185 $line->date_validation = $db->jdate($obj->date_validation);
1187 $total_debit += $line->debit;
1188 $total_credit += $line->credit;
1190 print
'<tr class="oddeven">';
1193 if (!empty($arrayfields[
't.piece_num'][
'checked'])) {
1195 $object->id = $line->id;
1196 $object->piece_num = $line->piece_num;
1197 print $object->getNomUrl(1,
'', 0,
'', 1);
1200 $totalarray[
'nbfield']++;
1205 if (!empty($arrayfields[
't.code_journal'][
'checked'])) {
1207 $result = $accountingjournal->fetch(
'', $line->code_journal);
1208 $journaltoshow = (($result > 0) ? $accountingjournal->getNomUrl(0, 0, 0,
'', 0) : $line->code_journal);
1209 print
'<td class="center">'.$journaltoshow.
'</td>';
1211 $totalarray[
'nbfield']++;
1216 if (!empty($arrayfields[
't.doc_date'][
'checked'])) {
1217 print
'<td class="center">'.dol_print_date($line->doc_date,
'day').
'</td>';
1219 $totalarray[
'nbfield']++;
1224 if (!empty($arrayfields[
't.doc_ref'][
'checked'])) {
1225 if ($line->doc_type ==
'customer_invoice') {
1226 $langs->loadLangs(array(
'bills'));
1228 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
1229 $objectstatic =
new Facture($db);
1230 $objectstatic->fetch($line->fk_doc);
1235 $urlsource = $_SERVER[
'PHP_SELF'].
'?id='.$objectstatic->id;
1236 $documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir);
1237 } elseif ($line->doc_type ==
'supplier_invoice') {
1238 $langs->loadLangs(array(
'bills'));
1240 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
1242 $objectstatic->fetch($line->fk_doc);
1246 $filedir = $conf->fournisseur->facture->dir_output.
'/'.
get_exdir($line->fk_doc, 2, 0, 0, $objectstatic, $modulepart).dol_sanitizeFileName($line->doc_ref);
1247 $subdir =
get_exdir($objectstatic->id, 2, 0, 0, $objectstatic, $modulepart).dol_sanitizeFileName($line->doc_ref);
1248 $documentlink = $formfile->getDocumentsLink($objectstatic->element, $subdir, $filedir);
1249 } elseif ($line->doc_type ==
'expense_report') {
1250 $langs->loadLangs(array(
'trips'));
1252 require_once DOL_DOCUMENT_ROOT.
'/expensereport/class/expensereport.class.php';
1254 $objectstatic->fetch($line->fk_doc);
1259 $urlsource = $_SERVER[
'PHP_SELF'].
'?id='.$objectstatic->id;
1260 $documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir);
1261 } elseif ($line->doc_type ==
'bank') {
1262 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
1264 $objectstatic->fetch($line->fk_doc);
1270 $labeltoshowalt =
'';
1271 if ($line->doc_type ==
'customer_invoice' || $line->doc_type ==
'supplier_invoice' || $line->doc_type ==
'expense_report') {
1272 $labeltoshow .= $objectstatic->getNomUrl(1,
'', 0, 0,
'', 0, -1, 1);
1273 $labeltoshow .= $documentlink;
1274 $labeltoshowalt .= $objectstatic->ref;
1275 } elseif ($line->doc_type ==
'bank') {
1276 $labeltoshow .= $objectstatic->getNomUrl(1);
1277 $labeltoshowalt .= $objectstatic->ref;
1278 $bank_ref = strstr($line->doc_ref,
'-');
1279 $labeltoshow .=
" " . $bank_ref;
1280 $labeltoshowalt .=
" " . $bank_ref;
1282 $labeltoshow .= $line->doc_ref;
1283 $labeltoshowalt .= $line->doc_ref;
1286 print
'<td class="nowraponall tdoverflowmax200" title="'.dol_escape_htmltag($labeltoshowalt).
'">';
1290 $totalarray[
'nbfield']++;
1295 if (!empty($arrayfields[
't.numero_compte'][
'checked'])) {
1296 print
'<td>'.length_accountg($line->numero_compte).
'</td>';
1298 $totalarray[
'nbfield']++;
1303 if (!empty($arrayfields[
't.subledger_account'][
'checked'])) {
1304 print
'<td>'.length_accounta($line->subledger_account).
'</td>';
1306 $totalarray[
'nbfield']++;
1311 if (!empty($arrayfields[
't.label_operation'][
'checked'])) {
1312 print
'<td class="small tdoverflowmax200" title="'.dol_escape_htmltag($line->label_operation).
'">'.
dol_escape_htmltag($line->label_operation).
'</td>';
1314 $totalarray[
'nbfield']++;
1319 if (!empty($arrayfields[
't.debit'][
'checked'])) {
1320 print
'<td class="right nowraponall amount">'.($line->debit != 0 ?
price($line->debit) :
'').
'</td>';
1322 $totalarray[
'nbfield']++;
1325 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'totaldebit';
1327 $totalarray[
'val'][
'totaldebit'] += $line->debit;
1331 if (!empty($arrayfields[
't.credit'][
'checked'])) {
1332 print
'<td class="right nowraponall amount">'.($line->credit != 0 ?
price($line->credit) :
'').
'</td>';
1334 $totalarray[
'nbfield']++;
1337 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'totalcredit';
1339 $totalarray[
'val'][
'totalcredit'] += $line->credit;
1343 if (!empty($arrayfields[
't.lettering_code'][
'checked'])) {
1344 print
'<td class="center">'.$line->lettering_code.
'</td>';
1346 $totalarray[
'nbfield']++;
1351 $parameters = array(
'arrayfields'=>$arrayfields,
'obj'=>$obj,
'i'=>$i,
'totalarray'=>&$totalarray);
1352 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters);
1353 print $hookmanager->resPrint;
1356 if (!empty($arrayfields[
't.date_creation'][
'checked'])) {
1357 print
'<td class="center">'.dol_print_date($line->date_creation,
'dayhour').
'</td>';
1359 $totalarray[
'nbfield']++;
1364 if (!empty($arrayfields[
't.tms'][
'checked'])) {
1365 print
'<td class="center">'.dol_print_date($line->date_modification,
'dayhour').
'</td>';
1367 $totalarray[
'nbfield']++;
1372 if (!empty($arrayfields[
't.date_export'][
'checked'])) {
1373 print
'<td class="center nowraponall">'.dol_print_date($line->date_export,
'dayhour').
'</td>';
1375 $totalarray[
'nbfield']++;
1380 if (!empty($arrayfields[
't.date_validated'][
'checked'])) {
1381 print
'<td class="center nowraponall">'.dol_print_date($line->date_validation,
'dayhour').
'</td>';
1383 $totalarray[
'nbfield']++;
1387 if (!empty($arrayfields[
't.import_key'][
'checked'])) {
1388 print
'<td class="tdoverflowmax100">'.$obj->import_key.
"</td>\n";
1390 $totalarray[
'nbfield']++;
1395 print
'<td class="nowraponall center">';
1396 if (($massactionbutton || $massaction) && $contextpage !=
'poslist') {
1398 if (in_array($line->id, $arrayofselected)) {
1401 print
'<input id="cb'.$line->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$line->id.
'"'.($selected ?
' checked="checked"' :
'').
' />';
1406 $totalarray[
'nbfield']++;
1415 include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';