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