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