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