dolibarr 21.0.0-alpha
listbyaccount.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2016 Neil Orley <neil.orley@oeris.fr>
3 * Copyright (C) 2013-2016 Olivier Geffroy <jeff@jeffinfo.com>
4 * Copyright (C) 2013-2020 Florian Henry <florian.henry@open-concept.pro>
5 * Copyright (C) 2013-2024 Alexandre Spangaro <alexandre@inovea-conseil.com>
6 * Copyright (C) 2018-2024 Frédéric France <frederic.france@free.fr>
7 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 3 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 */
22
29// Load Dolibarr environment
30require '../../main.inc.php';
31
32require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
33require_once DOL_DOCUMENT_ROOT.'/accountancy/class/lettering.class.php';
34require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php';
35require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php';
36require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
37require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
38require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
39require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
40
41// Load translation files required by the page
42$langs->loadLangs(array("accountancy", "compta"));
43
44$action = GETPOST('action', 'aZ09');
45$socid = GETPOSTINT('socid');
46$massaction = GETPOST('massaction', 'alpha');
47$confirm = GETPOST('confirm', 'alpha');
48$toselect = GETPOST('toselect', 'array');
49$type = GETPOST('type', 'alpha');
50if ($type == 'sub') {
51 $context_default = 'bookkeepingbysubaccountlist';
52} else {
53 $context_default = 'bookkeepingbyaccountlist';
54}
55$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : $context_default;
56$search_date_startyear = GETPOSTINT('search_date_startyear');
57$search_date_startmonth = GETPOSTINT('search_date_startmonth');
58$search_date_startday = GETPOSTINT('search_date_startday');
59$search_date_endyear = GETPOSTINT('search_date_endyear');
60$search_date_endmonth = GETPOSTINT('search_date_endmonth');
61$search_date_endday = GETPOSTINT('search_date_endday');
62$search_date_start = dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear);
63$search_date_end = dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear);
64$search_doc_date = dol_mktime(0, 0, 0, GETPOSTINT('doc_datemonth'), GETPOSTINT('doc_dateday'), GETPOSTINT('doc_dateyear'));
65$search_date_export_startyear = GETPOSTINT('search_date_export_startyear');
66$search_date_export_startmonth = GETPOSTINT('search_date_export_startmonth');
67$search_date_export_startday = GETPOSTINT('search_date_export_startday');
68$search_date_export_endyear = GETPOSTINT('search_date_export_endyear');
69$search_date_export_endmonth = GETPOSTINT('search_date_export_endmonth');
70$search_date_export_endday = GETPOSTINT('search_date_export_endday');
71$search_date_export_start = dol_mktime(0, 0, 0, $search_date_export_startmonth, $search_date_export_startday, $search_date_export_startyear);
72$search_date_export_end = dol_mktime(23, 59, 59, $search_date_export_endmonth, $search_date_export_endday, $search_date_export_endyear);
73$search_date_validation_startyear = GETPOSTINT('search_date_validation_startyear');
74$search_date_validation_startmonth = GETPOSTINT('search_date_validation_startmonth');
75$search_date_validation_startday = GETPOSTINT('search_date_validation_startday');
76$search_date_validation_endyear = GETPOSTINT('search_date_validation_endyear');
77$search_date_validation_endmonth = GETPOSTINT('search_date_validation_endmonth');
78$search_date_validation_endday = GETPOSTINT('search_date_validation_endday');
79$search_date_validation_start = dol_mktime(0, 0, 0, $search_date_validation_startmonth, $search_date_validation_startday, $search_date_validation_startyear);
80$search_date_validation_end = dol_mktime(23, 59, 59, $search_date_validation_endmonth, $search_date_validation_endday, $search_date_validation_endyear);
81// Due date start
82$search_date_due_start_day = GETPOSTINT('search_date_due_start_day');
83$search_date_due_start_month = GETPOSTINT('search_date_due_start_month');
84$search_date_due_start_year = GETPOSTINT('search_date_due_start_year');
85$search_date_due_start = dol_mktime(0, 0, 0, $search_date_due_start_month, $search_date_due_start_day, $search_date_due_start_year);
86// Due date end
87$search_date_due_end_day = GETPOSTINT('search_date_due_end_day');
88$search_date_due_end_month = GETPOSTINT('search_date_due_end_month');
89$search_date_due_end_year = GETPOSTINT('search_date_due_end_year');
90$search_date_due_end = dol_mktime(23, 59, 59, $search_date_due_end_month, $search_date_due_end_day, $search_date_due_end_year);
91$search_import_key = GETPOST("search_import_key", 'alpha');
92
93$search_account_category = GETPOSTINT('search_account_category');
94
95$search_accountancy_code_start = GETPOST('search_accountancy_code_start', 'alpha');
96if ($search_accountancy_code_start == - 1) {
97 $search_accountancy_code_start = '';
98}
99$search_accountancy_code_end = GETPOST('search_accountancy_code_end', 'alpha');
100if ($search_accountancy_code_end == - 1) {
101 $search_accountancy_code_end = '';
102}
103$search_doc_ref = GETPOST('search_doc_ref', 'alpha');
104$search_label_operation = GETPOST('search_label_operation', 'alpha');
105$search_mvt_num = GETPOST('search_mvt_num', 'alpha');
106$search_direction = GETPOST('search_direction', 'alpha');
107$search_ledger_code = GETPOST('search_ledger_code', 'array');
108$search_debit = GETPOST('search_debit', 'alpha');
109$search_credit = GETPOST('search_credit', 'alpha');
110$search_lettering_code = GETPOST('search_lettering_code', 'alpha');
111$search_not_reconciled = GETPOST('search_not_reconciled', 'alpha');
112
113if (GETPOST("button_delmvt_x") || GETPOST("button_delmvt.x") || GETPOST("button_delmvt")) {
114 $action = 'delbookkeepingyear';
115}
116
117// Load variable for pagination
118$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : getDolGlobalString('ACCOUNTING_LIMIT_LIST_VENTILATION', $conf->liste_limit);
119$sortfield = GETPOST('sortfield', 'aZ09comma');
120$sortorder = GETPOST('sortorder', 'aZ09comma');
121$optioncss = GETPOST('optioncss', 'alpha');
122$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
123if (empty($page) || $page < 0) {
124 $page = 0;
125}
126$offset = $limit * $page;
127$pageprev = $page - 1;
128$pagenext = $page + 1;
129if ($sortorder == "") {
130 $sortorder = "ASC";
131}
132if ($sortfield == "") {
133 $sortfield = "t.doc_date,t.rowid";
134}
135
136// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
137$object = new BookKeeping($db);
138$formfile = new FormFile($db);
139$hookmanager->initHooks(array($context_default));
140
141$formaccounting = new FormAccounting($db);
142$form = new Form($db);
143
144if (empty($search_date_start) && empty($search_date_end) && !GETPOSTISSET('search_date_startday') && !GETPOSTISSET('search_date_startmonth') && !GETPOSTISSET('search_date_starthour')) {
145 $sql = "SELECT date_start, date_end from ".MAIN_DB_PREFIX."accounting_fiscalyear ";
146 $sql .= " where date_start < '".$db->idate(dol_now())."' and date_end > '".$db->idate(dol_now())."'";
147 $sql .= $db->plimit(1);
148 $res = $db->query($sql);
149
150 if ($res->num_rows > 0) {
151 $fiscalYear = $db->fetch_object($res);
152 $search_date_start = strtotime($fiscalYear->date_start);
153 $search_date_end = strtotime($fiscalYear->date_end);
154 } else {
155 $month_start = getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1);
156 $year_start = dol_print_date(dol_now(), '%Y');
157 if (dol_print_date(dol_now(), '%m') < $month_start) {
158 $year_start--; // If current month is lower that starting fiscal month, we start last year
159 }
160 $year_end = $year_start + 1;
161 $month_end = $month_start - 1;
162 if ($month_end < 1) {
163 $month_end = 12;
164 $year_end--;
165 }
166 $search_date_start = dol_mktime(0, 0, 0, $month_start, 1, $year_start);
167 $search_date_end = dol_get_last_day($year_end, $month_end);
168 }
169}
170
171$arrayfields = array(
172 // 't.subledger_account'=>array('label'=>$langs->trans("SubledgerAccount"), 'checked'=>1),
173 't.piece_num' => array('label' => $langs->trans("TransactionNumShort"), 'checked' => 1),
174 't.code_journal' => array('label' => $langs->trans("Codejournal"), 'checked' => 1),
175 't.doc_date' => array('label' => $langs->trans("Docdate"), 'checked' => 1),
176 't.doc_ref' => array('label' => $langs->trans("Piece"), 'checked' => 1),
177 't.label_operation' => array('label' => $langs->trans("Label"), 'checked' => 1),
178 't.lettering_code' => array('label' => $langs->trans("Lettering"), 'checked' => 1),
179 't.debit' => array('label' => $langs->trans("AccountingDebit"), 'checked' => 1),
180 't.credit' => array('label' => $langs->trans("AccountingCredit"), 'checked' => 1),
181 't.balance' => array('label' => $langs->trans("Balance"), 'checked' => 1),
182 't.date_export' => array('label' => $langs->trans("DateExport"), 'checked' => -1),
183 't.date_validated' => array('label' => $langs->trans("DateValidation"), 'checked' => -1, 'enabled' => !getDolGlobalString("ACCOUNTANCY_DISABLE_CLOSURE_LINE_BY_LINE")),
184 't.date_lim_reglement' => array('label' => $langs->trans("DateDue"), 'checked' => 0),
185 't.import_key' => array('label' => $langs->trans("ImportId"), 'checked' => -1, 'position' => 1100),
186);
187
188if (!getDolGlobalString('ACCOUNTING_ENABLE_LETTERING')) {
189 unset($arrayfields['t.lettering_code']);
190}
191
192if ($search_date_start && empty($search_date_startyear)) {
193 $tmparray = dol_getdate($search_date_start);
194 $search_date_startyear = $tmparray['year'];
195 $search_date_startmonth = $tmparray['mon'];
196 $search_date_startday = $tmparray['mday'];
197}
198if ($search_date_end && empty($search_date_endyear)) {
199 $tmparray = dol_getdate($search_date_end);
200 $search_date_endyear = $tmparray['year'];
201 $search_date_endmonth = $tmparray['mon'];
202 $search_date_endday = $tmparray['mday'];
203}
204
205if (!isModEnabled('accounting')) {
207}
208if ($user->socid > 0) {
210}
211if (!$user->hasRight('accounting', 'mouvements', 'lire')) {
213}
214
215$error = 0;
216
217
218/*
219 * Action
220 */
221
222$filter = array();
223$param = '';
224$url_param = '';
225
226if (GETPOST('cancel', 'alpha')) {
227 $action = 'list';
228 $massaction = '';
229}
230if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'preunletteringauto' && $massaction != 'preunletteringmanual' && $massaction != 'predeletebookkeepingwriting') {
231 $massaction = '';
232}
233
234$parameters = array('socid' => $socid);
235$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
236if ($reshook < 0) {
237 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
238}
239
240if (empty($reshook)) {
241 include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
242
243 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
244 $search_doc_date = '';
245 $search_account_category = '';
246 $search_accountancy_code_start = '';
247 $search_accountancy_code_end = '';
248 $search_label_account = '';
249 $search_doc_ref = '';
250 $search_label_operation = '';
251 $search_mvt_num = '';
252 $search_direction = '';
253 $search_ledger_code = array();
254 $search_date_start = '';
255 $search_date_end = '';
256 $search_date_startyear = '';
257 $search_date_startmonth = '';
258 $search_date_startday = '';
259 $search_date_endyear = '';
260 $search_date_endmonth = '';
261 $search_date_endday = '';
262 $search_date_export_start = '';
263 $search_date_export_end = '';
264 $search_date_export_startyear = '';
265 $search_date_export_startmonth = '';
266 $search_date_export_startday = '';
267 $search_date_export_endyear = '';
268 $search_date_export_endmonth = '';
269 $search_date_export_endday = '';
270 $search_date_validation_start = '';
271 $search_date_validation_end = '';
272 $search_date_validation_startyear = '';
273 $search_date_validation_startmonth = '';
274 $search_date_validation_startday = '';
275 $search_date_validation_endyear = '';
276 $search_date_validation_endmonth = '';
277 $search_date_validation_endday = '';
278 // Due date start
279 $search_date_due_start_day = '';
280 $search_date_due_start_month = '';
281 $search_date_due_start_year = '';
282 $search_date_due_start = '';
283 // Due date end
284 $search_date_due_end_day = '';
285 $search_date_due_end_month = '';
286 $search_date_due_end_year = '';
287 $search_date_due_end = '';
288 $search_lettering_code = '';
289 $search_debit = '';
290 $search_credit = '';
291 $search_not_reconciled = '';
292 $search_import_key = '';
293 $toselect = array();
294 }
295
296 if (!empty($search_date_start)) {
297 $filter['t.doc_date>='] = $search_date_start;
298 $param .= '&search_date_startmonth='.$search_date_startmonth.'&search_date_startday='.$search_date_startday.'&search_date_startyear='.$search_date_startyear;
299 }
300 if (!empty($search_date_end)) {
301 $filter['t.doc_date<='] = $search_date_end;
302 $param .= '&search_date_endmonth='.$search_date_endmonth.'&search_date_endday='.$search_date_endday.'&search_date_endyear='.$search_date_endyear;
303 }
304 if (!empty($search_doc_date)) {
305 $filter['t.doc_date'] = $search_doc_date;
306 $param .= '&doc_datemonth='.GETPOSTINT('doc_datemonth').'&doc_dateday='.GETPOSTINT('doc_dateday').'&doc_dateyear='.GETPOSTINT('doc_dateyear');
307 }
308 if ($search_account_category != '-1' && !empty($search_account_category)) {
309 require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountancycategory.class.php';
310 $accountingcategory = new AccountancyCategory($db);
311
312 $listofaccountsforgroup = $accountingcategory->getCptsCat(0, 'fk_accounting_category = '.((int) $search_account_category));
313 $listofaccountsforgroup2 = array();
314 if (is_array($listofaccountsforgroup)) {
315 foreach ($listofaccountsforgroup as $tmpval) {
316 $listofaccountsforgroup2[] = "'".$db->escape($tmpval['id'])."'";
317 }
318 }
319 $filter['t.search_accounting_code_in'] = implode(',', $listofaccountsforgroup2);
320 $param .= '&search_account_category='.urlencode((string) ($search_account_category));
321 }
322 if (!empty($search_accountancy_code_start)) {
323 if ($type == 'sub') {
324 $filter['t.subledger_account>='] = $search_accountancy_code_start;
325 } else {
326 $filter['t.numero_compte>='] = $search_accountancy_code_start;
327 }
328 $param .= '&search_accountancy_code_start=' . urlencode($search_accountancy_code_start);
329 }
330 if (!empty($search_accountancy_code_end)) {
331 if ($type == 'sub') {
332 $filter['t.subledger_account<='] = $search_accountancy_code_end;
333 } else {
334 $filter['t.numero_compte<='] = $search_accountancy_code_end;
335 }
336 $param .= '&search_accountancy_code_end=' . urlencode($search_accountancy_code_end);
337 }
338 if (!empty($search_label_account)) {
339 $filter['t.label_compte'] = $search_label_account;
340 $param .= '&search_label_compte='.urlencode($search_label_account);
341 }
342 if (!empty($search_mvt_num)) {
343 $filter['t.piece_num'] = $search_mvt_num;
344 $param .= '&search_mvt_num='.urlencode((string) ($search_mvt_num));
345 }
346 if (!empty($search_doc_ref)) {
347 $filter['t.doc_ref'] = $search_doc_ref;
348 $param .= '&search_doc_ref='.urlencode($search_doc_ref);
349 }
350 if (!empty($search_label_operation)) {
351 $filter['t.label_operation'] = $search_label_operation;
352 $param .= '&search_label_operation='.urlencode($search_label_operation);
353 }
354 if (!empty($search_direction)) {
355 $filter['t.sens'] = $search_direction;
356 $param .= '&search_direction='.urlencode($search_direction);
357 }
358 if (!empty($search_ledger_code)) {
359 $filter['t.code_journal'] = $search_ledger_code;
360 foreach ($search_ledger_code as $code) {
361 $param .= '&search_ledger_code[]='.urlencode($code);
362 }
363 }
364 if (!empty($search_lettering_code)) {
365 $filter['t.lettering_code'] = $search_lettering_code;
366 $param .= '&search_lettering_code='.urlencode($search_lettering_code);
367 }
368 if (!empty($search_debit)) {
369 $filter['t.debit'] = $search_debit;
370 $param .= '&search_debit='.urlencode($search_debit);
371 }
372 if (!empty($search_credit)) {
373 $filter['t.credit'] = $search_credit;
374 $param .= '&search_credit='.urlencode($search_credit);
375 }
376 if (!empty($search_not_reconciled)) {
377 $filter['t.reconciled_option'] = $search_not_reconciled;
378 $param .= '&search_not_reconciled='.urlencode($search_not_reconciled);
379 }
380 if (!empty($search_date_export_start)) {
381 $filter['t.date_export>='] = $search_date_export_start;
382 $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;
383 }
384 if (!empty($search_date_export_end)) {
385 $filter['t.date_export<='] = $search_date_export_end;
386 $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;
387 }
388 if (!empty($search_date_validation_start)) {
389 $filter['t.date_validated>='] = $search_date_validation_start;
390 $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;
391 }
392 if (!empty($search_date_validation_end)) {
393 $filter['t.date_validated<='] = $search_date_validation_end;
394 $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;
395 }
396 // Due date start
397 if (!empty($search_date_due_start)) {
398 $filter['t.date_lim_reglement>='] = $search_date_due_start;
399 $param .= '&search_date_due_start_day='.$search_date_due_start_day.'&search_date_due_start_month='.$search_date_due_start_month.'&search_date_due_start_year='.$search_date_due_start_year;
400 }
401 // Due date end
402 if (!empty($search_date_due_end)) {
403 $filter['t.date_lim_reglement<='] = $search_date_due_end;
404 $param .= '&search_date_due_end_day='.$search_date_due_end_day.'&search_date_due_end_month='.$search_date_due_end_month.'&search_date_due_end_year='.$search_date_due_end_year;
405 }
406 if (!empty($search_import_key)) {
407 $filter['t.import_key'] = $search_import_key;
408 $param .= '&search_import_key='.urlencode($search_import_key);
409 }
410 // param with type of list
411 $url_param = substr($param, 1); // remove first "&"
412 if (!empty($type)) {
413 $param = '&type='.$type.$param;
414 }
415
416 //if ($action == 'delbookkeepingyearconfirm' && $user->hasRight('accounting', 'mouvements', 'supprimer')_tous) {
417 // $delmonth = GETPOST('delmonth', 'int');
418 // $delyear = GETPOST('delyear', 'int');
419 // if ($delyear == -1) {
420 // $delyear = 0;
421 // }
422 // $deljournal = GETPOST('deljournal', 'alpha');
423 // if ($deljournal == -1) {
424 // $deljournal = 0;
425 // }
426 //
427 // if (!empty($delmonth) || !empty($delyear) || !empty($deljournal)) {
428 // $result = $object->deleteByYearAndJournal($delyear, $deljournal, '', ($delmonth > 0 ? $delmonth : 0));
429 // if ($result < 0) {
430 // setEventMessages($object->error, $object->errors, 'errors');
431 // } else {
432 // setEventMessages("RecordDeleted", null, 'mesgs');
433 // }
434 //
435 // // Make a redirect to avoid to launch the delete later after a back button
436 // header("Location: ".$_SERVER["PHP_SELF"].($param ? '?'.$param : ''));
437 // exit;
438 // } else {
439 // setEventMessages("NoRecordDeleted", null, 'warnings');
440 // }
441 //}
442
443 // Mass actions
444 $objectclass = 'Bookkeeping';
445 $objectlabel = 'Bookkeeping';
446 $permissiontoread = $user->hasRight('societe', 'lire');
447 $permissiontodelete = $user->hasRight('societe', 'supprimer');
448 $permissiontoadd = $user->hasRight('societe', 'creer');
449 $uploaddir = $conf->societe->dir_output;
450 include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
451
452 if (!$error && $action == 'deletebookkeepingwriting' && $confirm == "yes" && $user->hasRight('accounting', 'mouvements', 'supprimer')) {
453 $db->begin();
454
455 if (getDolGlobalInt('ACCOUNTING_ENABLE_LETTERING')) {
456 $lettering = new Lettering($db);
457 $nb_lettering = $lettering->bookkeepingLetteringAll($toselect, true);
458 if ($nb_lettering < 0) {
459 setEventMessages('', $lettering->errors, 'errors');
460 $error++;
461 }
462 }
463
464 $nbok = 0;
465 if (!$error) {
466 foreach ($toselect as $toselectid) {
467 $result = $object->fetch($toselectid);
468 if ($result > 0 && (!isset($object->date_validation) || $object->date_validation === '')) {
469 $result = $object->deleteMvtNum($object->piece_num);
470 if ($result > 0) {
471 $nbok++;
472 } else {
473 setEventMessages($object->error, $object->errors, 'errors');
474 $error++;
475 break;
476 }
477 } elseif ($result < 0) {
478 setEventMessages($object->error, $object->errors, 'errors');
479 $error++;
480 break;
481 } elseif (isset($object->date_validation) && $object->date_validation != '') {
482 setEventMessages($langs->trans("ValidatedRecordWhereFound"), null, 'errors');
483 $error++;
484 break;
485 }
486 }
487 }
488
489 if (!$error) {
490 $db->commit();
491
492 // Message for elements well deleted
493 if ($nbok > 1) {
494 setEventMessages($langs->trans("RecordsDeleted", $nbok), null, 'mesgs');
495 } elseif ($nbok > 0) {
496 setEventMessages($langs->trans("RecordDeleted", $nbok), null, 'mesgs');
497 } elseif (!$error) {
498 setEventMessages($langs->trans("NoRecordDeleted"), null, 'mesgs');
499 }
500
501 header("Location: ".$_SERVER["PHP_SELF"]."?noreset=1".($param ? '&'.$param : ''));
502 exit;
503 } else {
504 $db->rollback();
505 }
506 }
507
508 // others mass actions
509 if (!$error && getDolGlobalInt('ACCOUNTING_ENABLE_LETTERING') && $user->hasRight('accounting', 'mouvements', 'creer')) {
510 if ($massaction == 'letteringauto') {
511 $lettering = new Lettering($db);
512 $nb_lettering = $lettering->bookkeepingLetteringAll($toselect);
513 if ($nb_lettering < 0) {
514 setEventMessages('', $lettering->errors, 'errors');
515 $error++;
516 $nb_lettering = max(0, abs($nb_lettering) - 2);
517 } elseif ($nb_lettering == 0) {
518 $nb_lettering = 0;
519 setEventMessages($langs->trans('AccountancyNoLetteringModified'), array(), 'mesgs');
520 }
521 if ($nb_lettering == 1) {
522 setEventMessages($langs->trans('AccountancyOneLetteringModifiedSuccessfully'), array(), 'mesgs');
523 } elseif ($nb_lettering > 1) {
524 setEventMessages($langs->trans('AccountancyLetteringModifiedSuccessfully', $nb_lettering), array(), 'mesgs');
525 }
526
527 if (!$error) {
528 header('Location: ' . $_SERVER['PHP_SELF'] . '?noreset=1' . $param);
529 exit();
530 }
531 } elseif ($massaction == 'letteringmanual') {
532 $lettering = new Lettering($db);
533 $result = $lettering->updateLettering($toselect);
534 if ($result < 0) {
535 setEventMessages('', $lettering->errors, 'errors');
536 } else {
537 setEventMessages($langs->trans($result == 0 ? 'AccountancyNoLetteringModified' : 'AccountancyOneLetteringModifiedSuccessfully'), array(), 'mesgs');
538 header('Location: ' . $_SERVER['PHP_SELF'] . '?noreset=1' . $param);
539 exit();
540 }
541 } elseif ($type == 'sub' && $massaction == 'letteringpartial') {
542 $lettering = new Lettering($db);
543 $result = $lettering->updateLettering($toselect, false, true);
544 if ($result < 0) {
545 setEventMessages('', $lettering->errors, 'errors');
546 } else {
547 setEventMessages($langs->trans($result == 0 ? 'AccountancyNoLetteringModified' : 'AccountancyOneLetteringModifiedSuccessfully'), array(), 'mesgs');
548 header('Location: ' . $_SERVER['PHP_SELF'] . '?noreset=1' . $param);
549 exit();
550 }
551 } elseif ($action == 'unletteringauto' && $confirm == "yes") {
552 $lettering = new Lettering($db);
553 $nb_lettering = $lettering->bookkeepingLetteringAll($toselect, true);
554 if ($nb_lettering < 0) {
555 setEventMessages('', $lettering->errors, 'errors');
556 $error++;
557 $nb_lettering = max(0, abs($nb_lettering) - 2);
558 } elseif ($nb_lettering == 0) {
559 $nb_lettering = 0;
560 setEventMessages($langs->trans('AccountancyNoUnletteringModified'), array(), 'mesgs');
561 }
562 if ($nb_lettering == 1) {
563 setEventMessages($langs->trans('AccountancyOneUnletteringModifiedSuccessfully'), array(), 'mesgs');
564 } elseif ($nb_lettering > 1) {
565 setEventMessages($langs->trans('AccountancyUnletteringModifiedSuccessfully', $nb_lettering), array(), 'mesgs');
566 }
567
568 if (!$error) {
569 header('Location: ' . $_SERVER['PHP_SELF'] . '?noreset=1' . $param);
570 exit();
571 }
572 } elseif ($action == 'unletteringmanual' && $confirm == "yes") {
573 $lettering = new Lettering($db);
574 $nb_lettering = $lettering->deleteLettering($toselect);
575 if ($result < 0) {
576 setEventMessages('', $lettering->errors, 'errors');
577 } else {
578 setEventMessages($langs->trans($result == 0 ? 'AccountancyNoUnletteringModified' : 'AccountancyOneUnletteringModifiedSuccessfully'), array(), 'mesgs');
579 header('Location: ' . $_SERVER['PHP_SELF'] . '?noreset=1' . $param);
580 exit();
581 }
582 }
583 }
584}
585
586
587/*
588 * View
589 */
590
591$formaccounting = new FormAccounting($db);
592$formfile = new FormFile($db);
593$formother = new FormOther($db);
594$form = new Form($db);
595
596$title_page = $langs->trans("Operations").' - '.$langs->trans("VueByAccountAccounting").' (';
597if ($type == 'sub') {
598 $title_page .= $langs->trans("BookkeepingSubAccount");
599} else {
600 $title_page .= $langs->trans("Bookkeeping");
601}
602$title_page .= ')';
603$help_url = 'EN:Module_Double_Entry_Accounting|FR:Module_Comptabilit&eacute;_en_Partie_Double';
604llxHeader('', $title_page, $help_url, '', 0, 0, '', '', '', 'mod-accountancy accountancy-consultation page-'.(($type == 'sub') ? 'sub' : '').'ledger');
605
606// List
607$nbtotalofrecords = '';
608if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
609 // TODO Perf Replace this by a count
610 if ($type == 'sub') {
611 $nbtotalofrecords = $object->fetchAllByAccount($sortorder, $sortfield, 0, 0, $filter, 'AND', 1, 1);
612 } else {
613 $nbtotalofrecords = $object->fetchAllByAccount($sortorder, $sortfield, 0, 0, $filter, 'AND', 0, 1);
614 }
615
616 if ($nbtotalofrecords < 0) {
617 setEventMessages($object->error, $object->errors, 'errors');
618 $error++;
619 }
620}
621
622$num = 0;
623if (!$error) {
624 if ($type == 'sub') {
625 $result = $object->fetchAllByAccount($sortorder, $sortfield, $limit, $offset, $filter, 'AND', 1);
626 } else {
627 $result = $object->fetchAllByAccount($sortorder, $sortfield, $limit, $offset, $filter, 'AND', 0);
628 }
629 //$num = count($object->lines);
630 $num = $result; // $result is total nb of lines, or limit + 1, but $object->lines is always limited to $limit
631
632 if ($result < 0) {
633 setEventMessages($object->error, $object->errors, 'errors');
634 }
635}
636
637$arrayofselected = is_array($toselect) ? $toselect : array();
638
639
641// $form_question = array();
642// $delyear = GETPOST('delyear', 'int');
643// $deljournal = GETPOST('deljournal', 'alpha');
644//
645// if (empty($delyear)) {
646// $delyear = dol_print_date(dol_now(), '%Y');
647// }
648// $month_array = array();
649// for ($i = 1; $i <= 12; $i++) {
650// $month_array[$i] = $langs->trans("Month".sprintf("%02d", $i));
651// }
652// $year_array = $formaccounting->selectyear_accountancy_bookkepping($delyear, 'delyear', 0, 'array');
653// $journal_array = $formaccounting->select_journal($deljournal, 'deljournal', '', 1, 1, 1, '', 0, 1);
654//
655// $form_question['delmonth'] = array(
656// 'name' => 'delmonth',
657// 'type' => 'select',
658// 'label' => $langs->trans('DelMonth'),
659// 'values' => $month_array,
660// 'default' => ''
661// );
662// $form_question['delyear'] = array(
663// 'name' => 'delyear',
664// 'type' => 'select',
665// 'label' => $langs->trans('DelYear'),
666// 'values' => $year_array,
667// 'default' => $delyear
668// );
669// $form_question['deljournal'] = array(
670// 'name' => 'deljournal',
671// 'type' => 'other', // We don't use select here, the journal_array is already a select html component
672// 'label' => $langs->trans('DelJournal'),
673// 'value' => $journal_array,
674// 'default' => $deljournal
675// );
676//
677// $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?'.$param, $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvt', $langs->transnoentitiesnoconv("RegistrationInAccounting")), 'delbookkeepingyearconfirm', $form_question, '', 1, 300);
678//}
679
680// Print form confirm
682print $formconfirm;
683
684// List of mass actions available
685$arrayofmassactions = array();
686if (getDolGlobalInt('ACCOUNTING_ENABLE_LETTERING') && $user->hasRight('accounting', 'mouvements', 'creer')) {
687 $arrayofmassactions['letteringauto'] = img_picto('', 'check', 'class="pictofixedwidth"') . $langs->trans('LetteringAuto');
688 $arrayofmassactions['preunletteringauto'] = img_picto('', 'uncheck', 'class="pictofixedwidth"') . $langs->trans('UnletteringAuto');
689 $arrayofmassactions['letteringmanual'] = img_picto('', 'check', 'class="pictofixedwidth"') . $langs->trans('LetteringManual');
690 if ($type == 'sub') {
691 $arrayofmassactions['letteringpartial'] = img_picto('', 'check', 'class="pictofixedwidth"') . $langs->trans('LetteringPartial');
692 }
693 $arrayofmassactions['preunletteringmanual'] = img_picto('', 'uncheck', 'class="pictofixedwidth"') . $langs->trans('UnletteringManual');
694}
695if ($user->hasRight('accounting', 'mouvements', 'supprimer')) {
696 $arrayofmassactions['predeletebookkeepingwriting'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
697}
698if (GETPOSTINT('nomassaction') || in_array($massaction, array('preunletteringauto', 'preunletteringmanual', 'predeletebookkeepingwriting'))) {
699 $arrayofmassactions = array();
700}
701$massactionbutton = $form->selectMassAction($massaction, $arrayofmassactions);
702
703print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
704print '<input type="hidden" name="token" value="'.newToken().'">';
705print '<input type="hidden" name="action" value="list">';
706if ($optioncss != '') {
707 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
708}
709print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
710print '<input type="hidden" name="type" value="'.$type.'">';
711print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
712print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
713print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
714
715$parameters = array('param' => $param);
716$reshook = $hookmanager->executeHooks('addMoreActionsButtonsList', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
717if ($reshook < 0) {
718 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
719}
720
721$newcardbutton = empty($hookmanager->resPrint) ? '' : $hookmanager->resPrint;
722
723if (empty($reshook)) {
724 $newcardbutton = dolGetButtonTitle($langs->trans('ViewFlatList'), '', 'fa fa-list paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/list.php?'.$param);
725 if ($type == 'sub') {
726 $newcardbutton .= dolGetButtonTitle($langs->trans('GroupByAccountAccounting'), '', 'fa fa-stream paddingleft imgforviewmode', DOL_URL_ROOT . '/accountancy/bookkeeping/listbyaccount.php?' . $url_param, '', 1, array('morecss' => 'marginleftonly'));
727 $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'));
728 } else {
729 $newcardbutton .= dolGetButtonTitle($langs->trans('GroupByAccountAccounting'), '', 'fa fa-stream paddingleft imgforviewmode', DOL_URL_ROOT . '/accountancy/bookkeeping/listbyaccount.php?' . $url_param, '', 1, array('morecss' => 'marginleftonly btnTitleSelected'));
730 $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'));
731 }
732 $newcardbutton .= dolGetButtonTitleSeparator();
733 $newcardbutton .= dolGetButtonTitle($langs->trans('NewAccountingMvt'), '', 'fa fa-plus-circle paddingleft', DOL_URL_ROOT.'/accountancy/bookkeeping/card.php?action=create');
734}
735
736if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
737 $param .= '&contextpage='.urlencode($contextpage);
738}
739if ($limit > 0 && $limit != $conf->liste_limit) {
740 $param .= '&limit='.((int) $limit);
741}
742
743print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_accountancy', 0, $newcardbutton, '', $limit, 0, 0, 1);
744
745if ($massaction == 'preunletteringauto') {
746 print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmMassUnletteringAuto"), $langs->trans("ConfirmMassUnletteringQuestion", count($toselect)), "unletteringauto", null, '', 0, 200, 500, 1);
747} elseif ($massaction == 'preunletteringmanual') {
748 print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmMassUnletteringManual"), $langs->trans("ConfirmMassUnletteringQuestion", count($toselect)), "unletteringmanual", null, '', 0, 200, 500, 1);
749} elseif ($massaction == 'predeletebookkeepingwriting') {
750 print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmMassDeleteBookkeepingWriting"), $langs->trans("ConfirmMassDeleteBookkeepingWritingQuestion", count($toselect)), "deletebookkeepingwriting", null, '', 0, 200, 500, 1);
751}
752//DeleteMvt=Supprimer des lignes d'opérations de la comptabilité
753//DelMonth=Mois à effacer
754//DelYear=Année à supprimer
755//DelJournal=Journal à supprimer
756//ConfirmDeleteMvt=Cette action supprime les lignes des opérations pour l'année/mois et/ou pour le journal sélectionné (au moins un critère est requis). Vous devrez utiliser de nouveau la fonctionnalité '%s' pour retrouver vos écritures dans la comptabilité.
757//ConfirmDeleteMvtPartial=Cette action supprime l'écriture de la comptabilité (toutes les lignes opérations liées à une même écriture seront effacées).
758
759//$topicmail = "Information";
760//$modelmail = "accountingbookkeeping";
761//$objecttmp = new BookKeeping($db);
762//$trackid = 'bk'.$object->id;
763include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
764
765$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
766$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')); // This also change content of $arrayfields
767if ($massactionbutton && $contextpage != 'poslist') {
768 $selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
769}
770
771// Reverse sort order
772if (preg_match('/^asc/i', $sortorder)) {
773 $sortorder = "asc";
774} else {
775 $sortorder = "desc";
776}
777
778// Warning to explain why list of record is not consistent with the other list view (missing a lot of lines)
779if ($type == 'sub') {
780 print info_admin($langs->trans("WarningRecordWithoutSubledgerAreExcluded"));
781}
782
783$moreforfilter = '';
784
785// Search on accountancy custom groups or account
786$moreforfilter .= '<div class="divsearchfield">';
787$moreforfilter .= $langs->trans('AccountAccounting').': ';
788$moreforfilter .= '<div class="nowrap inline-block">';
789if ($type == 'sub') {
790 $moreforfilter .= $formaccounting->select_auxaccount($search_accountancy_code_start, 'search_accountancy_code_start', $langs->trans('From'), 'maxwidth200');
791} else {
792 $moreforfilter .= $formaccounting->select_account($search_accountancy_code_start, 'search_accountancy_code_start', $langs->trans('From'), array(), 1, 1, 'maxwidth200');
793}
794$moreforfilter .= ' ';
795if ($type == 'sub') {
796 $moreforfilter .= $formaccounting->select_auxaccount($search_accountancy_code_end, 'search_accountancy_code_end', $langs->trans('to'), 'maxwidth200');
797} else {
798 $moreforfilter .= $formaccounting->select_account($search_accountancy_code_end, 'search_accountancy_code_end', $langs->trans('to'), array(), 1, 1, 'maxwidth200');
799}
800$stringforfirstkey = $langs->trans("KeyboardShortcut");
801if ($conf->browser->name == 'chrome') {
802 $stringforfirstkey .= ' ALT +';
803} elseif ($conf->browser->name == 'firefox') {
804 $stringforfirstkey .= ' ALT + SHIFT +';
805} else {
806 $stringforfirstkey .= ' CTL +';
807}
808$moreforfilter .= '&nbsp;&nbsp;&nbsp;<a id="previous_account" accesskey="p" title="' . $stringforfirstkey . ' p" class="classfortooltip" href="#"><i class="fa fa-chevron-left"></i></a>';
809$moreforfilter .= '&nbsp;&nbsp;&nbsp;<a id="next_account" accesskey="n" title="' . $stringforfirstkey . ' n" class="classfortooltip" href="#"><i class="fa fa-chevron-right"></i></a>';
810$moreforfilter .= <<<SCRIPT
811<script type="text/javascript">
812 jQuery(document).ready(function() {
813 var searchFormList = $('#searchFormList');
814 var searchAccountancyCodeStart = $('#search_accountancy_code_start');
815 var searchAccountancyCodeEnd = $('#search_accountancy_code_end');
816 jQuery('#previous_account').on('click', function() {
817 var previousOption = searchAccountancyCodeStart.find('option:selected').prev('option');
818 if (previousOption.length == 1) searchAccountancyCodeStart.val(previousOption.attr('value'));
819 searchAccountancyCodeEnd.val(searchAccountancyCodeStart.val());
820 searchFormList.submit();
821 });
822 jQuery('#next_account').on('click', function() {
823 var nextOption = searchAccountancyCodeStart.find('option:selected').next('option');
824 if (nextOption.length == 1) searchAccountancyCodeStart.val(nextOption.attr('value'));
825 searchAccountancyCodeEnd.val(searchAccountancyCodeStart.val());
826 searchFormList.submit();
827 });
828 jQuery('input[name="search_mvt_num"]').on("keypress", function(event) {
829 console.log(event);
830 });
831 });
832</script>
833SCRIPT;
834$moreforfilter .= '</div>';
835$moreforfilter .= '</div>';
836
837$moreforfilter .= '<div class="divsearchfield">';
838$moreforfilter .= $langs->trans('AccountingCategory').': ';
839$moreforfilter .= '<div class="nowrap inline-block">';
840$moreforfilter .= $formaccounting->select_accounting_category($search_account_category, 'search_account_category', 1, 0, 0, 0);
841$moreforfilter .= '</div>';
842$moreforfilter .= '</div>';
843
844$parameters = array();
845$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook
846if (empty($reshook)) {
847 $moreforfilter .= $hookmanager->resPrint;
848} else {
849 $moreforfilter = $hookmanager->resPrint;
850}
851
852print '<div class="liste_titre liste_titre_bydiv centpercent">';
853print $moreforfilter;
854print '</div>';
855
856print '<div class="div-table-responsive">';
857print '<table class="tagtable liste centpercent">';
858
859// Filters lines
860print '<tr class="liste_titre_filter">';
861// Action column
862if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
863 print '<td class="liste_titre center">';
864 $searchpicto = $form->showFilterButtons('left');
865 print $searchpicto;
866 print '</td>';
867}
868// Movement number
869if (!empty($arrayfields['t.piece_num']['checked'])) {
870 print '<td class="liste_titre"><input type="text" name="search_mvt_num" class="width50" value="'.dol_escape_htmltag($search_mvt_num).'"></td>';
871}
872// Code journal
873if (!empty($arrayfields['t.code_journal']['checked'])) {
874 print '<td class="liste_titre center">';
875 print $formaccounting->multi_select_journal($search_ledger_code, 'search_ledger_code', 0, 1, 1, 1, 'maxwidth75');
876 print '</td>';
877}
878// Date document
879if (!empty($arrayfields['t.doc_date']['checked'])) {
880 print '<td class="liste_titre center">';
881 print '<div class="nowrapfordate">';
882 print $form->selectDate($search_date_start, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"));
883 print '</div>';
884 print '<div class="nowrapfordate">';
885 print $form->selectDate($search_date_end, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to"));
886 print '</div>';
887 print '</td>';
888}
889// Ref document
890if (!empty($arrayfields['t.doc_ref']['checked'])) {
891 print '<td class="liste_titre"><input type="text" size="7" class="flat" name="search_doc_ref" value="'.dol_escape_htmltag($search_doc_ref).'"/></td>';
892}
893// Label operation
894if (!empty($arrayfields['t.label_operation']['checked'])) {
895 print '<td class="liste_titre"><input type="text" size="7" class="flat" name="search_label_operation" value="'.dol_escape_htmltag($search_label_operation).'"/></td>';
896}
897// Lettering code
898if (!empty($arrayfields['t.lettering_code']['checked'])) {
899 print '<td class="liste_titre center">';
900 print '<input type="text" size="3" class="flat" name="search_lettering_code" value="'.$search_lettering_code.'"/>';
901 print '<br><span class="nowrap"><input type="checkbox" name="search_not_reconciled" value="notreconciled"'.($search_not_reconciled == 'notreconciled' ? ' checked' : '').'>'.$langs->trans("NotReconciled").'</span>';
902 print '</td>';
903}
904// Debit
905if (!empty($arrayfields['t.debit']['checked'])) {
906 print '<td class="liste_titre right"><input type="text" class="flat" name="search_debit" size="4" value="'.dol_escape_htmltag($search_debit).'"></td>';
907}
908// Credit
909if (!empty($arrayfields['t.credit']['checked'])) {
910 print '<td class="liste_titre right"><input type="text" class="flat" name="search_credit" size="4" value="'.dol_escape_htmltag($search_credit).'"></td>';
911}
912// Balance
913if (!empty($arrayfields['t.balance']['checked'])) {
914 print '<td></td>';
915}
916// Date export
917if (!empty($arrayfields['t.date_export']['checked'])) {
918 print '<td class="liste_titre center">';
919 print '<div class="nowrapfordate">';
920 print $form->selectDate($search_date_export_start, 'search_date_export_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"));
921 print '</div>';
922 print '<div class="nowrapfordate">';
923 print $form->selectDate($search_date_export_end, 'search_date_export_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to"));
924 print '</div>';
925 print '</td>';
926}
927// Date validation
928if (!empty($arrayfields['t.date_validated']['checked'])) {
929 print '<td class="liste_titre center">';
930 print '<div class="nowrapfordate">';
931 print $form->selectDate($search_date_validation_start, 'search_date_validation_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"));
932 print '</div>';
933 print '<div class="nowrapfordate">';
934 print $form->selectDate($search_date_validation_end, 'search_date_validation_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to"));
935 print '</div>';
936 print '</td>';
937}
938// Due date start and end
939if (!empty($arrayfields['t.date_lim_reglement']['checked'])) {
940 print '<td class="liste_titre center">';
941 print '<div class="nowrapfordate">';
942 print $form->selectDate($search_date_due_start, 'search_date_due_start_', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"));
943 print '</div>';
944 print '<div class="nowrapfordate">';
945 print $form->selectDate($search_date_due_end, 'search_date_due_end_', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to"));
946 print '</div>';
947 print '</td>';
948}
949if (!empty($arrayfields['t.import_key']['checked'])) {
950 print '<td class="liste_titre center">';
951 print '<input class="flat searchstring maxwidth50" type="text" name="search_import_key" value="'.dol_escape_htmltag($search_import_key).'">';
952 print '</td>';
953}
954
955// Fields from hook
956$parameters = array('arrayfields' => $arrayfields);
957$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
958print $hookmanager->resPrint;
959
960// Action column
961if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
962 print '<td class="liste_titre center">';
963 $searchpicto = $form->showFilterButtons();
964 print $searchpicto;
965 print '</td>';
966}
967print "</tr>\n";
968
969print '<tr class="liste_titre">';
970if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
971 print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
972}
973if (!empty($arrayfields['t.piece_num']['checked'])) {
974 print_liste_field_titre($arrayfields['t.piece_num']['label'], $_SERVER['PHP_SELF'], "t.piece_num", "", $param, '', $sortfield, $sortorder, 'tdoverflowmax80imp ');
975}
976if (!empty($arrayfields['t.code_journal']['checked'])) {
977 print_liste_field_titre($arrayfields['t.code_journal']['label'], $_SERVER['PHP_SELF'], "t.code_journal", "", $param, '', $sortfield, $sortorder, 'center ');
978}
979if (!empty($arrayfields['t.doc_date']['checked'])) {
980 print_liste_field_titre($arrayfields['t.doc_date']['label'], $_SERVER['PHP_SELF'], "t.doc_date", "", $param, '', $sortfield, $sortorder, 'center ');
981}
982if (!empty($arrayfields['t.doc_ref']['checked'])) {
983 print_liste_field_titre($arrayfields['t.doc_ref']['label'], $_SERVER['PHP_SELF'], "t.doc_ref", "", $param, "", $sortfield, $sortorder);
984}
985if (!empty($arrayfields['t.label_operation']['checked'])) {
986 print_liste_field_titre($arrayfields['t.label_operation']['label'], $_SERVER['PHP_SELF'], "t.label_operation", "", $param, "", $sortfield, $sortorder);
987}
988if (!empty($arrayfields['t.lettering_code']['checked'])) {
989 print_liste_field_titre($arrayfields['t.lettering_code']['label'], $_SERVER['PHP_SELF'], "t.lettering_code", "", $param, '', $sortfield, $sortorder, 'center ');
990}
991if (!empty($arrayfields['t.debit']['checked'])) {
992 print_liste_field_titre($arrayfields['t.debit']['label'], $_SERVER['PHP_SELF'], "t.debit", "", $param, '', $sortfield, $sortorder, 'right ');
993}
994if (!empty($arrayfields['t.credit']['checked'])) {
995 print_liste_field_titre($arrayfields['t.credit']['label'], $_SERVER['PHP_SELF'], "t.credit", "", $param, '', $sortfield, $sortorder, 'right ');
996}
997if (!empty($arrayfields['t.balance']['checked'])) {
998 print_liste_field_titre($arrayfields['t.balance']['label'], "", "", "", $param, '', $sortfield, $sortorder, 'right ');
999}
1000if (!empty($arrayfields['t.date_export']['checked'])) {
1001 print_liste_field_titre($arrayfields['t.date_export']['label'], $_SERVER['PHP_SELF'], "t.date_export", "", $param, '', $sortfield, $sortorder, 'center ');
1002}
1003if (!empty($arrayfields['t.date_validated']['checked'])) {
1004 print_liste_field_titre($arrayfields['t.date_validated']['label'], $_SERVER['PHP_SELF'], "t.date_validated", "", $param, '', $sortfield, $sortorder, 'center ');
1005}
1006// Due date
1007if (!empty($arrayfields['t.date_lim_reglement']['checked'])) {
1008 print_liste_field_titre($arrayfields['t.date_lim_reglement']['label'], $_SERVER['PHP_SELF'], 't.date_lim_reglement', '', $param, '', $sortfield, $sortorder, 'center ');
1009}
1010if (!empty($arrayfields['t.import_key']['checked'])) {
1011 print_liste_field_titre($arrayfields['t.import_key']['label'], $_SERVER["PHP_SELF"], "t.import_key", "", $param, '', $sortfield, $sortorder, 'center ');
1012}
1013// Hook fields
1014$parameters = array('arrayfields' => $arrayfields, 'param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder);
1015$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
1016print $hookmanager->resPrint;
1017if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1018 print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
1019}
1020print "</tr>\n";
1021
1022$displayed_account_number = null; // Start with undefined to be able to distinguish with empty
1023
1024// Loop on record
1025// --------------------------------------------------------------------
1026$i = 0;
1027
1028$totalarray = array();
1029$totalarray['nbfield'] = 0;
1030$sous_total_debit = 0;
1031$sous_total_credit = 0;
1032$totalarray['val'] = array();
1033$totalarray['val']['totaldebit'] = 0;
1034$totalarray['val']['totalcredit'] = 0;
1035$totalarray['val']['totalbalance']=0;
1036
1037while ($i < min($num, $limit)) {
1038 $line = $object->lines[$i];
1039
1040 if ($type == 'sub') {
1041 $accountg = length_accounta($line->subledger_account);
1042 } else {
1043 $accountg = length_accountg($line->numero_compte);
1044 }
1045 //if (empty($accountg)) $accountg = '-';
1046
1047 $colspan = 0; // colspan before field 'label of operation'
1048 $colspanend = 0; // colspan after debit/credit
1049 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1050 $colspan++;
1051 }
1052 if (!empty($arrayfields['t.piece_num']['checked'])) {
1053 $colspan++;
1054 }
1055 if (!empty($arrayfields['t.code_journal']['checked'])) {
1056 $colspan++;
1057 }
1058 if (!empty($arrayfields['t.doc_date']['checked'])) {
1059 $colspan++;
1060 }
1061 if (!empty($arrayfields['t.doc_ref']['checked'])) {
1062 $colspan++;
1063 }
1064 if (!empty($arrayfields['t.label_operation']['checked'])) {
1065 $colspan++;
1066 }
1067 if (!empty($arrayfields['t.lettering_code']['checked'])) {
1068 $colspan++;
1069 }
1070
1071 if (!empty($arrayfields['t.balance']['checked'])) {
1072 $colspanend++;
1073 }
1074 if (!empty($arrayfields['t.date_export']['checked'])) {
1075 $colspanend++;
1076 }
1077 if (!empty($arrayfields['t.date_validated']['checked'])) {
1078 $colspanend++;
1079 }
1080 // Due date
1081 if (!empty($arrayfields['t.date_lim_reglement']['checked'])) {
1082 $colspanend++;
1083 }
1084 if (!empty($arrayfields['t.lettering_code']['checked'])) {
1085 $colspanend++;
1086 }
1087 if (!empty($arrayfields['t.import_key']['checked'])) {
1088 $colspanend++;
1089 }
1090 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1091 $colspan++;
1092 $colspanend--;
1093 }
1094
1095 // Is it a break ?
1096 if ($accountg != $displayed_account_number || !isset($displayed_account_number)) {
1097 // Show a subtotal by accounting account
1098 if (isset($displayed_account_number)) {
1099 print '<tr class="liste_total">';
1100 if ($type == 'sub') {
1101 print '<td class="right" colspan="' . $colspan . '">' . $langs->trans("TotalForAccount") . ' ' . length_accounta($displayed_account_number) . ':</td>';
1102 } else {
1103 print '<td class="right" colspan="' . $colspan . '">' . $langs->trans("TotalForAccount") . ' ' . length_accountg($displayed_account_number) . ':</td>';
1104 }
1105 print '<td class="nowrap right">'.price(price2num($sous_total_debit, 'MT')).'</td>';
1106 print '<td class="nowrap right">'.price(price2num($sous_total_credit, 'MT')).'</td>';
1107 if ($colspanend > 0) {
1108 print '<td colspan="'.$colspanend.'"></td>';
1109 }
1110 print '</tr>';
1111 // Show balance of last shown account
1112 $balance = $sous_total_debit - $sous_total_credit;
1113 print '<tr class="liste_total">';
1114 print '<td class="right" colspan="'.$colspan.'">'.$langs->trans("Balance").':</td>';
1115 if ($balance > 0) {
1116 print '<td class="nowraponall right">';
1117 print price(price2num($sous_total_debit - $sous_total_credit, 'MT'));
1118 print '</td>';
1119 print '<td></td>';
1120 } else {
1121 print '<td></td>';
1122 print '<td class="nowraponall right">';
1123 print price(price2num($sous_total_credit - $sous_total_debit, 'MT'));
1124 print '</td>';
1125 }
1126 if ($colspanend > 0) {
1127 print '<td colspan="'.$colspanend.'"></td>';
1128 }
1129 print '</tr>';
1130 }
1131
1132 // Show the break account
1133 print '<tr class="trforbreak">';
1134 print '<td colspan="'.($totalarray['nbfield'] ? $totalarray['nbfield'] : count($arrayfields) + 1).'" class="tdforbreak">';
1135 if ($type == 'sub') {
1136 if ($line->subledger_account != "" && $line->subledger_account != '-1') {
1137 print empty($line->subledger_label) ? '<span class="error">'.$langs->trans("Unknown").'</span>' : $line->subledger_label;
1138 print ' : ';
1139 print length_accounta($line->subledger_account);
1140 } else {
1141 // Should not happen: subledger account must be null or a non empty value
1142 print '<span class="error">' . $langs->trans("Unknown");
1143 if ($line->subledger_label) {
1144 print ' (' . $line->subledger_label . ')';
1145 $htmltext = 'EmptyStringForSubledgerAccountButSubledgerLabelDefined';
1146 } else {
1147 $htmltext = 'EmptyStringForSubledgerAccountAndSubledgerLabel';
1148 }
1149 print $form->textwithpicto('', $htmltext);
1150 print '</span>';
1151 }
1152 } else {
1153 if ($line->numero_compte != "" && $line->numero_compte != '-1') {
1154 print length_accountg($line->numero_compte) . ' : ' . $object->get_compte_desc($line->numero_compte);
1155 } else {
1156 print '<span class="error">' . $langs->trans("Unknown") . '</span>';
1157 }
1158 }
1159 print '</td>';
1160 print '</tr>';
1161
1162 $displayed_account_number = $accountg;
1163 //if (empty($displayed_account_number)) $displayed_account_number='-';
1164 $sous_total_debit = 0;
1165 $sous_total_credit = 0;
1166
1167 $colspan = 0;
1168 }
1169
1170 print '<tr class="oddeven">';
1171 // Action column
1172 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1173 print '<td class="nowraponall center">';
1174 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
1175 $selected = 0;
1176 if (in_array($line->id, $arrayofselected)) {
1177 $selected = 1;
1178 }
1179 print '<input id="cb' . $line->id . '" class="flat checkforselect" type="checkbox" name="toselect[]" value="' . $line->id . '"' . ($selected ? ' checked="checked"' : '') . ' />';
1180 }
1181 print '</td>';
1182 if (!$i) {
1183 $totalarray['nbfield']++;
1184 }
1185 }
1186 // Piece number
1187 if (!empty($arrayfields['t.piece_num']['checked'])) {
1188 print '<td>';
1189 $object->id = $line->id;
1190 $object->piece_num = $line->piece_num;
1191 print $object->getNomUrl(1, '', 0, '', 1);
1192 print '</td>';
1193 if (!$i) {
1194 $totalarray['nbfield']++;
1195 }
1196 }
1197
1198 // Journal code
1199 if (!empty($arrayfields['t.code_journal']['checked'])) {
1200 $accountingjournal = new AccountingJournal($db);
1201 $result = $accountingjournal->fetch(0, $line->code_journal);
1202 $journaltoshow = (($result > 0) ? $accountingjournal->getNomUrl(0, 0, 0, '', 0) : $line->code_journal);
1203 print '<td class="center tdoverflowmax80">'.$journaltoshow.'</td>';
1204 if (!$i) {
1205 $totalarray['nbfield']++;
1206 }
1207 }
1208
1209 // Document date
1210 if (!empty($arrayfields['t.doc_date']['checked'])) {
1211 print '<td class="center">'.dol_print_date($line->doc_date, 'day').'</td>';
1212 if (!$i) {
1213 $totalarray['nbfield']++;
1214 }
1215 }
1216
1217 // Document ref
1218 $modulepart = '';
1219 if (!empty($arrayfields['t.doc_ref']['checked'])) {
1220 if ($line->doc_type == 'customer_invoice') {
1221 $langs->loadLangs(array('bills'));
1222
1223 require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
1224 $objectstatic = new Facture($db);
1225 $objectstatic->fetch($line->fk_doc);
1226 //$modulepart = 'facture';
1227
1228 $filename = dol_sanitizeFileName($line->doc_ref);
1229 $filedir = $conf->facture->dir_output.'/'.dol_sanitizeFileName($line->doc_ref);
1230 $urlsource = $_SERVER['PHP_SELF'].'?id='.$objectstatic->id;
1231 $documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir);
1232 } elseif ($line->doc_type == 'supplier_invoice') {
1233 $langs->loadLangs(array('bills'));
1234
1235 require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
1236 $objectstatic = new FactureFournisseur($db);
1237 $objectstatic->fetch($line->fk_doc);
1238
1239 $modulepart = 'invoice_supplier';
1240 $filename = dol_sanitizeFileName($line->doc_ref);
1241 $filedir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($line->fk_doc, 2, 0, 0, $objectstatic, $modulepart).dol_sanitizeFileName($line->doc_ref);
1242 $subdir = get_exdir($objectstatic->id, 2, 0, 0, $objectstatic, $modulepart).dol_sanitizeFileName($line->doc_ref);
1243 $documentlink = $formfile->getDocumentsLink($objectstatic->element, $subdir, $filedir);
1244 } elseif ($line->doc_type == 'expense_report') {
1245 $langs->loadLangs(array('trips'));
1246
1247 require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
1248 $objectstatic = new ExpenseReport($db);
1249 $objectstatic->fetch($line->fk_doc);
1250 //$modulepart = 'expensereport';
1251
1252 $filename = dol_sanitizeFileName($line->doc_ref);
1253 $filedir = $conf->expensereport->dir_output.'/'.dol_sanitizeFileName($line->doc_ref);
1254 $urlsource = $_SERVER['PHP_SELF'].'?id='.$objectstatic->id;
1255 $documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir);
1256 } elseif ($line->doc_type == 'bank') {
1257 require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
1258 $objectstatic = new AccountLine($db);
1259 $objectstatic->fetch($line->fk_doc);
1260 } else {
1261 // Other type
1262 }
1263
1264 print '<td class="tdoverflowmax250">';
1265
1266 // Picto + Ref
1267 if ($line->doc_type == 'customer_invoice' || $line->doc_type == 'supplier_invoice' || $line->doc_type == 'expense_report') {
1268 print $objectstatic->getNomUrl(1, '', 0, 0, '', 0, -1, 1);
1269 print $documentlink;
1270 } elseif ($line->doc_type == 'bank') {
1271 print $objectstatic->getNomUrl(1);
1272 $bank_ref = strstr($line->doc_ref, '-');
1273 print " " . $bank_ref;
1274 } else {
1275 print $line->doc_ref;
1276 }
1277
1278 print "</td>\n";
1279 if (!$i) {
1280 $totalarray['nbfield']++;
1281 }
1282 }
1283
1284 // Label operation
1285 if (!empty($arrayfields['t.label_operation']['checked'])) {
1286 // Affiche un lien vers la facture client/fournisseur
1287 $doc_ref = preg_replace('/\‍(.*\‍)/', '', $line->doc_ref);
1288 if (strlen(length_accounta($line->subledger_account)) == 0) {
1289 print '<td class="small tdoverflowmax350 classfortooltip" title="'.dol_escape_htmltag($line->label_operation).'">'.dol_escape_htmltag($line->label_operation).'</td>';
1290 } else {
1291 print '<td class="small tdoverflowmax350 classfortooltip" title="'.dol_escape_htmltag($line->label_operation.($line->label_operation ? '<br>' : '').'<span style="font-size:0.8em">('.length_accounta($line->subledger_account).')').'">'.dol_escape_htmltag($line->label_operation).($line->label_operation ? '<br>' : '').'<span style="font-size:0.8em">('.dol_escape_htmltag(length_accounta($line->subledger_account)).')</span></td>';
1292 }
1293 if (!$i) {
1294 $totalarray['nbfield']++;
1295 }
1296 }
1297
1298 // Lettering code
1299 if (!empty($arrayfields['t.lettering_code']['checked'])) {
1300 print '<td class="center">'.dol_escape_htmltag($line->lettering_code).'</td>';
1301 if (!$i) {
1302 $totalarray['nbfield']++;
1303 }
1304 }
1305
1306 // Amount debit
1307 if (!empty($arrayfields['t.debit']['checked'])) {
1308 print '<td class="right nowraponall amount">'.($line->debit != 0 ? price($line->debit) : '').'</td>';
1309 if (!$i) {
1310 $totalarray['nbfield']++;
1311 }
1312 if (!$i) {
1313 $totalarray['pos'][$totalarray['nbfield']] = 'totaldebit';
1314 }
1315 $totalarray['val']['totaldebit'] += (float) $line->debit;
1316 }
1317
1318 // Amount credit
1319 if (!empty($arrayfields['t.credit']['checked'])) {
1320 print '<td class="right nowraponall amount">'.($line->credit != 0 ? price($line->credit) : '').'</td>';
1321 if (!$i) {
1322 $totalarray['nbfield']++;
1323 }
1324 if (!$i) {
1325 $totalarray['pos'][$totalarray['nbfield']] = 'totalcredit';
1326 }
1327 $totalarray['val']['totalcredit'] += (float) $line->credit;
1328 }
1329
1330 // Amount balance
1331 if (!empty($arrayfields['t.balance']['checked'])) {
1332 print '<td class="right nowraponall amount">'.price(price2num($sous_total_debit + $line->debit - $sous_total_credit - $line->credit, 'MT')).'</td>';
1333 if (!$i) {
1334 $totalarray['nbfield']++;
1335 }
1336 if (!$i) {
1337 $totalarray['pos'][$totalarray['nbfield']] = 'totalbalance';
1338 };
1339 $totalarray['val']['totalbalance'] += $line->debit - $line->credit;
1340 }
1341
1342 // Exported operation date
1343 if (!empty($arrayfields['t.date_export']['checked'])) {
1344 print '<td class="center">'.dol_print_date($line->date_export, 'dayhour').'</td>';
1345 if (!$i) {
1346 $totalarray['nbfield']++;
1347 }
1348 }
1349
1350 // Validated operation date
1351 if (!empty($arrayfields['t.date_validated']['checked'])) {
1352 print '<td class="center">'.dol_print_date($line->date_validation, 'dayhour').'</td>';
1353 if (!$i) {
1354 $totalarray['nbfield']++;
1355 }
1356 }
1357
1358 // Due date
1359 if (!empty($arrayfields['t.date_lim_reglement']['checked'])) {
1360 print '<td class="center">'.dol_print_date($line->date_lim_reglement, 'day').'</td>';
1361 if (!$i) {
1362 $totalarray['nbfield']++;
1363 }
1364 }
1365
1366 if (!empty($arrayfields['t.import_key']['checked'])) {
1367 print '<td class="tdoverflowmax125" title="'.dol_escape_htmltag($line->import_key).'">'.dol_escape_htmltag($line->import_key)."</td>\n";
1368 if (!$i) {
1369 $totalarray['nbfield']++;
1370 }
1371 }
1372
1373 // Fields from hook
1374 $parameters = array('arrayfields' => $arrayfields, 'obj' => $line);
1375 $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook
1376 print $hookmanager->resPrint;
1377
1378 // Action column
1379 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1380 print '<td class="nowraponall center">';
1381 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
1382 $selected = 0;
1383 if (in_array($line->id, $arrayofselected)) {
1384 $selected = 1;
1385 }
1386 print '<input id="cb' . $line->id . '" class="flat checkforselect" type="checkbox" name="toselect[]" value="' . $line->id . '"' . ($selected ? ' checked="checked"' : '') . ' />';
1387 }
1388 print '</td>';
1389 if (!$i) {
1390 $totalarray['nbfield']++;
1391 }
1392 }
1393
1394 // Comptabilise le sous-total
1395 $sous_total_debit += $line->debit;
1396 $sous_total_credit += $line->credit;
1397
1398 print "</tr>\n";
1399
1400 $i++;
1401}
1402
1403if ($num > 0 && $colspan > 0) {
1404 print '<tr class="liste_total">';
1405 print '<td class="right" colspan="'.$colspan.'">'.$langs->trans("TotalForAccount").' '.$accountg.':</td>';
1406 print '<td class="nowrap right">'.price(price2num($sous_total_debit, 'MT')).'</td>';
1407 print '<td class="nowrap right">'.price(price2num($sous_total_credit, 'MT')).'</td>';
1408 if ($colspanend > 0) {
1409 print '<td colspan="'.$colspanend.'"></td>';
1410 }
1411 print '</tr>';
1412 // Show balance of last shown account
1413 $balance = $sous_total_debit - $sous_total_credit;
1414 print '<tr class="liste_total">';
1415 print '<td class="right" colspan="'.$colspan.'">'.$langs->trans("Balance").':</td>';
1416 if ($balance > 0) {
1417 print '<td class="nowraponall right">';
1418 print price(price2num($sous_total_debit - $sous_total_credit, 'MT'));
1419 print '</td>';
1420 print '<td></td>';
1421 } else {
1422 print '<td></td>';
1423 print '<td class="nowraponall right">';
1424 print price(price2num($sous_total_credit - $sous_total_debit, 'MT'));
1425 print '</td>';
1426 }
1427 if ($colspanend > 0) {
1428 print '<td colspan="'.$colspanend.'"></td>';
1429 }
1430 print '</tr>';
1431}
1432
1433
1434// Clean total values to round them
1435if (!empty($totalarray['val']['totaldebit'])) {
1436 $totalarray['val']['totaldebit'] = (float) price2num($totalarray['val']['totaldebit'], 'MT');
1437}
1438if (!empty($totalarray['val']['totalcredit'])) {
1439 $totalarray['val']['totalcredit'] = (float) price2num($totalarray['val']['totalcredit'], 'MT');
1440}
1441if (!empty($totalarray['val']['totalbalance'])) {
1442 $totalarray['val']['totalbalance'] = (float) price2num($totalarray['val']['totaldebit'] - $totalarray['val']['totalcredit'], 'MT');
1443}
1444
1445// Show total line
1446include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
1447
1448// If no record found
1449if ($num == 0) {
1450 $colspan = 1;
1451 foreach ($arrayfields as $key => $val) {
1452 if (!empty($val['checked'])) {
1453 $colspan++;
1454 }
1455 }
1456 print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
1457}
1458
1459$parameters = array('arrayfields' => $arrayfields);
1460$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1461print $hookmanager->resPrint;
1462
1463print "</table>";
1464print '</div>';
1465
1466// TODO Replace this with mass delete action
1467//if ($user->hasRight('accounting', 'mouvements, 'supprimer_tous')) {
1468// print '<div class="tabsAction tabsActionNoBottom">'."\n";
1469// print '<a class="butActionDelete" name="button_delmvt" href="'.$_SERVER["PHP_SELF"].'?action=delbookkeepingyear&token='.newToken().($param ? '&'.$param : '').'">'.$langs->trans("DeleteMvt").'</a>';
1470// print '</div>';
1471//}
1472
1473print '</form>';
1474
1475// End of page
1476llxFooter();
1477$db->close();
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:58
length_accountg($account)
Return General accounting account with defined length (used for product and miscellaneous)
length_accounta($accounta)
Return Auxiliary accounting account of thirdparties with defined length.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:70
Class to manage bank transaction lines.
Class to manage categories of an accounting account.
Class to manage accounting journals.
Class to manage Ledger (General Ledger and Subledger)
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.
Class permettant la generation de composants html autre Only common components are here.
Class Lettering.
dol_get_last_day($year, $month=12, $gm=false)
Return GMT time for last day of a month or year.
Definition date.lib.php:613
llxFooter()
Footer empty.
Definition document.php:107
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
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.
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_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
dolGetButtonTitleSeparator($moreClass="")
Add space between dolGetButtonTitle.
print_barre_liste($title, $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.
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.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='')
Show information in HTML for admin users or standard users.
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') {
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
Definition repair.php:139
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.