dolibarr  18.0.6
list.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2013-2016 Olivier Geffroy <jeff@jeffinfo.com>
3  * Copyright (C) 2013-2016 Florian Henry <florian.henry@open-concept.pro>
4  * Copyright (C) 2013-2024 Alexandre Spangaro <aspangaro@open-dsi.fr>
5  * Copyright (C) 2022 Lionel Vessiller <lvessiller@open-dsi.fr>
6  * Copyright (C) 2016-2017 Laurent Destailleur <eldy@users.sourceforge.net>
7  * Copyright (C) 2018-2021 Frédéric France <frederic.france@netlogic.fr>
8  * Copyright (C) 2022 Progiseize <a.bisotti@progiseize.fr>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 3 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program. If not, see <https://www.gnu.org/licenses/>.
22  */
23 
30 // Load Dolibarr environment
31 require '../../main.inc.php';
32 require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
33 require_once DOL_DOCUMENT_ROOT.'/accountancy/class/lettering.class.php';
34 require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php';
35 require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php';
36 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
37 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
38 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
39 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
40 require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
41 
42 // Load translation files required by the page
43 $langs->loadLangs(array("accountancy", "compta"));
44 
45 $socid = GETPOST('socid', 'int');
46 
47 $action = GETPOST('action', 'aZ09');
48 $massaction = GETPOST('massaction', 'alpha');
49 $confirm = GETPOST('confirm', 'alpha');
50 $toselect = GETPOST('toselect', 'array');
51 $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'bookkeepinglist';
52 $search_mvt_num = GETPOST('search_mvt_num', 'int');
53 $search_doc_type = GETPOST("search_doc_type", 'alpha');
54 $search_doc_ref = GETPOST("search_doc_ref", 'alpha');
55 $search_date_startyear = GETPOST('search_date_startyear', 'int');
56 $search_date_startmonth = GETPOST('search_date_startmonth', 'int');
57 $search_date_startday = GETPOST('search_date_startday', 'int');
58 $search_date_endyear = GETPOST('search_date_endyear', 'int');
59 $search_date_endmonth = GETPOST('search_date_endmonth', 'int');
60 $search_date_endday = GETPOST('search_date_endday', 'int');
61 $search_date_start = dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear);
62 $search_date_end = dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear);
63 $search_doc_date = dol_mktime(0, 0, 0, GETPOST('doc_datemonth', 'int'), GETPOST('doc_dateday', 'int'), GETPOST('doc_dateyear', 'int'));
64 $search_date_creation_startyear = GETPOST('search_date_creation_startyear', 'int');
65 $search_date_creation_startmonth = GETPOST('search_date_creation_startmonth', 'int');
66 $search_date_creation_startday = GETPOST('search_date_creation_startday', 'int');
67 $search_date_creation_endyear = GETPOST('search_date_creation_endyear', 'int');
68 $search_date_creation_endmonth = GETPOST('search_date_creation_endmonth', 'int');
69 $search_date_creation_endday = GETPOST('search_date_creation_endday', 'int');
70 $search_date_creation_start = dol_mktime(0, 0, 0, $search_date_creation_startmonth, $search_date_creation_startday, $search_date_creation_startyear);
71 $search_date_creation_end = dol_mktime(23, 59, 59, $search_date_creation_endmonth, $search_date_creation_endday, $search_date_creation_endyear);
72 $search_date_modification_startyear = GETPOST('search_date_modification_startyear', 'int');
73 $search_date_modification_startmonth = GETPOST('search_date_modification_startmonth', 'int');
74 $search_date_modification_startday = GETPOST('search_date_modification_startday', 'int');
75 $search_date_modification_endyear = GETPOST('search_date_modification_endyear', 'int');
76 $search_date_modification_endmonth = GETPOST('search_date_modification_endmonth', 'int');
77 $search_date_modification_endday = GETPOST('search_date_modification_endday', 'int');
78 $search_date_modification_start = dol_mktime(0, 0, 0, $search_date_modification_startmonth, $search_date_modification_startday, $search_date_modification_startyear);
79 $search_date_modification_end = dol_mktime(23, 59, 59, $search_date_modification_endmonth, $search_date_modification_endday, $search_date_modification_endyear);
80 $search_date_export_startyear = GETPOST('search_date_export_startyear', 'int');
81 $search_date_export_startmonth = GETPOST('search_date_export_startmonth', 'int');
82 $search_date_export_startday = GETPOST('search_date_export_startday', 'int');
83 $search_date_export_endyear = GETPOST('search_date_export_endyear', 'int');
84 $search_date_export_endmonth = GETPOST('search_date_export_endmonth', 'int');
85 $search_date_export_endday = GETPOST('search_date_export_endday', 'int');
86 $search_date_export_start = dol_mktime(0, 0, 0, $search_date_export_startmonth, $search_date_export_startday, $search_date_export_startyear);
87 $search_date_export_end = dol_mktime(23, 59, 59, $search_date_export_endmonth, $search_date_export_endday, $search_date_export_endyear);
88 $search_date_validation_startyear = GETPOST('search_date_validation_startyear', 'int');
89 $search_date_validation_startmonth = GETPOST('search_date_validation_startmonth', 'int');
90 $search_date_validation_startday = GETPOST('search_date_validation_startday', 'int');
91 $search_date_validation_endyear = GETPOST('search_date_validation_endyear', 'int');
92 $search_date_validation_endmonth = GETPOST('search_date_validation_endmonth', 'int');
93 $search_date_validation_endday = GETPOST('search_date_validation_endday', 'int');
94 $search_date_validation_start = dol_mktime(0, 0, 0, $search_date_validation_startmonth, $search_date_validation_startday, $search_date_validation_startyear);
95 $search_date_validation_end = dol_mktime(23, 59, 59, $search_date_validation_endmonth, $search_date_validation_endday, $search_date_validation_endyear);
96 $search_import_key = GETPOST("search_import_key", 'alpha');
97 
98 $search_account_category = GETPOST('search_account_category', 'int');
99 
100 $search_accountancy_code = GETPOST("search_accountancy_code", 'alpha');
101 $search_accountancy_code_start = GETPOST('search_accountancy_code_start', 'alpha');
102 if ($search_accountancy_code_start == - 1) {
103  $search_accountancy_code_start = '';
104 }
105 $search_accountancy_code_end = GETPOST('search_accountancy_code_end', 'alpha');
106 if ($search_accountancy_code_end == - 1) {
107  $search_accountancy_code_end = '';
108 }
109 
110 $search_accountancy_aux_code = GETPOST("search_accountancy_aux_code", 'alpha');
111 $search_accountancy_aux_code_start = GETPOST('search_accountancy_aux_code_start', 'alpha');
112 if ($search_accountancy_aux_code_start == - 1) {
113  $search_accountancy_aux_code_start = '';
114 }
115 $search_accountancy_aux_code_end = GETPOST('search_accountancy_aux_code_end', 'alpha');
116 if ($search_accountancy_aux_code_end == - 1) {
117  $search_accountancy_aux_code_end = '';
118 }
119 $search_mvt_label = GETPOST('search_mvt_label', 'alpha');
120 $search_direction = GETPOST('search_direction', 'alpha');
121 $search_debit = GETPOST('search_debit', 'alpha');
122 $search_credit = GETPOST('search_credit', 'alpha');
123 $search_ledger_code = GETPOST('search_ledger_code', 'array');
124 $search_lettering_code = GETPOST('search_lettering_code', 'alpha');
125 $search_not_reconciled = GETPOST('search_not_reconciled', 'alpha');
126 
127 // Load variable for pagination
128 $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : (empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION) ? $conf->liste_limit : $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION);
129 $sortfield = GETPOST('sortfield', 'aZ09comma');
130 $sortorder = GETPOST('sortorder', 'aZ09comma');
131 $optioncss = GETPOST('optioncss', 'alpha');
132 $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
133 if (empty($page) || $page < 0) {
134  $page = 0;
135 }
136 $offset = $limit * $page;
137 $pageprev = $page - 1;
138 $pagenext = $page + 1;
139 if ($sortorder == "") {
140  $sortorder = "ASC";
141 }
142 if ($sortfield == "") {
143  $sortfield = "t.piece_num,t.rowid";
144 }
145 
146 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
147 $object = new BookKeeping($db);
148 $hookmanager->initHooks(array('bookkeepinglist'));
149 
150 $formaccounting = new FormAccounting($db);
151 $form = new Form($db);
152 
153 if (!in_array($action, array('delmouv', 'delmouvconfirm')) && !GETPOSTISSET('begin') && !GETPOSTISSET('formfilteraction') && GETPOST('page', 'int') == '' && !GETPOST('noreset', 'int') && $user->hasRight('accounting', 'mouvements', 'export')) {
154  if (empty($search_date_start) && empty($search_date_end) && !GETPOSTISSET('restore_lastsearch_values') && !GETPOST('search_accountancy_code_start')) {
155  $query = "SELECT date_start, date_end from ".MAIN_DB_PREFIX."accounting_fiscalyear ";
156  $query .= " where date_start < '".$db->idate(dol_now())."' and date_end > '".$db->idate(dol_now())."' limit 1";
157  $res = $db->query($query);
158 
159  if ($res->num_rows > 0) {
160  $fiscalYear = $db->fetch_object($res);
161  $search_date_start = strtotime($fiscalYear->date_start);
162  $search_date_end = strtotime($fiscalYear->date_end);
163  } else {
164  $month_start = ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1);
165  $year_start = dol_print_date(dol_now(), '%Y');
166  if (dol_print_date(dol_now(), '%m') < $month_start) {
167  $year_start--; // If current month is lower that starting fiscal month, we start last year
168  }
169  $year_end = $year_start + 1;
170  $month_end = $month_start - 1;
171  if ($month_end < 1) {
172  $month_end = 12;
173  $year_end--;
174  }
175  $search_date_start = dol_mktime(0, 0, 0, $month_start, 1, $year_start);
176  $search_date_end = dol_get_last_day($year_end, $month_end);
177  }
178  }
179 }
180 
181 
182 $arrayfields = array(
183  't.piece_num'=>array('label'=>$langs->trans("TransactionNumShort"), 'checked'=>1),
184  't.code_journal'=>array('label'=>$langs->trans("Codejournal"), 'checked'=>1),
185  't.doc_date'=>array('label'=>$langs->trans("Docdate"), 'checked'=>1),
186  't.doc_ref'=>array('label'=>$langs->trans("Piece"), 'checked'=>1),
187  't.numero_compte'=>array('label'=>$langs->trans("AccountAccountingShort"), 'checked'=>1),
188  't.subledger_account'=>array('label'=>$langs->trans("SubledgerAccount"), 'checked'=>1),
189  't.label_operation'=>array('label'=>$langs->trans("Label"), 'checked'=>1),
190  't.debit'=>array('label'=>$langs->trans("AccountingDebit"), 'checked'=>1),
191  't.credit'=>array('label'=>$langs->trans("AccountingCredit"), 'checked'=>1),
192  't.lettering_code'=>array('label'=>$langs->trans("LetteringCode"), 'checked'=>1),
193  't.date_creation'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0),
194  't.tms'=>array('label'=>$langs->trans("DateModification"), 'checked'=>0),
195  't.date_export'=>array('label'=>$langs->trans("DateExport"), 'checked'=>0),
196  't.date_validated'=>array('label'=>$langs->trans("DateValidationAndLock"), 'checked'=>0, 'enabled'=>!getDolGlobalString("ACCOUNTANCY_DISABLE_CLOSURE_LINE_BY_LINE")),
197  't.import_key'=>array('label'=>$langs->trans("ImportId"), 'checked'=>0, 'position'=>1100),
198 );
199 
200 if (empty($conf->global->ACCOUNTING_ENABLE_LETTERING)) {
201  unset($arrayfields['t.lettering_code']);
202 }
203 
204 $error = 0;
205 
206 if (!isModEnabled('accounting')) {
207  accessforbidden();
208 }
209 if ($user->socid > 0) {
210  accessforbidden();
211 }
212 if (!$user->hasRight('accounting', 'mouvements', 'lire')) {
213  accessforbidden();
214 }
215 
216 
217 /*
218  * Actions
219  */
220 
221 $param = '';
222 
223 if (GETPOST('cancel', 'alpha')) {
224  $action = 'list'; $massaction = '';
225 }
226 if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'preunletteringauto' && $massaction != 'preunletteringmanual' && $massaction != 'predeletebookkeepingwriting') {
227  $massaction = '';
228 }
229 
230 $parameters = array('socid'=>$socid);
231 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
232 if ($reshook < 0) {
233  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
234 }
235 
236 if (empty($reshook)) {
237  include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
238 
239  if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
240  $search_mvt_num = '';
241  $search_doc_type = '';
242  $search_doc_ref = '';
243  $search_doc_date = '';
244  $search_account_category = '';
245  $search_accountancy_code = '';
246  $search_accountancy_code_start = '';
247  $search_accountancy_code_end = '';
248  $search_accountancy_aux_code = '';
249  $search_accountancy_aux_code_start = '';
250  $search_accountancy_aux_code_end = '';
251  $search_mvt_label = '';
252  $search_direction = '';
253  $search_ledger_code = array();
254  $search_date_startyear = '';
255  $search_date_startmonth = '';
256  $search_date_startday = '';
257  $search_date_endyear = '';
258  $search_date_endmonth = '';
259  $search_date_endday = '';
260  $search_date_start = '';
261  $search_date_end = '';
262  $search_date_creation_startyear = '';
263  $search_date_creation_startmonth = '';
264  $search_date_creation_startday = '';
265  $search_date_creation_endyear = '';
266  $search_date_creation_endmonth = '';
267  $search_date_creation_endday = '';
268  $search_date_creation_start = '';
269  $search_date_creation_end = '';
270  $search_date_modification_startyear = '';
271  $search_date_modification_startmonth = '';
272  $search_date_modification_startday = '';
273  $search_date_modification_endyear = '';
274  $search_date_modification_endmonth = '';
275  $search_date_modification_endday = '';
276  $search_date_modification_start = '';
277  $search_date_modification_end = '';
278  $search_date_export_startyear = '';
279  $search_date_export_startmonth = '';
280  $search_date_export_startday = '';
281  $search_date_export_endyear = '';
282  $search_date_export_endmonth = '';
283  $search_date_export_endday = '';
284  $search_date_export_start = '';
285  $search_date_export_end = '';
286  $search_date_validation_startyear = '';
287  $search_date_validation_startmonth = '';
288  $search_date_validation_startday = '';
289  $search_date_validation_endyear = '';
290  $search_date_validation_endmonth = '';
291  $search_date_validation_endday = '';
292  $search_date_validation_start = '';
293  $search_date_validation_end = '';
294  $search_debit = '';
295  $search_credit = '';
296  $search_lettering_code = '';
297  $search_not_reconciled = '';
298  $search_import_key = '';
299  $toselect = array();
300  }
301 
302  // Must be after the remove filter action, before the export.
303  $filter = array();
304  if (!empty($search_date_start)) {
305  $filter['t.doc_date>='] = $search_date_start;
306  $tmp = dol_getdate($search_date_start);
307  $param .= '&search_date_startmonth='.urlencode($tmp['mon']).'&search_date_startday='.urlencode($tmp['mday']).'&search_date_startyear='.urlencode($tmp['year']);
308  }
309  if (!empty($search_date_end)) {
310  $filter['t.doc_date<='] = $search_date_end;
311  $tmp = dol_getdate($search_date_end);
312  $param .= '&search_date_endmonth='.urlencode($tmp['mon']).'&search_date_endday='.urlencode($tmp['mday']).'&search_date_endyear='.urlencode($tmp['year']);
313  }
314  if (!empty($search_doc_date)) {
315  $filter['t.doc_date'] = $search_doc_date;
316  $tmp = dol_getdate($search_doc_date);
317  $param .= '&doc_datemonth='.urlencode($tmp['mon']).'&doc_dateday='.urlencode($tmp['mday']).'&doc_dateyear='.urlencode($tmp['year']);
318  }
319  if (!empty($search_doc_type)) {
320  $filter['t.doc_type'] = $search_doc_type;
321  $param .= '&search_doc_type='.urlencode($search_doc_type);
322  }
323  if (!empty($search_doc_ref)) {
324  $filter['t.doc_ref'] = $search_doc_ref;
325  $param .= '&search_doc_ref='.urlencode($search_doc_ref);
326  }
327  if ($search_account_category != '-1' && !empty($search_account_category)) {
328  require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountancycategory.class.php';
329  $accountingcategory = new AccountancyCategory($db);
330 
331  $listofaccountsforgroup = $accountingcategory->getCptsCat(0, 'fk_accounting_category = '.((int) $search_account_category));
332  $listofaccountsforgroup2 = array();
333  if (is_array($listofaccountsforgroup)) {
334  foreach ($listofaccountsforgroup as $tmpval) {
335  $listofaccountsforgroup2[] = "'".$db->escape($tmpval['id'])."'";
336  }
337  }
338  $filter['t.search_accounting_code_in'] = join(',', $listofaccountsforgroup2);
339  $param .= '&search_account_category='.urlencode($search_account_category);
340  }
341  if (!empty($search_accountancy_code)) {
342  $filter['t.numero_compte'] = $search_accountancy_code;
343  $param .= '&search_accountancy_code='.urlencode($search_accountancy_code);
344  }
345  if (!empty($search_accountancy_code_start)) {
346  $filter['t.numero_compte>='] = $search_accountancy_code_start;
347  $param .= '&search_accountancy_code_start='.urlencode($search_accountancy_code_start);
348  }
349  if (!empty($search_accountancy_code_end)) {
350  $filter['t.numero_compte<='] = $search_accountancy_code_end;
351  $param .= '&search_accountancy_code_end='.urlencode($search_accountancy_code_end);
352  }
353  if (!empty($search_accountancy_aux_code)) {
354  $filter['t.subledger_account'] = $search_accountancy_aux_code;
355  $param .= '&search_accountancy_aux_code='.urlencode($search_accountancy_aux_code);
356  }
357  if (!empty($search_accountancy_aux_code_start)) {
358  $filter['t.subledger_account>='] = $search_accountancy_aux_code_start;
359  $param .= '&search_accountancy_aux_code_start='.urlencode($search_accountancy_aux_code_start);
360  }
361  if (!empty($search_accountancy_aux_code_end)) {
362  $filter['t.subledger_account<='] = $search_accountancy_aux_code_end;
363  $param .= '&search_accountancy_aux_code_end='.urlencode($search_accountancy_aux_code_end);
364  }
365  if (!empty($search_mvt_label)) {
366  $filter['t.label_operation'] = $search_mvt_label;
367  $param .= '&search_mvt_label='.urlencode($search_mvt_label);
368  }
369  if (!empty($search_direction)) {
370  $filter['t.sens'] = $search_direction;
371  $param .= '&search_direction='.urlencode($search_direction);
372  }
373  if (!empty($search_ledger_code)) {
374  $filter['t.code_journal'] = $search_ledger_code;
375  foreach ($search_ledger_code as $code) {
376  $param .= '&search_ledger_code[]='.urlencode($code);
377  }
378  }
379  if (!empty($search_mvt_num)) {
380  $filter['t.piece_num'] = $search_mvt_num;
381  $param .= '&search_mvt_num='.urlencode($search_mvt_num);
382  }
383  if (!empty($search_date_creation_start)) {
384  $filter['t.date_creation>='] = $search_date_creation_start;
385  $tmp = dol_getdate($search_date_creation_start);
386  $param .= '&search_date_creation_startmonth='.urlencode($tmp['mon']).'&search_date_creation_startday='.urlencode($tmp['mday']).'&search_date_creation_startyear='.urlencode($tmp['year']);
387  }
388  if (!empty($search_date_creation_end)) {
389  $filter['t.date_creation<='] = $search_date_creation_end;
390  $tmp = dol_getdate($search_date_creation_end);
391  $param .= '&search_date_creation_endmonth='.urlencode($tmp['mon']).'&search_date_creation_endday='.urlencode($tmp['mday']).'&search_date_creation_endyear='.urlencode($tmp['year']);
392  }
393  if (!empty($search_date_modification_start)) {
394  $filter['t.tms>='] = $search_date_modification_start;
395  $tmp = dol_getdate($search_date_modification_start);
396  $param .= '&search_date_modification_startmonth='.urlencode($tmp['mon']).'&search_date_modification_startday='.urlencode($tmp['mday']).'&search_date_modification_startyear='.urlencode($tmp['year']);
397  }
398  if (!empty($search_date_modification_end)) {
399  $filter['t.tms<='] = $search_date_modification_end;
400  $tmp = dol_getdate($search_date_modification_end);
401  $param .= '&search_date_modification_endmonth='.urlencode($tmp['mon']).'&search_date_modification_endday='.urlencode($tmp['mday']).'&search_date_modification_endyear='.urlencode($tmp['year']);
402  }
403  if (!empty($search_date_export_start)) {
404  $filter['t.date_export>='] = $search_date_export_start;
405  $tmp = dol_getdate($search_date_export_start);
406  $param .= '&search_date_export_startmonth='.urlencode($tmp['mon']).'&search_date_export_startday='.urlencode($tmp['mday']).'&search_date_export_startyear='.urlencode($tmp['year']);
407  }
408  if (!empty($search_date_export_end)) {
409  $filter['t.date_export<='] = $search_date_export_end;
410  $tmp = dol_getdate($search_date_export_end);
411  $param .= '&search_date_export_endmonth='.urlencode($tmp['mon']).'&search_date_export_endday='.urlencode($tmp['mday']).'&search_date_export_endyear='.urlencode($tmp['year']);
412  }
413  if (!empty($search_date_validation_start)) {
414  $filter['t.date_validated>='] = $search_date_validation_start;
415  $tmp = dol_getdate($search_date_validation_start);
416  $param .= '&search_date_validation_startmonth='.urlencode($tmp['mon']).'&search_date_validation_startday='.urlencode($tmp['mday']).'&search_date_validation_startyear='.urlencode($tmp['year']);
417  }
418  if (!empty($search_date_validation_end)) {
419  $filter['t.date_validated<='] = $search_date_validation_end;
420  $tmp = dol_getdate($search_date_validation_end);
421  $param .= '&search_date_validation_endmonth='.urlencode($tmp['mon']).'&search_date_validation_endday='.urlencode($tmp['mday']).'&search_date_validation_endyear='.urlencode($tmp['year']);
422  }
423  if (!empty($search_debit)) {
424  $filter['t.debit'] = $search_debit;
425  $param .= '&search_debit='.urlencode($search_debit);
426  }
427  if (!empty($search_credit)) {
428  $filter['t.credit'] = $search_credit;
429  $param .= '&search_credit='.urlencode($search_credit);
430  }
431  if (!empty($search_lettering_code)) {
432  $filter['t.lettering_code'] = $search_lettering_code;
433  $param .= '&search_lettering_code='.urlencode($search_lettering_code);
434  }
435  if (!empty($search_not_reconciled)) {
436  $filter['t.reconciled_option'] = $search_not_reconciled;
437  $param .= '&search_not_reconciled='.urlencode($search_not_reconciled);
438  }
439  if (!empty($search_import_key)) {
440  $filter['t.import_key'] = $search_import_key;
441  $param .= '&search_import_key='.urlencode($search_import_key);
442  }
443 
444  // Mass actions
445  $objectclass = 'Bookkeeping';
446  $objectlabel = 'Bookkeeping';
447  $permissiontoread = $user->hasRight('societe', 'lire');
448  $permissiontodelete = $user->hasRight('societe', 'supprimer');
449  $permissiontoadd = $user->hasRight('societe', 'creer');
450  $uploaddir = $conf->societe->dir_output;
451  include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
452 
453  if (!$error && $action == 'deletebookkeepingwriting' && $confirm == "yes" && $user->hasRight('accounting', 'mouvements', 'supprimer')) {
454  $db->begin();
455 
456  if (getDolGlobalInt('ACCOUNTING_ENABLE_LETTERING')) {
457  $lettering = new Lettering($db);
458  $nb_lettering = $lettering->bookkeepingLetteringAll($toselect, true);
459  if ($nb_lettering < 0) {
460  setEventMessages('', $lettering->errors, 'errors');
461  $error++;
462  }
463  }
464 
465  $nbok = 0;
466  if (!$error) {
467  foreach ($toselect as $toselectid) {
468  $result = $object->fetch($toselectid);
469  if ($result > 0 && (!isset($object->date_validation) || $object->date_validation === '')) {
470  $result = $object->deleteMvtNum($object->piece_num);
471  if ($result > 0) {
472  $nbok++;
473  } else {
474  setEventMessages($object->error, $object->errors, 'errors');
475  $error++;
476  break;
477  }
478  } elseif ($result < 0) {
479  setEventMessages($object->error, $object->errors, 'errors');
480  $error++;
481  break;
482  } elseif (isset($object->date_validation) && $object->date_validation != '') {
483  setEventMessages($langs->trans("ValidatedRecordWhereFound"), null, 'errors');
484  $error++;
485  break;
486  }
487  }
488  }
489 
490  if (!$error) {
491  $db->commit();
492 
493  // Message for elements well deleted
494  if ($nbok > 1) {
495  setEventMessages($langs->trans("RecordsDeleted", $nbok), null, 'mesgs');
496  } elseif ($nbok > 0) {
497  setEventMessages($langs->trans("RecordDeleted", $nbok), null, 'mesgs');
498  } else {
499  setEventMessages($langs->trans("NoRecordDeleted"), null, 'mesgs');
500  }
501 
502  header("Location: ".$_SERVER["PHP_SELF"]."?noreset=1".($param ? '&'.$param : ''));
503  exit;
504  } else {
505  $db->rollback();
506  }
507  }
508 
509  // others mass actions
510  if (!$error && getDolGlobalInt('ACCOUNTING_ENABLE_LETTERING') && $user->hasRight('accounting', 'mouvements', 'creer')) {
511  if ($massaction == 'letteringauto') {
512  $lettering = new Lettering($db);
513  $nb_lettering = $lettering->bookkeepingLetteringAll($toselect);
514  if ($nb_lettering < 0) {
515  setEventMessages('', $lettering->errors, 'errors');
516  $error++;
517  $nb_lettering = max(0, abs($nb_lettering) - 2);
518  } elseif ($nb_lettering == 0) {
519  $nb_lettering = 0;
520  setEventMessages($langs->trans('AccountancyNoLetteringModified'), array(), 'mesgs');
521  }
522  if ($nb_lettering == 1) {
523  setEventMessages($langs->trans('AccountancyOneLetteringModifiedSuccessfully'), array(), 'mesgs');
524  } elseif ($nb_lettering > 1) {
525  setEventMessages($langs->trans('AccountancyLetteringModifiedSuccessfully', $nb_lettering), array(), 'mesgs');
526  }
527 
528  if (!$error) {
529  header('Location: ' . $_SERVER['PHP_SELF'] . '?noreset=1' . $param);
530  exit();
531  }
532  } elseif ($massaction == 'letteringmanual') {
533  $lettering = new Lettering($db);
534  $result = $lettering->updateLettering($toselect);
535  if ($result < 0) {
536  setEventMessages('', $lettering->errors, 'errors');
537  } else {
538  setEventMessages($langs->trans('AccountancyOneLetteringModifiedSuccessfully'), array(), 'mesgs');
539  header('Location: ' . $_SERVER['PHP_SELF'] . '?noreset=1' . $param);
540  exit();
541  }
542  } elseif ($action == 'unletteringauto' && $confirm == "yes") {
543  $lettering = new Lettering($db);
544  $nb_lettering = $lettering->bookkeepingLetteringAll($toselect, true);
545  if ($nb_lettering < 0) {
546  setEventMessages('', $lettering->errors, 'errors');
547  $error++;
548  $nb_lettering = max(0, abs($nb_lettering) - 2);
549  } elseif ($nb_lettering == 0) {
550  $nb_lettering = 0;
551  setEventMessages($langs->trans('AccountancyNoUnletteringModified'), array(), 'mesgs');
552  }
553  if ($nb_lettering == 1) {
554  setEventMessages($langs->trans('AccountancyOneUnletteringModifiedSuccessfully'), array(), 'mesgs');
555  } elseif ($nb_lettering > 1) {
556  setEventMessages($langs->trans('AccountancyUnletteringModifiedSuccessfully', $nb_lettering), array(), 'mesgs');
557  }
558 
559  if (!$error) {
560  header('Location: ' . $_SERVER['PHP_SELF'] . '?noreset=1' . $param);
561  exit();
562  }
563  } elseif ($action == 'unletteringmanual' && $confirm == "yes") {
564  $lettering = new Lettering($db);
565  $nb_lettering = $lettering->deleteLettering($toselect);
566  if ($result < 0) {
567  setEventMessages('', $lettering->errors, 'errors');
568  } else {
569  setEventMessages($langs->trans('AccountancyOneUnletteringModifiedSuccessfully'), array(), 'mesgs');
570  header('Location: ' . $_SERVER['PHP_SELF'] . '?noreset=1' . $param);
571  exit();
572  }
573  }
574  }
575 }
576 
577 // Build and execute select (used by page and export action)
578 // must de set after the action that set $filter
579 // --------------------------------------------------------------------
580 
581 $sql = 'SELECT';
582 $sql .= ' t.rowid,';
583 $sql .= " t.doc_date,";
584 $sql .= " t.doc_type,";
585 $sql .= " t.doc_ref,";
586 $sql .= " t.fk_doc,";
587 $sql .= " t.fk_docdet,";
588 $sql .= " t.thirdparty_code,";
589 $sql .= " t.subledger_account,";
590 $sql .= " t.subledger_label,";
591 $sql .= " t.numero_compte,";
592 $sql .= " t.label_compte,";
593 $sql .= " t.label_operation,";
594 $sql .= " t.debit,";
595 $sql .= " t.credit,";
596 $sql .= " t.lettering_code,";
597 $sql .= " t.montant as amount,";
598 $sql .= " t.sens,";
599 $sql .= " t.fk_user_author,";
600 $sql .= " t.import_key,";
601 $sql .= " t.code_journal,";
602 $sql .= " t.journal_label,";
603 $sql .= " t.piece_num,";
604 $sql .= " t.date_creation,";
605 $sql .= " t.tms as date_modification,";
606 $sql .= " t.date_export,";
607 $sql .= " t.date_validated as date_validation,";
608 $sql .= " t.import_key";
609 
610 $sqlfields = $sql; // $sql fields to remove for count total
611 
612 $sql .= ' FROM '.MAIN_DB_PREFIX.$object->table_element.' as t';
613 // Manage filter
614 $sqlwhere = array();
615 if (count($filter) > 0) {
616  foreach ($filter as $key => $value) {
617  if ($key == 't.doc_date') {
618  $sqlwhere[] = $key."='".$db->idate($value)."'";
619  } elseif ($key == 't.doc_date>=' || $key == 't.doc_date<=') {
620  $sqlwhere[] = $key."'".$db->idate($value)."'";
621  } elseif ($key == 't.numero_compte>=' || $key == 't.numero_compte<=' || $key == 't.subledger_account>=' || $key == 't.subledger_account<=') {
622  $sqlwhere[] = $key."'".$db->escape($value)."'";
623  } elseif ($key == 't.fk_doc' || $key == 't.fk_docdet' || $key == 't.piece_num') {
624  $sqlwhere[] = $key.'='.((int) $value);
625  } elseif ($key == 't.subledger_account' || $key == 't.numero_compte') {
626  $sqlwhere[] = $key." LIKE '".$db->escape($value)."%'";
627  } elseif ($key == 't.subledger_account') {
628  $sqlwhere[] = natural_search($key, $value, 0, 1);
629  } elseif ($key == 't.date_creation>=' || $key == 't.date_creation<=') {
630  $sqlwhere[] = $key."'".$db->idate($value)."'";
631  } elseif ($key == 't.tms>=' || $key == 't.tms<=') {
632  $sqlwhere[] = $key."'".$db->idate($value)."'";
633  } elseif ($key == 't.date_export>=' || $key == 't.date_export<=') {
634  $sqlwhere[] = $key."'".$db->idate($value)."'";
635  } elseif ($key == 't.date_validated>=' || $key == 't.date_validated<=') {
636  $sqlwhere[] = $key."'".$db->idate($value)."'";
637  } elseif ($key == 't.credit' || $key == 't.debit') {
638  $sqlwhere[] = natural_search($key, $value, 1, 1);
639  } elseif ($key == 't.reconciled_option') {
640  $sqlwhere[] = 't.lettering_code IS NULL';
641  } elseif ($key == 't.code_journal' && !empty($value)) {
642  if (is_array($value)) {
643  $sqlwhere[] = natural_search("t.code_journal", join(',', $value), 3, 1);
644  } else {
645  $sqlwhere[] = natural_search("t.code_journal", $value, 3, 1);
646  }
647  } elseif ($key == 't.search_accounting_code_in' && !empty($value)) {
648  $sqlwhere[] = 't.numero_compte IN ('.$db->sanitize($value, 1).')';
649  } else {
650  $sqlwhere[] = natural_search($key, $value, 0, 1);
651  }
652  }
653 }
654 $sql .= ' WHERE t.entity IN ('.getEntity('accountancy').')';
655 
656 if (count($sqlwhere) > 0) {
657  $sql .= ' AND '.implode(' AND ', $sqlwhere);
658 }
659 //print $sql;
660 
661 /*
662  * View
663  */
664 
665 $formother = new FormOther($db);
666 $formfile = new FormFile($db);
667 
668 $title_page = $langs->trans("Operations").' - '.$langs->trans("Journals");
669 
670 // Count total nb of records
671 $nbtotalofrecords = '';
672 if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
673  /* The fast and low memory method to get and count full list converts the sql into a sql count */
674  $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql);
675  $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount);
676  $resql = $db->query($sqlforcount);
677  if ($resql) {
678  $objforcount = $db->fetch_object($resql);
679  $nbtotalofrecords = $objforcount->nbtotalofrecords;
680  } else {
681  dol_print_error($db);
682  }
683 
684  if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
685  $page = 0;
686  $offset = 0;
687  }
688  $db->free($resql);
689 }
690 
691 // Complete request and execute it with limit
692 $sql .= $db->order($sortfield, $sortorder);
693 if ($limit) {
694  $sql .= $db->plimit($limit + 1, $offset);
695 }
696 
697 $resql = $db->query($sql);
698 if (!$resql) {
699  dol_print_error($db);
700  exit;
701 }
702 
703 $num = $db->num_rows($resql);
704 
705 $arrayofselected = is_array($toselect) ? $toselect : array();
706 
707 // Output page
708 // --------------------------------------------------------------------
709 
710 llxHeader('', $title_page);
711 
712 $formconfirm = '';
713 
714 // Print form confirm
715 print $formconfirm;
716 
717 //$param=''; param started before
718 if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
719  $param .= '&contextpage='.urlencode($contextpage);
720 }
721 if ($limit > 0 && $limit != $conf->liste_limit) {
722  $param .= '&limit='.((int) $limit);
723 }
724 
725 // List of mass actions available
726 $arrayofmassactions = array();
727 if (getDolGlobalInt('ACCOUNTING_ENABLE_LETTERING') && $user->hasRight('accounting', 'mouvements', 'creer')) {
728  $arrayofmassactions['letteringauto'] = img_picto('', 'check', 'class="pictofixedwidth"') . $langs->trans('LetteringAuto');
729  $arrayofmassactions['preunletteringauto'] = img_picto('', 'uncheck', 'class="pictofixedwidth"') . $langs->trans('UnletteringAuto');
730  $arrayofmassactions['letteringmanual'] = img_picto('', 'check', 'class="pictofixedwidth"') . $langs->trans('LetteringManual');
731  $arrayofmassactions['preunletteringmanual'] = img_picto('', 'uncheck', 'class="pictofixedwidth"') . $langs->trans('UnletteringManual');
732 }
733 if ($user->hasRight('accounting', 'mouvements', 'supprimer')) {
734  $arrayofmassactions['predeletebookkeepingwriting'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
735 }
736 if (GETPOST('nomassaction', 'int') || in_array($massaction, array('preunletteringauto', 'preunletteringmanual', 'predeletebookkeepingwriting'))) {
737  $arrayofmassactions = array();
738 }
739 $massactionbutton = $form->selectMassAction($massaction, $arrayofmassactions);
740 
741 print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
742 print '<input type="hidden" name="token" value="'.newToken().'">';
743 print '<input type="hidden" name="action" value="list">';
744 if ($optioncss != '') {
745  print '<input type="hidden" name="optioncss" value="'.urlencode($optioncss).'">';
746 }
747 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
748 print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
749 print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
750 print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
751 
752 if (count($filter)) {
753  $buttonLabel = $langs->trans("ExportFilteredList");
754 } else {
755  $buttonLabel = $langs->trans("ExportList");
756 }
757 
758 $parameters = array('param' => $param);
759 $reshook = $hookmanager->executeHooks('addMoreActionsButtonsList', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
760 if ($reshook < 0) {
761  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
762 }
763 
764 $newcardbutton = empty($hookmanager->resPrint) ? '' : $hookmanager->resPrint;
765 
766 if (empty($reshook)) {
767  $newcardbutton .= dolGetButtonTitle($langs->trans('ViewFlatList'), '', 'fa fa-list paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/list.php?'.$param, '', 1, array('morecss' => 'marginleftonly btnTitleSelected'));
768  $newcardbutton .= dolGetButtonTitle($langs->trans('GroupByAccountAccounting'), '', 'fa fa-stream paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/listbyaccount.php?'.$param, '', 1, array('morecss' => 'marginleftonly'));
769  $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'));
770 
771  $url = './card.php?action=create';
772  if (!empty($socid)) {
773  $url .= '&socid='.$socid;
774  }
775  $newcardbutton .= dolGetButtonTitle($langs->trans('NewAccountingMvt'), '', 'fa fa-plus-circle paddingleft', $url, '', $user->hasRight('accounting', 'mouvements', 'creer'));
776 }
777 
778 print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_accountancy', 0, $newcardbutton, '', $limit, 0, 0, 1);
779 
780 if ($massaction == 'preunletteringauto') {
781  print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmMassUnletteringAuto"), $langs->trans("ConfirmMassUnletteringQuestion", count($toselect)), "unletteringauto", null, '', 0, 200, 500, 1);
782 } elseif ($massaction == 'preunletteringmanual') {
783  print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmMassUnletteringManual"), $langs->trans("ConfirmMassUnletteringQuestion", count($toselect)), "unletteringmanual", null, '', 0, 200, 500, 1);
784 } elseif ($massaction == 'predeletebookkeepingwriting') {
785  print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmMassDeleteBookkeepingWriting"), $langs->trans("ConfirmMassDeleteBookkeepingWritingQuestion", count($toselect)), "deletebookkeepingwriting", null, '', 0, 200, 500, 1);
786 }
787 
788 //$topicmail = "Information";
789 //$modelmail = "accountingbookkeeping";
790 //$objecttmp = new BookKeeping($db);
791 //$trackid = 'bk'.$object->id;
792 include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
793 
794 $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
795 $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN', '')); // This also change content of $arrayfields
796 if ($massactionbutton && $contextpage != 'poslist') {
797  $selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
798 }
799 
800 $moreforfilter = '';
801 $moreforfilter .= '<div class="divsearchfield">';
802 $moreforfilter .= $langs->trans('AccountingCategory').': ';
803 $moreforfilter .= '<div class="nowrap inline-block">';
804 $moreforfilter .= $formaccounting->select_accounting_category($search_account_category, 'search_account_category', 1, 0, 0, 0);
805 $moreforfilter .= '</div>';
806 $moreforfilter .= '</div>';
807 
808 $parameters = array();
809 $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
810 if (empty($reshook)) {
811  $moreforfilter .= $hookmanager->resPrint;
812 } else {
813  $moreforfilter = $hookmanager->resPrint;
814 }
815 
816 print '<div class="liste_titre liste_titre_bydiv centpercent">';
817 print $moreforfilter;
818 print '</div>';
819 
820 print '<div class="div-table-responsive">';
821 print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">';
822 
823 // Filters lines
824 print '<tr class="liste_titre_filter">';
825 // Action column
826 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
827  print '<td class="liste_titre center">';
828  $searchpicto = $form->showFilterButtons('left');
829  print $searchpicto;
830  print '</td>';
831 }
832 // Movement number
833 if (!empty($arrayfields['t.piece_num']['checked'])) {
834  print '<td class="liste_titre"><input type="text" name="search_mvt_num" size="6" value="'.dol_escape_htmltag($search_mvt_num).'"></td>';
835 }
836 // Code journal
837 if (!empty($arrayfields['t.code_journal']['checked'])) {
838  print '<td class="liste_titre center">';
839  print $formaccounting->multi_select_journal($search_ledger_code, 'search_ledger_code', 0, 1, 1, 1, 'small maxwidth75');
840  print '</td>';
841 }
842 // Date document
843 if (!empty($arrayfields['t.doc_date']['checked'])) {
844  print '<td class="liste_titre center">';
845  print '<div class="nowrap">';
846  print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"));
847  print '</div>';
848  print '<div class="nowrap">';
849  print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to"));
850  print '</div>';
851  print '</td>';
852 }
853 // Ref document
854 if (!empty($arrayfields['t.doc_ref']['checked'])) {
855  print '<td class="liste_titre"><input type="text" name="search_doc_ref" size="8" value="'.dol_escape_htmltag($search_doc_ref).'"></td>';
856 }
857 // Accountancy account
858 if (!empty($arrayfields['t.numero_compte']['checked'])) {
859  print '<td class="liste_titre">';
860  print '<div class="nowrap">';
861  print $formaccounting->select_account($search_accountancy_code_start, 'search_accountancy_code_start', $langs->trans('From'), array(), 1, 1, 'maxwidth150', 'account');
862  print '</div>';
863  print '<div class="nowrap">';
864  print $formaccounting->select_account($search_accountancy_code_end, 'search_accountancy_code_end', $langs->trans('to'), array(), 1, 1, 'maxwidth150', 'account');
865  print '</div>';
866  print '</td>';
867 }
868 // Subledger account
869 if (!empty($arrayfields['t.subledger_account']['checked'])) {
870  print '<td class="liste_titre">';
871  // TODO For the moment we keep a free input text instead of a combo. The select_auxaccount has problem because it does not
872  // use setup of keypress to select thirdparty and this hang browser on large database.
873  if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) {
874  print '<div class="nowrap">';
875  //print $langs->trans('From').' ';
876  print $formaccounting->select_auxaccount($search_accountancy_aux_code_start, 'search_accountancy_aux_code_start', $langs->trans('From'), 'maxwidth250', 'subledgeraccount');
877  print '</div>';
878  print '<div class="nowrap">';
879  print $formaccounting->select_auxaccount($search_accountancy_aux_code_end, 'search_accountancy_aux_code_end', $langs->trans('to'), 'maxwidth250', 'subledgeraccount');
880  print '</div>';
881  } else {
882  print '<input type="text" class="maxwidth75" name="search_accountancy_aux_code" value="'.dol_escape_htmltag($search_accountancy_aux_code).'">';
883  }
884  print '</td>';
885 }
886 // Label operation
887 if (!empty($arrayfields['t.label_operation']['checked'])) {
888  print '<td class="liste_titre">';
889  print '<input type="text" size="7" class="flat" name="search_mvt_label" value="'.dol_escape_htmltag($search_mvt_label).'"/>';
890  print '</td>';
891 }
892 // Debit
893 if (!empty($arrayfields['t.debit']['checked'])) {
894  print '<td class="liste_titre right">';
895  print '<input type="text" class="flat" name="search_debit" size="4" value="'.dol_escape_htmltag($search_debit).'">';
896  print '</td>';
897 }
898 // Credit
899 if (!empty($arrayfields['t.credit']['checked'])) {
900  print '<td class="liste_titre right">';
901  print '<input type="text" class="flat" name="search_credit" size="4" value="'.dol_escape_htmltag($search_credit).'">';
902  print '</td>';
903 }
904 // Lettering code
905 if (!empty($arrayfields['t.lettering_code']['checked'])) {
906  print '<td class="liste_titre center">';
907  print '<input type="text" size="3" class="flat" name="search_lettering_code" value="'.dol_escape_htmltag($search_lettering_code).'"/>';
908  print '<br><span class="nowrap"><input type="checkbox" name="search_not_reconciled" value="notreconciled"'.($search_not_reconciled == 'notreconciled' ? ' checked' : '').'>'.$langs->trans("NotReconciled").'</span>';
909  print '</td>';
910 }
911 
912 // Fields from hook
913 $parameters = array('arrayfields'=>$arrayfields);
914 $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
915 print $hookmanager->resPrint;
916 
917 // Date creation
918 if (!empty($arrayfields['t.date_creation']['checked'])) {
919  print '<td class="liste_titre center">';
920  print '<div class="nowrap">';
921  print $form->selectDate($search_date_creation_start, 'search_date_creation_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"));
922  print '</div>';
923  print '<div class="nowrap">';
924  print $form->selectDate($search_date_creation_end, 'search_date_creation_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to"));
925  print '</div>';
926  print '</td>';
927 }
928 // Date modification
929 if (!empty($arrayfields['t.tms']['checked'])) {
930  print '<td class="liste_titre center">';
931  print '<div class="nowrap">';
932  print $form->selectDate($search_date_modification_start, 'search_date_modification_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"));
933  print '</div>';
934  print '<div class="nowrap">';
935  print $form->selectDate($search_date_modification_end, 'search_date_modification_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"));
936  print '</div>';
937  print '</td>';
938 }
939 // Date export
940 if (!empty($arrayfields['t.date_export']['checked'])) {
941  print '<td class="liste_titre center">';
942  print '<div class="nowrap">';
943  print $form->selectDate($search_date_export_start, 'search_date_export_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"));
944  print '</div>';
945  print '<div class="nowrap">';
946  print $form->selectDate($search_date_export_end, 'search_date_export_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to"));
947  print '</div>';
948  print '</td>';
949 }
950 // Date validation
951 if (!empty($arrayfields['t.date_validated']['checked'])) {
952  print '<td class="liste_titre center">';
953  print '<div class="nowrap">';
954  print $form->selectDate($search_date_validation_start, 'search_date_validation_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"));
955  print '</div>';
956  print '<div class="nowrap">';
957  print $form->selectDate($search_date_validation_end, 'search_date_validation_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to"));
958  print '</div>';
959  print '</td>';
960 }
961 if (!empty($arrayfields['t.import_key']['checked'])) {
962  print '<td class="liste_titre center">';
963  print '<input class="flat searchstring maxwidth50" type="text" name="search_import_key" value="'.dol_escape_htmltag($search_import_key).'">';
964  print '</td>';
965 }
966 // Action column
967 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
968  print '<td class="liste_titre center">';
969  $searchpicto = $form->showFilterButtons();
970  print $searchpicto;
971  print '</td>';
972 }
973 print "</tr>\n";
974 
975 print '<tr class="liste_titre">';
976 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
977  print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch actioncolumn ');}
978 if (!empty($arrayfields['t.piece_num']['checked'])) {
979  print_liste_field_titre($arrayfields['t.piece_num']['label'], $_SERVER['PHP_SELF'], "t.piece_num", "", $param, "", $sortfield, $sortorder);
980 }
981 if (!empty($arrayfields['t.code_journal']['checked'])) {
982  print_liste_field_titre($arrayfields['t.code_journal']['label'], $_SERVER['PHP_SELF'], "t.code_journal", "", $param, '', $sortfield, $sortorder, 'center ');
983 }
984 if (!empty($arrayfields['t.doc_date']['checked'])) {
985  print_liste_field_titre($arrayfields['t.doc_date']['label'], $_SERVER['PHP_SELF'], "t.doc_date", "", $param, '', $sortfield, $sortorder, 'center ');
986 }
987 if (!empty($arrayfields['t.doc_ref']['checked'])) {
988  print_liste_field_titre($arrayfields['t.doc_ref']['label'], $_SERVER['PHP_SELF'], "t.doc_ref", "", $param, "", $sortfield, $sortorder);
989 }
990 if (!empty($arrayfields['t.numero_compte']['checked'])) {
991  print_liste_field_titre($arrayfields['t.numero_compte']['label'], $_SERVER['PHP_SELF'], "t.numero_compte", "", $param, "", $sortfield, $sortorder);
992 }
993 if (!empty($arrayfields['t.subledger_account']['checked'])) {
994  print_liste_field_titre($arrayfields['t.subledger_account']['label'], $_SERVER['PHP_SELF'], "t.subledger_account", "", $param, "", $sortfield, $sortorder);
995 }
996 if (!empty($arrayfields['t.label_operation']['checked'])) {
997  print_liste_field_titre($arrayfields['t.label_operation']['label'], $_SERVER['PHP_SELF'], "t.label_operation", "", $param, "", $sortfield, $sortorder);
998 }
999 if (!empty($arrayfields['t.debit']['checked'])) {
1000  print_liste_field_titre($arrayfields['t.debit']['label'], $_SERVER['PHP_SELF'], "t.debit", "", $param, '', $sortfield, $sortorder, 'right ');
1001 }
1002 if (!empty($arrayfields['t.credit']['checked'])) {
1003  print_liste_field_titre($arrayfields['t.credit']['label'], $_SERVER['PHP_SELF'], "t.credit", "", $param, '', $sortfield, $sortorder, 'right ');
1004 }
1005 if (!empty($arrayfields['t.lettering_code']['checked'])) {
1006  print_liste_field_titre($arrayfields['t.lettering_code']['label'], $_SERVER['PHP_SELF'], "t.lettering_code", "", $param, '', $sortfield, $sortorder, 'center ');
1007 }
1008 // Hook fields
1009 $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
1010 $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
1011 print $hookmanager->resPrint;
1012 if (!empty($arrayfields['t.date_creation']['checked'])) {
1013  print_liste_field_titre($arrayfields['t.date_creation']['label'], $_SERVER['PHP_SELF'], "t.date_creation", "", $param, '', $sortfield, $sortorder, 'center ');
1014 }
1015 if (!empty($arrayfields['t.tms']['checked'])) {
1016  print_liste_field_titre($arrayfields['t.tms']['label'], $_SERVER['PHP_SELF'], "t.tms", "", $param, '', $sortfield, $sortorder, 'center ');
1017 }
1018 if (!empty($arrayfields['t.date_export']['checked'])) {
1019  print_liste_field_titre($arrayfields['t.date_export']['label'], $_SERVER['PHP_SELF'], "t.date_export,t.doc_date", "", $param, '', $sortfield, $sortorder, 'center ');
1020 }
1021 if (!empty($arrayfields['t.date_validated']['checked'])) {
1022  print_liste_field_titre($arrayfields['t.date_validated']['label'], $_SERVER['PHP_SELF'], "t.date_validated,t.doc_date", "", $param, '', $sortfield, $sortorder, 'center ');
1023 }
1024 if (!empty($arrayfields['t.import_key']['checked'])) {
1025  print_liste_field_titre($arrayfields['t.import_key']['label'], $_SERVER["PHP_SELF"], "t.import_key", "", $param, '', $sortfield, $sortorder, 'center ');
1026 }
1027 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1028  print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
1029 }
1030 print "</tr>\n";
1031 
1032 
1033 $line = new BookKeepingLine();
1034 
1035 // Loop on record
1036 // --------------------------------------------------------------------
1037 $i = 0;
1038 $totalarray = array();
1039 $totalarray['nbfield'] = 0;
1040 $total_debit = 0;
1041 $total_credit = 0;
1042 $totalarray['val'] = array ();
1043 $totalarray['val']['totaldebit'] = 0;
1044 $totalarray['val']['totalcredit'] = 0;
1045 
1046 while ($i < min($num, $limit)) {
1047  $obj = $db->fetch_object($resql);
1048  if (empty($obj)) {
1049  break; // Should not happen
1050  }
1051 
1052  $line->id = $obj->rowid;
1053  $line->doc_date = $db->jdate($obj->doc_date);
1054  $line->doc_type = $obj->doc_type;
1055  $line->doc_ref = $obj->doc_ref;
1056  $line->fk_doc = $obj->fk_doc;
1057  $line->fk_docdet = $obj->fk_docdet;
1058  $line->thirdparty_code = $obj->thirdparty_code;
1059  $line->subledger_account = $obj->subledger_account;
1060  $line->subledger_label = $obj->subledger_label;
1061  $line->numero_compte = $obj->numero_compte;
1062  $line->label_compte = $obj->label_compte;
1063  $line->label_operation = $obj->label_operation;
1064  $line->debit = $obj->debit;
1065  $line->credit = $obj->credit;
1066  $line->montant = $obj->amount; // deprecated
1067  $line->amount = $obj->amount;
1068  $line->sens = $obj->sens;
1069  $line->lettering_code = $obj->lettering_code;
1070  $line->fk_user_author = $obj->fk_user_author;
1071  $line->import_key = $obj->import_key;
1072  $line->code_journal = $obj->code_journal;
1073  $line->journal_label = $obj->journal_label;
1074  $line->piece_num = $obj->piece_num;
1075  $line->date_creation = $db->jdate($obj->date_creation);
1076  $line->date_modification = $db->jdate($obj->date_modification);
1077  $line->date_export = $db->jdate($obj->date_export);
1078  $line->date_validation = $db->jdate($obj->date_validation);
1079 
1080  $total_debit += $line->debit;
1081  $total_credit += $line->credit;
1082 
1083  print '<tr class="oddeven">';
1084  // Action column
1085  if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1086  print '<td class="nowraponall center">';
1087  if (($massactionbutton || $massaction) && $contextpage != 'poslist') { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
1088  $selected = 0;
1089  if (in_array($line->id, $arrayofselected)) {
1090  $selected = 1;
1091  }
1092  print '<input id="cb'.$line->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$line->id.'"'.($selected ? ' checked="checked"' : '').' />';
1093  }
1094  print '</td>';
1095  if (!$i) {
1096  $totalarray['nbfield']++;
1097  }
1098  }
1099 
1100  // Piece number
1101  if (!empty($arrayfields['t.piece_num']['checked'])) {
1102  print '<td>';
1103  $object->id = $line->id;
1104  $object->piece_num = $line->piece_num;
1105  print $object->getNomUrl(1, '', 0, '', 1);
1106  print '</td>';
1107  if (!$i) {
1108  $totalarray['nbfield']++;
1109  }
1110  }
1111 
1112  // Journal code
1113  if (!empty($arrayfields['t.code_journal']['checked'])) {
1114  $accountingjournal = new AccountingJournal($db);
1115  $result = $accountingjournal->fetch('', $line->code_journal);
1116  $journaltoshow = (($result > 0) ? $accountingjournal->getNomUrl(0, 0, 0, '', 0) : $line->code_journal);
1117  print '<td class="center tdoverflowmax150">'.$journaltoshow.'</td>';
1118  if (!$i) {
1119  $totalarray['nbfield']++;
1120  }
1121  }
1122 
1123  // Document date
1124  if (!empty($arrayfields['t.doc_date']['checked'])) {
1125  print '<td class="center">'.dol_print_date($line->doc_date, 'day').'</td>';
1126  if (!$i) {
1127  $totalarray['nbfield']++;
1128  }
1129  }
1130 
1131  // Document ref
1132  if (!empty($arrayfields['t.doc_ref']['checked'])) {
1133  if ($line->doc_type == 'customer_invoice') {
1134  $langs->loadLangs(array('bills'));
1135 
1136  require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
1137  $objectstatic = new Facture($db);
1138  $objectstatic->fetch($line->fk_doc);
1139  //$modulepart = 'facture';
1140 
1141  $filename = dol_sanitizeFileName($line->doc_ref);
1142  $filedir = $conf->facture->dir_output.'/'.dol_sanitizeFileName($line->doc_ref);
1143  $urlsource = $_SERVER['PHP_SELF'].'?id='.$objectstatic->id;
1144  $documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir);
1145  } elseif ($line->doc_type == 'supplier_invoice') {
1146  $langs->loadLangs(array('bills'));
1147 
1148  require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
1149  $objectstatic = new FactureFournisseur($db);
1150  $objectstatic->fetch($line->fk_doc);
1151  //$modulepart = 'invoice_supplier';
1152 
1153  $filename = dol_sanitizeFileName($line->doc_ref);
1154  $filedir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($line->fk_doc, 2, 0, 0, $objectstatic, $modulepart).dol_sanitizeFileName($line->doc_ref);
1155  $subdir = get_exdir($objectstatic->id, 2, 0, 0, $objectstatic, $modulepart).dol_sanitizeFileName($line->doc_ref);
1156  $documentlink = $formfile->getDocumentsLink($objectstatic->element, $subdir, $filedir);
1157  } elseif ($line->doc_type == 'expense_report') {
1158  $langs->loadLangs(array('trips'));
1159 
1160  require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
1161  $objectstatic = new ExpenseReport($db);
1162  $objectstatic->fetch($line->fk_doc);
1163  //$modulepart = 'expensereport';
1164 
1165  $filename = dol_sanitizeFileName($line->doc_ref);
1166  $filedir = $conf->expensereport->dir_output.'/'.dol_sanitizeFileName($line->doc_ref);
1167  $urlsource = $_SERVER['PHP_SELF'].'?id='.$objectstatic->id;
1168  $documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir);
1169  } elseif ($line->doc_type == 'bank') {
1170  require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
1171  $objectstatic = new AccountLine($db);
1172  $objectstatic->fetch($line->fk_doc);
1173  } else {
1174  // Other type
1175  }
1176 
1177  $labeltoshow = '';
1178  $labeltoshowalt = '';
1179  if ($line->doc_type == 'customer_invoice' || $line->doc_type == 'supplier_invoice' || $line->doc_type == 'expense_report') {
1180  $labeltoshow .= $objectstatic->getNomUrl(1, '', 0, 0, '', 0, -1, 1);
1181  $labeltoshow .= $documentlink;
1182  $labeltoshowalt .= $objectstatic->ref;
1183  } elseif ($line->doc_type == 'bank') {
1184  $labeltoshow .= $objectstatic->getNomUrl(1);
1185  $labeltoshowalt .= $objectstatic->ref;
1186  $bank_ref = strstr($line->doc_ref, '-');
1187  $labeltoshow .= " " . $bank_ref;
1188  $labeltoshowalt .= " " . $bank_ref;
1189  } else {
1190  $labeltoshow .= $line->doc_ref;
1191  $labeltoshowalt .= $line->doc_ref;
1192  }
1193 
1194  print '<td class="nowraponall tdoverflowmax200" title="'.dol_escape_htmltag($labeltoshowalt).'">';
1195  print $labeltoshow;
1196  print "</td>\n";
1197  if (!$i) {
1198  $totalarray['nbfield']++;
1199  }
1200  }
1201 
1202  // Account number
1203  if (!empty($arrayfields['t.numero_compte']['checked'])) {
1204  print '<td>'.length_accountg($line->numero_compte).'</td>';
1205  if (!$i) {
1206  $totalarray['nbfield']++;
1207  }
1208  }
1209 
1210  // Subledger account
1211  if (!empty($arrayfields['t.subledger_account']['checked'])) {
1212  print '<td>'.length_accounta($line->subledger_account).'</td>';
1213  if (!$i) {
1214  $totalarray['nbfield']++;
1215  }
1216  }
1217 
1218  // Label operation
1219  if (!empty($arrayfields['t.label_operation']['checked'])) {
1220  print '<td class="small tdoverflowmax200" title="'.dol_escape_htmltag($line->label_operation).'">'.dol_escape_htmltag($line->label_operation).'</td>';
1221  if (!$i) {
1222  $totalarray['nbfield']++;
1223  }
1224  }
1225 
1226  // Amount debit
1227  if (!empty($arrayfields['t.debit']['checked'])) {
1228  print '<td class="right nowraponall amount">'.($line->debit != 0 ? price($line->debit) : '').'</td>';
1229  if (!$i) {
1230  $totalarray['nbfield']++;
1231  }
1232  if (!$i) {
1233  $totalarray['pos'][$totalarray['nbfield']] = 'totaldebit';
1234  }
1235  $totalarray['val']['totaldebit'] += $line->debit;
1236  }
1237 
1238  // Amount credit
1239  if (!empty($arrayfields['t.credit']['checked'])) {
1240  print '<td class="right nowraponall amount">'.($line->credit != 0 ? price($line->credit) : '').'</td>';
1241  if (!$i) {
1242  $totalarray['nbfield']++;
1243  }
1244  if (!$i) {
1245  $totalarray['pos'][$totalarray['nbfield']] = 'totalcredit';
1246  }
1247  $totalarray['val']['totalcredit'] += $line->credit;
1248  }
1249 
1250  // Lettering code
1251  if (!empty($arrayfields['t.lettering_code']['checked'])) {
1252  print '<td class="center">'.$line->lettering_code.'</td>';
1253  if (!$i) {
1254  $totalarray['nbfield']++;
1255  }
1256  }
1257 
1258  // Fields from hook
1259  $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
1260  $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook
1261  print $hookmanager->resPrint;
1262 
1263  // Creation operation date
1264  if (!empty($arrayfields['t.date_creation']['checked'])) {
1265  print '<td class="center">'.dol_print_date($line->date_creation, 'dayhour', 'tzuserrel').'</td>';
1266  if (!$i) {
1267  $totalarray['nbfield']++;
1268  }
1269  }
1270 
1271  // Modification operation date
1272  if (!empty($arrayfields['t.tms']['checked'])) {
1273  print '<td class="center">'.dol_print_date($line->date_modification, 'dayhour', 'tzuserrel').'</td>';
1274  if (!$i) {
1275  $totalarray['nbfield']++;
1276  }
1277  }
1278 
1279  // Exported operation date
1280  if (!empty($arrayfields['t.date_export']['checked'])) {
1281  print '<td class="center nowraponall">'.dol_print_date($line->date_export, 'dayhour', 'tzuserrel').'</td>';
1282  if (!$i) {
1283  $totalarray['nbfield']++;
1284  }
1285  }
1286 
1287  // Validated operation date
1288  if (!empty($arrayfields['t.date_validated']['checked'])) {
1289  print '<td class="center nowraponall">'.dol_print_date($line->date_validation, 'dayhour', 'tzuserrel').'</td>';
1290  if (!$i) {
1291  $totalarray['nbfield']++;
1292  }
1293  }
1294 
1295  if (!empty($arrayfields['t.import_key']['checked'])) {
1296  print '<td class="center">'.$obj->import_key."</td>\n";
1297  if (!$i) {
1298  $totalarray['nbfield']++;
1299  }
1300  }
1301 
1302  // Action column
1303  if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1304  print '<td class="nowraponall center">';
1305  if (($massactionbutton || $massaction) && $contextpage != 'poslist') { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
1306  $selected = 0;
1307  if (in_array($line->id, $arrayofselected)) {
1308  $selected = 1;
1309  }
1310  print '<input id="cb'.$line->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$line->id.'"'.($selected ? ' checked="checked"' : '').' />';
1311  }
1312  print '</td>';
1313  if (!$i) {
1314  $totalarray['nbfield']++;
1315  }
1316  }
1317 
1318 
1319  print "</tr>\n";
1320 
1321  $i++;
1322 }
1323 
1324 // Show total line
1325 include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
1326 
1327 // If no record found
1328 if ($num == 0) {
1329  $colspan = 1;
1330  foreach ($arrayfields as $key => $val) {
1331  if (!empty($val['checked'])) {
1332  $colspan++;
1333  }
1334  }
1335  print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
1336 }
1337 
1338 $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql);
1339 $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1340 print $hookmanager->resPrint;
1341 
1342 print "</table>";
1343 print '</div>';
1344 
1345 print '</form>';
1346 
1347 // End of page
1348 llxFooter();
1349 
1350 $db->close();
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:56
llxFooter()
Empty footer.
Definition: wrapper.php:70
Class to manage bank transaction lines.
Class to manage categories of an accounting account.
Class to manage accounting accounts.
Class to manage Ledger (General Ledger and Subledger)
Class BookKeepingLine.
Class to manage Trips and Expenses.
Class to manage suppliers invoices.
Class to manage invoices.
Class to manage generation of HTML components for accounting management.
Class to offer components to list and upload files.
Class to manage generation of HTML components Only common components must be here.
Classe permettant la generation de composants html autre Only common components are here.
Class Lettering.
if(isModEnabled('facture') && $user->hasRight('facture', 'lire')) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') && $user->hasRight('don', 'lire')) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $sql
Social contributions to pay.
Definition: index.php:746
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:143
dol_get_last_day($year, $month=12, $gm=false)
Return GMT time for last day of a month or year.
Definition: date.lib.php:596
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
natural_search($fields, $value, $mode=0, $nofirstand=0)
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart='')
Return a path to have a the directory according to object where files are stored.
dol_getdate($timestamp, $fast=false, $forcetimezone='')
Return an array with locale date info.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
$formconfirm
if ($action == 'delbookkeepingyear') {
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.