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