28 require
'../../main.inc.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.formaccounting.class.php';
35 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
36 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
37 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
40 $langs->loadLangs(array(
"accountancy",
"compta"));
42 $action =
GETPOST(
'action',
'aZ09');
43 $socid =
GETPOST(
'socid',
'int');
44 $massaction =
GETPOST(
'massaction',
'alpha');
45 $confirm =
GETPOST(
'confirm',
'alpha');
46 $toselect =
GETPOST(
'toselect',
'array');
47 $type =
GETPOST(
'type',
'alpha');
49 $context_default =
'bookkeepingbysubaccountlist';
51 $context_default =
'bookkeepingbyaccountlist';
53 $contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') : $context_default;
54 $search_date_startyear =
GETPOST(
'search_date_startyear',
'int');
55 $search_date_startmonth =
GETPOST(
'search_date_startmonth',
'int');
56 $search_date_startday =
GETPOST(
'search_date_startday',
'int');
57 $search_date_endyear =
GETPOST(
'search_date_endyear',
'int');
58 $search_date_endmonth =
GETPOST(
'search_date_endmonth',
'int');
59 $search_date_endday =
GETPOST(
'search_date_endday',
'int');
60 $search_date_start =
dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear);
61 $search_date_end =
dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear);
63 $search_date_export_startyear =
GETPOST(
'search_date_export_startyear',
'int');
64 $search_date_export_startmonth =
GETPOST(
'search_date_export_startmonth',
'int');
65 $search_date_export_startday =
GETPOST(
'search_date_export_startday',
'int');
66 $search_date_export_endyear =
GETPOST(
'search_date_export_endyear',
'int');
67 $search_date_export_endmonth =
GETPOST(
'search_date_export_endmonth',
'int');
68 $search_date_export_endday =
GETPOST(
'search_date_export_endday',
'int');
69 $search_date_export_start =
dol_mktime(0, 0, 0, $search_date_export_startmonth, $search_date_export_startday, $search_date_export_startyear);
70 $search_date_export_end =
dol_mktime(23, 59, 59, $search_date_export_endmonth, $search_date_export_endday, $search_date_export_endyear);
71 $search_date_validation_startyear =
GETPOST(
'search_date_validation_startyear',
'int');
72 $search_date_validation_startmonth =
GETPOST(
'search_date_validation_startmonth',
'int');
73 $search_date_validation_startday =
GETPOST(
'search_date_validation_startday',
'int');
74 $search_date_validation_endyear =
GETPOST(
'search_date_validation_endyear',
'int');
75 $search_date_validation_endmonth =
GETPOST(
'search_date_validation_endmonth',
'int');
76 $search_date_validation_endday =
GETPOST(
'search_date_validation_endday',
'int');
77 $search_date_validation_start =
dol_mktime(0, 0, 0, $search_date_validation_startmonth, $search_date_validation_startday, $search_date_validation_startyear);
78 $search_date_validation_end =
dol_mktime(23, 59, 59, $search_date_validation_endmonth, $search_date_validation_endday, $search_date_validation_endyear);
79 $search_import_key =
GETPOST(
"search_import_key",
'alpha');
81 $search_accountancy_code =
GETPOST(
"search_accountancy_code");
82 $search_accountancy_code_start =
GETPOST(
'search_accountancy_code_start',
'alpha');
83 if ($search_accountancy_code_start == - 1) {
84 $search_accountancy_code_start =
'';
86 $search_accountancy_code_end =
GETPOST(
'search_accountancy_code_end',
'alpha');
87 if ($search_accountancy_code_end == - 1) {
88 $search_accountancy_code_end =
'';
90 $search_doc_ref =
GETPOST(
'search_doc_ref',
'alpha');
91 $search_label_operation =
GETPOST(
'search_label_operation',
'alpha');
92 $search_mvt_num =
GETPOST(
'search_mvt_num',
'int');
93 $search_direction =
GETPOST(
'search_direction',
'alpha');
94 $search_ledger_code =
GETPOST(
'search_ledger_code',
'array');
95 $search_debit =
GETPOST(
'search_debit',
'alpha');
96 $search_credit =
GETPOST(
'search_credit',
'alpha');
97 $search_lettering_code =
GETPOST(
'search_lettering_code',
'alpha');
98 $search_not_reconciled =
GETPOST(
'search_not_reconciled',
'alpha');
101 $action =
'delbookkeepingyear';
105 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : (empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION) ? $conf->liste_limit : $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION);
106 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
107 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
108 $optioncss =
GETPOST(
'optioncss',
'alpha');
110 if (empty($page) || $page < 0) {
113 $offset = $limit * $page;
114 $pageprev = $page - 1;
115 $pagenext = $page + 1;
116 if ($sortorder ==
"") {
119 if ($sortfield ==
"") {
120 $sortfield =
"t.doc_date,t.rowid";
126 $hookmanager->initHooks(array($context_default));
131 if (empty($search_date_start) && empty($search_date_end) && !
GETPOSTISSET(
'search_date_startday') && !
GETPOSTISSET(
'search_date_startmonth') && !
GETPOSTISSET(
'search_date_starthour')) {
132 $sql =
"SELECT date_start, date_end from ".MAIN_DB_PREFIX.
"accounting_fiscalyear ";
133 $sql .=
" where date_start < '".$db->idate(
dol_now()).
"' and date_end > '".$db->idate(
dol_now()).
"'";
134 $sql .= $db->plimit(1);
135 $res = $db->query($sql);
137 if ($res->num_rows > 0) {
138 $fiscalYear = $db->fetch_object($res);
139 $search_date_start = strtotime($fiscalYear->date_start);
140 $search_date_end = strtotime($fiscalYear->date_end);
142 $month_start = ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1);
147 $year_end = $year_start + 1;
148 $month_end = $month_start - 1;
149 if ($month_end < 1) {
153 $search_date_start =
dol_mktime(0, 0, 0, $month_start, 1, $year_start);
158 $arrayfields = array(
160 't.piece_num'=>array(
'label'=>$langs->trans(
"TransactionNumShort"),
'checked'=>1),
161 't.code_journal'=>array(
'label'=>$langs->trans(
"Codejournal"),
'checked'=>1),
162 't.doc_date'=>array(
'label'=>$langs->trans(
"Docdate"),
'checked'=>1),
163 't.doc_ref'=>array(
'label'=>$langs->trans(
"Piece"),
'checked'=>1),
164 't.label_operation'=>array(
'label'=>$langs->trans(
"Label"),
'checked'=>1),
165 't.debit'=>array(
'label'=>$langs->trans(
"Debit"),
'checked'=>1),
166 't.credit'=>array(
'label'=>$langs->trans(
"Credit"),
'checked'=>1),
167 't.lettering_code'=>array(
'label'=>$langs->trans(
"LetteringCode"),
'checked'=>1),
168 't.date_export'=>array(
'label'=>$langs->trans(
"DateExport"),
'checked'=>1),
169 't.date_validated'=>array(
'label'=>$langs->trans(
"DateValidation"),
'checked'=>1,
'enabled'=>!
getDolGlobalString(
"ACCOUNTANCY_DISABLE_CLOSURE_LINE_BY_LINE")),
170 't.import_key'=>array(
'label'=>$langs->trans(
"ImportId"),
'checked'=>0,
'position'=>1100),
173 if (empty($conf->global->ACCOUNTING_ENABLE_LETTERING)) {
174 unset($arrayfields[
't.lettering_code']);
177 if ($search_date_start && empty($search_date_startyear)) {
179 $search_date_startyear = $tmparray[
'year'];
180 $search_date_startmonth = $tmparray[
'mon'];
181 $search_date_startday = $tmparray[
'mday'];
183 if ($search_date_end && empty($search_date_endyear)) {
185 $search_date_endyear = $tmparray[
'year'];
186 $search_date_endmonth = $tmparray[
'mon'];
187 $search_date_endday = $tmparray[
'mday'];
193 if ($user->socid > 0) {
196 if (empty($user->rights->accounting->mouvements->lire)) {
207 if (
GETPOST(
'cancel',
'alpha')) {
211 if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'preunlettering' && $massaction !=
'predeletebookkeepingwriting') {
215 $parameters = array(
'socid'=>$socid);
216 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
221 if (empty($reshook)) {
222 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
224 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
225 $search_doc_date =
'';
226 $search_accountancy_code =
'';
227 $search_accountancy_code_start =
'';
228 $search_accountancy_code_end =
'';
229 $search_label_account =
'';
230 $search_doc_ref =
'';
231 $search_label_operation =
'';
232 $search_mvt_num =
'';
233 $search_direction =
'';
234 $search_ledger_code = array();
235 $search_date_start =
'';
236 $search_date_end =
'';
237 $search_date_startyear =
'';
238 $search_date_startmonth =
'';
239 $search_date_startday =
'';
240 $search_date_endyear =
'';
241 $search_date_endmonth =
'';
242 $search_date_endday =
'';
243 $search_date_export_start =
'';
244 $search_date_export_end =
'';
245 $search_date_export_startyear =
'';
246 $search_date_export_startmonth =
'';
247 $search_date_export_startday =
'';
248 $search_date_export_endyear =
'';
249 $search_date_export_endmonth =
'';
250 $search_date_export_endday =
'';
251 $search_date_validation_start =
'';
252 $search_date_validation_end =
'';
253 $search_date_validation_startyear =
'';
254 $search_date_validation_startmonth =
'';
255 $search_date_validation_startday =
'';
256 $search_date_validation_endyear =
'';
257 $search_date_validation_endmonth =
'';
258 $search_date_validation_endday =
'';
261 $search_lettering_code =
'';
262 $search_not_reconciled =
'';
263 $search_import_key =
'';
270 if (!empty($search_date_start)) {
271 $filter[
't.doc_date>='] = $search_date_start;
272 $param .=
'&search_date_startmonth='.$search_date_startmonth.
'&search_date_startday='.$search_date_startday.
'&search_date_startyear='.$search_date_startyear;
274 if (!empty($search_date_end)) {
275 $filter[
't.doc_date<='] = $search_date_end;
276 $param .=
'&search_date_endmonth='.$search_date_endmonth.
'&search_date_endday='.$search_date_endday.
'&search_date_endyear='.$search_date_endyear;
278 if (!empty($search_doc_date)) {
279 $filter[
't.doc_date'] = $search_doc_date;
280 $param .=
'&doc_datemonth='.GETPOST(
'doc_datemonth',
'int').
'&doc_dateday='.
GETPOST(
'doc_dateday',
'int').
'&doc_dateyear='.
GETPOST(
'doc_dateyear',
'int');
282 if (!empty($search_accountancy_code_start)) {
283 if ($type ==
'sub') {
284 $filter[
't.subledger_account>='] = $search_accountancy_code_start;
286 $filter[
't.numero_compte>='] = $search_accountancy_code_start;
288 $param .=
'&search_accountancy_code_start=' . urlencode($search_accountancy_code_start);
290 if (!empty($search_accountancy_code_end)) {
291 if ($type ==
'sub') {
292 $filter[
't.subledger_account<='] = $search_accountancy_code_end;
294 $filter[
't.numero_compte<='] = $search_accountancy_code_end;
296 $param .=
'&search_accountancy_code_end=' . urlencode($search_accountancy_code_end);
298 if (!empty($search_label_account)) {
299 $filter[
't.label_compte'] = $search_label_account;
300 $param .=
'&search_label_compte='.urlencode($search_label_account);
302 if (!empty($search_mvt_num)) {
303 $filter[
't.piece_num'] = $search_mvt_num;
304 $param .=
'&search_mvt_num='.urlencode($search_mvt_num);
306 if (!empty($search_doc_ref)) {
307 $filter[
't.doc_ref'] = $search_doc_ref;
308 $param .=
'&search_doc_ref='.urlencode($search_doc_ref);
310 if (!empty($search_label_operation)) {
311 $filter[
't.label_operation'] = $search_label_operation;
312 $param .=
'&search_label_operation='.urlencode($search_label_operation);
314 if (!empty($search_direction)) {
315 $filter[
't.sens'] = $search_direction;
316 $param .=
'&search_direction='.urlencode($search_direction);
318 if (!empty($search_ledger_code)) {
319 $filter[
't.code_journal'] = $search_ledger_code;
320 foreach ($search_ledger_code as $code) {
321 $param .=
'&search_ledger_code[]='.urlencode($code);
324 if (!empty($search_debit)) {
325 $filter[
't.debit'] = $search_debit;
326 $param .=
'&search_debit='.urlencode($search_debit);
328 if (!empty($search_credit)) {
329 $filter[
't.credit'] = $search_credit;
330 $param .=
'&search_credit='.urlencode($search_credit);
332 if (!empty($search_lettering_code)) {
333 $filter[
't.lettering_code'] = $search_lettering_code;
334 $param .=
'&search_lettering_code='.urlencode($search_lettering_code);
336 if (!empty($search_not_reconciled)) {
337 $filter[
't.reconciled_option'] = $search_not_reconciled;
338 $param .=
'&search_not_reconciled='.urlencode($search_not_reconciled);
340 if (!empty($search_date_export_start)) {
341 $filter[
't.date_export>='] = $search_date_export_start;
342 $param .=
'&search_date_export_startmonth='.$search_date_export_startmonth.
'&search_date_export_startday='.$search_date_export_startday.
'&search_date_export_startyear='.$search_date_export_startyear;
344 if (!empty($search_date_export_end)) {
345 $filter[
't.date_export<='] = $search_date_export_end;
346 $param .=
'&search_date_export_endmonth='.$search_date_export_endmonth.
'&search_date_export_endday='.$search_date_export_endday.
'&search_date_export_endyear='.$search_date_export_endyear;
348 if (!empty($search_date_validation_start)) {
349 $filter[
't.date_validated>='] = $search_date_validation_start;
350 $param .=
'&search_date_validation_startmonth='.$search_date_validation_startmonth.
'&search_date_validation_startday='.$search_date_validation_startday.
'&search_date_validation_startyear='.$search_date_validation_startyear;
352 if (!empty($search_date_validation_end)) {
353 $filter[
't.date_validated<='] = $search_date_validation_end;
354 $param .=
'&search_date_validation_endmonth='.$search_date_validation_endmonth.
'&search_date_validation_endday='.$search_date_validation_endday.
'&search_date_validation_endyear='.$search_date_validation_endyear;
356 if (!empty($search_import_key)) {
357 $filter[
't.import_key'] = $search_import_key;
358 $param .=
'&search_import_key='.urlencode($search_import_key);
362 $url_param = substr($param, 1);
364 $param =
'&type='.$type.$param;
395 $objectclass =
'Bookkeeping';
396 $objectlabel =
'Bookkeeping';
397 $permissiontoread = $user->rights->societe->lire;
398 $permissiontodelete = $user->rights->societe->supprimer;
399 $permissiontoadd = $user->rights->societe->creer;
400 $uploaddir = $conf->societe->dir_output;
401 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
403 if (!$error && $action ==
'deletebookkeepingwriting' && $confirm ==
"yes" && $user->rights->accounting->mouvements->supprimer) {
405 foreach ($toselect as $toselectid) {
406 $result = $object->fetch($toselectid);
407 if ($result > 0 && (!isset($object->date_validation) || $object->date_validation ===
'')) {
408 $result = $object->deleteMvtNum($object->piece_num);
416 } elseif ($result < 0) {
426 } elseif ($nbok > 0) {
433 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?noreset=1".($param ?
'&'.$param :
''));
439 if (!$error &&
getDolGlobalInt(
'ACCOUNTING_ENABLE_LETTERING') && $user->rights->accounting->mouvements->creer) {
440 if ($massaction ==
'lettering') {
442 $nb_lettering = $lettering->bookkeepingLetteringAll($toselect);
443 if ($nb_lettering < 0) {
446 $nb_lettering = max(0, abs($nb_lettering) - 2);
447 } elseif ($nb_lettering == 0) {
449 setEventMessages($langs->trans(
'AccountancyNoLetteringModified'), array(),
'mesgs');
451 if ($nb_lettering == 1) {
452 setEventMessages($langs->trans(
'AccountancyOneLetteringModifiedSuccessfully'), array(),
'mesgs');
453 } elseif ($nb_lettering > 1) {
454 setEventMessages($langs->trans(
'AccountancyLetteringModifiedSuccessfully', $nb_lettering), array(),
'mesgs');
458 header(
'Location: ' . $_SERVER[
'PHP_SELF'] .
'?noreset=1' . $param);
461 } elseif ($action ==
'unlettering' && $confirm ==
"yes") {
463 $nb_lettering = $lettering->bookkeepingLetteringAll($toselect,
true);
464 if ($nb_lettering < 0) {
467 $nb_lettering = max(0, abs($nb_lettering) - 2);
468 } elseif ($nb_lettering == 0) {
470 setEventMessages($langs->trans(
'AccountancyNoUnletteringModified'), array(),
'mesgs');
472 if ($nb_lettering == 1) {
473 setEventMessages($langs->trans(
'AccountancyOneUnletteringModifiedSuccessfully'), array(),
'mesgs');
474 } elseif ($nb_lettering > 1) {
475 setEventMessages($langs->trans(
'AccountancyUnletteringModifiedSuccessfully', $nb_lettering), array(),
'mesgs');
479 header(
'Location: ' . $_SERVER[
'PHP_SELF'] .
'?noreset=1' . $param);
496 $title_page = $langs->trans(
"Operations").
' - '.$langs->trans(
"VueByAccountAccounting").
' (';
497 if ($type ==
'sub') {
498 $title_page .= $langs->trans(
"BookkeepingSubAccount");
500 $title_page .= $langs->trans(
"Bookkeeping");
507 $nbtotalofrecords =
'';
508 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
509 if ($type ==
'sub') {
510 $nbtotalofrecords = $object->fetchAllByAccount($sortorder, $sortfield, 0, 0, $filter,
'AND', 1);
512 $nbtotalofrecords = $object->fetchAllByAccount($sortorder, $sortfield, 0, 0, $filter);
515 if ($nbtotalofrecords < 0) {
520 if ($type ==
'sub') {
521 $result = $object->fetchAllByAccount($sortorder, $sortfield, $limit, $offset, $filter,
'AND', 1);
523 $result = $object->fetchAllByAccount($sortorder, $sortfield, $limit, $offset, $filter);
530 $arrayofselected = is_array($toselect) ? $toselect : array();
532 $num = count($object->lines);
580 $arrayofmassactions = array();
581 if (
getDolGlobalInt(
'ACCOUNTING_ENABLE_LETTERING') && $user->rights->accounting->mouvements->creer) {
582 $arrayofmassactions[
'lettering'] =
img_picto(
'',
'check',
'class="pictofixedwidth"') . $langs->trans(
'Lettering');
583 $arrayofmassactions[
'preunlettering'] =
img_picto(
'',
'uncheck',
'class="pictofixedwidth"') . $langs->trans(
'Unlettering');
585 if ($user->rights->accounting->mouvements->supprimer) {
586 $arrayofmassactions[
'predeletebookkeepingwriting'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
588 if (
GETPOST(
'nomassaction',
'int') || in_array($massaction, array(
'preunlettering',
'predeletebookkeepingwriting'))) {
589 $arrayofmassactions = array();
591 $massactionbutton =
$form->selectMassAction($massaction, $arrayofmassactions);
593 print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">';
594 print
'<input type="hidden" name="token" value="'.newToken().
'">';
595 print
'<input type="hidden" name="action" value="list">';
596 if ($optioncss !=
'') {
597 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
599 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
600 print
'<input type="hidden" name="type" value="'.$type.
'">';
601 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
602 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
603 print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
605 $parameters = array(
'param' => $param);
606 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtonsList', $parameters, $object, $action);
611 $newcardbutton = empty($hookmanager->resPrint) ?
'' : $hookmanager->resPrint;
613 if (empty($reshook)) {
614 $newcardbutton =
dolGetButtonTitle($langs->trans(
'ViewFlatList'),
'',
'fa fa-list paddingleft imgforviewmode', DOL_URL_ROOT.
'/accountancy/bookkeeping/list.php?'.$param);
615 if ($type ==
'sub') {
616 $newcardbutton .=
dolGetButtonTitle($langs->trans(
'GroupByAccountAccounting'),
'',
'fa fa-stream paddingleft imgforviewmode', DOL_URL_ROOT .
'/accountancy/bookkeeping/listbyaccount.php?' . $url_param,
'', 1, array(
'morecss' =>
'marginleftonly'));
617 $newcardbutton .=
dolGetButtonTitle($langs->trans(
'GroupBySubAccountAccounting'),
'',
'fa fa-align-left vmirror paddingleft imgforviewmode', DOL_URL_ROOT .
'/accountancy/bookkeeping/listbyaccount.php?type=sub&' . $url_param,
'', 1, array(
'morecss' =>
'marginleftonly btnTitleSelected'));
619 $newcardbutton .=
dolGetButtonTitle($langs->trans(
'GroupByAccountAccounting'),
'',
'fa fa-stream paddingleft imgforviewmode', DOL_URL_ROOT .
'/accountancy/bookkeeping/listbyaccount.php?' . $url_param,
'', 1, array(
'morecss' =>
'marginleftonly btnTitleSelected'));
620 $newcardbutton .=
dolGetButtonTitle($langs->trans(
'GroupBySubAccountAccounting'),
'',
'fa fa-align-left vmirror paddingleft imgforviewmode', DOL_URL_ROOT .
'/accountancy/bookkeeping/listbyaccount.php?type=sub&' . $url_param,
'', 1, array(
'morecss' =>
'marginleftonly'));
622 $newcardbutton .=
dolGetButtonTitle($langs->trans(
'NewAccountingMvt'),
'',
'fa fa-plus-circle paddingleft', DOL_URL_ROOT.
'/accountancy/bookkeeping/card.php?action=create');
625 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
626 $param .=
'&contextpage='.urlencode($contextpage);
628 if ($limit > 0 && $limit != $conf->liste_limit) {
629 $param .=
'&limit='.urlencode($limit);
632 print_barre_liste($title_page, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $result, $nbtotalofrecords,
'title_accountancy', 0, $newcardbutton,
'', $limit, 0, 0, 1);
634 if ($massaction ==
'preunlettering') {
635 print
$form->formconfirm($_SERVER[
"PHP_SELF"], $langs->trans(
"ConfirmMassUnlettering"), $langs->trans(
"ConfirmMassUnletteringQuestion", count($toselect)),
"unlettering",
null,
'', 0, 200, 500, 1);
636 } elseif ($massaction ==
'predeletebookkeepingwriting') {
637 print
$form->formconfirm($_SERVER[
"PHP_SELF"], $langs->trans(
"ConfirmMassDeleteBookkeepingWriting"), $langs->trans(
"ConfirmMassDeleteBookkeepingWritingQuestion", count($toselect)),
"deletebookkeepingwriting",
null,
'', 0, 200, 500, 1);
650 include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
652 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
653 $selectedfields =
$form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage);
654 if ($massactionbutton && $contextpage !=
'poslist') {
655 $selectedfields .=
$form->showCheckAddButtons(
'checkforselect', 1);
659 if (preg_match(
'/^asc/i', $sortorder)) {
666 if ($type ==
'sub') {
667 print
info_admin($langs->trans(
"WarningRecordWithoutSubledgerAreExcluded"));
673 $moreforfilter .=
'<div class="divsearchfield">';
674 $moreforfilter .= $langs->trans(
'AccountAccounting').
': ';
675 $moreforfilter .=
'<div class="nowrap inline-block">';
676 if ($type ==
'sub') {
677 $moreforfilter .= $formaccounting->select_auxaccount($search_accountancy_code_start,
'search_accountancy_code_start', $langs->trans(
'From'),
'maxwidth200');
679 $moreforfilter .= $formaccounting->select_account($search_accountancy_code_start,
'search_accountancy_code_start', $langs->trans(
'From'), array(), 1, 1,
'maxwidth200');
681 $moreforfilter .=
' ';
682 if ($type ==
'sub') {
683 $moreforfilter .= $formaccounting->select_auxaccount($search_accountancy_code_end,
'search_accountancy_code_end', $langs->trans(
'to'),
'maxwidth200');
685 $moreforfilter .= $formaccounting->select_account($search_accountancy_code_end,
'search_accountancy_code_end', $langs->trans(
'to'), array(), 1, 1,
'maxwidth200');
687 $moreforfilter .=
'</div>';
688 $moreforfilter .=
'</div>';
690 $parameters = array();
691 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters);
692 if (empty($reshook)) {
693 $moreforfilter .= $hookmanager->resPrint;
695 $moreforfilter = $hookmanager->resPrint;
698 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
699 print $moreforfilter;
702 print
'<div class="div-table-responsive">';
703 print
'<table class="tagtable liste centpercent">';
706 print
'<tr class="liste_titre_filter">';
709 if (!empty($arrayfields[
't.piece_num'][
'checked'])) {
710 print
'<td class="liste_titre"><input type="text" name="search_mvt_num" size="6" value="'.dol_escape_htmltag($search_mvt_num).
'"></td>';
713 if (!empty($arrayfields[
't.code_journal'][
'checked'])) {
714 print
'<td class="liste_titre center">';
715 print $formaccounting->multi_select_journal($search_ledger_code,
'search_ledger_code', 0, 1, 1, 1);
719 if (!empty($arrayfields[
't.doc_date'][
'checked'])) {
720 print
'<td class="liste_titre center">';
721 print
'<div class="nowrap">';
722 print
$form->selectDate($search_date_start,
'search_date_start', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"From"));
724 print
'<div class="nowrap">';
725 print
$form->selectDate($search_date_end,
'search_date_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"to"));
730 if (!empty($arrayfields[
't.doc_ref'][
'checked'])) {
731 print
'<td class="liste_titre"><input type="text" size="7" class="flat" name="search_doc_ref" value="'.dol_escape_htmltag($search_doc_ref).
'"/></td>';
734 if (!empty($arrayfields[
't.label_operation'][
'checked'])) {
735 print
'<td class="liste_titre"><input type="text" size="7" class="flat" name="search_label_operation" value="'.dol_escape_htmltag($search_label_operation).
'"/></td>';
738 if (!empty($arrayfields[
't.debit'][
'checked'])) {
739 print
'<td class="liste_titre right"><input type="text" class="flat" name="search_debit" size="4" value="'.dol_escape_htmltag($search_debit).
'"></td>';
742 if (!empty($arrayfields[
't.credit'][
'checked'])) {
743 print
'<td class="liste_titre right"><input type="text" class="flat" name="search_credit" size="4" value="'.dol_escape_htmltag($search_credit).
'"></td>';
746 if (!empty($arrayfields[
't.lettering_code'][
'checked'])) {
747 print
'<td class="liste_titre center">';
748 print
'<input type="text" size="3" class="flat" name="search_lettering_code" value="'.$search_lettering_code.
'"/>';
749 print
'<br><span class="nowrap"><input type="checkbox" name="search_not_reconciled" value="notreconciled"'.($search_not_reconciled ==
'notreconciled' ?
' checked' :
'').
'>'.$langs->trans(
"NotReconciled").
'</span>';
753 if (!empty($arrayfields[
't.date_export'][
'checked'])) {
754 print
'<td class="liste_titre center">';
755 print
'<div class="nowrap">';
756 print
$form->selectDate($search_date_export_start,
'search_date_export_start', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"From"));
758 print
'<div class="nowrap">';
759 print
$form->selectDate($search_date_export_end,
'search_date_export_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"to"));
764 if (!empty($arrayfields[
't.date_validated'][
'checked'])) {
765 print
'<td class="liste_titre center">';
766 print
'<div class="nowrap">';
767 print
$form->selectDate($search_date_validation_start,
'search_date_validation_start', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"From"));
769 print
'<div class="nowrap">';
770 print
$form->selectDate($search_date_validation_end,
'search_date_validation_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"to"));
774 if (!empty($arrayfields[
't.import_key'][
'checked'])) {
775 print
'<td class="liste_titre center">';
776 print
'<input class="flat searchstring maxwidth50" type="text" name="search_import_key" value="'.dol_escape_htmltag($search_import_key).
'">';
781 $parameters = array(
'arrayfields'=>$arrayfields);
782 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters);
783 print $hookmanager->resPrint;
786 print
'<td class="liste_titre center">';
787 $searchpicto =
$form->showFilterButtons();
792 print
'<tr class="liste_titre">';
793 if (!empty($arrayfields[
't.piece_num'][
'checked'])) {
794 print_liste_field_titre($arrayfields[
't.piece_num'][
'label'], $_SERVER[
'PHP_SELF'],
"t.piece_num",
"", $param,
'', $sortfield, $sortorder);
796 if (!empty($arrayfields[
't.code_journal'][
'checked'])) {
797 print_liste_field_titre($arrayfields[
't.code_journal'][
'label'], $_SERVER[
'PHP_SELF'],
"t.code_journal",
"", $param,
'', $sortfield, $sortorder,
'center ');
799 if (!empty($arrayfields[
't.doc_date'][
'checked'])) {
800 print_liste_field_titre($arrayfields[
't.doc_date'][
'label'], $_SERVER[
'PHP_SELF'],
"t.doc_date",
"", $param,
'', $sortfield, $sortorder,
'center ');
802 if (!empty($arrayfields[
't.doc_ref'][
'checked'])) {
803 print_liste_field_titre($arrayfields[
't.doc_ref'][
'label'], $_SERVER[
'PHP_SELF'],
"t.doc_ref",
"", $param,
"", $sortfield, $sortorder);
805 if (!empty($arrayfields[
't.label_operation'][
'checked'])) {
806 print_liste_field_titre($arrayfields[
't.label_operation'][
'label'], $_SERVER[
'PHP_SELF'],
"t.label_operation",
"", $param,
"", $sortfield, $sortorder);
808 if (!empty($arrayfields[
't.debit'][
'checked'])) {
809 print_liste_field_titre($arrayfields[
't.debit'][
'label'], $_SERVER[
'PHP_SELF'],
"t.debit",
"", $param,
'', $sortfield, $sortorder,
'right ');
811 if (!empty($arrayfields[
't.credit'][
'checked'])) {
812 print_liste_field_titre($arrayfields[
't.credit'][
'label'], $_SERVER[
'PHP_SELF'],
"t.credit",
"", $param,
'', $sortfield, $sortorder,
'right ');
814 if (!empty($arrayfields[
't.lettering_code'][
'checked'])) {
815 print_liste_field_titre($arrayfields[
't.lettering_code'][
'label'], $_SERVER[
'PHP_SELF'],
"t.lettering_code",
"", $param,
'', $sortfield, $sortorder,
'center ');
817 if (!empty($arrayfields[
't.date_export'][
'checked'])) {
818 print_liste_field_titre($arrayfields[
't.date_export'][
'label'], $_SERVER[
'PHP_SELF'],
"t.date_export",
"", $param,
'', $sortfield, $sortorder,
'center ');
820 if (!empty($arrayfields[
't.date_validated'][
'checked'])) {
821 print_liste_field_titre($arrayfields[
't.date_validated'][
'label'], $_SERVER[
'PHP_SELF'],
"t.date_validated",
"", $param,
'', $sortfield, $sortorder,
'center ');
823 if (!empty($arrayfields[
't.import_key'][
'checked'])) {
824 print_liste_field_titre($arrayfields[
't.import_key'][
'label'], $_SERVER[
"PHP_SELF"],
"t.import_key",
"", $param,
'', $sortfield, $sortorder,
'center ');
827 $parameters = array(
'arrayfields'=>$arrayfields,
'param'=>$param,
'sortfield'=>$sortfield,
'sortorder'=>$sortorder);
828 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters);
829 print $hookmanager->resPrint;
830 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ');
833 $displayed_account_number =
null;
839 $totalarray = array();
840 $totalarray[
'val'] = array ();
841 $totalarray[
'nbfield'] = 0;
844 $sous_total_debit = 0;
845 $sous_total_credit = 0;
846 $totalarray[
'val'][
'totaldebit'] = 0;
847 $totalarray[
'val'][
'totalcredit'] = 0;
849 while ($i < min($num, $limit)) {
850 $line = $object->lines[$i];
852 $total_debit += $line->debit;
853 $total_credit += $line->credit;
855 if ($type ==
'sub') {
864 if (!empty($arrayfields[
't.piece_num'][
'checked'])) { $colspan++; }
865 if (!empty($arrayfields[
't.code_journal'][
'checked'])) { $colspan++; }
866 if (!empty($arrayfields[
't.doc_date'][
'checked'])) { $colspan++; }
867 if (!empty($arrayfields[
't.doc_ref'][
'checked'])) { $colspan++; }
868 if (!empty($arrayfields[
't.label_operation'][
'checked'])) { $colspan++; }
869 if (!empty($arrayfields[
't.date_export'][
'checked'])) { $colspanend++; }
870 if (!empty($arrayfields[
't.date_validating'][
'checked'])) { $colspanend++; }
871 if (!empty($arrayfields[
't.lettering_code'][
'checked'])) { $colspanend++; }
874 if ($accountg != $displayed_account_number || !isset($displayed_account_number)) {
876 if (isset($displayed_account_number)) {
877 print
'<tr class="liste_total">';
878 if ($type ==
'sub') {
879 print
'<td class="right" colspan="' . $colspan .
'">' . $langs->trans(
"TotalForAccount") .
' ' .
length_accounta($displayed_account_number) .
':</td>';
881 print
'<td class="right" colspan="' . $colspan .
'">' . $langs->trans(
"TotalForAccount") .
' ' .
length_accountg($displayed_account_number) .
':</td>';
883 print
'<td class="nowrap right">'.price($sous_total_debit).
'</td>';
884 print
'<td class="nowrap right">'.price($sous_total_credit).
'</td>';
885 print
'<td colspan="'.$colspanend.
'"></td>';
888 $balance = $sous_total_debit - $sous_total_credit;
889 print
'<tr class="liste_total">';
890 print
'<td class="right" colspan="'.$colspan.
'">'.$langs->trans(
"Balance").
':</td>';
892 print
'<td class="nowraponall right">';
893 print
price($sous_total_debit - $sous_total_credit);
898 print
'<td class="nowraponall right">';
899 print
price($sous_total_credit - $sous_total_debit);
902 print
'<td colspan="'.$colspanend.
'"></td>';
907 print
'<tr class="trforbreak">';
908 print
'<td colspan="'.($totalarray[
'nbfield'] ? $totalarray[
'nbfield'] : count($arrayfields)+1).
'" class="tdforbreak">';
909 if ($type ==
'sub') {
910 if ($line->subledger_account !=
"" && $line->subledger_account !=
'-1') {
911 print $line->subledger_label .
' : ' .
length_accounta($line->subledger_account);
914 print
'<span class="error">' . $langs->trans(
"Unknown");
915 if ($line->subledger_label) {
916 print
' (' . $line->subledger_label .
')';
917 $htmltext =
'EmptyStringForSubledgerAccountButSubledgerLabelDefined';
919 $htmltext =
'EmptyStringForSubledgerAccountAndSubledgerLabel';
921 print
$form->textwithpicto(
'', $htmltext);
925 if ($line->numero_compte !=
"" && $line->numero_compte !=
'-1') {
926 print
length_accountg($line->numero_compte) .
' : ' . $object->get_compte_desc($line->numero_compte);
928 print
'<span class="error">' . $langs->trans(
"Unknown") .
'</span>';
934 $displayed_account_number = $accountg;
936 $sous_total_debit = 0;
937 $sous_total_credit = 0;
942 print
'<tr class="oddeven">';
945 if (!empty($arrayfields[
't.piece_num'][
'checked'])) {
947 $object->id = $line->id;
948 $object->piece_num = $line->piece_num;
949 print $object->getNomUrl(1,
'', 0,
'', 1);
952 $totalarray[
'nbfield']++;
957 if (!empty($arrayfields[
't.code_journal'][
'checked'])) {
959 $result = $accountingjournal->fetch(
'', $line->code_journal);
960 $journaltoshow = (($result > 0) ? $accountingjournal->getNomUrl(0, 0, 0,
'', 0) : $line->code_journal);
961 print
'<td class="center">'.$journaltoshow.
'</td>';
963 $totalarray[
'nbfield']++;
968 if (!empty($arrayfields[
't.doc_date'][
'checked'])) {
969 print
'<td class="center">'.dol_print_date($line->doc_date,
'day').
'</td>';
971 $totalarray[
'nbfield']++;
976 if (!empty($arrayfields[
't.doc_ref'][
'checked'])) {
977 if ($line->doc_type ==
'customer_invoice') {
978 $langs->loadLangs(array(
'bills'));
980 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
981 $objectstatic =
new Facture($db);
982 $objectstatic->fetch($line->fk_doc);
987 $urlsource = $_SERVER[
'PHP_SELF'].
'?id='.$objectstatic->id;
988 $documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir);
989 } elseif ($line->doc_type ==
'supplier_invoice') {
990 $langs->loadLangs(array(
'bills'));
992 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
994 $objectstatic->fetch($line->fk_doc);
998 $filedir = $conf->fournisseur->facture->dir_output.
'/'.
get_exdir($line->fk_doc, 2, 0, 0, $objectstatic, $modulepart).dol_sanitizeFileName($line->doc_ref);
999 $subdir =
get_exdir($objectstatic->id, 2, 0, 0, $objectstatic, $modulepart).dol_sanitizeFileName($line->doc_ref);
1000 $documentlink = $formfile->getDocumentsLink($objectstatic->element, $subdir, $filedir);
1001 } elseif ($line->doc_type ==
'expense_report') {
1002 $langs->loadLangs(array(
'trips'));
1004 require_once DOL_DOCUMENT_ROOT.
'/expensereport/class/expensereport.class.php';
1006 $objectstatic->fetch($line->fk_doc);
1011 $urlsource = $_SERVER[
'PHP_SELF'].
'?id='.$objectstatic->id;
1012 $documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir);
1013 } elseif ($line->doc_type ==
'bank') {
1014 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
1016 $objectstatic->fetch($line->fk_doc);
1021 print
'<td class="maxwidth400">';
1023 print
'<table class="nobordernopadding"><tr class="nocellnopadd">';
1025 print
'<td class="nobordernopadding">';
1027 if ($line->doc_type ==
'customer_invoice' || $line->doc_type ==
'supplier_invoice' || $line->doc_type ==
'expense_report') {
1028 print $objectstatic->getNomUrl(1,
'', 0, 0,
'', 0, -1, 1);
1029 print $documentlink;
1030 } elseif ($line->doc_type ==
'bank') {
1031 print $objectstatic->getNomUrl(1);
1032 $bank_ref = strstr($line->doc_ref,
'-');
1033 print
" " . $bank_ref;
1035 print $line->doc_ref;
1037 print
'</td></tr></table>';
1041 $totalarray[
'nbfield']++;
1046 if (!empty($arrayfields[
't.label_operation'][
'checked'])) {
1048 $doc_ref = preg_replace(
'/\(.*\)/',
'', $line->doc_ref);
1049 print strlen(
length_accounta($line->subledger_account)) == 0 ?
'<td>'.$line->label_operation.
'</td>' :
'<td>'.$line->label_operation.
'<br><span style="font-size:0.8em">('.
length_accounta($line->subledger_account).
')</span></td>';
1051 $totalarray[
'nbfield']++;
1056 if (!empty($arrayfields[
't.debit'][
'checked'])) {
1057 print
'<td class="right nowraponall amount">'.($line->debit ?
price($line->debit) :
'').
'</td>';
1059 $totalarray[
'nbfield']++;
1062 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'totaldebit';
1064 $totalarray[
'val'][
'totaldebit'] += $line->debit;
1068 if (!empty($arrayfields[
't.credit'][
'checked'])) {
1069 print
'<td class="right nowraponall amount">'.($line->credit ?
price($line->credit) :
'').
'</td>';
1071 $totalarray[
'nbfield']++;
1074 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'totalcredit';
1076 $totalarray[
'val'][
'totalcredit'] += $line->credit;
1080 if (!empty($arrayfields[
't.lettering_code'][
'checked'])) {
1081 print
'<td class="center">'.$line->lettering_code.
'</td>';
1083 $totalarray[
'nbfield']++;
1088 if (!empty($arrayfields[
't.date_export'][
'checked'])) {
1089 print
'<td class="center">'.dol_print_date($line->date_export,
'dayhour').
'</td>';
1091 $totalarray[
'nbfield']++;
1096 if (!empty($arrayfields[
't.date_validated'][
'checked'])) {
1097 print
'<td class="center">'.dol_print_date($line->date_validation,
'dayhour').
'</td>';
1099 $totalarray[
'nbfield']++;
1103 if (!empty($arrayfields[
't.import_key'][
'checked'])) {
1104 print
'<td class="tdoverflowmax100">'.$line->import_key.
"</td>\n";
1106 $totalarray[
'nbfield']++;
1111 $parameters = array(
'arrayfields'=>$arrayfields,
'obj'=>$line);
1112 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters);
1113 print $hookmanager->resPrint;
1116 print
'<td class="nowraponall center">';
1117 if (($massactionbutton || $massaction) && $contextpage !=
'poslist') {
1119 if (in_array($line->id, $arrayofselected)) {
1122 print
'<input id="cb' . $line->id .
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="' . $line->id .
'"' . ($selected ?
' checked="checked"' :
'') .
' />';
1126 $totalarray[
'nbfield']++;
1130 $sous_total_debit += $line->debit;
1131 $sous_total_credit += $line->credit;
1138 if ($num > 0 && $colspan > 0) {
1139 print
'<tr class="liste_total">';
1140 print
'<td class="right" colspan="'.$colspan.
'">'.$langs->trans(
"TotalForAccount").
' '.$accountg.
':</td>';
1141 print
'<td class="nowrap right">'.price($sous_total_debit).
'</td>';
1142 print
'<td class="nowrap right">'.price($sous_total_credit).
'</td>';
1143 print
'<td colspan="'.$colspanend.
'"></td>';
1146 $balance = $sous_total_debit - $sous_total_credit;
1147 print
'<tr class="liste_total">';
1148 print
'<td class="right" colspan="'.$colspan.
'">'.$langs->trans(
"Balance").
':</td>';
1150 print
'<td class="nowraponall right">';
1151 print
price($sous_total_debit - $sous_total_credit);
1156 print
'<td class="nowraponall right">';
1157 print
price($sous_total_credit - $sous_total_debit);
1160 print
'<td colspan="'.$colspanend.
'"></td>';
1165 include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';