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