31 require
'../../main.inc.php';
32 require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountancyexport.class.php';
33 require_once DOL_DOCUMENT_ROOT.
'/core/lib/accounting.lib.php';
34 require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/lettering.class.php';
35 require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/bookkeeping.class.php';
36 require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountingjournal.class.php';
37 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
38 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
39 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formaccounting.class.php';
40 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
41 require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
44 $langs->loadLangs(array(
"accountancy",
"compta"));
46 $socid =
GETPOST(
'socid',
'int');
48 $action =
GETPOST(
'action',
'aZ09');
49 $massaction =
GETPOST(
'massaction',
'alpha');
50 $confirm =
GETPOST(
'confirm',
'alpha');
51 $toselect =
GETPOST(
'toselect',
'array');
52 $contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'bookkeepinglist';
53 $search_mvt_num =
GETPOST(
'search_mvt_num',
'int');
54 $search_doc_type =
GETPOST(
"search_doc_type",
'alpha');
55 $search_doc_ref =
GETPOST(
"search_doc_ref",
'alpha');
56 $search_date_startyear =
GETPOST(
'search_date_startyear',
'int');
57 $search_date_startmonth =
GETPOST(
'search_date_startmonth',
'int');
58 $search_date_startday =
GETPOST(
'search_date_startday',
'int');
59 $search_date_endyear =
GETPOST(
'search_date_endyear',
'int');
60 $search_date_endmonth =
GETPOST(
'search_date_endmonth',
'int');
61 $search_date_endday =
GETPOST(
'search_date_endday',
'int');
62 $search_date_start =
dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear);
63 $search_date_end =
dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear);
65 $search_date_creation_startyear =
GETPOST(
'search_date_creation_startyear',
'int');
66 $search_date_creation_startmonth =
GETPOST(
'search_date_creation_startmonth',
'int');
67 $search_date_creation_startday =
GETPOST(
'search_date_creation_startday',
'int');
68 $search_date_creation_endyear =
GETPOST(
'search_date_creation_endyear',
'int');
69 $search_date_creation_endmonth =
GETPOST(
'search_date_creation_endmonth',
'int');
70 $search_date_creation_endday =
GETPOST(
'search_date_creation_endday',
'int');
71 $search_date_creation_start =
dol_mktime(0, 0, 0, $search_date_creation_startmonth, $search_date_creation_startday, $search_date_creation_startyear);
72 $search_date_creation_end =
dol_mktime(23, 59, 59, $search_date_creation_endmonth, $search_date_creation_endday, $search_date_creation_endyear);
73 $search_date_modification_startyear =
GETPOST(
'search_date_modification_startyear',
'int');
74 $search_date_modification_startmonth =
GETPOST(
'search_date_modification_startmonth',
'int');
75 $search_date_modification_startday =
GETPOST(
'search_date_modification_startday',
'int');
76 $search_date_modification_endyear =
GETPOST(
'search_date_modification_endyear',
'int');
77 $search_date_modification_endmonth =
GETPOST(
'search_date_modification_endmonth',
'int');
78 $search_date_modification_endday =
GETPOST(
'search_date_modification_endday',
'int');
79 $search_date_modification_start =
dol_mktime(0, 0, 0, $search_date_modification_startmonth, $search_date_modification_startday, $search_date_modification_startyear);
80 $search_date_modification_end =
dol_mktime(23, 59, 59, $search_date_modification_endmonth, $search_date_modification_endday, $search_date_modification_endyear);
81 $search_date_export_startyear =
GETPOST(
'search_date_export_startyear',
'int');
82 $search_date_export_startmonth =
GETPOST(
'search_date_export_startmonth',
'int');
83 $search_date_export_startday =
GETPOST(
'search_date_export_startday',
'int');
84 $search_date_export_endyear =
GETPOST(
'search_date_export_endyear',
'int');
85 $search_date_export_endmonth =
GETPOST(
'search_date_export_endmonth',
'int');
86 $search_date_export_endday =
GETPOST(
'search_date_export_endday',
'int');
87 $search_date_export_start =
dol_mktime(0, 0, 0, $search_date_export_startmonth, $search_date_export_startday, $search_date_export_startyear);
88 $search_date_export_end =
dol_mktime(23, 59, 59, $search_date_export_endmonth, $search_date_export_endday, $search_date_export_endyear);
89 $search_date_validation_startyear =
GETPOST(
'search_date_validation_startyear',
'int');
90 $search_date_validation_startmonth =
GETPOST(
'search_date_validation_startmonth',
'int');
91 $search_date_validation_startday =
GETPOST(
'search_date_validation_startday',
'int');
92 $search_date_validation_endyear =
GETPOST(
'search_date_validation_endyear',
'int');
93 $search_date_validation_endmonth =
GETPOST(
'search_date_validation_endmonth',
'int');
94 $search_date_validation_endday =
GETPOST(
'search_date_validation_endday',
'int');
95 $search_date_validation_start =
dol_mktime(0, 0, 0, $search_date_validation_startmonth, $search_date_validation_startday, $search_date_validation_startyear);
96 $search_date_validation_end =
dol_mktime(23, 59, 59, $search_date_validation_endmonth, $search_date_validation_endday, $search_date_validation_endyear);
97 $search_import_key =
GETPOST(
"search_import_key",
'alpha');
101 $action =
'delbookkeepingyear';
103 if (
GETPOST(
"button_export_file_x") ||
GETPOST(
"button_export_file.x") ||
GETPOST(
"button_export_file")) {
104 $action =
'export_file';
107 $search_account_category =
GETPOST(
'search_account_category',
'int');
109 $search_accountancy_code =
GETPOST(
"search_accountancy_code",
'alpha');
110 $search_accountancy_code_start =
GETPOST(
'search_accountancy_code_start',
'alpha');
111 if ($search_accountancy_code_start == - 1) {
112 $search_accountancy_code_start =
'';
114 $search_accountancy_code_end =
GETPOST(
'search_accountancy_code_end',
'alpha');
115 if ($search_accountancy_code_end == - 1) {
116 $search_accountancy_code_end =
'';
119 $search_accountancy_aux_code =
GETPOST(
"search_accountancy_aux_code",
'alpha');
120 $search_accountancy_aux_code_start =
GETPOST(
'search_accountancy_aux_code_start',
'alpha');
121 if ($search_accountancy_aux_code_start == - 1) {
122 $search_accountancy_aux_code_start =
'';
124 $search_accountancy_aux_code_end =
GETPOST(
'search_accountancy_aux_code_end',
'alpha');
125 if ($search_accountancy_aux_code_end == - 1) {
126 $search_accountancy_aux_code_end =
'';
128 $search_mvt_label =
GETPOST(
'search_mvt_label',
'alpha');
129 $search_direction =
GETPOST(
'search_direction',
'alpha');
130 $search_debit =
GETPOST(
'search_debit',
'alpha');
131 $search_credit =
GETPOST(
'search_credit',
'alpha');
132 $search_ledger_code =
GETPOST(
'search_ledger_code',
'array');
133 $search_lettering_code =
GETPOST(
'search_lettering_code',
'alpha');
134 $search_not_reconciled =
GETPOST(
'search_not_reconciled',
'alpha');
137 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : (empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION) ? $conf->liste_limit : $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION);
138 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
139 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
140 $optioncss =
GETPOST(
'optioncss',
'alpha');
142 if (empty($page) || $page < 0) {
145 $offset = $limit * $page;
146 $pageprev = $page - 1;
147 $pagenext = $page + 1;
148 if ($sortorder ==
"") {
151 if ($sortfield ==
"") {
152 $sortfield =
"t.piece_num,t.rowid";
157 $hookmanager->initHooks(array(
'bookkeepinglist'));
162 if (!in_array($action, array(
'export_file',
'delmouv',
'delmouvconfirm')) && !
GETPOSTISSET(
'begin') && !
GETPOSTISSET(
'formfilteraction') &&
GETPOST(
'page',
'int') ==
'' && !
GETPOST(
'noreset',
'int') && $user->hasRight(
'accounting',
'mouvements',
'export')) {
163 if (empty($search_date_start) && empty($search_date_end) && !
GETPOSTISSET(
'restore_lastsearch_values') && !
GETPOST(
'search_accountancy_code_start')) {
164 $query =
"SELECT date_start, date_end from ".MAIN_DB_PREFIX.
"accounting_fiscalyear ";
165 $query .=
" where date_start < '".$db->idate(
dol_now()).
"' and date_end > '".$db->idate(
dol_now()).
"' limit 1";
166 $res = $db->query($query);
168 if ($res->num_rows > 0) {
169 $fiscalYear = $db->fetch_object($res);
170 $search_date_start = strtotime($fiscalYear->date_start);
171 $search_date_end = strtotime($fiscalYear->date_end);
173 $month_start = ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1);
178 $year_end = $year_start + 1;
179 $month_end = $month_start - 1;
180 if ($month_end < 1) {
184 $search_date_start =
dol_mktime(0, 0, 0, $month_start, 1, $year_start);
191 $arrayfields = array(
192 't.piece_num'=>array(
'label'=>$langs->trans(
"TransactionNumShort"),
'checked'=>1),
193 't.code_journal'=>array(
'label'=>$langs->trans(
"Codejournal"),
'checked'=>1),
194 't.doc_date'=>array(
'label'=>$langs->trans(
"Docdate"),
'checked'=>1),
195 't.doc_ref'=>array(
'label'=>$langs->trans(
"Piece"),
'checked'=>1),
196 't.numero_compte'=>array(
'label'=>$langs->trans(
"AccountAccountingShort"),
'checked'=>1),
197 't.subledger_account'=>array(
'label'=>$langs->trans(
"SubledgerAccount"),
'checked'=>1),
198 't.label_operation'=>array(
'label'=>$langs->trans(
"Label"),
'checked'=>1),
199 't.debit'=>array(
'label'=>$langs->trans(
"AccountingDebit"),
'checked'=>1),
200 't.credit'=>array(
'label'=>$langs->trans(
"AccountingCredit"),
'checked'=>1),
201 't.lettering_code'=>array(
'label'=>$langs->trans(
"LetteringCode"),
'checked'=>1),
202 't.date_creation'=>array(
'label'=>$langs->trans(
"DateCreation"),
'checked'=>0),
203 't.tms'=>array(
'label'=>$langs->trans(
"DateModification"),
'checked'=>0),
204 't.date_export'=>array(
'label'=>$langs->trans(
"DateExport"),
'checked'=>1),
205 't.date_validated'=>array(
'label'=>$langs->trans(
"DateValidationAndLock"),
'checked'=>1,
'enabled'=>!
getDolGlobalString(
"ACCOUNTANCY_DISABLE_CLOSURE_LINE_BY_LINE")),
206 't.import_key'=>array(
'label'=>$langs->trans(
"ImportId"),
'checked'=>0,
'position'=>1100),
209 if (empty($conf->global->ACCOUNTING_ENABLE_LETTERING)) {
210 unset($arrayfields[
't.lettering_code']);
214 $listofformat = $accountancyexport->getType();
216 if (empty($listofformat[$formatexportset])) {
217 $formatexportset = 1;
225 if ($user->socid > 0) {
228 if (!$user->hasRight(
'accounting',
'mouvements',
'lire')) {
239 if (
GETPOST(
'cancel',
'alpha')) {
240 $action =
'list'; $massaction =
'';
242 if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'preunletteringauto' && $massaction !=
'preunletteringmanual' && $massaction !=
'predeletebookkeepingwriting') {
246 $parameters = array(
'socid'=>$socid);
247 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
252 if (empty($reshook)) {
253 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
255 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
256 $search_mvt_num =
'';
257 $search_doc_type =
'';
258 $search_doc_ref =
'';
259 $search_doc_date =
'';
260 $search_account_category =
'';
261 $search_accountancy_code =
'';
262 $search_accountancy_code_start =
'';
263 $search_accountancy_code_end =
'';
264 $search_accountancy_aux_code =
'';
265 $search_accountancy_aux_code_start =
'';
266 $search_accountancy_aux_code_end =
'';
267 $search_mvt_label =
'';
268 $search_direction =
'';
269 $search_ledger_code = array();
270 $search_date_startyear =
'';
271 $search_date_startmonth =
'';
272 $search_date_startday =
'';
273 $search_date_endyear =
'';
274 $search_date_endmonth =
'';
275 $search_date_endday =
'';
276 $search_date_start =
'';
277 $search_date_end =
'';
278 $search_date_creation_startyear =
'';
279 $search_date_creation_startmonth =
'';
280 $search_date_creation_startday =
'';
281 $search_date_creation_endyear =
'';
282 $search_date_creation_endmonth =
'';
283 $search_date_creation_endday =
'';
284 $search_date_creation_start =
'';
285 $search_date_creation_end =
'';
286 $search_date_modification_startyear =
'';
287 $search_date_modification_startmonth =
'';
288 $search_date_modification_startday =
'';
289 $search_date_modification_endyear =
'';
290 $search_date_modification_endmonth =
'';
291 $search_date_modification_endday =
'';
292 $search_date_modification_start =
'';
293 $search_date_modification_end =
'';
294 $search_date_export_startyear =
'';
295 $search_date_export_startmonth =
'';
296 $search_date_export_startday =
'';
297 $search_date_export_endyear =
'';
298 $search_date_export_endmonth =
'';
299 $search_date_export_endday =
'';
300 $search_date_export_start =
'';
301 $search_date_export_end =
'';
302 $search_date_validation_startyear =
'';
303 $search_date_validation_startmonth =
'';
304 $search_date_validation_startday =
'';
305 $search_date_validation_endyear =
'';
306 $search_date_validation_endmonth =
'';
307 $search_date_validation_endday =
'';
308 $search_date_validation_start =
'';
309 $search_date_validation_end =
'';
312 $search_lettering_code =
'';
313 $search_not_reconciled =
'';
314 $search_import_key =
'';
320 if (!empty($search_date_start)) {
321 $filter[
't.doc_date>='] = $search_date_start;
323 $param .=
'&search_date_startmonth='.urlencode($tmp[
'mon']).
'&search_date_startday='.urlencode($tmp[
'mday']).
'&search_date_startyear='.urlencode($tmp[
'year']);
325 if (!empty($search_date_end)) {
326 $filter[
't.doc_date<='] = $search_date_end;
328 $param .=
'&search_date_endmonth='.urlencode($tmp[
'mon']).
'&search_date_endday='.urlencode($tmp[
'mday']).
'&search_date_endyear='.urlencode($tmp[
'year']);
330 if (!empty($search_doc_date)) {
331 $filter[
't.doc_date'] = $search_doc_date;
333 $param .=
'&doc_datemonth='.urlencode($tmp[
'mon']).
'&doc_dateday='.urlencode($tmp[
'mday']).
'&doc_dateyear='.urlencode($tmp[
'year']);
335 if (!empty($search_doc_type)) {
336 $filter[
't.doc_type'] = $search_doc_type;
337 $param .=
'&search_doc_type='.urlencode($search_doc_type);
339 if (!empty($search_doc_ref)) {
340 $filter[
't.doc_ref'] = $search_doc_ref;
341 $param .=
'&search_doc_ref='.urlencode($search_doc_ref);
343 if ($search_account_category !=
'-1' && !empty($search_account_category)) {
344 require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountancycategory.class.php';
347 $listofaccountsforgroup = $accountingcategory->getCptsCat(0,
'fk_accounting_category = '.((
int) $search_account_category));
348 $listofaccountsforgroup2 = array();
349 if (is_array($listofaccountsforgroup)) {
350 foreach ($listofaccountsforgroup as $tmpval) {
351 $listofaccountsforgroup2[] =
"'".$db->escape($tmpval[
'id']).
"'";
354 $filter[
't.search_accounting_code_in'] = join(
',', $listofaccountsforgroup2);
355 $param .=
'&search_account_category='.urlencode($search_account_category);
357 if (!empty($search_accountancy_code)) {
358 $filter[
't.numero_compte'] = $search_accountancy_code;
359 $param .=
'&search_accountancy_code='.urlencode($search_accountancy_code);
361 if (!empty($search_accountancy_code_start)) {
362 $filter[
't.numero_compte>='] = $search_accountancy_code_start;
363 $param .=
'&search_accountancy_code_start='.urlencode($search_accountancy_code_start);
365 if (!empty($search_accountancy_code_end)) {
366 $filter[
't.numero_compte<='] = $search_accountancy_code_end;
367 $param .=
'&search_accountancy_code_end='.urlencode($search_accountancy_code_end);
369 if (!empty($search_accountancy_aux_code)) {
370 $filter[
't.subledger_account'] = $search_accountancy_aux_code;
371 $param .=
'&search_accountancy_aux_code='.urlencode($search_accountancy_aux_code);
373 if (!empty($search_accountancy_aux_code_start)) {
374 $filter[
't.subledger_account>='] = $search_accountancy_aux_code_start;
375 $param .=
'&search_accountancy_aux_code_start='.urlencode($search_accountancy_aux_code_start);
377 if (!empty($search_accountancy_aux_code_end)) {
378 $filter[
't.subledger_account<='] = $search_accountancy_aux_code_end;
379 $param .=
'&search_accountancy_aux_code_end='.urlencode($search_accountancy_aux_code_end);
381 if (!empty($search_mvt_label)) {
382 $filter[
't.label_operation'] = $search_mvt_label;
383 $param .=
'&search_mvt_label='.urlencode($search_mvt_label);
385 if (!empty($search_direction)) {
386 $filter[
't.sens'] = $search_direction;
387 $param .=
'&search_direction='.urlencode($search_direction);
389 if (!empty($search_ledger_code)) {
390 $filter[
't.code_journal'] = $search_ledger_code;
391 foreach ($search_ledger_code as $code) {
392 $param .=
'&search_ledger_code[]='.urlencode($code);
395 if (!empty($search_mvt_num)) {
396 $filter[
't.piece_num'] = $search_mvt_num;
397 $param .=
'&search_mvt_num='.urlencode($search_mvt_num);
399 if (!empty($search_date_creation_start)) {
400 $filter[
't.date_creation>='] = $search_date_creation_start;
402 $param .=
'&search_date_creation_startmonth='.urlencode($tmp[
'mon']).
'&search_date_creation_startday='.urlencode($tmp[
'mday']).
'&search_date_creation_startyear='.urlencode($tmp[
'year']);
404 if (!empty($search_date_creation_end)) {
405 $filter[
't.date_creation<='] = $search_date_creation_end;
407 $param .=
'&search_date_creation_endmonth='.urlencode($tmp[
'mon']).
'&search_date_creation_endday='.urlencode($tmp[
'mday']).
'&search_date_creation_endyear='.urlencode($tmp[
'year']);
409 if (!empty($search_date_modification_start)) {
410 $filter[
't.tms>='] = $search_date_modification_start;
411 $tmp =
dol_getdate($search_date_modification_start);
412 $param .=
'&search_date_modification_startmonth='.urlencode($tmp[
'mon']).
'&search_date_modification_startday='.urlencode($tmp[
'mday']).
'&search_date_modification_startyear='.urlencode($tmp[
'year']);
414 if (!empty($search_date_modification_end)) {
415 $filter[
't.tms<='] = $search_date_modification_end;
417 $param .=
'&search_date_modification_endmonth='.urlencode($tmp[
'mon']).
'&search_date_modification_endday='.urlencode($tmp[
'mday']).
'&search_date_modification_endyear='.urlencode($tmp[
'year']);
419 if (!empty($search_date_export_start)) {
420 $filter[
't.date_export>='] = $search_date_export_start;
422 $param .=
'&search_date_export_startmonth='.urlencode($tmp[
'mon']).
'&search_date_export_startday='.urlencode($tmp[
'mday']).
'&search_date_export_startyear='.urlencode($tmp[
'year']);
424 if (!empty($search_date_export_end)) {
425 $filter[
't.date_export<='] = $search_date_export_end;
427 $param .=
'&search_date_export_endmonth='.urlencode($tmp[
'mon']).
'&search_date_export_endday='.urlencode($tmp[
'mday']).
'&search_date_export_endyear='.urlencode($tmp[
'year']);
429 if (!empty($search_date_validation_start)) {
430 $filter[
't.date_validated>='] = $search_date_validation_start;
432 $param .=
'&search_date_validation_startmonth='.urlencode($tmp[
'mon']).
'&search_date_validation_startday='.urlencode($tmp[
'mday']).
'&search_date_validation_startyear='.urlencode($tmp[
'year']);
434 if (!empty($search_date_validation_end)) {
435 $filter[
't.date_validated<='] = $search_date_validation_end;
437 $param .=
'&search_date_validation_endmonth='.urlencode($tmp[
'mon']).
'&search_date_validation_endday='.urlencode($tmp[
'mday']).
'&search_date_validation_endyear='.urlencode($tmp[
'year']);
439 if (!empty($search_debit)) {
440 $filter[
't.debit'] = $search_debit;
441 $param .=
'&search_debit='.urlencode($search_debit);
443 if (!empty($search_credit)) {
444 $filter[
't.credit'] = $search_credit;
445 $param .=
'&search_credit='.urlencode($search_credit);
447 if (!empty($search_lettering_code)) {
448 $filter[
't.lettering_code'] = $search_lettering_code;
449 $param .=
'&search_lettering_code='.urlencode($search_lettering_code);
451 if (!empty($search_not_reconciled)) {
452 $filter[
't.reconciled_option'] = $search_not_reconciled;
453 $param .=
'&search_not_reconciled='.urlencode($search_not_reconciled);
455 if (!empty($search_import_key)) {
456 $filter[
't.import_key'] = $search_import_key;
457 $param .=
'&search_import_key='.urlencode($search_import_key);
486 if ($action ==
'setreexport') {
487 $setreexport =
GETPOST(
'value',
'int');
488 if (!
dolibarr_set_const($db,
"ACCOUNTING_REEXPORT", $setreexport,
'yesno', 0,
'', $conf->entity)) {
493 if ($conf->global->ACCOUNTING_REEXPORT == 1) {
494 setEventMessages($langs->trans(
"ExportOfPiecesAlreadyExportedIsEnable"),
null,
'mesgs');
496 setEventMessages($langs->trans(
"ExportOfPiecesAlreadyExportedIsDisable"),
null,
'warnings');
504 $objectclass =
'Bookkeeping';
505 $objectlabel =
'Bookkeeping';
506 $permissiontoread = $user->hasRight(
'societe',
'lire');
507 $permissiontodelete = $user->hasRight(
'societe',
'supprimer');
508 $permissiontoadd = $user->hasRight(
'societe',
'creer');
509 $uploaddir = $conf->societe->dir_output;
510 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
512 if (!$error && $action ==
'deletebookkeepingwriting' && $confirm ==
"yes" && $user->hasRight(
'accounting',
'mouvements',
'supprimer')) {
517 $nb_lettering = $lettering->bookkeepingLetteringAll($toselect,
true);
518 if ($nb_lettering < 0) {
526 foreach ($toselect as $toselectid) {
527 $result = $object->fetch($toselectid);
528 if ($result > 0 && (!isset($object->date_validation) || $object->date_validation ===
'')) {
529 $result = $object->deleteMvtNum($object->piece_num);
537 } elseif ($result < 0) {
551 } elseif ($nbok > 0) {
557 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?noreset=1".($param ?
'&'.$param :
''));
565 if (!$error &&
getDolGlobalInt(
'ACCOUNTING_ENABLE_LETTERING') && $user->hasRight(
'accounting',
'mouvements',
'creer')) {
566 if ($massaction ==
'letteringauto') {
568 $nb_lettering = $lettering->bookkeepingLetteringAll($toselect);
569 if ($nb_lettering < 0) {
572 $nb_lettering = max(0, abs($nb_lettering) - 2);
573 } elseif ($nb_lettering == 0) {
575 setEventMessages($langs->trans(
'AccountancyNoLetteringModified'), array(),
'mesgs');
577 if ($nb_lettering == 1) {
578 setEventMessages($langs->trans(
'AccountancyOneLetteringModifiedSuccessfully'), array(),
'mesgs');
579 } elseif ($nb_lettering > 1) {
580 setEventMessages($langs->trans(
'AccountancyLetteringModifiedSuccessfully', $nb_lettering), array(),
'mesgs');
584 header(
'Location: ' . $_SERVER[
'PHP_SELF'] .
'?noreset=1' . $param);
587 } elseif ($massaction ==
'letteringmanual') {
589 $result = $lettering->updateLettering($toselect);
593 setEventMessages($langs->trans(
'AccountancyOneLetteringModifiedSuccessfully'), array(),
'mesgs');
594 header(
'Location: ' . $_SERVER[
'PHP_SELF'] .
'?noreset=1' . $param);
597 } elseif ($action ==
'unletteringauto' && $confirm ==
"yes") {
599 $nb_lettering = $lettering->bookkeepingLetteringAll($toselect,
true);
600 if ($nb_lettering < 0) {
603 $nb_lettering = max(0, abs($nb_lettering) - 2);
604 } elseif ($nb_lettering == 0) {
606 setEventMessages($langs->trans(
'AccountancyNoUnletteringModified'), array(),
'mesgs');
608 if ($nb_lettering == 1) {
609 setEventMessages($langs->trans(
'AccountancyOneUnletteringModifiedSuccessfully'), array(),
'mesgs');
610 } elseif ($nb_lettering > 1) {
611 setEventMessages($langs->trans(
'AccountancyUnletteringModifiedSuccessfully', $nb_lettering), array(),
'mesgs');
615 header(
'Location: ' . $_SERVER[
'PHP_SELF'] .
'?noreset=1' . $param);
618 } elseif ($action ==
'unletteringmanual' && $confirm ==
"yes") {
620 $nb_lettering = $lettering->deleteLettering($toselect);
624 setEventMessages($langs->trans(
'AccountancyOneUnletteringModifiedSuccessfully'), array(),
'mesgs');
625 header(
'Location: ' . $_SERVER[
'PHP_SELF'] .
'?noreset=1' . $param);
638 $sql .=
" t.doc_date,";
639 $sql .=
" t.doc_type,";
640 $sql .=
" t.doc_ref,";
641 $sql .=
" t.fk_doc,";
642 $sql .=
" t.fk_docdet,";
643 $sql .=
" t.thirdparty_code,";
644 $sql .=
" t.subledger_account,";
645 $sql .=
" t.subledger_label,";
646 $sql .=
" t.numero_compte,";
647 $sql .=
" t.label_compte,";
648 $sql .=
" t.label_operation,";
650 $sql .=
" t.credit,";
651 $sql .=
" t.lettering_code,";
652 $sql .=
" t.montant as amount,";
654 $sql .=
" t.fk_user_author,";
655 $sql .=
" t.import_key,";
656 $sql .=
" t.code_journal,";
657 $sql .=
" t.journal_label,";
658 $sql .=
" t.piece_num,";
659 $sql .=
" t.date_creation,";
660 $sql .=
" t.tms as date_modification,";
661 $sql .=
" t.date_export,";
662 $sql .=
" t.date_validated as date_validation,";
663 $sql .=
" t.import_key";
667 $sql .=
' FROM '.MAIN_DB_PREFIX.$object->table_element.
' as t';
670 if (count($filter) > 0) {
671 foreach ($filter as $key => $value) {
672 if ($key ==
't.doc_date') {
673 $sqlwhere[] = $key.
"='".$db->idate($value).
"'";
674 } elseif ($key ==
't.doc_date>=' || $key ==
't.doc_date<=') {
675 $sqlwhere[] = $key.
"'".$db->idate($value).
"'";
676 } elseif ($key ==
't.numero_compte>=' || $key ==
't.numero_compte<=' || $key ==
't.subledger_account>=' || $key ==
't.subledger_account<=') {
677 $sqlwhere[] = $key.
"'".$db->escape($value).
"'";
678 } elseif ($key ==
't.fk_doc' || $key ==
't.fk_docdet' || $key ==
't.piece_num') {
679 $sqlwhere[] = $key.
'='.((int) $value);
680 } elseif ($key ==
't.subledger_account' || $key ==
't.numero_compte') {
681 $sqlwhere[] = $key.
" LIKE '".$db->escape($value).
"%'";
682 } elseif ($key ==
't.subledger_account') {
684 } elseif ($key ==
't.date_creation>=' || $key ==
't.date_creation<=') {
685 $sqlwhere[] = $key.
"'".$db->idate($value).
"'";
686 } elseif ($key ==
't.tms>=' || $key ==
't.tms<=') {
687 $sqlwhere[] = $key.
"'".$db->idate($value).
"'";
688 } elseif ($key ==
't.date_export>=' || $key ==
't.date_export<=') {
689 $sqlwhere[] = $key.
"'".$db->idate($value).
"'";
690 } elseif ($key ==
't.date_validated>=' || $key ==
't.date_validated<=') {
691 $sqlwhere[] = $key.
"'".$db->idate($value).
"'";
692 } elseif ($key ==
't.credit' || $key ==
't.debit') {
694 } elseif ($key ==
't.reconciled_option') {
695 $sqlwhere[] =
't.lettering_code IS NULL';
696 } elseif ($key ==
't.code_journal' && !empty($value)) {
697 if (is_array($value)) {
698 $sqlwhere[] =
natural_search(
"t.code_journal", join(
',', $value), 3, 1);
702 } elseif ($key ==
't.search_accounting_code_in' && !empty($value)) {
703 $sqlwhere[] =
't.numero_compte IN ('.$db->sanitize($value, 1).
')';
709 $sql .=
' WHERE t.entity IN ('.getEntity(
'accountancy').
')';
710 if (empty($conf->global->ACCOUNTING_REEXPORT)) {
711 $sql .=
" AND t.date_export IS NULL";
713 if (count($sqlwhere) > 0) {
714 $sql .=
' AND '.implode(
' AND ', $sqlwhere);
721 if ($action ==
'export_fileconfirm' && $user->hasRight(
'accounting',
'mouvements',
'export')) {
724 $result = $object->fetchAll($sortorder, $sortfield, 0, 0, $filter,
'AND', (empty($conf->global->ACCOUNTING_REEXPORT) ? 0 : 1));
732 $formatexport =
GETPOST(
'formatexport',
'int');
733 $notexportlettering =
GETPOST(
'notexportlettering',
'alpha');
735 if (!empty($notexportlettering)) {
736 if (is_array($object->lines)) {
737 foreach ($object->lines as $k => $movement) {
738 unset($object->lines[$k]->lettering_code);
739 unset($object->lines[$k]->date_lettering);
744 $notifiedexportdate =
GETPOST(
'notifiedexportdate',
'alpha');
745 $notifiedvalidationdate =
GETPOST(
'notifiedvalidationdate',
'alpha');
746 $withAttachment = !empty(trim(
GETPOST(
'notifiedexportfull',
'alphanohtml'))) ? 1 : 0;
749 $result = $accountancyexport->export($object->lines, $formatexport, $withAttachment);
755 if (!empty($notifiedexportdate) || !empty($notifiedvalidationdate)) {
756 if (is_array($object->lines)) {
760 foreach ($object->lines as $movement) {
763 $sql =
" UPDATE ".MAIN_DB_PREFIX.
"accounting_bookkeeping";
765 if (!empty($notifiedexportdate) && !empty($notifiedvalidationdate)) {
766 $sql .=
" date_export = '".$db->idate($now).
"'";
767 $sql .=
", date_validated = '".$db->idate($now).
"'";
768 } elseif (!empty($notifiedexportdate)) {
769 $sql .=
" date_export = '".$db->idate($now).
"'";
770 } elseif (!empty($notifiedvalidationdate)) {
771 $sql .=
" date_validated = '".$db->idate($now).
"'";
773 $sql .=
" WHERE rowid = ".((int) $movement->id);
775 dol_syslog(
"/accountancy/bookkeeping/list.php Function export_file Specify movements as exported", LOG_DEBUG);
777 $result = $db->query(
$sql);
788 $accountancyexport->errors[] = $langs->trans(
'NotAllExportedMovementsCouldBeRecordedAsExportedOrValidated');
797 header(
'Location: '.$_SERVER[
'PHP_SELF']);
811 $title_page = $langs->trans(
"Operations").
' - '.$langs->trans(
"Journals");
815 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
817 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords',
$sql);
818 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
819 $resql = $db->query($sqlforcount);
821 $objforcount = $db->fetch_object($resql);
835 $sql .= $db->order($sortfield, $sortorder);
837 $sql .= $db->plimit($limit + 1, $offset);
840 $resql = $db->query(
$sql);
846 $num = $db->num_rows($resql);
848 $arrayofselected = is_array($toselect) ? $toselect : array();
857 if ($action ==
'export_file') {
858 $form_question = array();
860 $form_question[
'formatexport'] = array(
861 'name' =>
'formatexport',
863 'label' => $langs->trans(
'Modelcsv'),
864 'values' => $listofformat,
865 'default' => $formatexportset,
866 'morecss' =>
'minwidth200 maxwidth200'
869 $form_question[
'separator0'] = array(
'name'=>
'separator0',
'type'=>
'separator');
873 $checked = !empty($conf->global->ACCOUNTING_DEFAULT_NOT_EXPORT_LETTERING) ?
'true' :
'false';
874 $form_question[
'notexportlettering'] = array(
875 'name' =>
'notexportlettering',
876 'type' =>
'checkbox',
877 'label' => $langs->trans(
'NotExportLettering'),
881 $form_question[
'separator1'] = array(
'name'=>
'separator1',
'type'=>
'separator');
885 $checked = (!isset($conf->global->ACCOUNTING_DEFAULT_NOT_NOTIFIED_EXPORT_DATE) || !empty($conf->global->ACCOUNTING_DEFAULT_NOT_NOTIFIED_EXPORT_DATE));
886 $form_question[
'notifiedexportdate'] = array(
887 'name' =>
'notifiedexportdate',
888 'type' =>
'checkbox',
889 'label' => $langs->trans(
'NotifiedExportDate'),
890 'value' => (!empty($conf->global->ACCOUNTING_DEFAULT_NOT_NOTIFIED_EXPORT_DATE) ?
'false' :
'true'),
893 $form_question[
'separator2'] = array(
'name'=>
'separator2',
'type'=>
'separator');
897 $checked = (isset($conf->global->ACCOUNTING_DEFAULT_NOT_NOTIFIED_VALIDATION_DATE) || !empty($conf->global->ACCOUNTING_DEFAULT_NOT_NOTIFIED_VALIDATION_DATE));
898 $form_question[
'notifiedvalidationdate'] = array(
899 'name' =>
'notifiedvalidationdate',
900 'type' =>
'checkbox',
901 'label' => $langs->trans(
'NotifiedValidationDate', $langs->transnoentitiesnoconv(
"MenuAccountancyClosure")),
905 $form_question[
'separator3'] = array(
'name'=>
'separator3',
'type'=>
'separator');
909 if (
getDolGlobalString(
'ACCOUNTING_EXPORT_MODELCSV') == AccountancyExport::$EXPORT_TYPE_QUADRATUS) {
910 $form_question[
'notifiedexportfull'] = array(
911 'name' =>
'notifiedexportfull',
912 'type' =>
'checkbox',
913 'label' => $langs->trans(
'NotifiedExportFull'),
918 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?'.$param, $langs->trans(
"ExportFilteredList").
'...', $langs->trans(
'ConfirmExportFile'),
'export_fileconfirm', $form_question,
'', 1, 420, 600);
966 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
967 $param .=
'&contextpage='.urlencode($contextpage);
969 if ($limit > 0 && $limit != $conf->liste_limit) {
970 $param .=
'&limit='.urlencode($limit);
974 $arrayofmassactions = array();
975 if (
getDolGlobalInt(
'ACCOUNTING_ENABLE_LETTERING') && $user->rights->accounting->mouvements->creer) {
976 $arrayofmassactions[
'letteringauto'] =
img_picto(
'',
'check',
'class="pictofixedwidth"') . $langs->trans(
'LetteringAuto');
977 $arrayofmassactions[
'preunletteringauto'] =
img_picto(
'',
'uncheck',
'class="pictofixedwidth"') . $langs->trans(
'UnletteringAuto');
978 $arrayofmassactions[
'letteringmanual'] =
img_picto(
'',
'check',
'class="pictofixedwidth"') . $langs->trans(
'LetteringManual');
979 $arrayofmassactions[
'preunletteringmanual'] =
img_picto(
'',
'uncheck',
'class="pictofixedwidth"') . $langs->trans(
'UnletteringManual');
981 if ($user->hasRight(
'accounting',
'mouvements',
'supprimer')) {
982 $arrayofmassactions[
'predeletebookkeepingwriting'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
984 if (
GETPOST(
'nomassaction',
'int') || in_array($massaction, array(
'preunletteringauto',
'preunletteringmanual',
'predeletebookkeepingwriting'))) {
985 $arrayofmassactions = array();
987 $massactionbutton =
$form->selectMassAction($massaction, $arrayofmassactions);
989 print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">';
990 print
'<input type="hidden" name="token" value="'.newToken().
'">';
991 print
'<input type="hidden" name="action" value="list">';
992 if ($optioncss !=
'') {
993 print
'<input type="hidden" name="optioncss" value="'.urlencode($optioncss).
'">';
995 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
996 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
997 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
998 print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
1000 if (count($filter)) {
1001 $buttonLabel = $langs->trans(
"ExportFilteredList");
1003 $buttonLabel = $langs->trans(
"ExportList");
1006 $parameters = array(
'param' => $param);
1007 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtonsList', $parameters, $object, $action);
1012 $newcardbutton = empty($hookmanager->resPrint) ?
'' : $hookmanager->resPrint;
1014 if (empty($reshook)) {
1016 if (!empty($conf->global->ACCOUNTING_REEXPORT)) {
1017 $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"');
1018 $newcardbutton .=
'<span class="valignmiddle marginrightonly paddingleft">'.$langs->trans(
"ClickToHideAlreadyExportedLines").
'</span>';
1019 $newcardbutton .=
'</a>';
1021 $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"');
1022 $newcardbutton .=
'<span class="valignmiddle marginrightonly paddingleft">'.$langs->trans(
"DocsAlreadyExportedAreExcluded").
'</span>';
1023 $newcardbutton .=
'</a>';
1026 if ($user->hasRight(
'accounting',
'mouvements',
'export')) {
1027 $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'));
1030 $newcardbutton .=
dolGetButtonTitle($langs->trans(
'ViewFlatList'),
'',
'fa fa-list paddingleft imgforviewmode', DOL_URL_ROOT.
'/accountancy/bookkeeping/list.php?'.$param,
'', 1, array(
'morecss' =>
'marginleftonly btnTitleSelected'));
1031 $newcardbutton .=
dolGetButtonTitle($langs->trans(
'GroupByAccountAccounting'),
'',
'fa fa-stream paddingleft imgforviewmode', DOL_URL_ROOT.
'/accountancy/bookkeeping/listbyaccount.php?'.$param,
'', 1, array(
'morecss' =>
'marginleftonly'));
1032 $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'));
1034 $url =
'./card.php?action=create';
1035 if (!empty($socid)) {
1036 $url .=
'&socid='.$socid;
1038 $newcardbutton .=
dolGetButtonTitle($langs->trans(
'NewAccountingMvt'),
'',
'fa fa-plus-circle paddingleft', $url,
'', $user->hasRight(
'accounting',
'mouvements',
'creer'));
1041 print_barre_liste($title_page, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num,
$nbtotalofrecords,
'title_accountancy', 0, $newcardbutton,
'', $limit, 0, 0, 1);
1043 if ($massaction ==
'preunletteringauto') {
1044 print
$form->formconfirm($_SERVER[
"PHP_SELF"], $langs->trans(
"ConfirmMassUnletteringAuto"), $langs->trans(
"ConfirmMassUnletteringQuestion", count($toselect)),
"unletteringauto",
null,
'', 0, 200, 500, 1);
1045 } elseif ($massaction ==
'preunletteringmanual') {
1046 print
$form->formconfirm($_SERVER[
"PHP_SELF"], $langs->trans(
"ConfirmMassUnletteringManual"), $langs->trans(
"ConfirmMassUnletteringQuestion", count($toselect)),
"unletteringmanual",
null,
'', 0, 200, 500, 1);
1047 } elseif ($massaction ==
'predeletebookkeepingwriting') {
1048 print
$form->formconfirm($_SERVER[
"PHP_SELF"], $langs->trans(
"ConfirmMassDeleteBookkeepingWriting"), $langs->trans(
"ConfirmMassDeleteBookkeepingWritingQuestion", count($toselect)),
"deletebookkeepingwriting",
null,
'', 0, 200, 500, 1);
1055 include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
1057 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
1058 $selectedfields =
$form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN',
''));
1059 if ($massactionbutton && $contextpage !=
'poslist') {
1060 $selectedfields .=
$form->showCheckAddButtons(
'checkforselect', 1);
1063 $moreforfilter =
'';
1064 $moreforfilter .=
'<div class="divsearchfield">';
1065 $moreforfilter .= $langs->trans(
'AccountingCategory').
': ';
1066 $moreforfilter .=
'<div class="nowrap inline-block">';
1067 $moreforfilter .= $formaccounting->select_accounting_category($search_account_category,
'search_account_category', 1, 0, 0, 0);
1068 $moreforfilter .=
'</div>';
1069 $moreforfilter .=
'</div>';
1071 $parameters = array();
1072 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
1073 if (empty($reshook)) {
1074 $moreforfilter .= $hookmanager->resPrint;
1076 $moreforfilter = $hookmanager->resPrint;
1079 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
1080 print $moreforfilter;
1083 print
'<div class="div-table-responsive">';
1084 print
'<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">';
1087 print
'<tr class="liste_titre_filter">';
1090 print
'<td class="liste_titre center">';
1091 $searchpicto =
$form->showFilterButtons(
'left');
1096 if (!empty($arrayfields[
't.piece_num'][
'checked'])) {
1097 print
'<td class="liste_titre"><input type="text" name="search_mvt_num" size="6" value="'.dol_escape_htmltag($search_mvt_num).
'"></td>';
1100 if (!empty($arrayfields[
't.code_journal'][
'checked'])) {
1101 print
'<td class="liste_titre center">';
1102 print $formaccounting->multi_select_journal($search_ledger_code,
'search_ledger_code', 0, 1, 1, 1,
'small maxwidth75');
1106 if (!empty($arrayfields[
't.doc_date'][
'checked'])) {
1107 print
'<td class="liste_titre center">';
1108 print
'<div class="nowrap">';
1109 print
$form->selectDate($search_date_start ? $search_date_start : -1,
'search_date_start', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"From"));
1111 print
'<div class="nowrap">';
1112 print
$form->selectDate($search_date_end ? $search_date_end : -1,
'search_date_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"to"));
1117 if (!empty($arrayfields[
't.doc_ref'][
'checked'])) {
1118 print
'<td class="liste_titre"><input type="text" name="search_doc_ref" size="8" value="'.dol_escape_htmltag($search_doc_ref).
'"></td>';
1121 if (!empty($arrayfields[
't.numero_compte'][
'checked'])) {
1122 print
'<td class="liste_titre">';
1123 print
'<div class="nowrap">';
1124 print $formaccounting->select_account($search_accountancy_code_start,
'search_accountancy_code_start', $langs->trans(
'From'), array(), 1, 1,
'maxwidth150',
'account');
1126 print
'<div class="nowrap">';
1127 print $formaccounting->select_account($search_accountancy_code_end,
'search_accountancy_code_end', $langs->trans(
'to'), array(), 1, 1,
'maxwidth150',
'account');
1132 if (!empty($arrayfields[
't.subledger_account'][
'checked'])) {
1133 print
'<td class="liste_titre">';
1136 if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) {
1137 print
'<div class="nowrap">';
1139 print $formaccounting->select_auxaccount($search_accountancy_aux_code_start,
'search_accountancy_aux_code_start', $langs->trans(
'From'),
'maxwidth250',
'subledgeraccount');
1141 print
'<div class="nowrap">';
1142 print $formaccounting->select_auxaccount($search_accountancy_aux_code_end,
'search_accountancy_aux_code_end', $langs->trans(
'to'),
'maxwidth250',
'subledgeraccount');
1145 print
'<input type="text" class="maxwidth75" name="search_accountancy_aux_code" value="'.dol_escape_htmltag($search_accountancy_aux_code).
'">';
1150 if (!empty($arrayfields[
't.label_operation'][
'checked'])) {
1151 print
'<td class="liste_titre">';
1152 print
'<input type="text" size="7" class="flat" name="search_mvt_label" value="'.dol_escape_htmltag($search_mvt_label).
'"/>';
1156 if (!empty($arrayfields[
't.debit'][
'checked'])) {
1157 print
'<td class="liste_titre right">';
1158 print
'<input type="text" class="flat" name="search_debit" size="4" value="'.dol_escape_htmltag($search_debit).
'">';
1162 if (!empty($arrayfields[
't.credit'][
'checked'])) {
1163 print
'<td class="liste_titre right">';
1164 print
'<input type="text" class="flat" name="search_credit" size="4" value="'.dol_escape_htmltag($search_credit).
'">';
1168 if (!empty($arrayfields[
't.lettering_code'][
'checked'])) {
1169 print
'<td class="liste_titre center">';
1170 print
'<input type="text" size="3" class="flat" name="search_lettering_code" value="'.dol_escape_htmltag($search_lettering_code).
'"/>';
1171 print
'<br><span class="nowrap"><input type="checkbox" name="search_not_reconciled" value="notreconciled"'.($search_not_reconciled ==
'notreconciled' ?
' checked' :
'').
'>'.$langs->trans(
"NotReconciled").
'</span>';
1176 $parameters = array(
'arrayfields'=>$arrayfields);
1177 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters);
1178 print $hookmanager->resPrint;
1181 if (!empty($arrayfields[
't.date_creation'][
'checked'])) {
1182 print
'<td class="liste_titre center">';
1183 print
'<div class="nowrap">';
1184 print
$form->selectDate($search_date_creation_start,
'search_date_creation_start', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"From"));
1186 print
'<div class="nowrap">';
1187 print
$form->selectDate($search_date_creation_end,
'search_date_creation_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"to"));
1192 if (!empty($arrayfields[
't.tms'][
'checked'])) {
1193 print
'<td class="liste_titre center">';
1194 print
'<div class="nowrap">';
1195 print
$form->selectDate($search_date_modification_start,
'search_date_modification_start', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"From"));
1197 print
'<div class="nowrap">';
1198 print
$form->selectDate($search_date_modification_end,
'search_date_modification_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"From"));
1203 if (!empty($arrayfields[
't.date_export'][
'checked'])) {
1204 print
'<td class="liste_titre center">';
1205 print
'<div class="nowrap">';
1206 print
$form->selectDate($search_date_export_start,
'search_date_export_start', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"From"));
1208 print
'<div class="nowrap">';
1209 print
$form->selectDate($search_date_export_end,
'search_date_export_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"to"));
1214 if (!empty($arrayfields[
't.date_validated'][
'checked'])) {
1215 print
'<td class="liste_titre center">';
1216 print
'<div class="nowrap">';
1217 print
$form->selectDate($search_date_validation_start,
'search_date_validation_start', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"From"));
1219 print
'<div class="nowrap">';
1220 print
$form->selectDate($search_date_validation_end,
'search_date_validation_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"to"));
1224 if (!empty($arrayfields[
't.import_key'][
'checked'])) {
1225 print
'<td class="liste_titre center">';
1226 print
'<input class="flat searchstring maxwidth50" type="text" name="search_import_key" value="'.dol_escape_htmltag($search_import_key).
'">';
1231 print
'<td class="liste_titre center">';
1232 $searchpicto =
$form->showFilterButtons();
1238 print
'<tr class="liste_titre">';
1240 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch actioncolumn ');}
1241 if (!empty($arrayfields[
't.piece_num'][
'checked'])) {
1242 print_liste_field_titre($arrayfields[
't.piece_num'][
'label'], $_SERVER[
'PHP_SELF'],
"t.piece_num",
"", $param,
"", $sortfield, $sortorder);
1244 if (!empty($arrayfields[
't.code_journal'][
'checked'])) {
1245 print_liste_field_titre($arrayfields[
't.code_journal'][
'label'], $_SERVER[
'PHP_SELF'],
"t.code_journal",
"", $param,
'', $sortfield, $sortorder,
'center ');
1247 if (!empty($arrayfields[
't.doc_date'][
'checked'])) {
1248 print_liste_field_titre($arrayfields[
't.doc_date'][
'label'], $_SERVER[
'PHP_SELF'],
"t.doc_date",
"", $param,
'', $sortfield, $sortorder,
'center ');
1250 if (!empty($arrayfields[
't.doc_ref'][
'checked'])) {
1251 print_liste_field_titre($arrayfields[
't.doc_ref'][
'label'], $_SERVER[
'PHP_SELF'],
"t.doc_ref",
"", $param,
"", $sortfield, $sortorder);
1253 if (!empty($arrayfields[
't.numero_compte'][
'checked'])) {
1254 print_liste_field_titre($arrayfields[
't.numero_compte'][
'label'], $_SERVER[
'PHP_SELF'],
"t.numero_compte",
"", $param,
"", $sortfield, $sortorder);
1256 if (!empty($arrayfields[
't.subledger_account'][
'checked'])) {
1257 print_liste_field_titre($arrayfields[
't.subledger_account'][
'label'], $_SERVER[
'PHP_SELF'],
"t.subledger_account",
"", $param,
"", $sortfield, $sortorder);
1259 if (!empty($arrayfields[
't.label_operation'][
'checked'])) {
1260 print_liste_field_titre($arrayfields[
't.label_operation'][
'label'], $_SERVER[
'PHP_SELF'],
"t.label_operation",
"", $param,
"", $sortfield, $sortorder);
1262 if (!empty($arrayfields[
't.debit'][
'checked'])) {
1263 print_liste_field_titre($arrayfields[
't.debit'][
'label'], $_SERVER[
'PHP_SELF'],
"t.debit",
"", $param,
'', $sortfield, $sortorder,
'right ');
1265 if (!empty($arrayfields[
't.credit'][
'checked'])) {
1266 print_liste_field_titre($arrayfields[
't.credit'][
'label'], $_SERVER[
'PHP_SELF'],
"t.credit",
"", $param,
'', $sortfield, $sortorder,
'right ');
1268 if (!empty($arrayfields[
't.lettering_code'][
'checked'])) {
1269 print_liste_field_titre($arrayfields[
't.lettering_code'][
'label'], $_SERVER[
'PHP_SELF'],
"t.lettering_code",
"", $param,
'', $sortfield, $sortorder,
'center ');
1272 $parameters = array(
'arrayfields'=>$arrayfields,
'param'=>$param,
'sortfield'=>$sortfield,
'sortorder'=>$sortorder);
1273 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters);
1274 print $hookmanager->resPrint;
1275 if (!empty($arrayfields[
't.date_creation'][
'checked'])) {
1276 print_liste_field_titre($arrayfields[
't.date_creation'][
'label'], $_SERVER[
'PHP_SELF'],
"t.date_creation",
"", $param,
'', $sortfield, $sortorder,
'center ');
1278 if (!empty($arrayfields[
't.tms'][
'checked'])) {
1279 print_liste_field_titre($arrayfields[
't.tms'][
'label'], $_SERVER[
'PHP_SELF'],
"t.tms",
"", $param,
'', $sortfield, $sortorder,
'center ');
1281 if (!empty($arrayfields[
't.date_export'][
'checked'])) {
1282 print_liste_field_titre($arrayfields[
't.date_export'][
'label'], $_SERVER[
'PHP_SELF'],
"t.date_export,t.doc_date",
"", $param,
'', $sortfield, $sortorder,
'center ');
1284 if (!empty($arrayfields[
't.date_validated'][
'checked'])) {
1285 print_liste_field_titre($arrayfields[
't.date_validated'][
'label'], $_SERVER[
'PHP_SELF'],
"t.date_validated,t.doc_date",
"", $param,
'', $sortfield, $sortorder,
'center ');
1287 if (!empty($arrayfields[
't.import_key'][
'checked'])) {
1288 print_liste_field_titre($arrayfields[
't.import_key'][
'label'], $_SERVER[
"PHP_SELF"],
"t.import_key",
"", $param,
'', $sortfield, $sortorder,
'center ');
1291 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ');
1301 $totalarray = array();
1302 $totalarray[
'nbfield'] = 0;
1305 $totalarray[
'val'] = array ();
1306 $totalarray[
'val'][
'totaldebit'] = 0;
1307 $totalarray[
'val'][
'totalcredit'] = 0;
1309 while ($i < min($num, $limit)) {
1310 $obj = $db->fetch_object($resql);
1315 $line->id = $obj->rowid;
1316 $line->doc_date = $db->jdate($obj->doc_date);
1317 $line->doc_type = $obj->doc_type;
1318 $line->doc_ref = $obj->doc_ref;
1319 $line->fk_doc = $obj->fk_doc;
1320 $line->fk_docdet = $obj->fk_docdet;
1321 $line->thirdparty_code = $obj->thirdparty_code;
1322 $line->subledger_account = $obj->subledger_account;
1323 $line->subledger_label = $obj->subledger_label;
1324 $line->numero_compte = $obj->numero_compte;
1325 $line->label_compte = $obj->label_compte;
1326 $line->label_operation = $obj->label_operation;
1327 $line->debit = $obj->debit;
1328 $line->credit = $obj->credit;
1329 $line->montant = $obj->amount;
1330 $line->amount = $obj->amount;
1331 $line->sens = $obj->sens;
1332 $line->lettering_code = $obj->lettering_code;
1333 $line->fk_user_author = $obj->fk_user_author;
1334 $line->import_key = $obj->import_key;
1335 $line->code_journal = $obj->code_journal;
1336 $line->journal_label = $obj->journal_label;
1337 $line->piece_num = $obj->piece_num;
1338 $line->date_creation = $db->jdate($obj->date_creation);
1339 $line->date_modification = $db->jdate($obj->date_modification);
1340 $line->date_export = $db->jdate($obj->date_export);
1341 $line->date_validation = $db->jdate($obj->date_validation);
1343 $total_debit += $line->debit;
1344 $total_credit += $line->credit;
1346 print
'<tr class="oddeven">';
1349 print
'<td class="nowraponall center">';
1350 if (($massactionbutton || $massaction) && $contextpage !=
'poslist') {
1352 if (in_array($line->id, $arrayofselected)) {
1355 print
'<input id="cb'.$line->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$line->id.
'"'.($selected ?
' checked="checked"' :
'').
' />';
1361 if (!empty($arrayfields[
't.piece_num'][
'checked'])) {
1363 $object->id = $line->id;
1364 $object->piece_num = $line->piece_num;
1365 print $object->getNomUrl(1,
'', 0,
'', 1);
1368 $totalarray[
'nbfield']++;
1373 if (!empty($arrayfields[
't.code_journal'][
'checked'])) {
1375 $result = $accountingjournal->fetch(
'', $line->code_journal);
1376 $journaltoshow = (($result > 0) ? $accountingjournal->getNomUrl(0, 0, 0,
'', 0) : $line->code_journal);
1377 print
'<td class="center tdoverflowmax150">'.$journaltoshow.
'</td>';
1379 $totalarray[
'nbfield']++;
1384 if (!empty($arrayfields[
't.doc_date'][
'checked'])) {
1385 print
'<td class="center">'.dol_print_date($line->doc_date,
'day').
'</td>';
1387 $totalarray[
'nbfield']++;
1392 if (!empty($arrayfields[
't.doc_ref'][
'checked'])) {
1393 if ($line->doc_type ==
'customer_invoice') {
1394 $langs->loadLangs(array(
'bills'));
1396 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
1397 $objectstatic =
new Facture($db);
1398 $objectstatic->fetch($line->fk_doc);
1403 $urlsource = $_SERVER[
'PHP_SELF'].
'?id='.$objectstatic->id;
1404 $documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir);
1405 } elseif ($line->doc_type ==
'supplier_invoice') {
1406 $langs->loadLangs(array(
'bills'));
1408 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
1410 $objectstatic->fetch($line->fk_doc);
1414 $filedir = $conf->fournisseur->facture->dir_output.
'/'.
get_exdir($line->fk_doc, 2, 0, 0, $objectstatic, $modulepart).dol_sanitizeFileName($line->doc_ref);
1415 $subdir =
get_exdir($objectstatic->id, 2, 0, 0, $objectstatic, $modulepart).dol_sanitizeFileName($line->doc_ref);
1416 $documentlink = $formfile->getDocumentsLink($objectstatic->element, $subdir, $filedir);
1417 } elseif ($line->doc_type ==
'expense_report') {
1418 $langs->loadLangs(array(
'trips'));
1420 require_once DOL_DOCUMENT_ROOT.
'/expensereport/class/expensereport.class.php';
1422 $objectstatic->fetch($line->fk_doc);
1427 $urlsource = $_SERVER[
'PHP_SELF'].
'?id='.$objectstatic->id;
1428 $documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir);
1429 } elseif ($line->doc_type ==
'bank') {
1430 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
1432 $objectstatic->fetch($line->fk_doc);
1438 $labeltoshowalt =
'';
1439 if ($line->doc_type ==
'customer_invoice' || $line->doc_type ==
'supplier_invoice' || $line->doc_type ==
'expense_report') {
1440 $labeltoshow .= $objectstatic->getNomUrl(1,
'', 0, 0,
'', 0, -1, 1);
1441 $labeltoshow .= $documentlink;
1442 $labeltoshowalt .= $objectstatic->ref;
1443 } elseif ($line->doc_type ==
'bank') {
1444 $labeltoshow .= $objectstatic->getNomUrl(1);
1445 $labeltoshowalt .= $objectstatic->ref;
1446 $bank_ref = strstr($line->doc_ref,
'-');
1447 $labeltoshow .=
" " . $bank_ref;
1448 $labeltoshowalt .=
" " . $bank_ref;
1450 $labeltoshow .= $line->doc_ref;
1451 $labeltoshowalt .= $line->doc_ref;
1454 print
'<td class="nowraponall tdoverflowmax200" title="'.dol_escape_htmltag($labeltoshowalt).
'">';
1458 $totalarray[
'nbfield']++;
1463 if (!empty($arrayfields[
't.numero_compte'][
'checked'])) {
1464 print
'<td>'.length_accountg($line->numero_compte).
'</td>';
1466 $totalarray[
'nbfield']++;
1471 if (!empty($arrayfields[
't.subledger_account'][
'checked'])) {
1472 print
'<td>'.length_accounta($line->subledger_account).
'</td>';
1474 $totalarray[
'nbfield']++;
1479 if (!empty($arrayfields[
't.label_operation'][
'checked'])) {
1480 print
'<td class="small tdoverflowmax200" title="'.dol_escape_htmltag($line->label_operation).
'">'.
dol_escape_htmltag($line->label_operation).
'</td>';
1482 $totalarray[
'nbfield']++;
1487 if (!empty($arrayfields[
't.debit'][
'checked'])) {
1488 print
'<td class="right nowraponall amount">'.($line->debit != 0 ?
price($line->debit) :
'').
'</td>';
1490 $totalarray[
'nbfield']++;
1493 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'totaldebit';
1495 $totalarray[
'val'][
'totaldebit'] += $line->debit;
1499 if (!empty($arrayfields[
't.credit'][
'checked'])) {
1500 print
'<td class="right nowraponall amount">'.($line->credit != 0 ?
price($line->credit) :
'').
'</td>';
1502 $totalarray[
'nbfield']++;
1505 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'totalcredit';
1507 $totalarray[
'val'][
'totalcredit'] += $line->credit;
1511 if (!empty($arrayfields[
't.lettering_code'][
'checked'])) {
1512 print
'<td class="center">'.$line->lettering_code.
'</td>';
1514 $totalarray[
'nbfield']++;
1519 $parameters = array(
'arrayfields'=>$arrayfields,
'obj'=>$obj,
'i'=>$i,
'totalarray'=>&$totalarray);
1520 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters);
1521 print $hookmanager->resPrint;
1524 if (!empty($arrayfields[
't.date_creation'][
'checked'])) {
1525 print
'<td class="center">'.dol_print_date($line->date_creation,
'dayhour').
'</td>';
1527 $totalarray[
'nbfield']++;
1532 if (!empty($arrayfields[
't.tms'][
'checked'])) {
1533 print
'<td class="center">'.dol_print_date($line->date_modification,
'dayhour').
'</td>';
1535 $totalarray[
'nbfield']++;
1540 if (!empty($arrayfields[
't.date_export'][
'checked'])) {
1541 print
'<td class="center nowraponall">'.dol_print_date($line->date_export,
'dayhour').
'</td>';
1543 $totalarray[
'nbfield']++;
1548 if (!empty($arrayfields[
't.date_validated'][
'checked'])) {
1549 print
'<td class="center nowraponall">'.dol_print_date($line->date_validation,
'dayhour').
'</td>';
1551 $totalarray[
'nbfield']++;
1555 if (!empty($arrayfields[
't.import_key'][
'checked'])) {
1556 print
'<td class="tdoverflowmax100">'.$obj->import_key.
"</td>\n";
1558 $totalarray[
'nbfield']++;
1564 print
'<td class="nowraponall center">';
1565 if (($massactionbutton || $massaction) && $contextpage !=
'poslist') {
1567 if (in_array($line->id, $arrayofselected)) {
1570 print
'<input id="cb'.$line->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$line->id.
'"'.($selected ?
' checked="checked"' :
'').
' />';
1576 $totalarray[
'nbfield']++;
1585 include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
1590 foreach ($arrayfields as $key => $val) {
1591 if (!empty($val[
'checked'])) {
1595 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
1598 $parameters = array(
'arrayfields'=>$arrayfields,
'sql'=>
$sql);
1599 $reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object, $action);
1600 print $hookmanager->resPrint;