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 = (int) 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$result = -1; // For static analysis
217$documentlink = ''; // For static analysis
218
219$permissiontoadd = $user->hasRight('accounting', 'mouvements', 'creer');
220
221
222/*
223 * Action
224 */
225
226$filter = array();
227$param = '';
228$url_param = '';
229
230if (GETPOST('cancel', 'alpha')) {
231 $action = 'list';
232 $massaction = '';
233}
234if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'preunletteringauto' && $massaction != 'preunletteringmanual' && $massaction != 'predeletebookkeepingwriting') {
235 $massaction = '';
236}
237
238$parameters = array('socid' => $socid);
239$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
240if ($reshook < 0) {
241 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
242}
243
244if (empty($reshook)) {
245 include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
246
247 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
248 $search_doc_date = '';
249 $search_account_category = '';
250 $search_accountancy_code_start = '';
251 $search_accountancy_code_end = '';
252 $search_label_account = '';
253 $search_doc_ref = '';
254 $search_label_operation = '';
255 $search_mvt_num = '';
256 $search_direction = '';
257 $search_ledger_code = array();
258 $search_date_start = '';
259 $search_date_end = '';
260 $search_date_startyear = '';
261 $search_date_startmonth = '';
262 $search_date_startday = '';
263 $search_date_endyear = '';
264 $search_date_endmonth = '';
265 $search_date_endday = '';
266 $search_date_export_start = '';
267 $search_date_export_end = '';
268 $search_date_export_startyear = '';
269 $search_date_export_startmonth = '';
270 $search_date_export_startday = '';
271 $search_date_export_endyear = '';
272 $search_date_export_endmonth = '';
273 $search_date_export_endday = '';
274 $search_date_validation_start = '';
275 $search_date_validation_end = '';
276 $search_date_validation_startyear = '';
277 $search_date_validation_startmonth = '';
278 $search_date_validation_startday = '';
279 $search_date_validation_endyear = '';
280 $search_date_validation_endmonth = '';
281 $search_date_validation_endday = '';
282 // Due date start
283 $search_date_due_start_day = '';
284 $search_date_due_start_month = '';
285 $search_date_due_start_year = '';
286 $search_date_due_start = '';
287 // Due date end
288 $search_date_due_end_day = '';
289 $search_date_due_end_month = '';
290 $search_date_due_end_year = '';
291 $search_date_due_end = '';
292 $search_lettering_code = '';
293 $search_debit = '';
294 $search_credit = '';
295 $search_not_reconciled = '';
296 $search_import_key = '';
297 $toselect = array();
298 }
299
300 if (!empty($search_date_start)) {
301 $filter['t.doc_date>='] = $search_date_start;
302 $param .= '&search_date_startmonth='.$search_date_startmonth.'&search_date_startday='.$search_date_startday.'&search_date_startyear='.$search_date_startyear;
303 }
304 if (!empty($search_date_end)) {
305 $filter['t.doc_date<='] = $search_date_end;
306 $param .= '&search_date_endmonth='.$search_date_endmonth.'&search_date_endday='.$search_date_endday.'&search_date_endyear='.$search_date_endyear;
307 }
308 if (!empty($search_doc_date)) {
309 $filter['t.doc_date'] = $search_doc_date;
310 $param .= '&doc_datemonth='.GETPOSTINT('doc_datemonth').'&doc_dateday='.GETPOSTINT('doc_dateday').'&doc_dateyear='.GETPOSTINT('doc_dateyear');
311 }
312 if ($search_account_category != '-1' && !empty($search_account_category)) {
313 require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountancycategory.class.php';
314 $accountingcategory = new AccountancyCategory($db);
315
316 $listofaccountsforgroup = $accountingcategory->getCptsCat(0, 'fk_accounting_category = '.((int) $search_account_category));
317 $listofaccountsforgroup2 = array();
318 if (is_array($listofaccountsforgroup)) {
319 foreach ($listofaccountsforgroup as $tmpval) {
320 $listofaccountsforgroup2[] = "'".$db->escape($tmpval['id'])."'";
321 }
322 }
323 $filter['t.search_accounting_code_in'] = implode(',', $listofaccountsforgroup2);
324 $param .= '&search_account_category='.urlencode((string) ($search_account_category));
325 }
326 if (!empty($search_accountancy_code_start)) {
327 if ($type == 'sub') {
328 $filter['t.subledger_account>='] = $search_accountancy_code_start;
329 } else {
330 $filter['t.numero_compte>='] = $search_accountancy_code_start;
331 }
332 $param .= '&search_accountancy_code_start=' . urlencode($search_accountancy_code_start);
333 }
334 if (!empty($search_accountancy_code_end)) {
335 if ($type == 'sub') {
336 $filter['t.subledger_account<='] = $search_accountancy_code_end;
337 } else {
338 $filter['t.numero_compte<='] = $search_accountancy_code_end;
339 }
340 $param .= '&search_accountancy_code_end=' . urlencode($search_accountancy_code_end);
341 }
342 if (!empty($search_label_account)) {
343 $filter['t.label_compte'] = $search_label_account;
344 $param .= '&search_label_compte='.urlencode($search_label_account);
345 }
346 if (!empty($search_mvt_num)) {
347 $filter['t.piece_num'] = $search_mvt_num;
348 $param .= '&search_mvt_num='.urlencode((string) ($search_mvt_num));
349 }
350 if (!empty($search_doc_ref)) {
351 $filter['t.doc_ref'] = $search_doc_ref;
352 $param .= '&search_doc_ref='.urlencode($search_doc_ref);
353 }
354 if (!empty($search_label_operation)) {
355 $filter['t.label_operation'] = $search_label_operation;
356 $param .= '&search_label_operation='.urlencode($search_label_operation);
357 }
358 if (!empty($search_direction)) {
359 $filter['t.sens'] = $search_direction;
360 $param .= '&search_direction='.urlencode($search_direction);
361 }
362 if (!empty($search_ledger_code)) {
363 $filter['t.code_journal'] = $search_ledger_code;
364 foreach ($search_ledger_code as $code) {
365 $param .= '&search_ledger_code[]='.urlencode($code);
366 }
367 }
368 if (!empty($search_lettering_code)) {
369 $filter['t.lettering_code'] = $search_lettering_code;
370 $param .= '&search_lettering_code='.urlencode($search_lettering_code);
371 }
372 if (!empty($search_debit)) {
373 $filter['t.debit'] = $search_debit;
374 $param .= '&search_debit='.urlencode($search_debit);
375 }
376 if (!empty($search_credit)) {
377 $filter['t.credit'] = $search_credit;
378 $param .= '&search_credit='.urlencode($search_credit);
379 }
380 if (!empty($search_not_reconciled)) {
381 $filter['t.reconciled_option'] = $search_not_reconciled;
382 $param .= '&search_not_reconciled='.urlencode($search_not_reconciled);
383 }
384 if (!empty($search_date_export_start)) {
385 $filter['t.date_export>='] = $search_date_export_start;
386 $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;
387 }
388 if (!empty($search_date_export_end)) {
389 $filter['t.date_export<='] = $search_date_export_end;
390 $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;
391 }
392 if (!empty($search_date_validation_start)) {
393 $filter['t.date_validated>='] = $search_date_validation_start;
394 $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;
395 }
396 if (!empty($search_date_validation_end)) {
397 $filter['t.date_validated<='] = $search_date_validation_end;
398 $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;
399 }
400 // Due date start
401 if (!empty($search_date_due_start)) {
402 $filter['t.date_lim_reglement>='] = $search_date_due_start;
403 $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;
404 }
405 // Due date end
406 if (!empty($search_date_due_end)) {
407 $filter['t.date_lim_reglement<='] = $search_date_due_end;
408 $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;
409 }
410 if (!empty($search_import_key)) {
411 $filter['t.import_key'] = $search_import_key;
412 $param .= '&search_import_key='.urlencode($search_import_key);
413 }
414 // param with type of list
415 $url_param = substr($param, 1); // remove first "&"
416 if (!empty($type)) {
417 $param = '&type='.$type.$param;
418 }
419
420 //if ($action == 'delbookkeepingyearconfirm' && $user->hasRight('accounting', 'mouvements', 'supprimer')_tous) {
421 // $delmonth = GETPOST('delmonth', 'int');
422 // $delyear = GETPOST('delyear', 'int');
423 // if ($delyear == -1) {
424 // $delyear = 0;
425 // }
426 // $deljournal = GETPOST('deljournal', 'alpha');
427 // if ($deljournal == -1) {
428 // $deljournal = 0;
429 // }
430 //
431 // if (!empty($delmonth) || !empty($delyear) || !empty($deljournal)) {
432 // $result = $object->deleteByYearAndJournal($delyear, $deljournal, '', ($delmonth > 0 ? $delmonth : 0));
433 // if ($result < 0) {
434 // setEventMessages($object->error, $object->errors, 'errors');
435 // } else {
436 // setEventMessages("RecordDeleted", null, 'mesgs');
437 // }
438 //
439 // // Make a redirect to avoid to launch the delete later after a back button
440 // header("Location: ".$_SERVER["PHP_SELF"].($param ? '?'.$param : ''));
441 // exit;
442 // } else {
443 // setEventMessages("NoRecordDeleted", null, 'warnings');
444 // }
445 //}
446
447 // Mass actions
448 $objectclass = 'Bookkeeping';
449 $objectlabel = 'Bookkeeping';
450 $permissiontoread = $user->hasRight('societe', 'lire');
451 $permissiontodelete = $user->hasRight('societe', 'supprimer');
452 $permissiontoadd = $user->hasRight('societe', 'creer');
453 $uploaddir = $conf->societe->dir_output;
454 include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
455
456 if (!$error && $action == 'deletebookkeepingwriting' && $confirm == "yes" && $user->hasRight('accounting', 'mouvements', 'supprimer')) {
457 $db->begin();
458
459 if (getDolGlobalInt('ACCOUNTING_ENABLE_LETTERING')) {
460 $lettering = new Lettering($db);
461 $nb_lettering = $lettering->bookkeepingLetteringAll($toselect, true);
462 if ($nb_lettering < 0) {
463 setEventMessages('', $lettering->errors, 'errors');
464 $error++;
465 }
466 }
467
468 $nbok = 0;
469 if (!$error) {
470 foreach ($toselect as $toselectid) {
471 $result = $object->fetch($toselectid);
472 if ($result > 0 && (!isset($object->date_validation) || $object->date_validation === '')) {
473 $result = $object->deleteMvtNum($object->piece_num);
474 if ($result > 0) {
475 $nbok++;
476 } else {
477 setEventMessages($object->error, $object->errors, 'errors');
478 $error++;
479 break;
480 }
481 } elseif ($result < 0) {
482 setEventMessages($object->error, $object->errors, 'errors');
483 $error++;
484 break;
485 } elseif (isset($object->date_validation) && $object->date_validation != '') {
486 setEventMessages($langs->trans("ValidatedRecordWhereFound"), null, 'errors');
487 $error++;
488 break;
489 }
490 }
491 }
492
493 if (!$error) {
494 $db->commit();
495
496 // Message for elements well deleted
497 if ($nbok > 1) {
498 setEventMessages($langs->trans("RecordsDeleted", $nbok), null, 'mesgs');
499 } elseif ($nbok > 0) {
500 setEventMessages($langs->trans("RecordDeleted", $nbok), null, 'mesgs');
501 } elseif (!$error) {
502 setEventMessages($langs->trans("NoRecordDeleted"), null, 'mesgs');
503 }
504
505 header("Location: ".$_SERVER["PHP_SELF"]."?noreset=1".($param ? '&'.$param : ''));
506 exit;
507 } else {
508 $db->rollback();
509 }
510 }
511
512 // others mass actions
513 if (!$error && getDolGlobalInt('ACCOUNTING_ENABLE_LETTERING')) {
514 if ($massaction == 'letteringauto' && $permissiontoadd) {
515 $lettering = new Lettering($db);
516 $nb_lettering = $lettering->bookkeepingLetteringAll($toselect);
517 if ($nb_lettering < 0) {
518 setEventMessages('', $lettering->errors, 'errors');
519 $error++;
520 $nb_lettering = max(0, abs($nb_lettering) - 2);
521 } elseif ($nb_lettering == 0) {
522 $nb_lettering = 0;
523 setEventMessages($langs->trans('AccountancyNoLetteringModified'), array(), 'mesgs');
524 }
525 if ($nb_lettering == 1) {
526 setEventMessages($langs->trans('AccountancyOneLetteringModifiedSuccessfully'), array(), 'mesgs');
527 } elseif ($nb_lettering > 1) {
528 setEventMessages($langs->trans('AccountancyLetteringModifiedSuccessfully', $nb_lettering), array(), 'mesgs');
529 }
530
531 if (!$error) {
532 header('Location: ' . $_SERVER['PHP_SELF'] . '?noreset=1' . $param);
533 exit();
534 }
535 } elseif ($massaction == 'letteringmanual' && $permissiontoadd) {
536 $lettering = new Lettering($db);
537 $result = $lettering->updateLettering($toselect);
538 if ($result < 0) {
539 setEventMessages('', $lettering->errors, 'errors');
540 } else {
541 setEventMessages($langs->trans($result == 0 ? 'AccountancyNoLetteringModified' : 'AccountancyOneLetteringModifiedSuccessfully'), array(), 'mesgs');
542 header('Location: ' . $_SERVER['PHP_SELF'] . '?noreset=1' . $param);
543 exit();
544 }
545 } elseif ($type == 'sub' && $massaction == 'letteringpartial') {
546 $lettering = new Lettering($db);
547 $result = $lettering->updateLettering($toselect, false, true);
548 if ($result < 0) {
549 setEventMessages('', $lettering->errors, 'errors');
550 } else {
551 setEventMessages($langs->trans($result == 0 ? 'AccountancyNoLetteringModified' : 'AccountancyOneLetteringModifiedSuccessfully'), array(), 'mesgs');
552 header('Location: ' . $_SERVER['PHP_SELF'] . '?noreset=1' . $param);
553 exit();
554 }
555 } elseif ($action == 'unletteringauto' && $confirm == "yes" && $permissiontoadd) {
556 $lettering = new Lettering($db);
557 $nb_lettering = $lettering->bookkeepingLetteringAll($toselect, true);
558 if ($nb_lettering < 0) {
559 setEventMessages('', $lettering->errors, 'errors');
560 $error++;
561 $nb_lettering = max(0, abs($nb_lettering) - 2);
562 } elseif ($nb_lettering == 0) {
563 $nb_lettering = 0;
564 setEventMessages($langs->trans('AccountancyNoUnletteringModified'), array(), 'mesgs');
565 }
566 if ($nb_lettering == 1) {
567 setEventMessages($langs->trans('AccountancyOneUnletteringModifiedSuccessfully'), array(), 'mesgs');
568 } elseif ($nb_lettering > 1) {
569 setEventMessages($langs->trans('AccountancyUnletteringModifiedSuccessfully', $nb_lettering), array(), 'mesgs');
570 }
571
572 if (!$error) {
573 header('Location: ' . $_SERVER['PHP_SELF'] . '?noreset=1' . $param);
574 exit();
575 }
576 } elseif ($action == 'unletteringmanual' && $confirm == "yes" && $permissiontoadd) {
577 $lettering = new Lettering($db);
578 $nb_lettering = $lettering->deleteLettering($toselect);
579 if ($result < 0) {
580 setEventMessages('', $lettering->errors, 'errors');
581 } else {
582 setEventMessages($langs->trans($result == 0 ? 'AccountancyNoUnletteringModified' : 'AccountancyOneUnletteringModifiedSuccessfully'), array(), 'mesgs');
583 header('Location: ' . $_SERVER['PHP_SELF'] . '?noreset=1' . $param);
584 exit();
585 }
586 }
587 }
588}
589
590
591/*
592 * View
593 */
594
595$formaccounting = new FormAccounting($db);
596$formfile = new FormFile($db);
597$formother = new FormOther($db);
598$form = new Form($db);
599
600$title_page = $langs->trans("Operations").' - '.$langs->trans("VueByAccountAccounting").' (';
601if ($type == 'sub') {
602 $title_page .= $langs->trans("BookkeepingSubAccount");
603} else {
604 $title_page .= $langs->trans("Bookkeeping");
605}
606$title_page .= ')';
607$help_url = 'EN:Module_Double_Entry_Accounting|FR:Module_Comptabilit&eacute;_en_Partie_Double';
608llxHeader('', $title_page, $help_url, '', 0, 0, '', '', '', 'mod-accountancy accountancy-consultation page-'.(($type == 'sub') ? 'sub' : '').'ledger');
609
610// List
611$nbtotalofrecords = '';
612if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
613 // TODO Perf Replace this by a count
614 if ($type == 'sub') {
615 $nbtotalofrecords = $object->fetchAllByAccount($sortorder, $sortfield, 0, 0, $filter, 'AND', 1, 1);
616 } else {
617 $nbtotalofrecords = $object->fetchAllByAccount($sortorder, $sortfield, 0, 0, $filter, 'AND', 0, 1);
618 }
619
620 if ($nbtotalofrecords < 0) {
621 setEventMessages($object->error, $object->errors, 'errors');
622 $error++;
623 }
624}
625
626$num = 0;
627if (!$error) {
628 if ($type == 'sub') {
629 $result = $object->fetchAllByAccount($sortorder, $sortfield, $limit, $offset, $filter, 'AND', 1);
630 } else {
631 $result = $object->fetchAllByAccount($sortorder, $sortfield, $limit, $offset, $filter, 'AND', 0);
632 }
633 //$num = count($object->lines);
634 $num = $result; // $result is total nb of lines, or limit + 1, but $object->lines is always limited to $limit
635
636 if ($result < 0) {
637 setEventMessages($object->error, $object->errors, 'errors');
638 }
639}
640
641$arrayofselected = is_array($toselect) ? $toselect : array();
642
643
645// $form_question = array();
646// $delyear = GETPOST('delyear', 'int');
647// $deljournal = GETPOST('deljournal', 'alpha');
648//
649// if (empty($delyear)) {
650// $delyear = dol_print_date(dol_now(), '%Y');
651// }
652// $month_array = array();
653// for ($i = 1; $i <= 12; $i++) {
654// $month_array[$i] = $langs->trans("Month".sprintf("%02d", $i));
655// }
656// $year_array = $formaccounting->selectyear_accountancy_bookkepping($delyear, 'delyear', 0, 'array');
657// $journal_array = $formaccounting->select_journal($deljournal, 'deljournal', '', 1, 1, 1, '', 0, 1);
658//
659// $form_question['delmonth'] = array(
660// 'name' => 'delmonth',
661// 'type' => 'select',
662// 'label' => $langs->trans('DelMonth'),
663// 'values' => $month_array,
664// 'default' => ''
665// );
666// $form_question['delyear'] = array(
667// 'name' => 'delyear',
668// 'type' => 'select',
669// 'label' => $langs->trans('DelYear'),
670// 'values' => $year_array,
671// 'default' => $delyear
672// );
673// $form_question['deljournal'] = array(
674// 'name' => 'deljournal',
675// 'type' => 'other', // We don't use select here, the journal_array is already a select html component
676// 'label' => $langs->trans('DelJournal'),
677// 'value' => $journal_array,
678// 'default' => $deljournal
679// );
680//
681// $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?'.$param, $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvt', $langs->transnoentitiesnoconv("RegistrationInAccounting")), 'delbookkeepingyearconfirm', $form_question, '', 1, 300);
682//}
683
684// Print form confirm
686print $formconfirm;
687
688// List of mass actions available
689$arrayofmassactions = array();
690if (getDolGlobalInt('ACCOUNTING_ENABLE_LETTERING') && $user->hasRight('accounting', 'mouvements', 'creer')) {
691 $arrayofmassactions['letteringauto'] = img_picto('', 'check', 'class="pictofixedwidth"') . $langs->trans('LetteringAuto');
692 $arrayofmassactions['preunletteringauto'] = img_picto('', 'uncheck', 'class="pictofixedwidth"') . $langs->trans('UnletteringAuto');
693 $arrayofmassactions['letteringmanual'] = img_picto('', 'check', 'class="pictofixedwidth"') . $langs->trans('LetteringManual');
694 if ($type == 'sub') {
695 $arrayofmassactions['letteringpartial'] = img_picto('', 'check', 'class="pictofixedwidth"') . $langs->trans('LetteringPartial');
696 }
697 $arrayofmassactions['preunletteringmanual'] = img_picto('', 'uncheck', 'class="pictofixedwidth"') . $langs->trans('UnletteringManual');
698}
699if ($user->hasRight('accounting', 'mouvements', 'supprimer')) {
700 $arrayofmassactions['predeletebookkeepingwriting'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
701}
702if (GETPOSTINT('nomassaction') || in_array($massaction, array('preunletteringauto', 'preunletteringmanual', 'predeletebookkeepingwriting'))) {
703 $arrayofmassactions = array();
704}
705$massactionbutton = $form->selectMassAction($massaction, $arrayofmassactions);
706
707print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
708print '<input type="hidden" name="token" value="'.newToken().'">';
709print '<input type="hidden" name="action" value="list">';
710if ($optioncss != '') {
711 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
712}
713print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
714print '<input type="hidden" name="type" value="'.$type.'">';
715print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
716print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
717print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
718
719$parameters = array('param' => $param);
720$reshook = $hookmanager->executeHooks('addMoreActionsButtonsList', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
721if ($reshook < 0) {
722 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
723}
724
725$newcardbutton = empty($hookmanager->resPrint) ? '' : $hookmanager->resPrint;
726
727if (empty($reshook)) {
728 $newcardbutton = dolGetButtonTitle($langs->trans('ViewFlatList'), '', 'fa fa-list paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/list.php?'.$param);
729 if ($type == 'sub') {
730 $newcardbutton .= dolGetButtonTitle($langs->trans('GroupByAccountAccounting'), '', 'fa fa-stream paddingleft imgforviewmode', DOL_URL_ROOT . '/accountancy/bookkeeping/listbyaccount.php?' . $url_param, '', 1, array('morecss' => 'marginleftonly'));
731 $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'));
732 } else {
733 $newcardbutton .= dolGetButtonTitle($langs->trans('GroupByAccountAccounting'), '', 'fa fa-stream paddingleft imgforviewmode', DOL_URL_ROOT . '/accountancy/bookkeeping/listbyaccount.php?' . $url_param, '', 1, array('morecss' => 'marginleftonly btnTitleSelected'));
734 $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'));
735 }
736 $newcardbutton .= dolGetButtonTitleSeparator();
737 $newcardbutton .= dolGetButtonTitle($langs->trans('NewAccountingMvt'), '', 'fa fa-plus-circle paddingleft', DOL_URL_ROOT.'/accountancy/bookkeeping/card.php?action=create');
738}
739
740if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
741 $param .= '&contextpage='.urlencode($contextpage);
742}
743if ($limit > 0 && $limit != $conf->liste_limit) {
744 $param .= '&limit='.((int) $limit);
745}
746
747print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_accountancy', 0, $newcardbutton, '', $limit, 0, 0, 1);
748
749if ($massaction == 'preunletteringauto') {
750 print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmMassUnletteringAuto"), $langs->trans("ConfirmMassUnletteringQuestion", count($toselect)), "unletteringauto", null, '', 0, 200, 500, 1);
751} elseif ($massaction == 'preunletteringmanual') {
752 print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmMassUnletteringManual"), $langs->trans("ConfirmMassUnletteringQuestion", count($toselect)), "unletteringmanual", null, '', 0, 200, 500, 1);
753} elseif ($massaction == 'predeletebookkeepingwriting') {
754 print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmMassDeleteBookkeepingWriting"), $langs->trans("ConfirmMassDeleteBookkeepingWritingQuestion", count($toselect)), "deletebookkeepingwriting", null, '', 0, 200, 500, 1);
755}
756//DeleteMvt=Supprimer des lignes d'opérations de la comptabilité
757//DelMonth=Mois à effacer
758//DelYear=Année à supprimer
759//DelJournal=Journal à supprimer
760//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é.
761//ConfirmDeleteMvtPartial=Cette action supprime l'écriture de la comptabilité (toutes les lignes opérations liées à une même écriture seront effacées).
762
763//$topicmail = "Information";
764//$modelmail = "accountingbookkeeping";
765//$objecttmp = new BookKeeping($db);
766//$trackid = 'bk'.$object->id;
767include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
768
769$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
770$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')); // This also change content of $arrayfields
771if ($massactionbutton && $contextpage != 'poslist') {
772 $selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
773}
774
775// Reverse sort order
776if (preg_match('/^asc/i', $sortorder)) {
777 $sortorder = "asc";
778} else {
779 $sortorder = "desc";
780}
781
782// Warning to explain why list of record is not consistent with the other list view (missing a lot of lines)
783if ($type == 'sub') {
784 print info_admin($langs->trans("WarningRecordWithoutSubledgerAreExcluded"));
785}
786
787$moreforfilter = '';
788
789// Search on accountancy custom groups or account
790$moreforfilter .= '<div class="divsearchfield">';
791$moreforfilter .= $langs->trans('AccountAccounting').': ';
792$moreforfilter .= '<div class="nowrap inline-block">';
793if ($type == 'sub') {
794 $moreforfilter .= $formaccounting->select_auxaccount($search_accountancy_code_start, 'search_accountancy_code_start', $langs->trans('From'), 'maxwidth200');
795} else {
796 $moreforfilter .= $formaccounting->select_account($search_accountancy_code_start, 'search_accountancy_code_start', $langs->trans('From'), array(), 1, 1, 'maxwidth200');
797}
798$moreforfilter .= ' ';
799if ($type == 'sub') {
800 $moreforfilter .= $formaccounting->select_auxaccount($search_accountancy_code_end, 'search_accountancy_code_end', $langs->trans('to'), 'maxwidth200');
801} else {
802 $moreforfilter .= $formaccounting->select_account($search_accountancy_code_end, 'search_accountancy_code_end', $langs->trans('to'), array(), 1, 1, 'maxwidth200');
803}
804$stringforfirstkey = $langs->trans("KeyboardShortcut");
805if ($conf->browser->name == 'chrome') {
806 $stringforfirstkey .= ' ALT +';
807} elseif ($conf->browser->name == 'firefox') {
808 $stringforfirstkey .= ' ALT + SHIFT +';
809} else {
810 $stringforfirstkey .= ' CTL +';
811}
812$moreforfilter .= '&nbsp;&nbsp;&nbsp;<a id="previous_account" accesskey="p" title="' . $stringforfirstkey . ' p" class="classfortooltip" href="#"><i class="fa fa-chevron-left"></i></a>';
813$moreforfilter .= '&nbsp;&nbsp;&nbsp;<a id="next_account" accesskey="n" title="' . $stringforfirstkey . ' n" class="classfortooltip" href="#"><i class="fa fa-chevron-right"></i></a>';
814$moreforfilter .= <<<SCRIPT
815<script type="text/javascript">
816 jQuery(document).ready(function() {
817 var searchFormList = $('#searchFormList');
818 var searchAccountancyCodeStart = $('#search_accountancy_code_start');
819 var searchAccountancyCodeEnd = $('#search_accountancy_code_end');
820 jQuery('#previous_account').on('click', function() {
821 var previousOption = searchAccountancyCodeStart.find('option:selected').prev('option');
822 if (previousOption.length == 1) searchAccountancyCodeStart.val(previousOption.attr('value'));
823 searchAccountancyCodeEnd.val(searchAccountancyCodeStart.val());
824 searchFormList.submit();
825 });
826 jQuery('#next_account').on('click', function() {
827 var nextOption = searchAccountancyCodeStart.find('option:selected').next('option');
828 if (nextOption.length == 1) searchAccountancyCodeStart.val(nextOption.attr('value'));
829 searchAccountancyCodeEnd.val(searchAccountancyCodeStart.val());
830 searchFormList.submit();
831 });
832 jQuery('input[name="search_mvt_num"]').on("keypress", function(event) {
833 console.log(event);
834 });
835 });
836</script>
837SCRIPT;
838$moreforfilter .= '</div>';
839$moreforfilter .= '</div>';
840
841$moreforfilter .= '<div class="divsearchfield">';
842$moreforfilter .= $langs->trans('AccountingCategory').': ';
843$moreforfilter .= '<div class="nowrap inline-block">';
844$moreforfilter .= $formaccounting->select_accounting_category($search_account_category, 'search_account_category', 1, 0, 0, 0);
845$moreforfilter .= '</div>';
846$moreforfilter .= '</div>';
847
848$parameters = array();
849$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
850if (empty($reshook)) {
851 $moreforfilter .= $hookmanager->resPrint;
852} else {
853 $moreforfilter = $hookmanager->resPrint;
854}
855
856print '<div class="liste_titre liste_titre_bydiv centpercent">';
857print $moreforfilter;
858print '</div>';
859
860print '<div class="div-table-responsive">';
861print '<table class="tagtable liste centpercent listwithfilterbefore">';
862
863// Filters lines
864print '<tr class="liste_titre_filter">';
865// Action column
866if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
867 print '<td class="liste_titre center">';
868 $searchpicto = $form->showFilterButtons('left');
869 print $searchpicto;
870 print '</td>';
871}
872// Movement number
873if (!empty($arrayfields['t.piece_num']['checked'])) {
874 print '<td class="liste_titre"><input type="text" name="search_mvt_num" class="width50" value="'.dol_escape_htmltag($search_mvt_num).'"></td>';
875}
876// Code journal
877if (!empty($arrayfields['t.code_journal']['checked'])) {
878 print '<td class="liste_titre center">';
879 print $formaccounting->multi_select_journal($search_ledger_code, 'search_ledger_code', 0, 1, 1, 1, 'maxwidth75');
880 print '</td>';
881}
882// Date document
883if (!empty($arrayfields['t.doc_date']['checked'])) {
884 print '<td class="liste_titre center">';
885 print '<div class="nowrapfordate">';
886 print $form->selectDate($search_date_start, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"));
887 print '</div>';
888 print '<div class="nowrapfordate">';
889 print $form->selectDate($search_date_end, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to"));
890 print '</div>';
891 print '</td>';
892}
893// Ref document
894if (!empty($arrayfields['t.doc_ref']['checked'])) {
895 print '<td class="liste_titre"><input type="text" size="7" class="flat" name="search_doc_ref" value="'.dol_escape_htmltag($search_doc_ref).'"/></td>';
896}
897// Label operation
898if (!empty($arrayfields['t.label_operation']['checked'])) {
899 print '<td class="liste_titre"><input type="text" size="7" class="flat" name="search_label_operation" value="'.dol_escape_htmltag($search_label_operation).'"/></td>';
900}
901// Lettering code
902if (!empty($arrayfields['t.lettering_code']['checked'])) {
903 print '<td class="liste_titre center">';
904 print '<input type="text" size="3" class="flat" name="search_lettering_code" value="'.$search_lettering_code.'"/>';
905 print '<br><span class="nowrap"><input type="checkbox" name="search_not_reconciled" value="notreconciled"'.($search_not_reconciled == 'notreconciled' ? ' checked' : '').'>'.$langs->trans("NotReconciled").'</span>';
906 print '</td>';
907}
908// Debit
909if (!empty($arrayfields['t.debit']['checked'])) {
910 print '<td class="liste_titre right"><input type="text" class="flat" name="search_debit" size="4" value="'.dol_escape_htmltag($search_debit).'"></td>';
911}
912// Credit
913if (!empty($arrayfields['t.credit']['checked'])) {
914 print '<td class="liste_titre right"><input type="text" class="flat" name="search_credit" size="4" value="'.dol_escape_htmltag($search_credit).'"></td>';
915}
916// Balance
917if (!empty($arrayfields['t.balance']['checked'])) {
918 print '<td></td>';
919}
920// Date export
921if (!empty($arrayfields['t.date_export']['checked'])) {
922 print '<td class="liste_titre center">';
923 print '<div class="nowrapfordate">';
924 print $form->selectDate($search_date_export_start, 'search_date_export_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"));
925 print '</div>';
926 print '<div class="nowrapfordate">';
927 print $form->selectDate($search_date_export_end, 'search_date_export_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to"));
928 print '</div>';
929 print '</td>';
930}
931// Date validation
932if (!empty($arrayfields['t.date_validated']['checked'])) {
933 print '<td class="liste_titre center">';
934 print '<div class="nowrapfordate">';
935 print $form->selectDate($search_date_validation_start, 'search_date_validation_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"));
936 print '</div>';
937 print '<div class="nowrapfordate">';
938 print $form->selectDate($search_date_validation_end, 'search_date_validation_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to"));
939 print '</div>';
940 print '</td>';
941}
942// Due date start and end
943if (!empty($arrayfields['t.date_lim_reglement']['checked'])) {
944 print '<td class="liste_titre center">';
945 print '<div class="nowrapfordate">';
946 print $form->selectDate($search_date_due_start, 'search_date_due_start_', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"));
947 print '</div>';
948 print '<div class="nowrapfordate">';
949 print $form->selectDate($search_date_due_end, 'search_date_due_end_', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to"));
950 print '</div>';
951 print '</td>';
952}
953if (!empty($arrayfields['t.import_key']['checked'])) {
954 print '<td class="liste_titre center">';
955 print '<input class="flat searchstring maxwidth50" type="text" name="search_import_key" value="'.dol_escape_htmltag($search_import_key).'">';
956 print '</td>';
957}
958
959// Fields from hook
960$parameters = array('arrayfields' => $arrayfields);
961$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
962print $hookmanager->resPrint;
963
964// Action column
965if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
966 print '<td class="liste_titre center">';
967 $searchpicto = $form->showFilterButtons();
968 print $searchpicto;
969 print '</td>';
970}
971print "</tr>\n";
972
973print '<tr class="liste_titre">';
974if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
975 print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
976}
977if (!empty($arrayfields['t.piece_num']['checked'])) {
978 print_liste_field_titre($arrayfields['t.piece_num']['label'], $_SERVER['PHP_SELF'], "t.piece_num", "", $param, '', $sortfield, $sortorder, 'tdoverflowmax80imp ');
979}
980if (!empty($arrayfields['t.code_journal']['checked'])) {
981 print_liste_field_titre($arrayfields['t.code_journal']['label'], $_SERVER['PHP_SELF'], "t.code_journal", "", $param, '', $sortfield, $sortorder, 'center ');
982}
983if (!empty($arrayfields['t.doc_date']['checked'])) {
984 print_liste_field_titre($arrayfields['t.doc_date']['label'], $_SERVER['PHP_SELF'], "t.doc_date", "", $param, '', $sortfield, $sortorder, 'center ');
985}
986if (!empty($arrayfields['t.doc_ref']['checked'])) {
987 print_liste_field_titre($arrayfields['t.doc_ref']['label'], $_SERVER['PHP_SELF'], "t.doc_ref", "", $param, "", $sortfield, $sortorder);
988}
989if (!empty($arrayfields['t.label_operation']['checked'])) {
990 print_liste_field_titre($arrayfields['t.label_operation']['label'], $_SERVER['PHP_SELF'], "t.label_operation", "", $param, "", $sortfield, $sortorder);
991}
992if (!empty($arrayfields['t.lettering_code']['checked'])) {
993 print_liste_field_titre($arrayfields['t.lettering_code']['label'], $_SERVER['PHP_SELF'], "t.lettering_code", "", $param, '', $sortfield, $sortorder, 'center ');
994}
995if (!empty($arrayfields['t.debit']['checked'])) {
996 print_liste_field_titre($arrayfields['t.debit']['label'], $_SERVER['PHP_SELF'], "t.debit", "", $param, '', $sortfield, $sortorder, 'right ');
997}
998if (!empty($arrayfields['t.credit']['checked'])) {
999 print_liste_field_titre($arrayfields['t.credit']['label'], $_SERVER['PHP_SELF'], "t.credit", "", $param, '', $sortfield, $sortorder, 'right ');
1000}
1001if (!empty($arrayfields['t.balance']['checked'])) {
1002 print_liste_field_titre($arrayfields['t.balance']['label'], "", "", "", $param, '', $sortfield, $sortorder, 'right ');
1003}
1004if (!empty($arrayfields['t.date_export']['checked'])) {
1005 print_liste_field_titre($arrayfields['t.date_export']['label'], $_SERVER['PHP_SELF'], "t.date_export", "", $param, '', $sortfield, $sortorder, 'center ');
1006}
1007if (!empty($arrayfields['t.date_validated']['checked'])) {
1008 print_liste_field_titre($arrayfields['t.date_validated']['label'], $_SERVER['PHP_SELF'], "t.date_validated", "", $param, '', $sortfield, $sortorder, 'center ');
1009}
1010// Due date
1011if (!empty($arrayfields['t.date_lim_reglement']['checked'])) {
1012 print_liste_field_titre($arrayfields['t.date_lim_reglement']['label'], $_SERVER['PHP_SELF'], 't.date_lim_reglement', '', $param, '', $sortfield, $sortorder, 'center ');
1013}
1014if (!empty($arrayfields['t.import_key']['checked'])) {
1015 print_liste_field_titre($arrayfields['t.import_key']['label'], $_SERVER["PHP_SELF"], "t.import_key", "", $param, '', $sortfield, $sortorder, 'center ');
1016}
1017// Hook fields
1018$parameters = array('arrayfields' => $arrayfields, 'param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder);
1019$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
1020print $hookmanager->resPrint;
1021if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1022 print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
1023}
1024print "</tr>\n";
1025
1026$displayed_account_number = null; // Start with undefined to be able to distinguish with empty
1027
1028$objectstatic = null; // Init for static analysis
1029$objectlink = ''; // Init for static analysis
1030$result = -1; // Init for static analysis
1031
1032// Loop on record
1033// --------------------------------------------------------------------
1034$i = 0;
1035
1036$totalarray = array();
1037$totalarray['nbfield'] = 0;
1038$sous_total_debit = 0;
1039$sous_total_credit = 0;
1040$totalarray['val'] = array();
1041$totalarray['val']['totaldebit'] = 0;
1042$totalarray['val']['totalcredit'] = 0;
1043$totalarray['val']['totalbalance'] = 0;
1044
1045// Init for static analysis
1046$colspan = 0; // colspan before field 'label of operation'
1047$colspanend = 0; // colspan after debit/credit
1048$accountg = '-';
1049
1050while ($i < min($num, $limit)) {
1051 $line = $object->lines[$i];
1052
1053 if ($type == 'sub') {
1054 $accountg = length_accounta($line->subledger_account);
1055 } else {
1056 $accountg = length_accountg($line->numero_compte);
1057 }
1058 //if (empty($accountg)) $accountg = '-';
1059
1060 $colspan = 0; // colspan before field 'label of operation'
1061 $colspanend = 0; // colspan after debit/credit
1062 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1063 $colspan++;
1064 }
1065 if (!empty($arrayfields['t.piece_num']['checked'])) {
1066 $colspan++;
1067 }
1068 if (!empty($arrayfields['t.code_journal']['checked'])) {
1069 $colspan++;
1070 }
1071 if (!empty($arrayfields['t.doc_date']['checked'])) {
1072 $colspan++;
1073 }
1074 if (!empty($arrayfields['t.doc_ref']['checked'])) {
1075 $colspan++;
1076 }
1077 if (!empty($arrayfields['t.label_operation']['checked'])) {
1078 $colspan++;
1079 }
1080 if (!empty($arrayfields['t.lettering_code']['checked'])) {
1081 $colspan++;
1082 }
1083
1084 if (!empty($arrayfields['t.balance']['checked'])) {
1085 $colspanend++;
1086 }
1087 if (!empty($arrayfields['t.date_export']['checked'])) {
1088 $colspanend++;
1089 }
1090 if (!empty($arrayfields['t.date_validated']['checked'])) {
1091 $colspanend++;
1092 }
1093 // Due date
1094 if (!empty($arrayfields['t.date_lim_reglement']['checked'])) {
1095 $colspanend++;
1096 }
1097 if (!empty($arrayfields['t.lettering_code']['checked'])) {
1098 $colspanend++;
1099 }
1100 if (!empty($arrayfields['t.import_key']['checked'])) {
1101 $colspanend++;
1102 }
1103 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1104 $colspan++;
1105 $colspanend--;
1106 }
1107
1108 // Is it a break ?
1109 if ($accountg != $displayed_account_number || !isset($displayed_account_number)) {
1110 // Show a subtotal by accounting account
1111 if (isset($displayed_account_number)) {
1112 print '<tr class="liste_total">';
1113 if ($type == 'sub') {
1114 print '<td class="right" colspan="' . $colspan . '">' . $langs->trans("TotalForAccount") . ' ' . length_accounta($displayed_account_number) . ':</td>';
1115 } else {
1116 print '<td class="right" colspan="' . $colspan . '">' . $langs->trans("TotalForAccount") . ' ' . length_accountg($displayed_account_number) . ':</td>';
1117 }
1118 print '<td class="nowrap right">'.price(price2num($sous_total_debit, 'MT')).'</td>';
1119 print '<td class="nowrap right">'.price(price2num($sous_total_credit, 'MT')).'</td>';
1120 if ($colspanend > 0) {
1121 print '<td colspan="'.$colspanend.'"></td>';
1122 }
1123 print '</tr>';
1124 // Show balance of last shown account
1125 $balance = $sous_total_debit - $sous_total_credit;
1126 print '<tr class="liste_total">';
1127 print '<td class="right" colspan="'.$colspan.'">'.$langs->trans("Balance").':</td>';
1128 if ($balance > 0) {
1129 print '<td class="nowraponall right">';
1130 print price(price2num($sous_total_debit - $sous_total_credit, 'MT'));
1131 print '</td>';
1132 print '<td></td>';
1133 } else {
1134 print '<td></td>';
1135 print '<td class="nowraponall right">';
1136 print price(price2num($sous_total_credit - $sous_total_debit, 'MT'));
1137 print '</td>';
1138 }
1139 if ($colspanend > 0) {
1140 print '<td colspan="'.$colspanend.'"></td>';
1141 }
1142 print '</tr>';
1143 }
1144
1145 // Show the break account
1146 print '<tr class="trforbreak">';
1147 print '<td colspan="'.($totalarray['nbfield'] ? $totalarray['nbfield'] : count($arrayfields) + 1).'" class="tdforbreak">';
1148 if ($type == 'sub') {
1149 if ($line->subledger_account != "" && $line->subledger_account != '-1') {
1150 print empty($line->subledger_label) ? '<span class="error">'.$langs->trans("Unknown").'</span>' : $line->subledger_label;
1151 print ' : ';
1152 print length_accounta($line->subledger_account);
1153 } else {
1154 // Should not happen: subledger account must be null or a non empty value
1155 print '<span class="error">' . $langs->trans("Unknown");
1156 if ($line->subledger_label) {
1157 print ' (' . $line->subledger_label . ')';
1158 $htmltext = 'EmptyStringForSubledgerAccountButSubledgerLabelDefined';
1159 } else {
1160 $htmltext = 'EmptyStringForSubledgerAccountAndSubledgerLabel';
1161 }
1162 print $form->textwithpicto('', $htmltext);
1163 print '</span>';
1164 }
1165 } else {
1166 if ($line->numero_compte != "" && $line->numero_compte != '-1') {
1167 print length_accountg($line->numero_compte) . ' : ' . $object->get_compte_desc($line->numero_compte);
1168 } else {
1169 print '<span class="error">' . $langs->trans("Unknown") . '</span>';
1170 }
1171 }
1172 print '</td>';
1173 print '</tr>';
1174
1175 $displayed_account_number = $accountg;
1176 //if (empty($displayed_account_number)) $displayed_account_number='-';
1177 $sous_total_debit = 0;
1178 $sous_total_credit = 0;
1179
1180 $colspan = 0;
1181 }
1182
1183 print '<tr class="oddeven">';
1184 // Action column
1185 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1186 print '<td class="nowraponall center">';
1187 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
1188 $selected = 0;
1189 if (in_array($line->id, $arrayofselected)) {
1190 $selected = 1;
1191 }
1192 print '<input id="cb' . $line->id . '" class="flat checkforselect" type="checkbox" name="toselect[]" value="' . $line->id . '"' . ($selected ? ' checked="checked"' : '') . ' />';
1193 }
1194 print '</td>';
1195 if (!$i) {
1196 $totalarray['nbfield']++;
1197 }
1198 }
1199 // Piece number
1200 if (!empty($arrayfields['t.piece_num']['checked'])) {
1201 print '<td>';
1202 $object->id = $line->id;
1203 $object->piece_num = $line->piece_num;
1204 print $object->getNomUrl(1, '', 0, '', 1);
1205 print '</td>';
1206 if (!$i) {
1207 $totalarray['nbfield']++;
1208 }
1209 }
1210
1211 // Journal code
1212 if (!empty($arrayfields['t.code_journal']['checked'])) {
1213 $accountingjournal = new AccountingJournal($db);
1214 $result = $accountingjournal->fetch(0, $line->code_journal);
1215 $journaltoshow = (($result > 0) ? $accountingjournal->getNomUrl(0, 0, 0, '', 0) : $line->code_journal);
1216 print '<td class="center tdoverflowmax80">'.$journaltoshow.'</td>';
1217 if (!$i) {
1218 $totalarray['nbfield']++;
1219 }
1220 }
1221
1222 // Document date
1223 if (!empty($arrayfields['t.doc_date']['checked'])) {
1224 print '<td class="center">'.dol_print_date($line->doc_date, 'day').'</td>';
1225 if (!$i) {
1226 $totalarray['nbfield']++;
1227 }
1228 }
1229
1230 // Document ref
1231 $modulepart = '';
1232 if (!empty($arrayfields['t.doc_ref']['checked'])) {
1233 if ($line->doc_type == 'customer_invoice') {
1234 $langs->loadLangs(array('bills'));
1235
1236 require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
1237 $objectstatic = new Facture($db);
1238 $objectstatic->fetch($line->fk_doc);
1239 //$modulepart = 'facture';
1240
1241 $filename = dol_sanitizeFileName($line->doc_ref);
1242 $filedir = $conf->facture->dir_output.'/'.dol_sanitizeFileName($line->doc_ref);
1243 $urlsource = $_SERVER['PHP_SELF'].'?id='.$objectstatic->id;
1244 $documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir);
1245 } elseif ($line->doc_type == 'supplier_invoice') {
1246 $langs->loadLangs(array('bills'));
1247
1248 require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
1249 $objectstatic = new FactureFournisseur($db);
1250 $objectstatic->fetch($line->fk_doc);
1251
1252 $modulepart = 'invoice_supplier';
1253 $filename = dol_sanitizeFileName($line->doc_ref);
1254 $filedir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($line->fk_doc, 2, 0, 0, $objectstatic, $modulepart).dol_sanitizeFileName($line->doc_ref);
1255 $subdir = get_exdir($objectstatic->id, 2, 0, 0, $objectstatic, $modulepart).dol_sanitizeFileName($line->doc_ref);
1256 $documentlink = $formfile->getDocumentsLink($objectstatic->element, $subdir, $filedir);
1257 } elseif ($line->doc_type == 'expense_report') {
1258 $langs->loadLangs(array('trips'));
1259
1260 require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
1261 $objectstatic = new ExpenseReport($db);
1262 $objectstatic->fetch($line->fk_doc);
1263 //$modulepart = 'expensereport';
1264
1265 $filename = dol_sanitizeFileName($line->doc_ref);
1266 $filedir = $conf->expensereport->dir_output.'/'.dol_sanitizeFileName($line->doc_ref);
1267 $urlsource = $_SERVER['PHP_SELF'].'?id='.$objectstatic->id;
1268 $documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir);
1269 } elseif ($line->doc_type == 'bank') {
1270 require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
1271 $objectstatic = new AccountLine($db);
1272 $objectstatic->fetch($line->fk_doc);
1273 } else {
1274 // Other type
1275 }
1276
1277 print '<td class="tdoverflowmax250">';
1278
1279 // Picto + Ref
1280 if ($line->doc_type == 'customer_invoice' || $line->doc_type == 'supplier_invoice' || $line->doc_type == 'expense_report') {
1281 print $objectstatic->getNomUrl(1, '', 0, 0, '', 0, -1, 1);
1282 print $documentlink;
1283 } elseif ($line->doc_type == 'bank') {
1284 print $objectstatic->getNomUrl(1);
1285 $bank_ref = strstr($line->doc_ref, '-');
1286 print " " . $bank_ref;
1287 } else {
1288 print $line->doc_ref;
1289 }
1290
1291 print "</td>\n";
1292 if (!$i) {
1293 $totalarray['nbfield']++;
1294 }
1295 }
1296
1297 // Label operation
1298 if (!empty($arrayfields['t.label_operation']['checked'])) {
1299 // Show a link to the customer/supplier invoice
1300 $doc_ref = preg_replace('/\‍(.*\‍)/', '', $line->doc_ref);
1301 if (strlen(length_accounta($line->subledger_account)) == 0) {
1302 print '<td class="small tdoverflowmax350 classfortooltip" title="'.dol_escape_htmltag($line->label_operation).'">'.dol_escape_htmltag($line->label_operation).'</td>';
1303 } else {
1304 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>';
1305 }
1306 if (!$i) {
1307 $totalarray['nbfield']++;
1308 }
1309 }
1310
1311 // Lettering code
1312 if (!empty($arrayfields['t.lettering_code']['checked'])) {
1313 print '<td class="center">'.dol_escape_htmltag($line->lettering_code).'</td>';
1314 if (!$i) {
1315 $totalarray['nbfield']++;
1316 }
1317 }
1318
1319 // Amount debit
1320 if (!empty($arrayfields['t.debit']['checked'])) {
1321 print '<td class="right nowraponall amount">'.($line->debit != 0 ? price($line->debit) : '').'</td>';
1322 if (!$i) {
1323 $totalarray['nbfield']++;
1324 }
1325 if (!$i) {
1326 $totalarray['pos'][$totalarray['nbfield']] = 'totaldebit';
1327 }
1328 $totalarray['val']['totaldebit'] += (float) $line->debit;
1329 }
1330
1331 // Amount credit
1332 if (!empty($arrayfields['t.credit']['checked'])) {
1333 print '<td class="right nowraponall amount">'.($line->credit != 0 ? price($line->credit) : '').'</td>';
1334 if (!$i) {
1335 $totalarray['nbfield']++;
1336 }
1337 if (!$i) {
1338 $totalarray['pos'][$totalarray['nbfield']] = 'totalcredit';
1339 }
1340 $totalarray['val']['totalcredit'] += (float) $line->credit;
1341 }
1342
1343 // Amount balance
1344 if (!empty($arrayfields['t.balance']['checked'])) {
1345 print '<td class="right nowraponall amount">'.price(price2num($sous_total_debit + $line->debit - $sous_total_credit - $line->credit, 'MT')).'</td>';
1346 if (!$i) {
1347 $totalarray['nbfield']++;
1348 }
1349 if (!$i) {
1350 $totalarray['pos'][$totalarray['nbfield']] = 'totalbalance';
1351 };
1352 $totalarray['val']['totalbalance'] += $line->debit - $line->credit;
1353 }
1354
1355 // Exported operation date
1356 if (!empty($arrayfields['t.date_export']['checked'])) {
1357 print '<td class="center">'.dol_print_date($line->date_export, 'dayhour').'</td>';
1358 if (!$i) {
1359 $totalarray['nbfield']++;
1360 }
1361 }
1362
1363 // Validated operation date
1364 if (!empty($arrayfields['t.date_validated']['checked'])) {
1365 print '<td class="center">'.dol_print_date($line->date_validation, 'dayhour').'</td>';
1366 if (!$i) {
1367 $totalarray['nbfield']++;
1368 }
1369 }
1370
1371 // Due date
1372 if (!empty($arrayfields['t.date_lim_reglement']['checked'])) {
1373 print '<td class="center">'.dol_print_date($line->date_lim_reglement, 'day').'</td>';
1374 if (!$i) {
1375 $totalarray['nbfield']++;
1376 }
1377 }
1378
1379 if (!empty($arrayfields['t.import_key']['checked'])) {
1380 print '<td class="tdoverflowmax125" title="'.dol_escape_htmltag($line->import_key).'">'.dol_escape_htmltag($line->import_key)."</td>\n";
1381 if (!$i) {
1382 $totalarray['nbfield']++;
1383 }
1384 }
1385
1386 // Fields from hook
1387 $parameters = array('arrayfields' => $arrayfields, 'obj' => $line);
1388 $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook
1389 print $hookmanager->resPrint;
1390
1391 // Action column
1392 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1393 print '<td class="nowraponall center">';
1394 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
1395 $selected = 0;
1396 if (in_array($line->id, $arrayofselected)) {
1397 $selected = 1;
1398 }
1399 print '<input id="cb' . $line->id . '" class="flat checkforselect" type="checkbox" name="toselect[]" value="' . $line->id . '"' . ($selected ? ' checked="checked"' : '') . ' />';
1400 }
1401 print '</td>';
1402 if (!$i) {
1403 $totalarray['nbfield']++;
1404 }
1405 }
1406
1407 // Comptabilise le sous-total
1408 $sous_total_debit += $line->debit;
1409 $sous_total_credit += $line->credit;
1410
1411 print "</tr>\n";
1412
1413 $i++;
1414}
1415
1416if ($num > 0 && $colspan > 0) {
1417 print '<tr class="liste_total">';
1418 print '<td class="right" colspan="'.$colspan.'">'.$langs->trans("TotalForAccount").' '.$accountg.':</td>';
1419 print '<td class="nowrap right">'.price(price2num($sous_total_debit, 'MT')).'</td>';
1420 print '<td class="nowrap right">'.price(price2num($sous_total_credit, 'MT')).'</td>';
1421 if ($colspanend > 0) {
1422 print '<td colspan="'.$colspanend.'"></td>';
1423 }
1424 print '</tr>';
1425 // Show balance of last shown account
1426 $balance = $sous_total_debit - $sous_total_credit;
1427 print '<tr class="liste_total">';
1428 print '<td class="right" colspan="'.$colspan.'">'.$langs->trans("Balance").':</td>';
1429 if ($balance > 0) {
1430 print '<td class="nowraponall right">';
1431 print price(price2num($sous_total_debit - $sous_total_credit, 'MT'));
1432 print '</td>';
1433 print '<td></td>';
1434 } else {
1435 print '<td></td>';
1436 print '<td class="nowraponall right">';
1437 print price(price2num($sous_total_credit - $sous_total_debit, 'MT'));
1438 print '</td>';
1439 }
1440 if ($colspanend > 0) {
1441 print '<td colspan="'.$colspanend.'"></td>';
1442 }
1443 print '</tr>';
1444}
1445
1446
1447// Clean total values to round them
1448if (!empty($totalarray['val']['totaldebit'])) {
1449 $totalarray['val']['totaldebit'] = (float) price2num($totalarray['val']['totaldebit'], 'MT');
1450}
1451if (!empty($totalarray['val']['totalcredit'])) {
1452 $totalarray['val']['totalcredit'] = (float) price2num($totalarray['val']['totalcredit'], 'MT');
1453}
1454if (!empty($totalarray['val']['totalbalance'])) {
1455 $totalarray['val']['totalbalance'] = (float) price2num($totalarray['val']['totaldebit'] - $totalarray['val']['totalcredit'], 'MT');
1456}
1457
1458// Show total line
1459include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
1460
1461// If no record found
1462if ($num == 0) {
1463 $colspan = 1;
1464 foreach ($arrayfields as $key => $val) {
1465 if (!empty($val['checked'])) {
1466 $colspan++;
1467 }
1468 }
1469 print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
1470}
1471
1472$parameters = array('arrayfields' => $arrayfields);
1473$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1474print $hookmanager->resPrint;
1475
1476print "</table>";
1477print '</div>';
1478
1479// TODO Replace this with mass delete action
1480//if ($user->hasRight('accounting', 'mouvements, 'supprimer_tous')) {
1481// print '<div class="tabsAction tabsActionNoBottom">'."\n";
1482// print '<a class="butActionDelete" name="button_delmvt" href="'.$_SERVER["PHP_SELF"].'?action=delbookkeepingyear&token='.newToken().($param ? '&'.$param : '').'">'.$langs->trans("DeleteMvt").'</a>';
1483// print '</div>';
1484//}
1485
1486print '</form>';
1487
1488// End of page
1489llxFooter();
1490$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:615
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...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $selectlimitsuffix=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
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.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
getDolGlobalString($key, $default='')
Return a 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...
$objectlink
$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:137
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.