dolibarr 25.0.0-alpha
bankentries_list.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2004-2024 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2005-2010 Regis Houssin <regis.houssin@inodbox.com>
5 * Copyright (C) 2012 Vinícius Nogueira <viniciusvgn@gmail.com>
6 * Copyright (C) 2014 Florian Henry <florian.henry@open-cooncept.pro>
7 * Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
8 * Copyright (C) 2016 Juanjo Menent <jmenent@2byte.es>
9 * Copyright (C) 2017-2019 Alexandre Spangaro <aspangaro@open-dsi.fr>
10 * Copyright (C) 2018 Ferran Marcet <fmarcet@2byte.es>
11 * Copyright (C) 2018-2026 Frédéric France <frederic.france@free.fr>
12 * Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
13 * Copyright (C) 2024-2026 MDW <mdeweerd@users.noreply.github.com>
14 *
15 * This program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 3 of the License, or
18 * (at your option) any later version.
19 *
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * You should have received a copy of the GNU General Public License
26 * along with this program. If not, see <https://www.gnu.org/licenses/>.
27 */
28
35// Load Dolibarr environment
36require '../../main.inc.php';
46require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
47require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
48require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php';
49
50require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
51require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
52require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
53require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/bankcateg.class.php';
54require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
55require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php';
56require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/paymentvat.class.php';
57require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
58require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/paymentsocialcontribution.class.php';
59require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php';
60require_once DOL_DOCUMENT_ROOT.'/salaries/class/paymentsalary.class.php';
61require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/paymentvarious.class.php';
62require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/bonprelevement.class.php';
63require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php';
64require_once DOL_DOCUMENT_ROOT.'/don/class/paymentdonation.class.php';
65require_once DOL_DOCUMENT_ROOT.'/expensereport/class/paymentexpensereport.class.php';
66require_once DOL_DOCUMENT_ROOT.'/loan/class/loan.class.php';
67require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php';
68require_once DOL_DOCUMENT_ROOT.'/compta/paiement/cheque/class/remisecheque.class.php';
69
70// Load translation files required by the page
71$langs->loadLangs(array("banks", "bills", "categories", "companies", "margins", "salaries", "loan", "donations", "trips", "members", "compta", "accountancy"));
72
73$id = GETPOSTINT('id');
74$ref = GETPOST('ref', 'alpha');
75$action = GETPOST('action', 'aZ09');
76$cancel = GETPOST('cancel', 'alpha');
77$confirm = GETPOST('confirm', 'alpha');
78$contextpage = 'bankentrieslist';
79$massaction = GETPOST('massaction', 'alpha');
80$optioncss = GETPOST('optioncss', 'aZ09');
81$mode = GETPOST('mode', 'aZ');
82
83$dateop = dol_mktime(12, 0, 0, GETPOSTINT("opmonth"), GETPOSTINT("opday"), GETPOSTINT("opyear"));
84$search_debit = GETPOST("search_debit", 'alpha');
85$search_credit = GETPOST("search_credit", 'alpha');
86$search_type = GETPOST("search_type", 'alpha');
87$search_account = GETPOST("search_account", 'int') ? GETPOST("search_account", 'int') : GETPOST("account", 'int');
88$search_accountancy_code = GETPOST('search_accountancy_code', 'alpha') ? GETPOST('search_accountancy_code', 'alpha') : GETPOST('accountancy_code', 'alpha');
89$search_bid = GETPOST("search_bid", 'int') ? GETPOST("search_bid", 'int') : GETPOST("bid", 'int'); // Category id
90$search_ref = GETPOST('search_ref', 'alpha');
91$search_description = GETPOST("search_description", 'alpha');
92$search_dt_start = dol_mktime(0, 0, 0, GETPOSTINT('search_start_dtmonth'), GETPOSTINT('search_start_dtday'), GETPOSTINT('search_start_dtyear'));
93$search_dt_end = dol_mktime(0, 0, 0, GETPOSTINT('search_end_dtmonth'), GETPOSTINT('search_end_dtday'), GETPOSTINT('search_end_dtyear'));
94$search_dv_start = dol_mktime(0, 0, 0, GETPOSTINT('search_start_dvmonth'), GETPOSTINT('search_start_dvday'), GETPOSTINT('search_start_dvyear'));
95$search_dv_end = dol_mktime(0, 0, 0, GETPOSTINT('search_end_dvmonth'), GETPOSTINT('search_end_dvday'), GETPOSTINT('search_end_dvyear'));
96$search_thirdparty_user = GETPOST("search_thirdparty", 'alpha') ? GETPOST("search_thirdparty", 'alpha') : GETPOST("thirdparty", 'alpha');
97$search_req_nb = GETPOST("req_nb", 'alpha');
98$search_num_releve = GETPOST("search_num_releve", 'alpha');
99$search_conciliated = GETPOST("search_conciliated", 'int');
100$search_fk_bordereau = GETPOST("search_fk_bordereau", 'int');
101$optioncss = GETPOST('optioncss', 'alpha');
102$toselect = GETPOST('toselect', 'array:int');
103$num_releve = GETPOST("num_releve", "alpha");
104if (empty($dateop)) {
105 $dateop = -1;
106}
107
108$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
109$sortfield = GETPOST('sortfield', 'aZ09comma');
110$sortorder = GETPOST('sortorder', 'aZ09comma');
111$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT('page');
112if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
113 // If $page is not defined, or '' or -1 or if we click on clear filters
114 $page = 0;
115}
116$offset = $limit * $page;
117$pageprev = $page - 1;
118$pagenext = $page + 1;
119if (!$sortorder) {
120 $sortorder = 'desc,desc,desc';
121}
122if (!$sortfield) {
123 $sortfield = 'b.datev,b.dateo,b.rowid';
124}
125
126$object = new Account($db);
127if ($id > 0 || !empty($ref)) {
128 $result = $object->fetch($id, $ref);
129 $search_account = $object->id; // Force the search field on id of account
130
131 if (!($object->id > 0)) {
132 recordNotFound('', 0);
133 }
134}
135
136// redefine contextpage to depend on bank account
137$contextpage = 'banktransactionlist'.(empty($object->id) ? '' : '-'.$object->id);
138
139$mode_balance_ok = false;
140//if (($sortfield == 'b.datev' || $sortfield == 'b.datev,b.dateo,b.rowid')) // TODO Manage balance when account not selected
141if (($sortfield == 'b.datev' || $sortfield == 'b.datev,b.dateo,b.rowid')) {
142 $sortfield = 'b.datev,b.dateo,b.rowid';
143 if ($id > 0 || !empty($ref) || $search_account > 0) {
144 $mode_balance_ok = true;
145 }
146}
147
148// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
149$hookmanager->initHooks(array('banktransactionlist', $contextpage));
150
151$extrafieldsobjectkey = 'bank'; // Used by extrafields_..._tpl.php
152
153// fetch optionals attributes and labels
154$extrafields->fetch_name_optionals_label($extrafieldsobjectkey);
155$search_array_options = $extrafields->getOptionalsFromPost($extrafieldsobjectkey, '', 'search_');
156
157$arrayfields = array(
158 'b.rowid' => array('label' => $langs->trans("Ref"), 'checked' => '1','position' => 10),
159 'b.label' => array('label' => $langs->trans("Description"), 'checked' => '1','position' => 20),
160 'b.dateo' => array('label' => $langs->trans("DateOperationShort"), 'checked' => '-1','position' => 30),
161 'b.datev' => array('label' => $langs->trans("DateValueShort"), 'checked' => '1','position' => 40),
162 'type' => array('label' => $langs->trans("Type"), 'checked' => '1','position' => 50),
163 'b.num_chq' => array('label' => $langs->trans("Numero"), 'checked' => '0','position' => 60),
164 'b.fk_bordereau' => array('label' => $langs->trans("ChequeNumber"), 'checked' => '0', 'position' => 65),
165 'bu.label' => array('label' => $langs->trans("ThirdParty").'/'.$langs->trans("User"), 'checked' => '1', 'position' => 70),
166 'ba.ref' => array('label' => $langs->trans("BankAccount"), 'checked' => (($id > 0 || !empty($ref)) ? '0' : '1'), 'position' => 80),
167 'b.debit' => array('label' => $langs->trans("Debit"), 'checked' => '1', 'position' => 90),
168 'b.credit' => array('label' => $langs->trans("Credit"), 'checked' => '1', 'position' => 100),
169 'balancebefore' => array('label' => $langs->trans("BalanceBefore"), 'checked' => '0', 'position' => 110),
170 'balance' => array('label' => $langs->trans("Balance"), 'checked' => '1', 'position' => 120),
171 'b.num_releve' => array('label' => $langs->trans("AccountStatement"), 'checked' => '1', 'position' => 130),
172 'b.conciliated' => array('label' => $langs->trans("BankLineReconciled"), 'enabled' => (string) (int) $object->rappro, 'checked' => ($action == 'reconcile' ? '1' : '0'), 'position' => 140),
173);
174// Extra fields
175include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
176// Add hook to complete $arrayfield
177$parameters = array('arrayfields' => &$arrayfields);
178$reshook = $hookmanager->executeHooks('completeArrayFields', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
179
180$object->fields = dol_sort_array($object->fields, 'position');
181$arrayfields = dol_sort_array($arrayfields, 'position');
182
183// Security check
184$fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref : ''));
185$fieldtype = (!empty($ref) ? 'ref' : 'rowid');
186if ($fieldvalue) {
187 if ($user->socid) {
188 $socid = $user->socid;
189 }
190 $result = restrictedArea($user, 'banque', $fieldvalue, 'bank_account&bank_account', '', '', $fieldtype);
191} else {
192 if ($user->socid) {
193 $socid = $user->socid;
194 }
195 $result = restrictedArea($user, 'banque');
196}
197
198
199/*
200 * Actions
201 */
202
203if (GETPOST('cancel', 'alpha')) {
204 $action = 'list';
205 $massaction = '';
206}
207if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
208 $massaction = '';
209}
210
211$parameters = array();
212$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
213if ($reshook < 0) {
214 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
215}
216
217include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
218
219if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
220 $search_dt_start = '';
221 $search_dt_end = '';
222 $search_dv_start = '';
223 $search_dv_end = '';
224 $search_type = "";
225 $search_debit = "";
226 $search_credit = "";
227 $search_bid = "";
228 $search_ref = "";
229 $search_req_nb = '';
230 $search_description = '';
231 $search_thirdparty_user = '';
232 $search_num_releve = '';
233 $search_conciliated = '';
234 $search_fk_bordereau = '';
235 $toselect = array();
236
237 $search_account = "";
238 if ($id > 0 || !empty($ref)) {
239 $search_account = $object->id;
240 }
241}
242
243if (empty($reshook)) {
244 $objectclass = 'Account';
245 $objectlabel = 'BankTransaction';
246 $permissiontoread = $user->hasRight('banque', 'lire');
247 $permissiontodelete = $user->hasRight('banque', 'modifier');
248 $uploaddir = $conf->bank->dir_output;
249 include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
250}
251
252$rowids = GETPOST('rowid', 'array:int');
253
254// Conciliation
255if ((GETPOST('confirm_savestatement', 'alpha') || GETPOST('confirm_reconcile', 'alpha'))
256 && (GETPOST("num_releve", "alpha") || !empty($rowids))
257 && $user->hasRight('banque', 'consolidate')
258 && (!GETPOSTISSET('pageplusone') || (GETPOST('pageplusone') == GETPOST('pageplusoneold')))) {
259 $error = 0;
260
261 // Definition, nettoyage parameters
262 $num_releve = GETPOST("num_releve", "alpha");
263
264 if ($num_releve) {
265 $bankline = new AccountLine($db);
266
267 $rowids = GETPOST('rowid', 'array:int');
268
269 if (!empty($rowids) && is_array($rowids)) {
270 foreach ($rowids as $row) {
271 if ($row > 0) {
272 $result = $bankline->fetch($row);
273 $bankline->num_releve = $num_releve; // GETPOST("num_releve");
274 $result = $bankline->update_conciliation($user, GETPOSTINT("cat"), GETPOST('confirm_reconcile', 'alpha') ? 1 : 0); // If we confirm_reconcile, we set flag 'rappro' to 1.
275 if ($result < 0) {
276 setEventMessages($bankline->error, $bankline->errors, 'errors');
277 $error++;
278 break;
279 }
280 }
281 }
282 if (!$error && count($rowids) > 0) {
283 setEventMessages($langs->trans("XNewLinesConciliated", count($rowids)), null);
284 }
285 } else {
286 $error++;
287 $langs->load("errors");
288 setEventMessages($langs->trans("NoRecordSelected"), null, 'errors');
289 }
290 } else {
291 $error++;
292 $langs->load("errors");
293 setEventMessages($langs->trans("ErrorPleaseTypeBankTransactionReportName"), null, 'errors');
294 }
295
296 if (!$error) {
297 $param = 'action=reconcile&contextpage=banktransactionlist&id='.((int) $object->id).'&search_account='.((int) $object->id);
298 if ($page) {
299 $param .= '&page='.urlencode((string) ($page));
300 }
301 if ($offset) {
302 $param .= '&offset='.urlencode((string) ($offset));
303 }
304 if ($limit) {
305 $param .= '&limit='.((int) $limit);
306 }
307 if ($search_conciliated != '' && $search_conciliated != '-1') {
308 $param .= '&search_conciliated='.urlencode((string) ($search_conciliated));
309 }
310 if ($search_thirdparty_user) {
311 $param .= '&search_thirdparty='.urlencode($search_thirdparty_user);
312 }
313 if ($search_num_releve) {
314 $param .= '&search_num_releve='.urlencode($search_num_releve);
315 }
316 if ($search_description) {
317 $param .= '&search_description='.urlencode($search_description);
318 }
319 if (dol_strlen($search_dt_start) > 0) {
320 $param .= '&search_start_dtmonth='.GETPOSTINT('search_start_dtmonth').'&search_start_dtday='.GETPOSTINT('search_start_dtday').'&search_start_dtyear='.GETPOSTINT('search_start_dtyear');
321 }
322 if (dol_strlen($search_dt_end) > 0) {
323 $param .= '&search_end_dtmonth='.GETPOSTINT('search_end_dtmonth').'&search_end_dtday='.GETPOSTINT('search_end_dtday').'&search_end_dtyear='.GETPOSTINT('search_end_dtyear');
324 }
325 if (dol_strlen($search_dv_start) > 0) {
326 $param .= '&search_start_dvmonth='.GETPOSTINT('search_start_dvmonth').'&search_start_dvday='.GETPOSTINT('search_start_dvday').'&search_start_dvyear='.GETPOSTINT('search_start_dvyear');
327 }
328 if (dol_strlen($search_dv_end) > 0) {
329 $param .= '&search_end_dvmonth='.GETPOSTINT('search_end_dvmonth').'&search_end_dvday='.GETPOSTINT('search_end_dvday').'&search_end_dvyear='.GETPOSTINT('search_end_dvyear');
330 }
331 if ($search_type) {
332 $param .= '&search_type='.urlencode($search_type);
333 }
334 if ($search_debit) {
335 $param .= '&search_debit='.urlencode($search_debit);
336 }
337 if ($search_credit) {
338 $param .= '&search_credit='.urlencode($search_credit);
339 }
340 $param .= '&sortfield='.urlencode($sortfield).'&sortorder='.urlencode($sortorder);
341 header('Location: '.$_SERVER["PHP_SELF"].'?'.$param); // To avoid to submit twice and allow the back button
342 exit;
343 }
344}
345
346
347if (GETPOST('save') && !$cancel && $user->hasRight('banque', 'modifier')) {
348 $error = 0;
349
350 if (price2num(GETPOST("addcredit")) > 0) {
351 $amount = price2num(GETPOST("addcredit"));
352 } else {
353 $amount = price2num(-1 * (float) price2num(GETPOST("adddebit")));
354 }
355
356 $operation = GETPOST("operation", 'alpha');
357 $num_chq = GETPOST("num_chq", 'alpha');
358 $label = GETPOST("label", 'alpha');
359 $cat1 = GETPOST("cat1", 'alpha');
360
361 $bankaccountid = $id;
362 if (GETPOSTINT('add_account') > 0) {
363 $bankaccountid = GETPOSTINT('add_account');
364 }
365 if (!$dateop) {
366 $error++;
367 setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), null, 'errors');
368 }
369 if (!$operation) {
370 $error++;
371 setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), null, 'errors');
372 }
373 if (!$label) {
374 $error++;
375 setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors');
376 }
377 if (!$amount) {
378 $error++;
379 setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Amount")), null, 'errors');
380 }
381 if (!($bankaccountid > 0)) {
382 $error++;
383 setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BankAccount")), null, 'errors');
384 }
385 /*if (isModEnabled('accounting') && (empty($search_accountancy_code) || $search_accountancy_code == '-1'))
386 {
387 setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("AccountAccounting")), null, 'errors');
388 $error++;
389 }*/
390
391 if (!$error && getDolGlobalString('BANK_USE_OLD_VARIOUS_PAYMENT')) {
392 $objecttmp = new Account($db);
393 $objecttmp->fetch($bankaccountid);
394 $insertid = $objecttmp->addline((int) $dateop, $operation, $label, (float) $amount, $num_chq, ($cat1 > 0 ? $cat1 : 0), $user, '', '', $search_accountancy_code);
395 if ($insertid > 0) {
396 setEventMessages($langs->trans("RecordSaved"), null, 'mesgs');
397 header("Location: ".$_SERVER['PHP_SELF'].($id ? "?id=".$id : ''));
398 exit;
399 } else {
400 setEventMessages($object->error, $object->errors, 'errors');
401 }
402 } else {
403 $action = 'addline';
404 }
405}
406
407if ($action == 'confirm_deleteonreconcile' && $confirm == 'yes' && $user->hasRight('banque', 'modifier')) {
408 $accline = new AccountLine($db);
409 $result = $accline->fetch(GETPOSTINT("rowid"));
410 $result = $accline->delete($user);
411 if ($result <= 0) {
412 setEventMessages($accline->error, $accline->errors, 'errors');
413 } else {
414 setEventMessages('RecordDeleted', null, 'mesgs');
415 }
416
417 $action = 'reconcile';
418}
419
420if ($action == 'confirm_delete' && $confirm == 'yes' && $user->hasRight('banque', 'modifier')) {
421 $accline = new AccountLine($db);
422 $result = $accline->fetch(GETPOSTINT("rowid"));
423 $result = $accline->delete($user);
424 if ($result <= 0) {
425 setEventMessages($accline->error, $accline->errors, 'errors');
426 } else {
427 setEventMessages('RecordDeleted', null, 'mesgs');
428 }
429}
430
431
432/*
433 * View
434 */
435
436$form = new Form($db);
437$formother = new FormOther($db);
438$formaccounting = new FormAccounting($db);
439
440$companystatic = new Societe($db);
441$bankaccountstatic = new Account($db);
442$userstatic = new User($db);
443
444$banktransferstatic = new BonPrelevement($db);
445$societestatic = new Societe($db);
446$userstatic = new User($db);
447$chargestatic = new ChargeSociales($db);
448$loanstatic = new Loan($db);
449$memberstatic = new Adherent($db);
450$donstatic = new Don($db);
451$paymentstatic = new Paiement($db);
452$paymentsupplierstatic = new PaiementFourn($db);
453$paymentscstatic = new PaymentSocialContribution($db);
454$paymentvatstatic = new PaymentVAT($db);
455$paymentsalstatic = new PaymentSalary($db);
456$paymentdonationstatic = new PaymentDonation($db);
457$paymentvariousstatic = new PaymentVarious($db);
458$paymentexpensereportstatic = new PaymentExpenseReport($db);
459$bankstatic = new Account($db);
460$banklinestatic = new AccountLine($db);
461$bordereaustatic = new RemiseCheque($db);
462
463$now = dol_now();
464
465// Must be before button action
466$param = '';
467if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
468 $param .= '&contextpage='.urlencode($contextpage);
469}
470if ($limit > 0 && $limit != $conf->liste_limit) {
471 $param .= '&limit='.((int) $limit);
472}
473if ($id > 0) {
474 $param .= '&id='.urlencode((string) ($id));
475}
476if (!empty($ref)) {
477 $param .= '&ref='.urlencode($ref);
478}
479if (!empty($search_ref)) {
480 $param .= '&search_ref='.urlencode($search_ref);
481}
482if (!empty($search_description)) {
483 $param .= '&search_description='.urlencode($search_description);
484}
485if (!empty($search_type)) {
486 $param .= '&type='.urlencode($search_type);
487}
488if (!empty($search_thirdparty_user)) {
489 $param .= '&search_thirdparty='.urlencode($search_thirdparty_user);
490}
491if (!empty($search_debit)) {
492 $param .= '&search_debit='.urlencode($search_debit);
493}
494if (!empty($search_credit)) {
495 $param .= '&search_credit='.urlencode($search_credit);
496}
497if ($search_account > 0) {
498 $param .= '&search_account='.((int) $search_account);
499}
500if (!empty($search_num_releve)) {
501 $param .= '&search_num_releve='.urlencode($search_num_releve);
502}
503if ($search_conciliated != '' && $search_conciliated != '-1') {
504 $param .= '&search_conciliated='.urlencode((string) ($search_conciliated));
505}
506if ($search_fk_bordereau > 0) {
507 $param .= '$&search_fk_bordereau='.urlencode((string) ($search_fk_bordereau));
508}
509if ($search_bid > 0) { // Category id
510 $param .= '&search_bid='.((int) $search_bid);
511}
512if (dol_strlen($search_dt_start) > 0) {
513 $param .= '&search_start_dtmonth='.GETPOSTINT('search_start_dtmonth').'&search_start_dtday='.GETPOSTINT('search_start_dtday').'&search_start_dtyear='.GETPOSTINT('search_start_dtyear');
514}
515if (dol_strlen($search_dt_end) > 0) {
516 $param .= '&search_end_dtmonth='.GETPOSTINT('search_end_dtmonth').'&search_end_dtday='.GETPOSTINT('search_end_dtday').'&search_end_dtyear='.GETPOSTINT('search_end_dtyear');
517}
518if (dol_strlen($search_dv_start) > 0) {
519 $param .= '&search_start_dvmonth='.GETPOSTINT('search_start_dvmonth').'&search_start_dvday='.GETPOSTINT('search_start_dvday').'&search_start_dvyear='.GETPOSTINT('search_start_dvyear');
520}
521if (dol_strlen($search_dv_end) > 0) {
522 $param .= '&search_end_dvmonth='.GETPOSTINT('search_end_dvmonth').'&search_end_dvday='.GETPOSTINT('search_end_dvday').'&search_end_dvyear='.GETPOSTINT('search_end_dvyear');
523}
524if ($search_req_nb) {
525 $param .= '&req_nb='.urlencode($search_req_nb);
526}
527if (GETPOSTINT("search_thirdparty")) {
528 $param .= '&thirdparty='.urlencode((string) (GETPOSTINT("search_thirdparty")));
529}
530if ($optioncss != '') {
531 $param .= '&optioncss='.urlencode($optioncss);
532}
533if ($action == 'reconcile' || $action == 'confirm_deleteonreconcile') {
534 $param .= '&action=reconcile';
535}
536$totalarray = array(
537 'nbfield' => 0,
538 'totalcred' => 0,
539 'totaldeb' => 0,
540);
541// Add $param from extra fields
542include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
543
544$options = array();
545
546$buttonreconcile = '';
547$morehtmlref = '';
548
549if ($id > 0 || !empty($ref)) {
550 $title = $object->ref.' - '.$langs->trans("Transactions");
551} else {
552 $title = $langs->trans("BankTransactions");
553}
554$help_url = '';
555
556llxHeader('', $title, $help_url, '', 0, 0, array(), array(), $param);
557
558
559if ($id > 0 || !empty($ref)) {
560 // Load bank groups
561 require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/bankcateg.class.php';
562 $bankcateg = new BankCateg($db);
563
564 $arrayofbankcateg = $bankcateg->fetchAll();
565 foreach ($arrayofbankcateg as $bankcategory) {
566 $options[$bankcategory->id] = $bankcategory->label;
567 }
568
569 // Bank card
570 $head = bank_prepare_head($object);
571 $activetab = 'journal';
572 if ($action == 'reconcile' || $action == 'confirm_deleteonreconcile') {
573 $activetab = 'reconcile';
574 }
575 print dol_get_fiche_head($head, $activetab, $langs->trans("FinancialAccount"), 0, 'account');
576
577 $linkback = '<a href="'.DOL_URL_ROOT.'/compta/bank/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
578
579 dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0, '', '', 1);
580
581 print dol_get_fiche_end();
582}
583
584$sql = "SELECT b.rowid, b.dateo as do, b.datev as dv, b.amount, b.label, b.rappro as conciliated, b.num_releve, b.num_chq,";
585$sql .= " b.fk_account, b.fk_type, b.fk_bordereau,";
586$sql .= " ba.rowid as bankid, ba.ref as bankref";
587// Add fields from extrafields
588if (!empty($extrafields->attributes[$extrafieldsobjectkey]['label'])) {
589 foreach ($extrafields->attributes[$extrafieldsobjectkey]['label'] as $key => $val) {
590 $sql .= ($extrafields->attributes[$extrafieldsobjectkey]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : '');
591 }
592}
593// Add fields from hooks
594$parameters = array();
595$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
596$sql .= $hookmanager->resPrint;
597$sql .= " FROM ";
598if ($search_bid > 0) {
599 $sql .= MAIN_DB_PREFIX."category_bankline as l,";
600}
601$sql .= " ".MAIN_DB_PREFIX."bank_account as ba,";
602$sql .= " ".MAIN_DB_PREFIX."bank as b";
603if (!empty($extrafields->attributes[$extrafieldsobjectkey]['label']) && is_array($extrafields->attributes[$extrafieldsobjectkey]['label']) && count($extrafields->attributes[$extrafieldsobjectkey]['label'])) {
604 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$extrafieldsobjectkey."_extrafields as ef on (b.rowid = ef.fk_object)";
605}
606
607// Add fields from hooks
608$parameters = array();
609$reshook = $hookmanager->executeHooks('printFieldListJoin', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
610$sql .= $hookmanager->resPrint;
611
612$sql .= " WHERE b.fk_account = ba.rowid";
613$sql .= " AND ba.entity IN (".getEntity('bank_account').")";
614if ($search_account > 0) {
615 $sql .= " AND b.fk_account = ".((int) $search_account);
616}
617// Search period criteria
618if (dol_strlen($search_dt_start) > 0) {
619 $sql .= " AND b.dateo >= '".$db->idate($search_dt_start)."'";
620}
621if (dol_strlen($search_dt_end) > 0) {
622 $sql .= " AND b.dateo <= '".$db->idate($search_dt_end)."'";
623}
624// Search period criteria
625if (dol_strlen($search_dv_start) > 0) {
626 $sql .= " AND b.datev >= '".$db->idate($search_dv_start)."'";
627}
628if (dol_strlen($search_dv_end) > 0) {
629 $sql .= " AND b.datev <= '".$db->idate($search_dv_end)."'";
630}
631if ($search_ref) {
632 $sql .= natural_search("b.rowid", $search_ref, 1);
633}
634if ($search_req_nb) {
635 $sql .= natural_search("b.num_chq", $search_req_nb);
636}
637if ($search_num_releve) {
638 $sql .= natural_search("b.num_releve", $search_num_releve);
639}
640if ($search_conciliated != '' && $search_conciliated != '-1') {
641 $sql .= " AND b.rappro = ".((int) $search_conciliated);
642}
643if ($search_fk_bordereau > 0) {
644 $sql .= " AND b.fk_bordereau = " . ((int) $search_fk_bordereau);
645}
646if ($search_thirdparty_user) {
647 $sql .= " AND (b.rowid IN ";
648 $sql .= " ( SELECT bu.fk_bank FROM ".MAIN_DB_PREFIX."bank_url AS bu";
649 $sql .= " JOIN ".MAIN_DB_PREFIX."bank AS b2 ON b2.rowid = bu.fk_bank";
650 $sql .= " JOIN ".MAIN_DB_PREFIX."user AS subUser ON (bu.type = 'user' AND bu.url_id = subUser.rowid)";
651 $sql .= " WHERE ". natural_search(array("subUser.firstname", "subUser.lastname"), $search_thirdparty_user, 0, 1).")";
652
653 $sql .= " OR b.rowid IN ";
654 $sql .= " ( SELECT bu.fk_bank FROM ".MAIN_DB_PREFIX."bank_url AS bu";
655 $sql .= " JOIN ".MAIN_DB_PREFIX."bank AS b2 ON b2.rowid = bu.fk_bank";
656 $sql .= " JOIN ".MAIN_DB_PREFIX."societe AS subSoc ON (bu.type = 'company' AND bu.url_id = subSoc.rowid)";
657 $sql .= " WHERE ". natural_search(array("subSoc.nom"), $search_thirdparty_user, 0, 1);
658 $sql .= "))";
659}
660if ($search_description) {
661 $search_description_to_use = $search_description;
662 $arrayoffixedlabels = array(
663 'payment_salary',
664 'CustomerInvoicePayment',
665 'CustomerInvoicePaymentBack',
666 'SupplierInvoicePayment',
667 'SupplierInvoicePaymentBack',
668 'DonationPayment',
669 'ExpenseReportPayment',
670 'SocialContributionPayment',
671 'SubscriptionPayment',
672 'WithdrawalPayment'
673 );
674 foreach ($arrayoffixedlabels as $keyforlabel) {
675 $translatedlabel = $langs->transnoentitiesnoconv($keyforlabel);
676 if (preg_match('/'.$search_description.'/i', $translatedlabel)) {
677 $search_description_to_use .= "|".$keyforlabel;
678 }
679 }
680 $sql .= natural_search("b.label", $search_description_to_use); // Warning some text are just translation keys, not translated strings
681}
682
683if ($search_bid > 0) {
684 $sql .= " AND b.rowid = l.lineid AND l.fk_categ = ".((int) $search_bid);
685}
686if (!empty($search_type)) {
687 $sql .= " AND b.fk_type = '".$db->escape($search_type)."'";
688}
689// Search criteria amount
690if ($search_debit) {
691 $sql .= natural_search('-b.amount', $search_debit, 1);
692 $sql .= ' AND b.amount <= 0';
693}
694if ($search_credit) {
695 $sql .= natural_search('b.amount', $search_credit, 1);
696 $sql .= ' AND b.amount >= 0';
697}
698// Add where from extra fields
699include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
700
701// Add where from hooks
702$parameters = array();
703$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
704$sql .= $hookmanager->resPrint;
705
706$sql .= $db->order($sortfield, $sortorder);
707
708$nbtotalofrecords = '';
709$nbtotalofpages = 0;
710if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
711 $result = $db->query($sql);
712 $nbtotalofrecords = $db->num_rows($result);
713 $nbtotalofpages = ceil($nbtotalofrecords / $limit);
714}
715
716if (($id > 0 || !empty($ref)) && ((string) $page == '')) {
717 // We open a list of transaction of a dedicated account and no page was set by default
718 // We force on last page.
719 $page = ($nbtotalofpages - 1);
720 $offset = $limit * $page;
721 if ($page < 0) {
722 $page = 0;
723 }
724}
725if ($page >= $nbtotalofpages) {
726 // If we made a search and result has low page than the page number we were on
727 $page = ($nbtotalofpages - 1);
728 $offset = $limit * $page;
729 if ($page < 0) {
730 $page = 0;
731 }
732}
733
734
735// If not account defined $mode_balance_ok=false
736if (empty($search_account)) {
737 $mode_balance_ok = false;
738}
739// If a search is done $mode_balance_ok=false
740if (!empty($search_ref)) {
741 $mode_balance_ok = false;
742}
743if (!empty($search_description)) {
744 $mode_balance_ok = false;
745}
746if (!empty($search_type)) {
747 $mode_balance_ok = false;
748}
749if (!empty($search_debit)) {
750 $mode_balance_ok = false;
751}
752if (!empty($search_credit)) {
753 $mode_balance_ok = false;
754}
755if (!empty($search_thirdparty_user)) {
756 $mode_balance_ok = false;
757}
758if ($search_conciliated != '' && $search_conciliated != '-1') {
759 $mode_balance_ok = false;
760}
761if (!empty($search_num_releve)) {
762 $mode_balance_ok = false;
763}
764if (!empty($search_fk_bordereau)) {
765 $mode_balance_ok = false;
766}
767
768$sql .= $db->plimit($limit + 1, $offset);
769//print $sql;
770dol_syslog('compta/bank/bankentries_list.php', LOG_DEBUG);
771$resql = $db->query($sql);
772if ($resql) {
773 $num = $db->num_rows($resql);
774
775 $arrayofselected = (!empty($toselect) && is_array($toselect)) ? $toselect : array();
776
777 // List of mass actions available
778 $arrayofmassactions = array(
779 //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
780 //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
781 );
782 if (in_array($massaction, array('presend', 'predelete'))) {
783 $arrayofmassactions = array();
784 }
785 $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
786
787 // Confirmation delete
788 if ($action == 'delete') {
789 $text = $langs->trans('ConfirmDeleteTransaction');
790 print $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id.'&rowid='.GETPOSTINT("rowid"), $langs->trans('DeleteTransaction'), $text, 'confirm_delete', null, '', 1);
791 }
792
793 // Lines of title fields
794 print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'" name="search_form">'."\n";
795 if ($optioncss != '') {
796 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
797 }
798 print '<input type="hidden" name="token" value="'.newToken().'">';
799 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
800 print '<input type="hidden" name="action" value="'.($action != 'delete' ? $action : 'search').'">';
801 if (!empty($mode)) {
802 print '<input type="hidden" name="mode" value="'.dol_escape_htmltag($mode).'">';
803 }
804 print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
805 print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
806 print '<input type="hidden" name="page" value="'.$page.'">';
807 print '<input type="hidden" name="id" value="'.$id.'">';
808 print '<input type="hidden" name="ref" value="'.$ref.'">';
809 if (GETPOSTINT('bid')) {
810 print '<input type="hidden" name="bid" value="'.GETPOSTINT("bid").'">';
811 }
812
813 // Form to add a transaction with no invoice
814 if ($user->hasRight('banque', 'modifier') && $action == 'addline' && getDolGlobalString('BANK_USE_OLD_VARIOUS_PAYMENT')) {
815 print load_fiche_titre($langs->trans("AddBankRecordLong"), '', '');
816
817 print '<table class="noborder centpercent">';
818
819 print '<tr class="liste_titre">';
820 print '<td>'.$langs->trans("Description").'</td>';
821 print '<td>'.$langs->trans("Date").'</td>';
822 print '<td>&nbsp;</td>';
823 print '<td>'.$langs->trans("Type").'</td>';
824 print '<td>'.$langs->trans("Numero").'</td>';
825 print '<td class=right>'.$langs->trans("BankAccount").'</td>';
826 print '<td class=right>'.$langs->trans("Debit").'</td>';
827 print '<td class=right>'.$langs->trans("Credit").'</td>';
828 /*if (isModEnabled('accounting'))
829 {
830 print '<td class="center">';
831 print $langs->trans("AccountAccounting");
832 print '</td>';
833 }*/
834 print '<td class="center">&nbsp;</td>';
835 print '</tr>';
836
837 print '<tr>';
838 print '<td>';
839 print '<input name="label" class="flat minwidth200" type="text" value="'.GETPOST("label", "alpha").'">';
840 if (is_array($options) && count($options)) {
841 print '<br>'.$langs->trans("Rubrique").': ';
842 print Form::selectarray('cat1', $options, GETPOST('cat1'), 1);
843 }
844 print '</td>';
845 print '<td class="nowrap">';
846 print $form->selectDate(empty($dateop) ? -1 : $dateop, 'op', 0, 0, 0, 'transaction');
847 print '</td>';
848 print '<td>&nbsp;</td>';
849 print '<td class="nowrap">';
850 print $form->select_types_paiements((GETPOST('operation') ? GETPOST('operation') : ($object->type == Account::TYPE_CASH ? 'LIQ' : '')), 'operation', '1,2', 2, 1, 0, 0, 1, '', 1);
851 print '</td>';
852 print '<td>';
853 print '<input name="num_chq" class="flat" type="text" size="4" value="'.GETPOST("num_chq", "alpha").'">';
854 print '</td>';
855 //if (! $search_account > 0)
856 //{
857 print '<td class=right>';
858 print $form->select_comptes(GETPOSTINT('add_account') ? GETPOSTINT('add_account') : $search_account, 'add_account', 0, '', 1, ($id > 0 || !empty($ref) ? ' disabled="disabled"' : ''), 0, '', 1);
859 print '</td>';
860 //}
861 print '<td class="right"><input name="adddebit" class="flat" type="text" size="4" value="'.GETPOST("adddebit", "alpha").'"></td>';
862 print '<td class="right"><input name="addcredit" class="flat" type="text" size="4" value="'.GETPOST("addcredit", "alpha").'"></td>';
863 /*if (isModEnabled('accounting'))
864 {
865 print '<td class="center">';
866 print $formaccounting->select_account($search_accountancy_code, 'search_accountancy_code', 1, null, 1, 1, '');
867 print '</td>';
868 }*/
869 print '<td class="center">';
870 print '<input type="submit" name="save" class="button buttongen marginbottomonly button-add" value="'.$langs->trans("Add").'"><br>';
871 print '<input type="submit" name="cancel" class="button buttongen marginbottomonly button-cancel" value="'.$langs->trans("Cancel").'">';
872 print '</td></tr>';
873
874 print '</table>';
875 print '<br>';
876 }
877
878 // Code to adjust value date with plus and less picto using an Ajax call instead of a full reload of page
879 $urlajax = DOL_URL_ROOT.'/core/ajax/bankconciliate.php?format=dayreduceformat&token='.currentToken();
880 print '
881 <script type="text/javascript">
882 $(function() {
883 $("a.ajaxforbankoperationchange").each(function(){
884 var current = $(this);
885 current.click(function()
886 {
887 var url = "'.$urlajax.'&"+current.attr("href").split("?")[1];
888 console.log("We click on ajaxforbankoperationchange url="+url);
889 $.get(url, function(data)
890 {
891 console.log(data);
892 current.parent().parent().find(".spanforajaxedit").replaceWith(data);
893 });
894 return false;
895 });
896 });
897 });
898 </script>
899 ';
900
901 $i = 0;
902
903 // Title
904 $bankcateg = new BankCateg($db);
905
906 $newcardbutton = '';
907 if ($action != 'addline') {
908 if (!getDolGlobalString('BANK_DISABLE_DIRECT_INPUT')) {
909 if ($object->status == $object::STATUS_CLOSED) {
910 $newcardbutton = dolGetButtonTitle($langs->trans('AddBankRecord'), 'Bank account is closed', 'fa fa-plus-circle', $_SERVER["PHP_SELF"].'?action=addline&token='.newToken().'&page='.$page.$param, '', -2);
911 } else {
912 if (!getDolGlobalString('BANK_USE_OLD_VARIOUS_PAYMENT')) { // Default is to record miscellaneous direct entries using miscellaneous payments
913 $newcardbutton = dolGetButtonTitle($langs->trans('AddBankRecord'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/compta/bank/various_payment/card.php?action=create&accountid='.urlencode($search_account).'&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.urlencode($search_account)), '', $user->hasRight('banque', 'modifier'));
914 } else { // If direct entries is not done using miscellaneous payments
915 $newcardbutton = dolGetButtonTitle($langs->trans('AddBankRecord'), '', 'fa fa-plus-circle', $_SERVER["PHP_SELF"].'?action=addline&token='.newToken().'&page='.$page.$param, '', $user->hasRight('banque', 'modifier'));
916 }
917 }
918 } else {
919 $newcardbutton = dolGetButtonTitle($langs->trans('AddBankRecord'), 'Direct input in bank lines has been disabled by option BANK_DISABLE_DIRECT_INPUT', 'fa fa-plus-circle', $_SERVER["PHP_SELF"].'?action=addline&token='.newToken().'&page='.$page.$param, '', -2);
920 }
921 }
922
923 $morehtml = '';
924
925 if ($action != 'addline' && $action != 'reconcile' && $action != 'confirm_deleteonreconcile') {
926 $morehtml .= $buttonreconcile;
927 }
928
929 $morehtmlright = '<!-- Add New button -->'.$newcardbutton;
930
931 $picto = 'bank_account';
932 if ($id > 0 || !empty($ref)) {
933 $picto = '';
934 }
935
936 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
937 print_barre_liste($langs->trans("BankTransactions"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton.$morehtml, $num, $nbtotalofrecords, $picto, 0, $morehtmlright, '', $limit, 0, 0, 1);
938
939 // Form to reconcile
940 if ($user->hasRight('banque', 'consolidate') && ($action == 'reconcile' || $action == 'confirm_deleteonreconcile')) {
941 // Show last bank statements
942 $nbmax = 12; // We show last 12 receipts (so we can have more than one year)
943 $listoflastreceipts = '';
944 $sql = "SELECT DISTINCT num_releve FROM ".MAIN_DB_PREFIX."bank";
945 $sql .= " WHERE fk_account = ".((int) $object->id)." AND num_releve IS NOT NULL";
946 $sql .= $db->order("num_releve", "DESC");
947 $sql .= $db->plimit($nbmax + 1);
948
949 $last_receipts = array();
950 $last_releve = '';
951 $last_ok = 0;
952 $numr = 0;
953
954 $resqlr = $db->query($sql);
955 if ($resqlr) {
956 $i = 0;
957 $numr = $db->num_rows($resqlr);
958 while (($i < $numr) && ($i < $nbmax)) {
959 $objr = $db->fetch_object($resqlr);
960 if ($objr) {
961 $last_receipts[] = $objr->num_releve;
962 if (!$last_ok) {
963 $last_releve = $objr->num_releve;
964 $last_ok = 1;
965 }
966 }
967 $i++;
968 }
969 }
970
971 print '<!-- form with reconciliation input -->'."\n";
972 print '<div class="valignmiddle inline-block" style="padding-right: 20px;">';
973 if (getDolGlobalInt('NW_RECEIPTNUMBERFORMAT')) {
974 print '<strong>'.$langs->trans("InputReceiptNumber").'</strong>: ';
975 print '<input class="flat width100 center" id="num_releve" list="num_releve_list" name="num_releve" type="text" value="'.(GETPOST('num_releve') ? GETPOST('num_releve') : '').'">';
976 } else {
977 $texttoshow = $langs->trans("InputReceiptNumber").': ';
978 $yyyy = dol_substr($langs->transnoentitiesnoconv("Year"), 0, 1).substr($langs->transnoentitiesnoconv("Year"), 0, 1).substr($langs->transnoentitiesnoconv("Year"), 0, 1).substr($langs->transnoentitiesnoconv("Year"), 0, 1);
979 $mm = dol_substr($langs->transnoentitiesnoconv("Month"), 0, 1).substr($langs->transnoentitiesnoconv("Month"), 0, 1);
980 $dd = dol_substr($langs->transnoentitiesnoconv("Day"), 0, 1).substr($langs->transnoentitiesnoconv("Day"), 0, 1);
981 $placeholder = $yyyy.$mm;
982 $placeholder2 = $yyyy.$mm;
983 $placeholder2 .= ' '.$langs->trans("or").' ';
984 $placeholder2 .= $yyyy.$mm.$dd;
985 if (!$placeholder) {
986 $texttoshow .= $langs->trans("InputReceiptNumberBis");
987 }
988 print $texttoshow;
989 print '<input class="flat width100 center" pattern="[0-9]+" title="'.dol_escape_htmltag($texttoshow.': '.$placeholder2).'" id="num_releve" list="num_releve_list" name="num_releve" placeholder="'.dol_escape_htmltag($placeholder).'" type="text" value="'.(GETPOSTINT('num_releve') ? GETPOSTINT('num_releve') : '').'">'; // The only default value is value we just entered
990 }
991
992 // Output last values into combo list.
993 if (!empty($last_receipts)) {
994 print '<datalist id="num_releve_list">';
995 foreach ($last_receipts as $num_releve) {
996 print '<option value="'.$num_releve.'"></option>'; // TODO We can add some info into option
997 }
998 print '</datalist>';
999 }
1000
1001 print '</div>';
1002 if (is_array($options) && count($options)) {
1003 print $langs->trans("EventualyAddCategory").': ';
1004 print Form::selectarray('cat', $options, GETPOST('cat'), 1);
1005 }
1006 print '<br><div style="margin-top: 5px;"><span class="opacitymedium">'.$langs->trans("ThenCheckLinesAndConciliate").'</span> ';
1007 print '<input type="submit" class="button" name="confirm_reconcile" value="'.$langs->trans("Conciliate").'">';
1008 print ' <span class="opacitymedium">'.$langs->trans("otherwise").'</span> ';
1009 print '<input type="submit" class="button small" name="confirm_savestatement" value="'.$langs->trans("SaveStatementOnly").'">';
1010 //print ' <span class="opacitymedium">'.$langs->trans("or").'</span> ';
1011 //print '<input type="submit" name="cancel" class="button button-cancel small" value="'.$langs->trans("Cancel").'">';
1012 print '</div>';
1013
1014 print '<br>';
1015 print '<!-- Last bank statements -->'."\n";
1016 print $langs->trans("LastAccountStatements").' : ';
1017
1018 foreach ($last_receipts as $num_releve) {
1019 $newentreyinlist = '<a target="_blank" href="'.DOL_URL_ROOT.'/compta/bank/releve.php?account='.((int) $id).'&num='.urlencode($num_releve).'">';
1020 $newentreyinlist .= img_picto($num_releve, 'generic', 'class="paddingright"');
1021 $newentreyinlist .= dol_escape_htmltag($num_releve).'</a> &nbsp; ';
1022 $listoflastreceipts = $newentreyinlist.$listoflastreceipts;
1023 }
1024 if ($numr >= $nbmax) {
1025 $listoflastreceipts = "... &nbsp; ".$listoflastreceipts;
1026 }
1027 print $listoflastreceipts;
1028 if ($numr <= 0) {
1029 print '<b>'.$langs->trans("None").'</b>';
1030 }
1031
1032 // Using BANK_REPORT_LAST_NUM_RELEVE to automatically report last num (or not)
1033 if (getDolGlobalString('BANK_REPORT_LAST_NUM_RELEVE')) {
1034 print '
1035 <script type="text/javascript">
1036 $("#num_releve").val("' . $last_releve.'");
1037 </script>
1038 ';
1039 }
1040 print '<br><br>';
1041 }
1042
1043 // We can add page now to param
1044 if ($page != '') {
1045 $param .= '&page='.urlencode((string) ($page));
1046 }
1047
1048 $moreforfilter = '';
1049 $moreforfilter .= '<div class="divsearchfield">';
1050 $moreforfilter .= $langs->trans('DateOperationShort');
1051 $moreforfilter .= ($conf->browser->layout == 'phone' ? '<br>' : ' ');
1052 $moreforfilter .= '<div class="nowrap inline-block">';
1053 $moreforfilter .= $form->selectDate($search_dt_start, 'search_start_dt', 0, 0, 1, "search_form", 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
1054 $moreforfilter .= '</div>';
1055 $moreforfilter .= ($conf->browser->layout == 'phone' ? '' : ' ');
1056 $moreforfilter .= '<div class="nowrap inline-block">';
1057 $moreforfilter .= $form->selectDate($search_dt_end, 'search_end_dt', 0, 0, 1, "search_form", 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
1058 $moreforfilter .= '</div>';
1059 $moreforfilter .= '</div>';
1060
1061 $moreforfilter .= '<div class="divsearchfield">';
1062 $moreforfilter .= $langs->trans('DateValueShort');
1063 $moreforfilter .= ($conf->browser->layout == 'phone' ? '<br>' : ' ');
1064 $moreforfilter .= '<div class="nowrap inline-block">';
1065 $moreforfilter .= $form->selectDate($search_dv_start, 'search_start_dv', 0, 0, 1, "search_form", 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
1066 $moreforfilter .= '</div>';
1067 $moreforfilter .= ($conf->browser->layout == 'phone' ? '' : ' ');
1068 $moreforfilter .= '<div class="nowrap inline-block">';
1069 $moreforfilter .= $form->selectDate($search_dv_end, 'search_end_dv', 0, 0, 1, "search_form", 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
1070 $moreforfilter .= '</div>';
1071 $moreforfilter .= '</div>';
1072
1073 if (isModEnabled('category')) {
1074 // Categories
1075 if (isModEnabled('category') && $user->hasRight('categorie', 'lire')) {
1076 $langs->load('categories');
1077
1078 // Bank line
1079 $moreforfilter .= '<div class="divsearchfield">';
1080 $tmptitle = $langs->trans('RubriquesTransactions');
1081 $cate_arbo = $form->select_all_categories(Categorie::TYPE_BANK_LINE, $search_bid, 'parent', 0, 0, 1);
1082 $moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"').$form->selectarray('search_bid', $cate_arbo, $search_bid, $tmptitle, 0, 0, '', 0, 0, 0, '', '', 1);
1083 $moreforfilter .= '</div>';
1084 }
1085 }
1086
1087 $parameters = array();
1088 $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1089 if (empty($reshook)) {
1090 $moreforfilter .= $hookmanager->resPrint;
1091 } else {
1092 $moreforfilter = $hookmanager->resPrint;
1093 }
1094
1095 if ($moreforfilter) {
1096 print '<div class="liste_titre liste_titre_bydiv centpercent">';
1097 print $moreforfilter;
1098 print '</div>'."\n";
1099 }
1100
1101 $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
1102 $htmlofselectarray = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, $conf->main_checkbox_left_column); // This also change content of $arrayfields with user setup
1103 $selectedfields = ($mode != 'kanban' ? $htmlofselectarray : '');
1104 $selectedfields .= (($action == 'reconcile' || $action == 'confirm_deleteonreconcile') ? $form->showCheckAddButtons('checkforselect', 1) : '');
1105
1106 // When action is 'reconcile', we force to have the column num_releve always enabled (otherwise we can't make reconciliation).
1107 if ($action == 'reconcile' || $action == 'confirm_deleteonreconcile') {
1108 $arrayfields['b.num_releve']['checked'] = 1;
1109 }
1110
1111 print '<div class="div-table-responsive">';
1112 print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
1113
1114 // Fields title search
1115 // --------------------------------------------------------------------
1116 print '<tr class="liste_titre_filter">';
1117 // Actions and select
1118 if ($conf->main_checkbox_left_column) {
1119 print '<td class="liste_titre valignmiddle center">';
1120 $searchpicto = $form->showFilterButtons('left');
1121 print $searchpicto;
1122 //$searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0, 'checkforselect', 1);
1123 //print $searchpicto;
1124 print '</td>';
1125 }
1126 if (!empty($arrayfields['b.rowid']['checked'])) {
1127 print '<td class="liste_titre">';
1128 print '<input type="text" class="flat" name="search_ref" size="2" value="'.dol_escape_htmltag($search_ref).'">';
1129 print '</td>';
1130 }
1131 if (!empty($arrayfields['b.label']['checked'])) {
1132 print '<td class="liste_titre">';
1133 print '<input type="text" class="flat maxwidth100" name="search_description" value="'.dol_escape_htmltag($search_description).'">';
1134 print '</td>';
1135 }
1136 if (!empty($arrayfields['b.dateo']['checked'])) {
1137 print '<td class="liste_titre">&nbsp;</td>';
1138 }
1139 if (!empty($arrayfields['b.datev']['checked'])) {
1140 print '<td class="liste_titre">&nbsp;</td>';
1141 }
1142 // Type
1143 if (!empty($arrayfields['type']['checked'])) {
1144 print '<td class="liste_titre">';
1145 print $form->select_types_paiements(empty($search_type) ? '' : $search_type, 'search_type', '', 2, 1, 1, 0, 1, 'maxwidth100', 1);
1146 print '</td>';
1147 }
1148 // Numero
1149 if (!empty($arrayfields['b.num_chq']['checked'])) {
1150 print '<td class="liste_titre center"><input type="text" class="flat" name="req_nb" value="'.dol_escape_htmltag($search_req_nb).'" size="2"></td>';
1151 }
1152 // Bordereau
1153 if (!empty($arrayfields['b.fk_bordereau']['checked'])) {
1154 print '<td class="liste_titre center"><input type="text" class="flat width50" name="search_fk_bordereau" value="'.dol_escape_htmltag($search_fk_bordereau).'"></td>';
1155 }
1156 // Thirdparty
1157 if (!empty($arrayfields['bu.label']['checked'])) {
1158 print '<td class="liste_titre"><input type="text" class="flat maxwidth75" name="search_thirdparty" value="'.dol_escape_htmltag($search_thirdparty_user).'"></td>';
1159 }
1160 // Ref
1161 if (!empty($arrayfields['ba.ref']['checked'])) {
1162 print '<td class="liste_titre">';
1163 $form->select_comptes($search_account, 'search_account', 0, '', 1, ($id > 0 || !empty($ref) ? ' disabled="disabled"' : ''), 0, 'maxwidth100');
1164 print '</td>';
1165 }
1166 // Debit
1167 if (!empty($arrayfields['b.debit']['checked'])) {
1168 print '<td class="liste_titre right">';
1169 print '<input type="text" class="flat width50" name="search_debit" value="'.dol_escape_htmltag($search_debit).'">';
1170 print '</td>';
1171 }
1172 // Credit
1173 if (!empty($arrayfields['b.credit']['checked'])) {
1174 print '<td class="liste_titre right">';
1175 print '<input type="text" class="flat width50" name="search_credit" value="'.dol_escape_htmltag($search_credit).'">';
1176 print '</td>';
1177 }
1178 // Balance before
1179 if (!empty($arrayfields['balancebefore']['checked'])) {
1180 print '<td class="liste_titre right">';
1181 $htmltext = $langs->trans("BalanceVisibilityDependsOnSortAndFilters", $langs->transnoentitiesnoconv("DateValue"));
1182 print $form->textwithpicto('', $htmltext, 1);
1183 print '</td>';
1184 }
1185 // Balance
1186 if (!empty($arrayfields['balance']['checked'])) {
1187 print '<td class="liste_titre right">';
1188 $htmltext = $langs->trans("BalanceVisibilityDependsOnSortAndFilters", $langs->transnoentitiesnoconv("DateValue"));
1189 print $form->textwithpicto('', $htmltext, 1);
1190 print '</td>';
1191 }
1192 // Numero statement
1193 if (!empty($arrayfields['b.num_releve']['checked'])) {
1194 // False positive @phan-suppress-next-line PhanTypeInvalidDimOffset
1195 print '<td class="liste_titre center"><input type="text" class="flat width50" name="search_num_releve" value="'.dol_escape_htmltag($search_num_releve).'"></td>';
1196 }
1197 // Conciliated
1198 if (!empty($arrayfields['b.conciliated']['checked'])) {
1199 print '<td class="liste_titre center parentonrightofpage">';
1200 print $form->selectyesno('search_conciliated', $search_conciliated, 1, false, 1, 1, 'search_status onrightofpage width75');
1201 print '</td>';
1202 }
1203 // Extra fields
1204 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
1205 // Action edit/delete and select
1206 print '<td class="nowraponall center"></td>';
1207
1208 // Actions and select
1209 if (!$conf->main_checkbox_left_column) {
1210 print '<td class="liste_titre valignmiddle center">';
1211 //$searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0, 'checkforselect', 1);
1212 //print $searchpicto;
1213 $searchpicto = $form->showFilterButtons();
1214 print $searchpicto;
1215 print '</td>';
1216 }
1217 print "</tr>\n";
1218
1219 $totalarray = array();
1220 $totalarray['nbfield'] = 0;
1221
1222 // Fields title
1223 print '<tr class="liste_titre">';
1224 // Actions and select
1225 if ($conf->main_checkbox_left_column) {
1226 print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
1227 $totalarray['nbfield']++;
1228 }
1229 if (!empty($arrayfields['b.rowid']['checked'])) {
1230 print_liste_field_titre($arrayfields['b.rowid']['label'], $_SERVER['PHP_SELF'], 'b.rowid', '', $param, '', $sortfield, $sortorder);
1231 $totalarray['nbfield']++;
1232 }
1233 if (!empty($arrayfields['b.label']['checked'])) {
1234 print_liste_field_titre($arrayfields['b.label']['label'], $_SERVER['PHP_SELF'], 'b.label', '', $param, '', $sortfield, $sortorder);
1235 $totalarray['nbfield']++;
1236 }
1237 if (!empty($arrayfields['b.dateo']['checked'])) {
1238 print_liste_field_titre($arrayfields['b.dateo']['label'], $_SERVER['PHP_SELF'], 'b.dateo', '', $param, '', $sortfield, $sortorder, "center ");
1239 $totalarray['nbfield']++;
1240 }
1241 if (!empty($arrayfields['b.datev']['checked'])) {
1242 print_liste_field_titre($arrayfields['b.datev']['label'], $_SERVER['PHP_SELF'], 'b.datev,b.dateo,b.rowid', '', $param, '', $sortfield, $sortorder, 'center ');
1243 $totalarray['nbfield']++;
1244 }
1245 if (!empty($arrayfields['type']['checked'])) {
1246 print_liste_field_titre($arrayfields['type']['label'], $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder);
1247 $totalarray['nbfield']++;
1248 }
1249 if (!empty($arrayfields['b.num_chq']['checked'])) {
1250 print_liste_field_titre($arrayfields['b.num_chq']['label'], $_SERVER['PHP_SELF'], 'b.num_chq', '', $param, '', $sortfield, $sortorder, "center ");
1251 $totalarray['nbfield']++;
1252 }
1253 if (!empty($arrayfields['b.fk_bordereau']['checked'])) {
1254 print_liste_field_titre($arrayfields['b.fk_bordereau']['label'], $_SERVER['PHP_SELF'], 'b.fk_bordereau', '', $param, '', $sortfield, $sortorder, "center ");
1255 $totalarray['nbfield']++;
1256 }
1257 if (!empty($arrayfields['bu.label']['checked'])) {
1258 print_liste_field_titre($arrayfields['bu.label']['label'], $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder);
1259 $totalarray['nbfield']++;
1260 }
1261 if (!empty($arrayfields['ba.ref']['checked'])) {
1262 print_liste_field_titre($arrayfields['ba.ref']['label'], $_SERVER['PHP_SELF'], 'ba.ref', '', $param, '', $sortfield, $sortorder);
1263 $totalarray['nbfield']++;
1264 }
1265 if (!empty($arrayfields['b.debit']['checked'])) {
1266 print_liste_field_titre($arrayfields['b.debit']['label'], $_SERVER['PHP_SELF'], 'b.amount', '', $param, '', $sortfield, $sortorder, "right ");
1267 $totalarray['nbfield']++;
1268 }
1269 if (!empty($arrayfields['b.credit']['checked'])) {
1270 print_liste_field_titre($arrayfields['b.credit']['label'], $_SERVER['PHP_SELF'], 'b.amount', '', $param, '', $sortfield, $sortorder, "right ");
1271 $totalarray['nbfield']++;
1272 }
1273 if (!empty($arrayfields['balancebefore']['checked'])) {
1274 print_liste_field_titre($arrayfields['balancebefore']['label'], $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, "right ");
1275 $totalarray['nbfield']++;
1276 }
1277 if (!empty($arrayfields['balance']['checked'])) {
1278 print_liste_field_titre($arrayfields['balance']['label'], $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, "right ");
1279 $totalarray['nbfield']++;
1280 }
1281 if (!empty($arrayfields['b.num_releve']['checked'])) {
1282 // @phan-suppress-next-line PhanTypeInvalidDimOffset
1283 print_liste_field_titre($arrayfields['b.num_releve']['label'], $_SERVER['PHP_SELF'], 'b.num_releve', '', $param, '', $sortfield, $sortorder, "center ");
1284 $totalarray['nbfield']++;
1285 }
1286 if (!empty($arrayfields['b.conciliated']['checked'])) {
1287 print_liste_field_titre($arrayfields['b.conciliated']['label'], $_SERVER['PHP_SELF'], 'b.rappro', '', $param, '', $sortfield, $sortorder, "center ");
1288 $totalarray['nbfield']++;
1289 }
1290
1291 // Extra fields
1292 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
1293 // Hook fields
1294 $parameters = array('arrayfields' => $arrayfields, 'param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder, 'totalarray' => &$totalarray);
1295 $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1296 print $hookmanager->resPrint;
1297 // Action edit/delete and select
1298 print '<td class="nowraponall center"></td>';
1299 $totalarray['nbfield']++;
1300 // Actions and select
1301 if (!$conf->main_checkbox_left_column) {
1302 //print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
1303 print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'maxwidthsearch center ');
1304 $totalarray['nbfield']++;
1305 }
1306 print "</tr>\n";
1307
1308 $balance = 0; // For balance
1309 $balancebefore = 0; // For balance
1310 $balancecalculated = false;
1311 $posconciliatecol = 0;
1312 $cachebankaccount = array();
1313
1314 $sign = 1;
1315
1316 // Loop on each record
1317 $i = 0;
1318 $savnbfield = $totalarray['nbfield'];
1319 $totalarray = array();
1320 $totalarray['nbfield'] = 0;
1321 $totalarray['totaldeb'] = 0;
1322 $totalarray['totalcred'] = 0;
1323
1324 $imaxinloop = ($limit ? min($num, $limit) : $num);
1325 while ($i < $imaxinloop) {
1326 $objp = $db->fetch_object($resql);
1327 $links = $bankaccountstatic->get_url($objp->rowid);
1328 // If we are in a situation where we need/can show balance, we calculate the start of balance
1329 if (!$balancecalculated && (!empty($arrayfields['balancebefore']['checked']) || !empty($arrayfields['balance']['checked'])) && ($mode_balance_ok || $search_conciliated === '0')) {
1330 if (!$search_account) {
1331 dol_print_error(null, 'account is not defined but $mode_balance_ok is true');
1332 exit;
1333 }
1334
1335 // Loop on each record before
1336 $sign = 1;
1337 $i = 0;
1338 $sqlforbalance = 'SELECT SUM(b.amount) as previoustotal';
1339 $sqlforbalance .= " FROM ";
1340 $sqlforbalance .= " ".MAIN_DB_PREFIX."bank_account as ba,";
1341 $sqlforbalance .= " ".MAIN_DB_PREFIX."bank as b";
1342 $sqlforbalance .= " WHERE b.fk_account = ba.rowid";
1343 $sqlforbalance .= " AND ba.entity IN (".getEntity('bank_account').")";
1344 $sqlforbalance .= " AND b.fk_account = ".((int) $search_account);
1345 // To limit record on the page
1346 $sqlforbalance .= " AND (b.datev < '".$db->idate($db->jdate($objp->dv))."' OR (b.datev = '".$db->idate($db->jdate($objp->dv))."' AND (b.dateo < '".$db->idate($db->jdate($objp->do))."' OR (b.dateo = '".$db->idate($db->jdate($objp->do))."' AND b.rowid < ".((int) $objp->rowid)."))))";
1347 $resqlforbalance = $db->query($sqlforbalance);
1348
1349 //print $sqlforbalance;
1350 if ($resqlforbalance) {
1351 $objforbalance = $db->fetch_object($resqlforbalance);
1352 if ($objforbalance) {
1353 // If sort is desc,desc,desc then total of previous date + amount is the balancebefore of the previous line before the line to show
1354 if ($sortfield == 'b.datev,b.dateo,b.rowid' && ($sortorder == 'desc' || $sortorder == 'desc,desc' || $sortorder == 'desc,desc,desc')) {
1355 $balancebefore = $objforbalance->previoustotal + ($sign * $objp->amount);
1356 } else {
1357 // If sort is asc,asc,asc then total of previous date is balance of line before the next line to show
1358 $balance = $objforbalance->previoustotal;
1359 }
1360 }
1361 } else {
1363 }
1364
1365 $balancecalculated = true;
1366
1367 // Output a line with start balance
1368 if ($user->hasRight('banque', 'consolidate') && ($action == 'reconcile' || $action == 'confirm_deleteonreconcile')) {
1369 $tmpnbfieldbeforebalance = 0;
1370 $tmpnbfieldafterbalance = 0;
1371 $balancefieldfound = 0;
1372 foreach ($arrayfields as $key => $val) {
1373 if ($key == 'balancebefore' || $key == 'balance') {
1374 $balancefieldfound++;
1375 continue;
1376 }
1377 if (!empty($arrayfields[$key]['checked'])) {
1378 if (!$balancefieldfound) {
1379 $tmpnbfieldbeforebalance++;
1380 } else {
1381 $tmpnbfieldafterbalance++;
1382 }
1383 }
1384 }
1385 // Extra
1386 $element = $extrafieldsobjectkey;
1387 if (!empty($extrafields->attributes[$element]['label']) && is_array($extrafields->attributes[$element]['label']) && count($extrafields->attributes[$element]['label'])) {
1388 foreach ($extrafields->attributes[$element]['label'] as $key => $val) {
1389 if (!empty($arrayfields["ef.".$key]['checked'])) {
1390 if (!empty($arrayfields[$key]['checked'])) {
1391 if (!$balancefieldfound) {
1392 $tmpnbfieldbeforebalance++;
1393 } else {
1394 $tmpnbfieldafterbalance++;
1395 }
1396 }
1397 }
1398 }
1399 }
1400
1401 print '<tr class="oddeven trforbreak">';
1402 // Action column
1403 if ($conf->main_checkbox_left_column) {
1404 print '<td></td>';
1405 }
1406 if ($tmpnbfieldbeforebalance) {
1407 print '<td colspan="'.$tmpnbfieldbeforebalance.'">';
1408 print '&nbsp;';
1409 print '</td>';
1410 }
1411
1412 if (!empty($arrayfields['balancebefore']['checked'])) {
1413 print '<td class="right">';
1414 if ($search_conciliated !== '0') {
1415 if ($sortfield == 'b.datev,b.dateo,b.rowid' && ($sortorder == 'desc' || $sortorder == 'desc,desc' || $sortorder == 'desc,desc,desc')) {
1416 print price(price2num($balancebefore, 'MT'), 1, $langs);
1417 } else {
1418 print price(price2num($balance, 'MT'), 1, $langs);
1419 }
1420 }
1421 print '</td>';
1422 }
1423 if (!empty($arrayfields['balance']['checked'])) {
1424 print '<td class="right">';
1425 if ($search_conciliated !== '0') { // If not filter of filter on "conciliated"
1426 if ($sortfield == 'b.datev,b.dateo,b.rowid' && ($sortorder == 'desc' || $sortorder == 'desc,desc' || $sortorder == 'desc,desc,desc')) {
1427 print price(price2num($balancebefore, 'MT'), 1, $langs);
1428 } else {
1429 print price(price2num($balance, 'MT'), 1, $langs);
1430 }
1431 }
1432 print '</td>';
1433 }
1434
1435 if (!empty($arrayfields['b.num_releve']['checked'])) {
1436 print '<td></td>';
1437 }
1438
1439 // conciliate
1440 print '<td colspan="'.($tmpnbfieldafterbalance).'">';
1441 print '&nbsp;';
1442 print '</td>';
1443
1444 // Action column
1445 if (!$conf->main_checkbox_left_column) {
1446 print '<td></td>';
1447 }
1448
1449 print '</tr>';
1450 }
1451 }
1452
1453 if ($sortfield == 'b.datev,b.dateo,b.rowid' && ($sortorder == 'desc' || $sortorder == 'desc,desc' || $sortorder == 'desc,desc,desc')) {
1454 $balance = price2num($balancebefore, 'MT'); // balance = balancebefore of previous line (sort is desc)
1455 $balancebefore = price2num($balancebefore - ($sign * $objp->amount), 'MT');
1456 } else {
1457 $balancebefore = price2num($balance, 'MT'); // balancebefore = balance of previous line (sort is asc)
1458 $balance = price2num($balance + ($sign * $objp->amount), 'MT');
1459 }
1460
1461 if (empty($cachebankaccount[$objp->bankid])) {
1462 $bankaccounttmp = new Account($db);
1463 $bankaccounttmp->fetch($objp->bankid);
1464 $cachebankaccount[$objp->bankid] = $bankaccounttmp;
1465 $bankaccount = $bankaccounttmp;
1466 } else {
1467 $bankaccount = $cachebankaccount[$objp->bankid];
1468 }
1469
1470 if (!getDolGlobalString('BANK_COLORIZE_MOVEMENT')) {
1471 $backgroundcolor = "class='oddeven'";
1472 } else {
1473 if ($objp->amount < 0) {
1474 $color = '#' . getDolGlobalString('BANK_COLORIZE_MOVEMENT_COLOR1', 'fca955');
1475 $backgroundcolor = 'style="background: '.$color.';"';
1476 } else {
1477 $color = '#' . getDolGlobalString('BANK_COLORIZE_MOVEMENT_COLOR2', '7fdb86');
1478 $backgroundcolor = 'style="background: '.$color.';"';
1479 }
1480 }
1481
1482 $banklinestatic->id = $objp->rowid;
1483 $banklinestatic->ref = (string) $objp->rowid;
1484
1485 print '<tr class="oddeven" '.$backgroundcolor.'>';
1486
1487 // Action column
1488 if ($conf->main_checkbox_left_column) {
1489 print '<td class="center">';
1490 if (!$objp->conciliated && ($action == 'reconcile' || $action == 'confirm_deleteonreconcile')) {
1491 print '<input class="flat checkforselect" name="rowid['.$objp->rowid.']" type="checkbox" name="toselect[]" value="'.$objp->rowid.'" size="1"'.(!empty($tmparray[$objp->rowid]) ? ' checked' : '').'>';
1492 }
1493 print '</td>';
1494 if (!$i) {
1495 $totalarray['nbfield']++;
1496 }
1497 }
1498
1499 // Ref
1500 if (!empty($arrayfields['b.rowid']['checked'])) {
1501 print '<td class="nowrap left">';
1502 print $banklinestatic->getNomUrl(1);
1503 print '</td>';
1504 if (!$i) {
1505 $totalarray['nbfield']++;
1506 }
1507 }
1508
1509 // Description
1510 if (!empty($arrayfields['b.label']['checked'])) {
1511 $labeltoshow = '';
1512 $titletoshow = '';
1513 $reg = array();
1514 preg_match('/\‍((.+)\‍)/i', $objp->label, $reg); // Si texte entoure de parenthee on tente recherche de traduction
1515 if (!empty($reg[1]) && $langs->trans($reg[1]) != $reg[1]) {
1516 // Example: $reg[1] = 'CustomerInvoicePayment', 'SupplierInvoicePayment', ... (or on old version: 'WithdrawalPayment', 'BankTransferPayment')
1517 $labeltoshow = $langs->trans($reg[1]);
1518 } else {
1519 if ($objp->label == '(payment_salary)') {
1520 $labeltoshow = $langs->trans("SalaryPayment");
1521 } else {
1522 $labeltoshow = dol_escape_htmltag($objp->label);
1523 $titletoshow = $objp->label;
1524 }
1525 }
1526
1527
1528 print '<td class="tdoverflowmax250"'.($titletoshow ? ' title="'.dol_escape_htmltag($titletoshow).'"' : '').'>';
1529
1530 // Add info about links after description
1531 $cachebankaccount = array();
1532 foreach ($links as $key => $val) {
1533 print '<!-- '.$links[$key]['type'].' -->';
1534 if ($links[$key]['type'] == 'withdraw') {
1535 $banktransferstatic->id = $links[$key]['url_id'];
1536 $banktransferstatic->ref = $links[$key]['label'];
1537 print $banktransferstatic->getNomUrl(0).($labeltoshow ? ' ' : '');
1538 } elseif ($links[$key]['type'] == 'payment') {
1539 $paymentstatic->id = $links[$key]['url_id'];
1540 $paymentstatic->ref = (string) $links[$key]['url_id']; // FIXME This is id, not ref of payment
1541 $paymentstatic->date = $db->jdate($objp->do);
1542 print $paymentstatic->getNomUrl(2).($labeltoshow ? ' ' : '');
1543 } elseif ($links[$key]['type'] == 'payment_supplier') {
1544 $paymentsupplierstatic->id = $links[$key]['url_id'];
1545 $paymentsupplierstatic->ref = (string) $links[$key]['url_id']; // FIXME This is id, not ref of payment
1546 print $paymentsupplierstatic->getNomUrl(2).($labeltoshow ? ' ' : '');
1547 } elseif ($links[$key]['type'] == 'payment_sc') {
1548 $paymentscstatic->id = $links[$key]['url_id'];
1549 $paymentscstatic->ref = (string) $links[$key]['url_id'];
1550 $paymentscstatic->label = $links[$key]['label'];
1551 print $paymentscstatic->getNomUrl(2).($labeltoshow ? ' ' : '');
1552 } elseif ($links[$key]['type'] == 'payment_vat') {
1553 $paymentvatstatic->id = $links[$key]['url_id'];
1554 $paymentvatstatic->ref = (string) $links[$key]['url_id'];
1555 print $paymentvatstatic->getNomUrl(2).($labeltoshow ? ' ' : '');
1556 } elseif ($links[$key]['type'] == 'payment_salary') {
1557 $paymentsalstatic->id = $links[$key]['url_id'];
1558 $paymentsalstatic->ref = (string) $links[$key]['url_id'];
1559 $paymentsalstatic->label = $links[$key]['label'];
1560 print $paymentsalstatic->getNomUrl(2).($labeltoshow ? ' ' : '');
1561 } elseif ($links[$key]['type'] == 'payment_loan') {
1562 print '<a href="'.DOL_URL_ROOT.'/loan/payment/card.php?id='.$links[$key]['url_id'].'">';
1563 print ' '.img_object($langs->trans('ShowPayment'), 'payment').' ';
1564 print '</a>'.($labeltoshow ? ' ' : '');
1565 } elseif ($links[$key]['type'] == 'payment_donation') {
1566 $paymentdonationstatic->id = $links[$key]['url_id'];
1567 $paymentdonationstatic->ref = (string) $links[$key]['url_id'];
1568 print $paymentdonationstatic->getNomUrl(2).($labeltoshow ? ' ' : '');
1569 } elseif ($links[$key]['type'] == 'payment_expensereport') {
1570 $paymentexpensereportstatic->id = $links[$key]['url_id'];
1571 $paymentexpensereportstatic->ref = (string) $links[$key]['url_id'];
1572 print $paymentexpensereportstatic->getNomUrl(2).($labeltoshow ? ' ' : '');
1573 } elseif ($links[$key]['type'] == 'payment_various') {
1574 $paymentvariousstatic->id = $links[$key]['url_id'];
1575 $paymentvariousstatic->ref = (string) $links[$key]['url_id'];
1576 print $paymentvariousstatic->getNomUrl(2).($labeltoshow ? ' ' : '');
1577 } elseif ($links[$key]['type'] == 'banktransfert') {
1578 // Do not show link to transfer since there is no transfer card (avoid confusion). Can already be accessed from transaction detail.
1579 if ($objp->amount > 0) {
1580 $banklinestatic->fetch($links[$key]['url_id']);
1581 $bankstatic->id = $banklinestatic->fk_account;
1582 $bankstatic->label = $banklinestatic->bank_account_ref;
1583 print $langs->trans("TransferFrom").' ';
1584 print $bankstatic->getNomUrl(1, 'transactions');
1585 print ' '.$langs->trans("toward").' ';
1586 $bankstatic->id = $objp->bankid;
1587 $bankstatic->label = $objp->bankref;
1588 print $bankstatic->getNomUrl(1, '');
1589 print($labeltoshow ? ' - ' : '');
1590 } else {
1591 $bankstatic->id = $objp->bankid;
1592 $bankstatic->label = $objp->bankref;
1593 print $langs->trans("TransferFrom").' ';
1594 print $bankstatic->getNomUrl(1, '');
1595 print ' '.$langs->trans("toward").' ';
1596 $banklinestatic->fetch($links[$key]['url_id']);
1597 $bankstatic->id = $banklinestatic->fk_account;
1598 $bankstatic->label = $banklinestatic->bank_account_ref;
1599 print $bankstatic->getNomUrl(1, 'transactions');
1600 print($labeltoshow ? ' - ' : '');
1601 }
1602 //var_dump($links);
1603 } elseif ($links[$key]['type'] == 'company') {
1604 } elseif ($links[$key]['type'] == 'user') {
1605 } elseif ($links[$key]['type'] == 'member') {
1606 } elseif ($links[$key]['type'] == 'sc') {
1607 } elseif ($links[$key]['type'] == 'vat') {
1608 } elseif ($links[$key]['type'] == 'salary') {
1609 // Information is already shown using the payment_salary link. No need of this link.
1610 } else {
1611 // Show link with label $links[$key]['label']
1612 print '<a href="'.$links[$key]['url'].$links[$key]['url_id'].'">';
1613 if (preg_match('/^\‍((.*)\‍)$/i', $links[$key]['label'], $reg)) {
1614 // Generic label because it is in parentheses. We display it translated.
1615 if ($reg[1] == 'paiement') {
1616 $reg[1] = 'Payment';
1617 }
1618 print $langs->trans($reg[1]);
1619 } else {
1620 print $links[$key]['label'];
1621 }
1622 print '</a>'.($labeltoshow ? ' - ' : '');
1623 }
1624 }
1625
1626 print $labeltoshow; // Already escaped
1627
1628 print '</td>';
1629 if (!$i) {
1630 $totalarray['nbfield']++;
1631 }
1632 }
1633
1634 // Date ope
1635 if (!empty($arrayfields['b.dateo']['checked'])) {
1636 print '<td class="nowraponall center">';
1637 print '<span class="spanforajaxedit" id="dateoperation_'.$objp->rowid.'" title="'.dol_print_date($db->jdate($objp->do), "day").'">';
1638 print dol_print_date($db->jdate($objp->do), "dayreduceformat");
1639 print "</span>";
1640 print '&nbsp;';
1641 print '<span class="inline-block">';
1642 print '<a class="ajaxforbankoperationchange" href="'.$_SERVER['PHP_SELF'].'?action=doprev&amp;account='.$objp->bankid.'&amp;rowid='.$objp->rowid.'">';
1643 print img_edit_remove()."</a> ";
1644 print '<a class="ajaxforbankoperationchange" href="'.$_SERVER['PHP_SELF'].'?action=donext&amp;account='.$objp->bankid.'&amp;rowid='.$objp->rowid.'">';
1645 print img_edit_add()."</a>";
1646 print '</span>';
1647 print "</td>\n";
1648 if (!$i) {
1649 $totalarray['nbfield']++;
1650 }
1651 }
1652
1653 // Date value
1654 if (!empty($arrayfields['b.datev']['checked'])) {
1655 print '<td class="nowraponall center">';
1656 print '<span class="spanforajaxedit" id="datevalue_'.$objp->rowid.'" title="'.dol_print_date($db->jdate($objp->dv), "day").'">';
1657 print dol_print_date($db->jdate($objp->dv), "dayreduceformat");
1658 print "</span>";
1659 print '&nbsp;';
1660 print '<span class="inline-block">';
1661 print '<a class="ajaxforbankoperationchange" href="'.$_SERVER['PHP_SELF'].'?action=dvprev&amp;account='.$objp->bankid.'&amp;rowid='.$objp->rowid.'">';
1662 print img_edit_remove()."</a> ";
1663 print '<a class="ajaxforbankoperationchange" href="'.$_SERVER['PHP_SELF'].'?action=dvnext&amp;account='.$objp->bankid.'&amp;rowid='.$objp->rowid.'">';
1664 print img_edit_add()."</a>";
1665 print '</span>';
1666 print "</td>\n";
1667 if (!$i) {
1668 $totalarray['nbfield']++;
1669 }
1670 }
1671
1672 // Payment type
1673 if (!empty($arrayfields['type']['checked'])) {
1674 $labeltype = ($langs->transnoentitiesnoconv("PaymentTypeShort".$objp->fk_type) != "PaymentTypeShort".$objp->fk_type) ? $langs->transnoentitiesnoconv("PaymentTypeShort".$objp->fk_type) : $langs->getLabelFromKey($db, $objp->fk_type, 'c_paiement', 'code', 'libelle', '', 1);
1675 if (empty($arrayfields['b.num_chq']['checked'])) {
1676 $labeltype .= ($objp->num_chq ? ' <span class="opacitymedium">- '.$objp->num_chq.'</span>' : '');
1677 }
1678 print '<td class="tdoverflowmax100" title="'.dolPrintLabel($labeltype).'">';
1679 if ($labeltype == 'SOLD') {
1680 print '&nbsp;'; //$langs->trans("InitialBankBalance");
1681 } else {
1682 print dolPrintHTML($labeltype);
1683 }
1684 print "</td>\n";
1685 if (!$i) {
1686 $totalarray['nbfield']++;
1687 }
1688 }
1689
1690 // Num cheque
1691 if (!empty($arrayfields['b.num_chq']['checked'])) {
1692 print '<td class="tdoverflowmax100 center" title="'.($objp->num_chq ? dolPrintLabel($objp->num_chq) : "").'">'.($objp->num_chq ? dolPrintLabel($objp->num_chq) : "")."</td>\n";
1693 if (!$i) {
1694 $totalarray['nbfield']++;
1695 }
1696 }
1697
1698 // Cheque
1699 if (!empty($arrayfields['b.fk_bordereau']['checked'])) {
1700 $bordereaustatic->fetch($objp->fk_bordereau);
1701 print '<td class="nowraponall center">';
1702 print $bordereaustatic->getNomUrl();
1703 print '</td>';
1704 if (!$i) {
1705 $totalarray['nbfield']++;
1706 }
1707 }
1708
1709 // Third party
1710 if (!empty($arrayfields['bu.label']['checked'])) {
1711 print '<td class="tdoverflowmax125">';
1712
1713 $companylinked_id = 0;
1714 $userlinked_id = 0;
1715 $type_link = "";
1716 $thirdstr = "";
1717
1718 //payment line type to define user display and user or company linked
1719 foreach ($links as $key => $value) {
1720 if ($links[$key]['type'] == 'payment_sc') {
1721 $type_link = 'payment_sc';
1722 }
1723 if ($links[$key]['type'] == 'payment_salary') {
1724 $type_link = 'payment_salary';
1725 }
1726 if ($links[$key]['type'] == 'payment_donation') {
1727 $paymentdonationstatic->fetch($links[$key]['url_id']);
1728 $donstatic->fetch($paymentdonationstatic->fk_donation);
1729 $companylinked_id = $donstatic->socid;
1730 if (!$companylinked_id) {
1731 $thirdstr = ($donstatic->societe !== "" ?
1732 $donstatic->societe :
1733 $donstatic->firstname." ".$donstatic->lastname);
1734 }
1735 }
1736 if ($links[$key]['type'] == 'payment_expensereport') {
1737 $type_link = 'payment_expensereport';
1738 }
1739
1740 if ($links[$key]['type'] == 'company') {
1741 $companylinked_id = $links[$key]['url_id'];
1742 }
1743 if ($links[$key]['type'] == 'user') {
1744 $userlinked_id = $links[$key]['url_id'];
1745 }
1746 }
1747
1748 // Show more information in the column thirdparty.
1749 if ($companylinked_id) {
1750 // TODO Add a cache of loaded companies here ?
1751 $companystatic->fetch($companylinked_id);
1752 print $companystatic->getNomUrl(1);
1753 } elseif ($userlinked_id &&
1754 (($type_link == 'payment_salary' && $user->hasRight('salaries', 'read'))
1755 || ($type_link == 'payment_sc' && $user->hasRight('tax', 'charges', 'lire'))
1756 || ($type_link == 'payment_expensereport' && $user->hasRight('expensereport', 'lire')))) {
1757 // Get object user from cache or load it
1758 if (!empty($conf->cache['user'][$userlinked_id])) {
1759 $tmpuser = $conf->cache['user'][$userlinked_id];
1760 } else {
1761 $tmpuser = new User($db);
1762 $tmpuser->fetch($userlinked_id);
1763 $conf->cache['user'][$userlinked_id] = $tmpuser;
1764 }
1765 print $tmpuser->getNomUrl(-1);
1766 } elseif ($thirdstr) {
1767 print $thirdstr;
1768 } else {
1769 print '&nbsp;';
1770 }
1771
1772 print '</td>';
1773 if (!$i) {
1774 $totalarray['nbfield']++;
1775 }
1776 }
1777
1778 // Bank account
1779 if (!empty($arrayfields['ba.ref']['checked'])) {
1780 print '<td class="nowrap">';
1781 print $bankaccount->getNomUrl(1);
1782 print "</td>\n";
1783 if (!$i) {
1784 $totalarray['nbfield']++;
1785 }
1786 }
1787
1788 // Debit
1789 if (!empty($arrayfields['b.debit']['checked'])) {
1790 print '<td class="nowraponall right"><span class="amount">';
1791 if ($objp->amount < 0) {
1792 print price($objp->amount * -1);
1793 $totalarray['totaldeb'] += $objp->amount;
1794 }
1795 print "</span></td>\n";
1796 if (!$i) {
1797 $totalarray['nbfield']++;
1798 }
1799 if (!$i) {
1800 $totalarray['totaldebfield'] = $totalarray['nbfield'];
1801 }
1802 }
1803
1804 // Credit
1805 if (!empty($arrayfields['b.credit']['checked'])) {
1806 print '<td class="nowraponall right"><span class="amount">';
1807 if ($objp->amount > 0) {
1808 print price($objp->amount);
1809 $totalarray['totalcred'] += $objp->amount;
1810 }
1811 print "</span></td>\n";
1812 if (!$i) {
1813 $totalarray['nbfield']++;
1814 }
1815 if (!$i) {
1816 $totalarray['totalcredfield'] = $totalarray['nbfield'];
1817 }
1818 }
1819
1820 // Balance before
1821 if (!empty($arrayfields['balancebefore']['checked'])) {
1822 if ($mode_balance_ok) {
1823 if ($balancebefore >= 0) {
1824 print '<td class="nowrap right">&nbsp;'.price($balancebefore).'</td>';
1825 } else {
1826 print '<td class="error nowrap right">&nbsp;'.price($balancebefore).'</td>';
1827 }
1828 } else {
1829 print '<td class="right">-</td>';
1830 }
1831 if (!$i) {
1832 $totalarray['nbfield']++;
1833 }
1834 }
1835
1836 // Balance after
1837 if (!empty($arrayfields['balance']['checked'])) {
1838 if ($mode_balance_ok) {
1839 if ($balance >= 0) {
1840 print '<td class="nowrap right">&nbsp;'.price($balance).'</td>';
1841 } else {
1842 print '<td class="error nowrap right">&nbsp;'.price($balance).'</td>';
1843 }
1844 } else {
1845 print '<td class="right">-</td>';
1846 }
1847 if (!$i) {
1848 $totalarray['nbfield']++;
1849 }
1850 }
1851
1852 if (!empty($arrayfields['b.num_releve']['checked'])) {
1853 print '<td class="nowraponall center">';
1854 // Transaction reconciliated or edit link
1855 if ($bankaccount->canBeConciliated() > 0) {
1856 if ($objp->num_releve) {
1857 print '<a href="releve.php?num='.urlencode($objp->num_releve).'&account='.urlencode($objp->bankid).'&save_lastsearch_values=1">'.dol_escape_htmltag($objp->num_releve).'</a>';
1858 }
1859 }
1860 print '</td>';
1861 if (!$i) {
1862 $totalarray['nbfield']++;
1863 $posconciliatecol = $totalarray['nbfield'];
1864 }
1865 }
1866
1867 // Conciliated
1868 if (!empty($arrayfields['b.conciliated']['checked'])) {
1869 print '<td class="nowraponall center">';
1870 print yn($objp->conciliated);
1871 print '</td>';
1872 if (!$i) {
1873 $totalarray['nbfield']++;
1874 }
1875 }
1876
1877 if (!empty($arrayfields['b.fk_bordereau']['checked'])) {
1878 $bordereaustatic->fetch($objp->fk_bordereau);
1879 print '<td class="nowraponall center">';
1880 print $bordereaustatic->getNomUrl();
1881 print '</td>';
1882 if (!$i) {
1883 $totalarray['nbfield']++;
1884 }
1885 }
1886
1887 // Extra fields
1888 $obj = $objp; // Because extrafield template use $obj and not $objp as object variable name
1889 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
1890 // Fields from hook
1891 $parameters = array('arrayfields' => $arrayfields, 'object' => $object, 'obj' => $objp, 'i' => $i, 'totalarray' => &$totalarray);
1892 $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $objecttmpect may have been modified by hook
1893 print $hookmanager->resPrint;
1894
1895 // Action edit/delete and select
1896 print '<td class="nowraponall center">';
1897 // Transaction reconciliated or edit link
1898 if ($objp->conciliated && $bankaccount->canBeConciliated() > 0) { // If line not conciliated and account can be conciliated
1899 print '<a class="editfielda" href="'.DOL_URL_ROOT.'/compta/bank/line.php?save_lastsearch_values=1&rowid='.$objp->rowid.($object->id > 0 ? '&account='.$object->id : '').'&page='.$page.'">';
1900 print img_edit();
1901 print '</a>';
1902 } else {
1903 if ($user->hasRight('banque', 'modifier') || $user->hasRight('banque', 'consolidate')) {
1904 print '<a class="editfielda" href="'.DOL_URL_ROOT.'/compta/bank/line.php?save_lastsearch_values=1&rowid='.$objp->rowid.($object->id > 0 ? '&account='.$object->id : '').'&page='.$page.'">';
1905 print img_edit();
1906 print '</a>';
1907 } else {
1908 print '<a class="editfielda" href="'.DOL_URL_ROOT.'/compta/bank/line.php?save_lastsearch_values=1&rowid='.$objp->rowid.($object->id > 0 ? '&account='.$object->id : '').'&page='.$page.'">';
1909 print img_view();
1910 print '</a>';
1911 }
1912 if ($bankaccount->canBeConciliated() > 0 && empty($objp->conciliated)) {
1913 if ($db->jdate($objp->dv) < ($now - $conf->bank->rappro->warning_delay)) {
1914 print ' '.img_warning($langs->trans("ReconciliationLate"));
1915 }
1916 }
1917 if ($user->hasRight('banque', 'modifier')) {
1918 // Strip the surrounding & so the leading action= we put first stays the only action= in the URL.
1919 // Without this the URL ends up with two action= params; PHP picks the last one and the page silently switches to 'reconcile' instead of 'delete'.
1920 $parambis = preg_replace('/&?action=(reconcile|confirm_deleteonreconcile)(&|$)/', '\2', $param);
1921 print '<a href="'.$_SERVER["PHP_SELF"].'?action='.($action == 'reconcile' ? 'confirm_deleteonreconcile&confirm=yes' : 'delete').'&token='.newToken().'&rowid='.$objp->rowid.'&page='.$page.$parambis.($sortfield ? '&sortfield='.$sortfield : '').($sortorder ? '&sortorder='.$sortorder : '').'">';
1922 print img_delete('', 'class="marginleftonly"');
1923 print '</a>';
1924 }
1925 }
1926 print '</td>';
1927 if (!$i) {
1928 $totalarray['nbfield']++;
1929 }
1930
1931 // Action column
1932 if (!$conf->main_checkbox_left_column) {
1933 print '<td class="center">';
1934 if (!$objp->conciliated && ($action == 'reconcile' || $action == 'confirm_deleteonreconcile')) {
1935 print '<input class="flat checkforselect" name="rowid['.$objp->rowid.']" type="checkbox" value="'.$objp->rowid.'" size="1"'.(!empty($tmparray[$objp->rowid]) ? ' checked' : '').'>';
1936 }
1937 print '</td>';
1938 if (!$i) {
1939 $totalarray['nbfield']++;
1940 }
1941 }
1942
1943 print "</tr>\n";
1944
1945 $i++;
1946 }
1947
1948 // Show total line
1949 if (isset($totalarray['totaldebfield']) || isset($totalarray['totalcredfield'])) {
1950 print '<tr class="liste_total">';
1951 $i = 0;
1952 while ($i < $totalarray['nbfield']) {
1953 $i++;
1954 if ($i == 1) {
1955 if ($num < $limit && empty($offset)) {
1956 print '<td class="left">'.$langs->trans("Total").'</td>';
1957 } else {
1958 print '<td class="left tdoverflowmax50" title="'.$langs->trans("Totalforthispage").'">'.$langs->trans("Totalforthispage").'</td>';
1959 }
1960 } elseif ($totalarray['totaldebfield'] == $i) {
1961 print '<td class="right"><span class="amount">'.price(-1 * $totalarray['totaldeb']).'</span></td>';
1962 } elseif ($totalarray['totalcredfield'] == $i) {
1963 print '<td class="right"><span class="amount">'.price($totalarray['totalcred']).'</span></td>';
1964 } elseif ($i == $posconciliatecol) {
1965 print '<td class="center">';
1966 print '</td>';
1967 } else {
1968 print '<td></td>';
1969 }
1970 }
1971 print '</tr>';
1972 }
1973
1974 // If no record found
1975 if ($num == 0) {
1976 $colspan = 1;
1977 foreach ($arrayfields as $key => $val) {
1978 if (!empty($val['checked'])) {
1979 $colspan++;
1980 }
1981 }
1982 print '<tr><td colspan="'.($colspan + 1).'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
1983 }
1984
1985 print "</table>";
1986 print "</div>";
1987
1988 print '</form>';
1989 $db->free($resql);
1990} else {
1992}
1993
1994// End of page
1995llxFooter();
1996$db->close();
$id
Support class for third parties, contacts, members, users or resources.
Definition account.php:47
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
$totalarray
Definition list.php:501
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:91
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:73
bank_prepare_head(Account $object)
Prepare array with list of tabs.
Definition bank.lib.php:40
Class to manage bank accounts.
Class to manage bank transaction lines.
Class to manage members of a foundation.
Class to manage bank categories.
Class to manage withdrawal receipts.
Class for managing the social charges.
Class to manage donations.
Definition don.class.php:41
Class to manage generation of HTML components for accounting management.
Class to manage generation of HTML components Only common components must be here.
static selectarray($htmlname, $array, $id='', $show_empty=0, $key_in_label=0, $value_as_key=0, $moreparam='', $translate=0, $maxlen=0, $disabled=0, $sort='', $morecss='minwidth75', $addjscombo=1, $moreparamonempty='', $disablebademail=0, $nohtmlescape=0)
Return a HTML select string, built from an array of key+value.
Class to help generate other html components Only common components are here.
Loan.
Class to manage payments for supplier invoices.
Class to manage payments of customer invoices.
Class to manage payments of donations.
Class to manage payments of expense report.
Class to manage payments of salaries.
Class to manage payments of social contributions.
Class to manage payments of social contributions.
Class to manage various payments.
Class to manage cheque delivery receipts.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage Dolibarr users.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
dol_now($mode='gmt')
Return date for now.
recordNotFound($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Displays an error page when a record is not found.
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...
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
currentToken()
Return the value of token currently saved into session with name 'token'.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
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.
natural_search($fields, $value, $mode=0, $nofirstand=0, $sqltoadd='')
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by the value of a given key, which produces ascending (default) or descending out...
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
dol_substr($string, $start, $length=null, $stringencoding='', $trunconbytes=0)
Make a substring.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
print_liste_field_titre($name, $file="", $field="", $begin="", $param="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
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)
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
dolPrintHTML($s, $allowiframe=0, $moreallowedtags=array())
Return a string (that can be on several lines) ready to be output on a HTML page.
Definition html.lib.php:73
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
Definition html.lib.php:519
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.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Definition html.lib.php:717
img_view($titlealt='default', $float=0, $other='class="valignmiddle"')
Show logo view card.
dolPrintLabel($s, $escapeonlyhtmltags=0)
Return a string label (so on 1 line only and that should not contains any HTML) ready to be output on...
Definition html.lib.php:44
yn($yesno, $format=1, $color=0)
Return yes or no in current language.
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip='', $forcenowrapcolumntitle=0)
Get title line of an array.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
img_edit_add($titlealt='default', $other='')
Show logo "+".
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
img_edit_remove($titlealt='default', $other='')
Show logo "-".
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...
Definition html.lib.php:172
print $langs trans("Show") . '< td style="' . $timeColor . '" align="center"> s</td > badge status0 badge status4 badge status3 Error badge status8< td align="center">< span class="badge ' . $badge . '"></span ></td >< td align="center">< a href="#" class="button button-small" onclick="openLogModal(this)" data-req="' . dol_escape_htmltag($reqSafe) . '" data-res="' . dol_escape_htmltag($resSafe) . '" data-err="' . dol_escape_htmltag($errSafe) . '">< span class="fa fa-search-plus"></span ></a ></td ></tr >< tr >< td colspan="' . $colspan . '" class="opacitymedium"></td ></tr ></table ></div ></form > logModal none logModal none s a JSON string
if(preg_match('/(crypted|dolcrypt):/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
'integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter[:Sortfield]]]',...
Definition repair.php:130
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.