dolibarr 19.0.3
bankentries_list.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2004-2019 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-2021 Frédéric France <frederic.france@netlogic.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 = GETPOST('id', 'int');
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, GETPOST("opmonth", 'int'), GETPOST("opday", 'int'), GETPOST("opyear", 'int'));
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");
81$search_ref = GETPOST('search_ref', 'alpha');
82$search_description = GETPOST("search_description", 'alpha');
83$search_dt_start = dol_mktime(0, 0, 0, GETPOST('search_start_dtmonth', 'int'), GETPOST('search_start_dtday', 'int'), GETPOST('search_start_dtyear', 'int'));
84$search_dt_end = dol_mktime(0, 0, 0, GETPOST('search_end_dtmonth', 'int'), GETPOST('search_end_dtday', 'int'), GETPOST('search_end_dtyear', 'int'));
85$search_dv_start = dol_mktime(0, 0, 0, GETPOST('search_start_dvmonth', 'int'), GETPOST('search_start_dvday', 'int'), GETPOST('search_start_dvyear', 'int'));
86$search_dv_end = dol_mktime(0, 0, 0, GETPOST('search_end_dvmonth', 'int'), GETPOST('search_end_dvday', 'int'), GETPOST('search_end_dvyear', 'int'));
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 = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
100$sortfield = GETPOST('sortfield', 'aZ09comma');
101$sortorder = GETPOST('sortorder', 'aZ09comma');
102$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
103$pageplusone = GETPOST("pageplusone", 'int');
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 parametres
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($page);
294 }
295 if ($offset) {
296 $param .= '&offset='.urlencode($offset);
297 }
298 if ($limit) {
299 $param .= '&limit='.((int) $limit);
300 }
301 if ($search_conciliated != '' && $search_conciliated != '-1') {
302 $param .= '&search_conciliated='.urlencode($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='.GETPOST('search_start_dtmonth', 'int').'&search_start_dtday='.GETPOST('search_start_dtday', 'int').'&search_start_dtyear='.GETPOST('search_start_dtyear', 'int');
315 }
316 if (dol_strlen($search_dt_end) > 0) {
317 $param .= '&search_end_dtmonth='.GETPOST('search_end_dtmonth', 'int').'&search_end_dtday='.GETPOST('search_end_dtday', 'int').'&search_end_dtyear='.GETPOST('search_end_dtyear', 'int');
318 }
319 if (dol_strlen($search_dv_start) > 0) {
320 $param .= '&search_start_dvmonth='.GETPOST('search_start_dvmonth', 'int').'&search_start_dvday='.GETPOST('search_start_dvday', 'int').'&search_start_dvyear='.GETPOST('search_start_dvyear', 'int');
321 }
322 if (dol_strlen($search_dv_end) > 0) {
323 $param .= '&search_end_dvmonth='.GETPOST('search_end_dvmonth', 'int').'&search_end_dvday='.GETPOST('search_end_dvday', 'int').'&search_end_dvyear='.GETPOST('search_end_dvyear', 'int');
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 (GETPOST('add_account', 'int') > 0) {
357 $bankaccountid = GETPOST('add_account', 'int');
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(GETPOST("rowid", "int"));
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($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='.urlencode($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($search_conciliated);
485}
486if ($search_fk_bordereau > 0) {
487 $param .= '$&search_fk_bordereau='.urlencode($search_fk_bordereau);
488}
489if ($search_bid > 0) {
490 $param .= '&search_bid='.urlencode($search_bid);
491}
492if (dol_strlen($search_dt_start) > 0) {
493 $param .= '&search_start_dtmonth='.GETPOST('search_start_dtmonth', 'int').'&search_start_dtday='.GETPOST('search_start_dtday', 'int').'&search_start_dtyear='.GETPOST('search_start_dtyear', 'int');
494}
495if (dol_strlen($search_dt_end) > 0) {
496 $param .= '&search_end_dtmonth='.GETPOST('search_end_dtmonth', 'int').'&search_end_dtday='.GETPOST('search_end_dtday', 'int').'&search_end_dtyear='.GETPOST('search_end_dtyear', 'int');
497}
498if (dol_strlen($search_dv_start) > 0) {
499 $param .= '&search_start_dvmonth='.GETPOST('search_start_dvmonth', 'int').'&search_start_dvday='.GETPOST('search_start_dvday', 'int').'&search_start_dvyear='.GETPOST('search_start_dvyear', 'int');
500}
501if (dol_strlen($search_dv_end) > 0) {
502 $param .= '&search_end_dvmonth='.GETPOST('search_end_dvmonth', 'int').'&search_end_dvday='.GETPOST('search_end_dvday', 'int').'&search_end_dvyear='.GETPOST('search_end_dvyear', 'int');
503}
504if ($search_req_nb) {
505 $param .= '&req_nb='.urlencode($search_req_nb);
506}
507if (GETPOST("search_thirdparty", 'int')) {
508 $param .= '&thirdparty='.urlencode(GETPOST("search_thirdparty", 'int'));
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 foreach ($bankcateg->fetchAll() as $bankcategory) {
545 $options[$bankcategory->id] = $bankcategory->label;
546 }
547
548 // Bank card
549 $head = bank_prepare_head($object);
550 print dol_get_fiche_head($head, 'journal', $langs->trans("FinancialAccount"), 0, 'account');
551
552 $linkback = '<a href="'.DOL_URL_ROOT.'/compta/bank/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
553
554 dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0, '', '', 1);
555
556 print dol_get_fiche_end();
557
558
559 /*
560 * Buttons actions
561 */
562
563 if ($action != 'reconcile') {
564 if ($object->canBeConciliated() > 0) {
565 $allowautomaticconciliation = false; // TODO
566 $titletoconciliatemanual = $langs->trans("Conciliate");
567 $titletoconciliateauto = $langs->trans("Conciliate");
568 if ($allowautomaticconciliation) {
569 $titletoconciliatemanual .= ' ('.$langs->trans("Manual").')';
570 $titletoconciliateauto .= ' ('.$langs->trans("Auto").')';
571 }
572
573 // If not cash account and can be reconciliate
574 if ($user->hasRight('banque', 'consolidate')) {
575 $newparam = $param;
576 $newparam = preg_replace('/search_conciliated=\d+/i', '', $newparam);
577 $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>';
578 } else {
579 $buttonreconcile = '<a class="butActionRefused" style="margin-bottom: 5px !important; margin-top: 5px !important" title="'.$langs->trans("NotEnoughPermissions").'" href="#">'.$titletoconciliatemanual.'</a>';
580 }
581
582 if ($allowautomaticconciliation) {
583 // If not cash account and can be reconciliate
584 if ($user->hasRight('banque', 'consolidate')) {
585 $newparam = $param;
586 $newparam = preg_replace('/search_conciliated=\d+/i', '', $newparam);
587 $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>';
588 } else {
589 $buttonreconcile .= ' <a class="butActionRefused" style="margin-bottom: 5px !important; margin-top: 5px !important" title="'.$langs->trans("NotEnoughPermissions").'" href="#">'.$titletoconciliateauto.'</a>';
590 }
591 }
592 }
593 }
594}
595
596$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,";
597$sql .= " b.fk_account, b.fk_type, b.fk_bordereau,";
598$sql .= " ba.rowid as bankid, ba.ref as bankref";
599// Add fields from extrafields
600if (!empty($extrafields->attributes[$object->table_element]['label'])) {
601 foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
602 $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : '');
603 }
604}
605// Add fields from hooks
606$parameters = array();
607$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
608$sql .= $hookmanager->resPrint;
609$sql .= " FROM ";
610if ($search_bid > 0) {
611 $sql .= MAIN_DB_PREFIX."bank_class as l,";
612}
613$sql .= " ".MAIN_DB_PREFIX."bank_account as ba,";
614$sql .= " ".MAIN_DB_PREFIX."bank as b";
615if (!empty($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
616 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (b.rowid = ef.fk_object)";
617}
618
619// Add fields from hooks
620$parameters = array();
621$reshook = $hookmanager->executeHooks('printFieldListJoin', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
622$sql .= $hookmanager->resPrint;
623
624$sql .= " WHERE b.fk_account = ba.rowid";
625$sql .= " AND ba.entity IN (".getEntity('bank_account').")";
626if ($search_account > 0) {
627 $sql .= " AND b.fk_account = ".((int) $search_account);
628}
629// Search period criteria
630if (dol_strlen($search_dt_start) > 0) {
631 $sql .= " AND b.dateo >= '".$db->idate($search_dt_start)."'";
632}
633if (dol_strlen($search_dt_end) > 0) {
634 $sql .= " AND b.dateo <= '".$db->idate($search_dt_end)."'";
635}
636// Search period criteria
637if (dol_strlen($search_dv_start) > 0) {
638 $sql .= " AND b.datev >= '".$db->idate($search_dv_start)."'";
639}
640if (dol_strlen($search_dv_end) > 0) {
641 $sql .= " AND b.datev <= '".$db->idate($search_dv_end)."'";
642}
643if ($search_ref) {
644 $sql .= natural_search("b.rowid", $search_ref, 1);
645}
646if ($search_req_nb) {
647 $sql .= natural_search("b.num_chq", $search_req_nb);
648}
649if ($search_num_releve) {
650 $sql .= natural_search("b.num_releve", $search_num_releve);
651}
652if ($search_conciliated != '' && $search_conciliated != '-1') {
653 $sql .= " AND b.rappro = ".((int) $search_conciliated);
654}
655if ($search_fk_bordereau > 0) {
656 $sql .= " AND b.fk_bordereau = " . ((int) $search_fk_bordereau);
657}
658if ($search_thirdparty_user) {
659 $sql.= " AND (b.rowid IN ";
660 $sql.= " ( SELECT bu.fk_bank FROM ".MAIN_DB_PREFIX."bank_url AS bu";
661 $sql.= " JOIN ".MAIN_DB_PREFIX."bank AS b2 ON b2.rowid = bu.fk_bank";
662 $sql.= " JOIN ".MAIN_DB_PREFIX."user AS subUser ON (bu.type = 'user' AND bu.url_id = subUser.rowid)";
663 $sql.= " WHERE ". natural_search(array("subUser.firstname", "subUser.lastname"), $search_thirdparty_user, '', 1).")";
664
665 $sql.= " OR b.rowid IN ";
666 $sql.= " ( SELECT bu.fk_bank FROM ".MAIN_DB_PREFIX."bank_url AS bu";
667 $sql.= " JOIN ".MAIN_DB_PREFIX."bank AS b2 ON b2.rowid = bu.fk_bank";
668 $sql.= " JOIN ".MAIN_DB_PREFIX."societe AS subSoc ON (bu.type = 'company' AND bu.url_id = subSoc.rowid)";
669 $sql.= " WHERE ". natural_search(array("subSoc.nom"), $search_thirdparty_user, '', 1);
670 $sql.= "))";
671}
672if ($search_description) {
673 $search_description_to_use = $search_description;
674 $arrayoffixedlabels = array(
675 'payment_salary',
676 'CustomerInvoicePayment', 'CustomerInvoicePaymentBack',
677 'SupplierInvoicePayment', 'SupplierInvoicePaymentBack',
678 'DonationPayment',
679 'ExpenseReportPayment',
680 'SocialContributionPayment',
681 'SubscriptionPayment',
682 'WithdrawalPayment'
683 );
684 foreach ($arrayoffixedlabels as $keyforlabel) {
685 $translatedlabel = $langs->transnoentitiesnoconv($keyforlabel);
686 if (preg_match('/'.$search_description.'/i', $translatedlabel)) {
687 $search_description_to_use .= "|".$keyforlabel;
688 }
689 }
690 $sql .= natural_search("b.label", $search_description_to_use); // Warning some text are just translation keys, not translated strings
691}
692
693if ($search_bid > 0) {
694 $sql .= " AND b.rowid = l.lineid AND l.fk_categ = ".((int) $search_bid);
695}
696if (!empty($search_type)) {
697 $sql .= " AND b.fk_type = '".$db->escape($search_type)."'";
698}
699// Search criteria amount
700if ($search_debit) {
701 $sql .= natural_search('ABS(b.amount)', $search_debit, 1);
702 $sql .= ' AND b.amount <= 0';
703}
704if ($search_credit) {
705 $sql .= natural_search('b.amount', $search_credit, 1);
706 $sql .= ' AND b.amount >= 0';
707}
708// Add where from extra fields
709include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
710
711// Add where from hooks
712$parameters = array();
713$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
714$sql .= $hookmanager->resPrint;
715
716$sql .= $db->order($sortfield, $sortorder);
717
718$nbtotalofrecords = '';
719$nbtotalofpages = 0;
720if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
721 $result = $db->query($sql);
722 $nbtotalofrecords = $db->num_rows($result);
723 $nbtotalofpages = ceil($nbtotalofrecords / $limit);
724}
725
726if (($id > 0 || !empty($ref)) && ((string) $page == '')) {
727 // We open a list of transaction of a dedicated account and no page was set by defaut
728 // We force on last page.
729 $page = ($nbtotalofpages - 1);
730 $offset = $limit * $page;
731 if ($page < 0) {
732 $page = 0;
733 }
734}
735if ($page >= $nbtotalofpages) {
736 // If we made a search and result has low page than the page number we were on
737 $page = ($nbtotalofpages - 1);
738 $offset = $limit * $page;
739 if ($page < 0) {
740 $page = 0;
741 }
742}
743
744
745// If not account defined $mode_balance_ok=false
746if (empty($search_account)) {
747 $mode_balance_ok = false;
748}
749// If a search is done $mode_balance_ok=false
750if (!empty($search_ref)) {
751 $mode_balance_ok = false;
752}
753if (!empty($search_description)) {
754 $mode_balance_ok = false;
755}
756if (!empty($search_type)) {
757 $mode_balance_ok = false;
758}
759if (!empty($search_debit)) {
760 $mode_balance_ok = false;
761}
762if (!empty($search_credit)) {
763 $mode_balance_ok = false;
764}
765if (!empty($search_thirdparty_user)) {
766 $mode_balance_ok = false;
767}
768if ($search_conciliated != '' && $search_conciliated != '-1') {
769 $mode_balance_ok = false;
770}
771if (!empty($search_num_releve)) {
772 $mode_balance_ok = false;
773}
774if (!empty($search_fk_bordereau)) {
775 $mode_balance_ok = false;
776}
777
778$sql .= $db->plimit($limit + 1, $offset);
779//print $sql;
780dol_syslog('compta/bank/bankentries_list.php', LOG_DEBUG);
781$resql = $db->query($sql);
782if ($resql) {
783 $num = $db->num_rows($resql);
784
785 $arrayofselected = (!empty($toselect) && is_array($toselect)) ? $toselect : array();
786
787 // List of mass actions available
788 $arrayofmassactions = array(
789 //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
790 //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
791 );
792 //if ($user->rights->bank->supprimer) $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
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='.GETPOST("rowid", 'int'), $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 (GETPOST('bid')) {
821 print '<input type="hidden" name="bid" value="'.GETPOST("bid", 'int').'">';
822 }
823
824 // Form to reconcile
825 if ($user->hasRight('banque', 'consolidate') && $action == 'reconcile') {
826 print '<div class="valignmiddle inline-block" style="padding-right: 20px;">';
827 $texttoshow = $langs->trans("InputReceiptNumber").': ';
828 $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);
829 $mm = dol_substr($langs->transnoentitiesnoconv("Month"), 0, 1).substr($langs->transnoentitiesnoconv("Month"), 0, 1);
830 $dd = dol_substr($langs->transnoentitiesnoconv("Day"), 0, 1).substr($langs->transnoentitiesnoconv("Day"), 0, 1);
831 $placeholder = $yyyy.$mm;
832 $placeholder .= ' '.$langs->trans("or").' ';
833 $placeholder .= $yyyy.$mm.$dd;
834 if (!$placeholder) {
835 $texttoshow .= $langs->trans("InputReceiptNumberBis");
836 }
837 print $texttoshow;
838 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="'.(GETPOST('num_releve', 'int') ? GETPOST('num_releve', 'int') : '').'">'; // The only default value is value we just entered
839 print '</div>';
840 if (is_array($options) && count($options)) {
841 print $langs->trans("EventualyAddCategory").': ';
842 print Form::selectarray('cat', $options, GETPOST('cat'), 1);
843 }
844 print '<br><div style="margin-top: 5px;"><span class="opacitymedium">'.$langs->trans("ThenCheckLinesAndConciliate").'</span> ';
845 print '<input class="button" name="confirm_savestatement" type="submit" value="'.$langs->trans("SaveStatementOnly").'">';
846 print ' '.$langs->trans("or").' ';
847 print '<input class="button" name="confirm_reconcile" type="submit" value="'.$langs->trans("Conciliate").'">';
848 print ' '.$langs->trans("or").' ';
849 print '<input type="submit" name="cancel" class="button button-cancel" value="'.$langs->trans("Cancel").'">';
850 print '</div>';
851
852 // Show last bank statements
853 $nbmax = 12; // We show last 12 receipts (so we can have more than one year)
854 $liste = "";
855 $sql = "SELECT DISTINCT num_releve FROM ".MAIN_DB_PREFIX."bank";
856 $sql .= " WHERE fk_account = ".((int) $object->id)." AND num_releve IS NOT NULL";
857 $sql .= $db->order("num_releve", "DESC");
858 $sql .= $db->plimit($nbmax + 1);
859 print '<br>';
860 print $langs->trans("LastAccountStatements").' : ';
861 $resqlr = $db->query($sql);
862 if ($resqlr) {
863 $numr = $db->num_rows($resqlr);
864 $i = 0;
865 $last_ok = 0;
866 while (($i < $numr) && ($i < $nbmax)) {
867 $objr = $db->fetch_object($resqlr);
868 if (!$last_ok) {
869 $last_releve = $objr->num_releve;
870 $last_ok = 1;
871 }
872 $i++;
873 $liste = '<a href="'.DOL_URL_ROOT.'/compta/bank/releve.php?account='.$id.'&amp;num='.$objr->num_releve.'">'.$objr->num_releve.'</a> &nbsp; '.$liste;
874 }
875 if ($numr >= $nbmax) {
876 $liste = "... &nbsp; ".$liste;
877 }
878 print $liste;
879 if ($numr <= 0) {
880 print '<b>'.$langs->trans("None").'</b>';
881 }
882 } else {
883 dol_print_error($db);
884 }
885
886 // Using BANK_REPORT_LAST_NUM_RELEVE to automatically report last num (or not)
887 if (getDolGlobalString('BANK_REPORT_LAST_NUM_RELEVE')) {
888 print '
889 <script type="text/javascript">
890 $("#num_releve").val("' . $last_releve.'");
891 </script>
892 ';
893 }
894 print '<br><br>';
895 }
896
897 // Form to add a transaction with no invoice
898 if ($user->hasRight('banque', 'modifier') && $action == 'addline' && getDolGlobalString('BANK_USE_OLD_VARIOUS_PAYMENT')) {
899 print load_fiche_titre($langs->trans("AddBankRecordLong"), '', '');
900
901 print '<table class="noborder centpercent">';
902
903 print '<tr class="liste_titre">';
904 print '<td>'.$langs->trans("Description").'</td>';
905 print '<td>'.$langs->trans("Date").'</td>';
906 print '<td>&nbsp;</td>';
907 print '<td>'.$langs->trans("Type").'</td>';
908 print '<td>'.$langs->trans("Numero").'</td>';
909 print '<td class=right>'.$langs->trans("BankAccount").'</td>';
910 print '<td class=right>'.$langs->trans("Debit").'</td>';
911 print '<td class=right>'.$langs->trans("Credit").'</td>';
912 /*if (isModEnabled('accounting'))
913 {
914 print '<td class="center">';
915 print $langs->trans("AccountAccounting");
916 print '</td>';
917 }*/
918 print '<td align="center">&nbsp;</td>';
919 print '</tr>';
920
921 print '<tr>';
922 print '<td>';
923 print '<input name="label" class="flat minwidth200" type="text" value="'.GETPOST("label", "alpha").'">';
924 if (is_array($options) && count($options)) {
925 print '<br>'.$langs->trans("Rubrique").': ';
926 print Form::selectarray('cat1', $options, GETPOST('cat1'), 1);
927 }
928 print '</td>';
929 print '<td class="nowrap">';
930 print $form->selectDate(empty($dateop) ? -1 : $dateop, 'op', 0, 0, 0, 'transaction');
931 print '</td>';
932 print '<td>&nbsp;</td>';
933 print '<td class="nowrap">';
934 $form->select_types_paiements((GETPOST('operation') ? GETPOST('operation') : ($object->courant == Account::TYPE_CASH ? 'LIQ' : '')), 'operation', '1,2', 2, 1);
935 print '</td>';
936 print '<td>';
937 print '<input name="num_chq" class="flat" type="text" size="4" value="'.GETPOST("num_chq", "alpha").'">';
938 print '</td>';
939 //if (! $search_account > 0)
940 //{
941 print '<td class=right>';
942 $form->select_comptes(GETPOST('add_account', 'int') ? GETPOST('add_account', 'int') : $search_account, 'add_account', 0, '', 1, ($id > 0 || !empty($ref) ? ' disabled="disabled"' : ''));
943 print '</td>';
944 //}
945 print '<td class="right"><input name="adddebit" class="flat" type="text" size="4" value="'.GETPOST("adddebit", "alpha").'"></td>';
946 print '<td class="right"><input name="addcredit" class="flat" type="text" size="4" value="'.GETPOST("addcredit", "alpha").'"></td>';
947 /*if (isModEnabled('accounting'))
948 {
949 print '<td class="center">';
950 print $formaccounting->select_account($search_accountancy_code, 'search_accountancy_code', 1, null, 1, 1, '');
951 print '</td>';
952 }*/
953 print '<td class="center">';
954 print '<input type="submit" name="save" class="button buttongen marginbottomonly button-add" value="'.$langs->trans("Add").'"><br>';
955 print '<input type="submit" name="cancel" class="button buttongen marginbottomonly button-cancel" value="'.$langs->trans("Cancel").'">';
956 print '</td></tr>';
957
958 print '</table>';
959 print '<br>';
960 }
961
962 // Code to adjust value date with plus and less picto using an Ajax call instead of a full reload of page
963 $urlajax = DOL_URL_ROOT.'/core/ajax/bankconciliate.php?token='.currentToken();
964 print '
965 <script type="text/javascript">
966 $(function() {
967 $("a.ajaxforbankoperationchange").each(function(){
968 var current = $(this);
969 current.click(function()
970 {
971 var url = "'.$urlajax.'&"+current.attr("href").split("?")[1];
972 $.get(url, function(data)
973 {
974 console.log(url)
975 console.log(data)
976 current.parent().parent().find(".spanforajaxedit").replaceWith(data);
977 });
978 return false;
979 });
980 });
981 });
982 </script>
983 ';
984
985 $i = 0;
986
987 // Title
988 $bankcateg = new BankCateg($db);
989
990 $newcardbutton = '';
991 if ($action != 'addline' && $action != 'reconcile') {
992 if (!getDolGlobalString('BANK_DISABLE_DIRECT_INPUT')) {
993 if (!getDolGlobalString('BANK_USE_OLD_VARIOUS_PAYMENT')) { // Default is to record miscellaneous direct entries using miscellaneous payments
994 $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);
995 } else { // If direct entries is not done using miscellaneous payments
996 $newcardbutton = dolGetButtonTitle($langs->trans('AddBankRecord'), '', 'fa fa-plus-circle', $_SERVER["PHP_SELF"].'?action=addline&token='.newToken().'&page='.$page.$param, '', $user->rights->banque->modifier);
997 }
998 } else {
999 $newcardbutton = dolGetButtonTitle($langs->trans('AddBankRecord'), '', 'fa fa-plus-circle', $_SERVER["PHP_SELF"].'?action=addline&token='.newToken().'&page='.$page.$param, '', -1);
1000 }
1001 }
1002
1003 $morehtml = '';
1004 /*$morehtml = '<div class="inline-block '.(($buttonreconcile || $newcardbutton) ? 'marginrightonly' : '').'">';
1005 $morehtml .= '<label for="pageplusone">'.$langs->trans("Page")."</label> "; // ' Page ';
1006 $morehtml .= '<input type="text" name="pageplusone" id="pageplusone" class="flat right width25 pageplusone" value="'.($page + 1).'">';
1007 $morehtml .= '/'.$nbtotalofpages.' ';
1008 $morehtml .= '</div>';
1009 */
1010
1011 if ($action != 'addline' && $action != 'reconcile') {
1012 $morehtml .= $buttonreconcile;
1013 }
1014
1015 $morehtml .= '<!-- Add New button -->'.$newcardbutton;
1016
1017 $picto = 'bank_account';
1018 if ($id > 0 || !empty($ref)) {
1019 $picto = '';
1020 }
1021
1022 print_barre_liste($langs->trans("BankTransactions"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, $picto, 0, $morehtml, '', $limit, 0, 0, 1);
1023
1024 // We can add page now to param
1025 if ($page != '') {
1026 $param .= '&page='.urlencode($page);
1027 }
1028
1029 $moreforfilter = '';
1030
1031 $moreforfilter .= '<div class="divsearchfield">';
1032 $moreforfilter .= $langs->trans('DateOperationShort');
1033 $moreforfilter .= ($conf->browser->layout == 'phone' ? '<br>' : ' ');
1034 $moreforfilter .= '<div class="nowrap inline-block">';
1035 $moreforfilter .= $form->selectDate($search_dt_start, 'search_start_dt', 0, 0, 1, "search_form", 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
1036 $moreforfilter .= '</div>';
1037 $moreforfilter .= ($conf->browser->layout == 'phone' ? '' : ' ');
1038 $moreforfilter .= '<div class="nowrap inline-block">';
1039 $moreforfilter .= $form->selectDate($search_dt_end, 'search_end_dt', 0, 0, 1, "search_form", 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
1040 $moreforfilter .= '</div>';
1041 $moreforfilter .= '</div>';
1042
1043 $moreforfilter .= '<div class="divsearchfield">';
1044 $moreforfilter .= $langs->trans('DateValueShort');
1045 $moreforfilter .= ($conf->browser->layout == 'phone' ? '<br>' : ' ');
1046 $moreforfilter .= '<div class="nowrap inline-block">';
1047 $moreforfilter .= $form->selectDate($search_dv_start, 'search_start_dv', 0, 0, 1, "search_form", 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
1048 $moreforfilter .= '</div>';
1049 $moreforfilter .= ($conf->browser->layout == 'phone' ? '' : ' ');
1050 $moreforfilter .= '<div class="nowrap inline-block">';
1051 $moreforfilter .= $form->selectDate($search_dv_end, 'search_end_dv', 0, 0, 1, "search_form", 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
1052 $moreforfilter .= '</div>';
1053 $moreforfilter .= '</div>';
1054
1055 if (isModEnabled('categorie')) {
1056 // Categories
1057 if (isModEnabled('categorie') && $user->hasRight('categorie', 'lire')) {
1058 $langs->load('categories');
1059
1060 // Bank line
1061 $moreforfilter .= '<div class="divsearchfield">';
1062 $tmptitle = $langs->trans('RubriquesTransactions');
1063 $cate_arbo = $form->select_all_categories(Categorie::TYPE_BANK_LINE, $search_bid, 'parent', null, null, 1);
1064 $moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"').$form->selectarray('search_bid', $cate_arbo, $search_bid, $tmptitle, 0, 0, '', 0, 0, 0, '', '', 1);
1065 $moreforfilter .= '</div>';
1066 }
1067 }
1068
1069 $parameters = array();
1070 $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1071 if (empty($reshook)) {
1072 $moreforfilter .= $hookmanager->resPrint;
1073 } else {
1074 $moreforfilter = $hookmanager->resPrint;
1075 }
1076
1077 if ($moreforfilter) {
1078 print '<div class="liste_titre liste_titre_bydiv centpercent">';
1079 print $moreforfilter;
1080 print '</div>'."\n";
1081 }
1082
1083 $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
1084 $selectedfields = ($mode != 'kanban' ? $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) : ''); // This also change content of $arrayfields
1085 // When action is 'reconcile', we force to have the column num_releve always enabled (otherwise we can't make reconciliation).
1086 if ($action == 'reconcile') {
1087 $arrayfields['b.num_releve']['checked'] = 1;
1088 }
1089
1090 print '<div class="div-table-responsive">';
1091 print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
1092
1093 // Fields title search
1094 // --------------------------------------------------------------------
1095 print '<tr class="liste_titre_filter">';
1096 // Actions and select
1097 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1098 print '<td class="liste_titre valignmiddle center">';
1099 $searchpicto = $form->showFilterButtons('left');
1100 print $searchpicto;
1101 //$searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0, 'checkforselect', 1);
1102 //print $searchpicto;
1103 print '</td>';
1104 }
1105 if (!empty($arrayfields['b.rowid']['checked'])) {
1106 print '<td class="liste_titre">';
1107 print '<input type="text" class="flat" name="search_ref" size="2" value="'.dol_escape_htmltag($search_ref).'">';
1108 print '</td>';
1109 }
1110 if (!empty($arrayfields['b.label']['checked'])) {
1111 print '<td class="liste_titre">';
1112 print '<input type="text" class="flat maxwidth100" name="search_description" value="'.dol_escape_htmltag($search_description).'">';
1113 print '</td>';
1114 }
1115 if (!empty($arrayfields['b.dateo']['checked'])) {
1116 print '<td class="liste_titre">&nbsp;</td>';
1117 }
1118 if (!empty($arrayfields['b.datev']['checked'])) {
1119 print '<td class="liste_titre">&nbsp;</td>';
1120 }
1121 if (!empty($arrayfields['type']['checked'])) {
1122 print '<td class="liste_titre" align="center">';
1123 print $form->select_types_paiements(empty($search_type) ? '' : $search_type, 'search_type', '', 2, 1, 1, 0, 1, 'maxwidth100', 1);
1124 print '</td>';
1125 }
1126 // Numero
1127 if (!empty($arrayfields['b.num_chq']['checked'])) {
1128 print '<td class="liste_titre" align="center"><input type="text" class="flat" name="req_nb" value="'.dol_escape_htmltag($search_req_nb).'" size="2"></td>';
1129 }
1130 // Checked
1131 if (!empty($arrayfields['bu.label']['checked'])) {
1132 print '<td class="liste_titre"><input type="text" class="flat maxwidth75" name="search_thirdparty" value="'.dol_escape_htmltag($search_thirdparty_user).'"></td>';
1133 }
1134 // Ref
1135 if (!empty($arrayfields['ba.ref']['checked'])) {
1136 print '<td class="liste_titre">';
1137 $form->select_comptes($search_account, 'search_account', 0, '', 1, ($id > 0 || !empty($ref) ? ' disabled="disabled"' : ''), 0, 'maxwidth100');
1138 print '</td>';
1139 }
1140 // Debit
1141 if (!empty($arrayfields['b.debit']['checked'])) {
1142 print '<td class="liste_titre right">';
1143 print '<input type="text" class="flat width50" name="search_debit" value="'.dol_escape_htmltag($search_debit).'">';
1144 print '</td>';
1145 }
1146 // Credit
1147 if (!empty($arrayfields['b.credit']['checked'])) {
1148 print '<td class="liste_titre right">';
1149 print '<input type="text" class="flat width50" name="search_credit" value="'.dol_escape_htmltag($search_credit).'">';
1150 print '</td>';
1151 }
1152 // Balance before
1153 if (!empty($arrayfields['balancebefore']['checked'])) {
1154 print '<td class="liste_titre right">';
1155 $htmltext = $langs->trans("BalanceVisibilityDependsOnSortAndFilters", $langs->transnoentitiesnoconv("DateValue"));
1156 print $form->textwithpicto('', $htmltext, 1);
1157 print '</td>';
1158 }
1159 // Balance
1160 if (!empty($arrayfields['balance']['checked'])) {
1161 print '<td class="liste_titre right">';
1162 $htmltext = $langs->trans("BalanceVisibilityDependsOnSortAndFilters", $langs->transnoentitiesnoconv("DateValue"));
1163 print $form->textwithpicto('', $htmltext, 1);
1164 print '</td>';
1165 }
1166 // Numero statement
1167 if (!empty($arrayfields['b.num_releve']['checked'])) {
1168 print '<td class="liste_titre" align="center"><input type="text" class="flat" name="search_num_releve" value="'.dol_escape_htmltag($search_num_releve).'" size="3"></td>';
1169 }
1170 // Conciliated
1171 if (!empty($arrayfields['b.conciliated']['checked'])) {
1172 print '<td class="liste_titre center parentonrightofpage">';
1173 print $form->selectyesno('search_conciliated', $search_conciliated, 1, false, 1, 1, 'search_status onrightofpage maxwidth75');
1174 print '</td>';
1175 }
1176 // Bordereau
1177 if (!empty($arrayfields['b.fk_bordereau']['checked'])) {
1178 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>';
1179 }
1180 // Extra fields
1181 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
1182 // Action edit/delete and select
1183 print '<td class="nowraponall" align="center"></td>';
1184
1185 // Actions and select
1186 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1187 print '<td class="liste_titre valignmiddle center">';
1188 //$searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0, 'checkforselect', 1);
1189 //print $searchpicto;
1190 $searchpicto = $form->showFilterButtons();
1191 print $searchpicto;
1192 print '</td>';
1193 }
1194 print "</tr>\n";
1195
1196 $totalarray = array();
1197 $totalarray['nbfield'] = 0;
1198
1199 // Fields title
1200 print '<tr class="liste_titre">';
1201 // Actions and select
1202 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1203 print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
1204 $totalarray['nbfield']++;
1205 }
1206 if (!empty($arrayfields['b.rowid']['checked'])) {
1207 print_liste_field_titre($arrayfields['b.rowid']['label'], $_SERVER['PHP_SELF'], 'b.rowid', '', $param, '', $sortfield, $sortorder);
1208 $totalarray['nbfield']++;
1209 }
1210 if (!empty($arrayfields['b.label']['checked'])) {
1211 print_liste_field_titre($arrayfields['b.label']['label'], $_SERVER['PHP_SELF'], 'b.label', '', $param, '', $sortfield, $sortorder);
1212 $totalarray['nbfield']++;
1213 }
1214 if (!empty($arrayfields['b.dateo']['checked'])) {
1215 print_liste_field_titre($arrayfields['b.dateo']['label'], $_SERVER['PHP_SELF'], 'b.dateo', '', $param, '', $sortfield, $sortorder, "center ");
1216 $totalarray['nbfield']++;
1217 }
1218 if (!empty($arrayfields['b.datev']['checked'])) {
1219 print_liste_field_titre($arrayfields['b.datev']['label'], $_SERVER['PHP_SELF'], 'b.datev,b.dateo,b.rowid', '', $param, '', $sortfield, $sortorder, 'center ');
1220 $totalarray['nbfield']++;
1221 }
1222 if (!empty($arrayfields['type']['checked'])) {
1223 print_liste_field_titre($arrayfields['type']['label'], $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'center ');
1224 $totalarray['nbfield']++;
1225 }
1226 if (!empty($arrayfields['b.num_chq']['checked'])) {
1227 print_liste_field_titre($arrayfields['b.num_chq']['label'], $_SERVER['PHP_SELF'], 'b.num_chq', '', $param, '', $sortfield, $sortorder, "center ");
1228 $totalarray['nbfield']++;
1229 }
1230 if (!empty($arrayfields['bu.label']['checked'])) {
1231 print_liste_field_titre($arrayfields['bu.label']['label'], $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder);
1232 $totalarray['nbfield']++;
1233 }
1234 if (!empty($arrayfields['ba.ref']['checked'])) {
1235 print_liste_field_titre($arrayfields['ba.ref']['label'], $_SERVER['PHP_SELF'], 'ba.ref', '', $param, '', $sortfield, $sortorder);
1236 $totalarray['nbfield']++;
1237 }
1238 if (!empty($arrayfields['b.debit']['checked'])) {
1239 print_liste_field_titre($arrayfields['b.debit']['label'], $_SERVER['PHP_SELF'], 'b.amount', '', $param, '', $sortfield, $sortorder, "right ");
1240 $totalarray['nbfield']++;
1241 }
1242 if (!empty($arrayfields['b.credit']['checked'])) {
1243 print_liste_field_titre($arrayfields['b.credit']['label'], $_SERVER['PHP_SELF'], 'b.amount', '', $param, '', $sortfield, $sortorder, "right ");
1244 $totalarray['nbfield']++;
1245 }
1246 if (!empty($arrayfields['balancebefore']['checked'])) {
1247 print_liste_field_titre($arrayfields['balancebefore']['label'], $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, "right ");
1248 $totalarray['nbfield']++;
1249 }
1250 if (!empty($arrayfields['balance']['checked'])) {
1251 print_liste_field_titre($arrayfields['balance']['label'], $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, "right ");
1252 $totalarray['nbfield']++;
1253 }
1254 if (!empty($arrayfields['b.num_releve']['checked'])) {
1255 print_liste_field_titre($arrayfields['b.num_releve']['label'], $_SERVER['PHP_SELF'], 'b.num_releve', '', $param, '', $sortfield, $sortorder, "center ");
1256 $totalarray['nbfield']++;
1257 }
1258 if (!empty($arrayfields['b.conciliated']['checked'])) {
1259 print_liste_field_titre($arrayfields['b.conciliated']['label'], $_SERVER['PHP_SELF'], 'b.rappro', '', $param, '', $sortfield, $sortorder, "center ");
1260 $totalarray['nbfield']++;
1261 }
1262 if (!empty($arrayfields['b.fk_bordereau']['checked'])) {
1263 print_liste_field_titre($arrayfields['b.fk_bordereau']['label'], $_SERVER['PHP_SELF'], 'b.fk_bordereau', '', $param, '', $sortfield, $sortorder, "center ");
1264 $totalarray['nbfield']++;
1265 }
1266
1267 // Extra fields
1268 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
1269 // Hook fields
1270 $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder, 'totalarray'=>&$totalarray);
1271 $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1272 print $hookmanager->resPrint;
1273 // Action edit/delete and select
1274 print '<td class="nowraponall" align="center"></td>';
1275 $totalarray['nbfield']++;
1276 // Actions and select
1277 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1278 //print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
1279 print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'maxwidthsearch center ');
1280 $totalarray['nbfield']++;
1281 }
1282 print "</tr>\n";
1283
1284 $balance = 0; // For balance
1285 $balancebefore = 0; // For balance
1286 $balancecalculated = false;
1287 $posconciliatecol = 0;
1288 $cachebankaccount = array();
1289
1290 $sign = 1;
1291
1292 // Loop on each record
1293 $i = 0;
1294 $savnbfield = $totalarray['nbfield'];
1295 $totalarray = array();
1296 $totalarray['nbfield'] = 0;
1297 $totalarray['totaldeb'] = 0;
1298 $totalarray['totalcred'] = 0;
1299
1300 $imaxinloop = ($limit ? min($num, $limit) : $num);
1301 while ($i < $imaxinloop) {
1302 $objp = $db->fetch_object($resql);
1303 $links = $bankaccountstatic->get_url($objp->rowid);
1304
1305 // If we are in a situation where we need/can show balance, we calculate the start of balance
1306 if (!$balancecalculated && (!empty($arrayfields['balancebefore']['checked']) || !empty($arrayfields['balance']['checked'])) && ($mode_balance_ok || $search_conciliated === '0')) {
1307 if (!$search_account) {
1308 dol_print_error('', 'account is not defined but $mode_balance_ok is true');
1309 exit;
1310 }
1311
1312 // Loop on each record before
1313 $sign = 1;
1314 $i = 0;
1315 $sqlforbalance = 'SELECT SUM(b.amount) as previoustotal';
1316 $sqlforbalance .= " FROM ";
1317 $sqlforbalance .= " ".MAIN_DB_PREFIX."bank_account as ba,";
1318 $sqlforbalance .= " ".MAIN_DB_PREFIX."bank as b";
1319 $sqlforbalance .= " WHERE b.fk_account = ba.rowid";
1320 $sqlforbalance .= " AND ba.entity IN (".getEntity('bank_account').")";
1321 $sqlforbalance .= " AND b.fk_account = ".((int) $search_account);
1322 $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."))))";
1323 $resqlforbalance = $db->query($sqlforbalance);
1324 //print $sqlforbalance;
1325 if ($resqlforbalance) {
1326 $objforbalance = $db->fetch_object($resqlforbalance);
1327 if ($objforbalance) {
1328 // If sort is desc,desc,desc then total of previous date + amount is the balancebefore of the previous line before the line to show
1329 if ($sortfield == 'b.datev,b.dateo,b.rowid' && ($sortorder == 'desc' || $sortorder == 'desc,desc' || $sortorder == 'desc,desc,desc')) {
1330 $balancebefore = $objforbalance->previoustotal + ($sign * $objp->amount);
1331 } else {
1332 // If sort is asc,asc,asc then total of previous date is balance of line before the next line to show
1333 $balance = $objforbalance->previoustotal;
1334 }
1335 }
1336 } else {
1337 dol_print_error($db);
1338 }
1339
1340 $balancecalculated = true;
1341
1342 // Output a line with start balance
1343 if ($user->hasRight('banque', 'consolidate') && $action == 'reconcile') {
1344 $tmpnbfieldbeforebalance = 0;
1345 $tmpnbfieldafterbalance = 0;
1346 $balancefieldfound = 0;
1347 foreach ($arrayfields as $key => $val) {
1348 if ($key == 'balancebefore' || $key == 'balance') {
1349 $balancefieldfound++;
1350 continue;
1351 }
1352 if (!empty($arrayfields[$key]['checked'])) {
1353 if (!$balancefieldfound) {
1354 $tmpnbfieldbeforebalance++;
1355 } else {
1356 $tmpnbfieldafterbalance++;
1357 }
1358 }
1359 }
1360 // Extra
1361 $element = $extrafieldsobjectkey;
1362 if (!empty($extrafields->attributes[$element]['label']) && is_array($extrafields->attributes[$element]['label']) && count($extrafields->attributes[$element]['label'])) {
1363 foreach ($extrafields->attributes[$element]['label'] as $key => $val) {
1364 if (!empty($arrayfields["ef.".$key]['checked'])) {
1365 if (!empty($arrayfields[$key]['checked'])) {
1366 if (!$balancefieldfound) {
1367 $tmpnbfieldbeforebalance++;
1368 } else {
1369 $tmpnbfieldafterbalance++;
1370 }
1371 }
1372 }
1373 }
1374 }
1375
1376 print '<tr class="oddeven trforbreak">';
1377 // Action column
1378 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1379 print '<td></td>';
1380 }
1381 if ($tmpnbfieldbeforebalance) {
1382 print '<td colspan="'.$tmpnbfieldbeforebalance.'">';
1383 print '&nbsp;';
1384 print '</td>';
1385 }
1386
1387 if (!empty($arrayfields['balancebefore']['checked'])) {
1388 print '<td class="right">';
1389 if ($search_conciliated !== '0') {
1390 print price(price2num($balance, 'MT'), 1, $langs);
1391 }
1392 print '</td>';
1393 }
1394 if (!empty($arrayfields['balance']['checked'])) {
1395 print '<td class="right">';
1396 if ($search_conciliated !== '0') {
1397 print price(price2num($balance, 'MT'), 1, $langs);
1398 }
1399 print '</td>';
1400 }
1401 if (!empty($arrayfields['b.num_releve']['checked'])) {
1402 print '<td class="center">';
1403 print '<input type="checkbox" id="selectAll" title="'.dol_escape_htmltag($langs->trans("SelectAll")).'" />';
1404 print ' <script type="text/javascript">
1405 $("input#selectAll").change(function() {
1406 $("input[type=checkbox][name^=rowid]").prop("checked", $(this).is(":checked"));
1407 });
1408 </script>';
1409 print '</td>';
1410 }
1411
1412 // conciliate
1413 print '<td colspan="'.($tmpnbfieldafterbalance).'">';
1414 print '&nbsp;';
1415 print '</td>';
1416
1417 // Action column
1418 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1419 print '<td></td>';
1420 }
1421
1422 print '</tr>';
1423 }
1424 }
1425
1426 if ($sortfield == 'b.datev,b.dateo,b.rowid' && ($sortorder == 'desc' || $sortorder == 'desc,desc' || $sortorder == 'desc,desc,desc')) {
1427 $balance = price2num($balancebefore, 'MT'); // balance = balancebefore of previous line (sort is desc)
1428 $balancebefore = price2num($balancebefore - ($sign * $objp->amount), 'MT');
1429 } else {
1430 $balancebefore = price2num($balance, 'MT'); // balancebefore = balance of previous line (sort is asc)
1431 $balance = price2num($balance + ($sign * $objp->amount), 'MT');
1432 }
1433
1434 if (empty($cachebankaccount[$objp->bankid])) {
1435 $bankaccounttmp = new Account($db);
1436 $bankaccounttmp->fetch($objp->bankid);
1437 $cachebankaccount[$objp->bankid] = $bankaccounttmp;
1438 $bankaccount = $bankaccounttmp;
1439 } else {
1440 $bankaccount = $cachebankaccount[$objp->bankid];
1441 }
1442
1443 if (!getDolGlobalString('BANK_COLORIZE_MOVEMENT')) {
1444 $backgroundcolor = "class='oddeven'";
1445 } else {
1446 if ($objp->amount < 0) {
1447 $color = '#' . getDolGlobalString('BANK_COLORIZE_MOVEMENT_COLOR1', 'fca955');
1448 $backgroundcolor = 'style="background: '.$color.';"';
1449 } else {
1450 $color = '#' . getDolGlobalString('BANK_COLORIZE_MOVEMENT_COLOR2', '7fdb86');
1451 $backgroundcolor = 'style="background: '.$color.';"';
1452 }
1453 }
1454
1455 $banklinestatic->id = $objp->rowid;
1456 $banklinestatic->ref = $objp->rowid;
1457
1458 print '<tr class="oddeven" '.$backgroundcolor.'>';
1459
1460 // Action column
1461 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1462 print '<td>';
1463 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
1464 $selected = 0;
1465 if (in_array($obj->rowid, $arrayofselected)) {
1466 $selected = 1;
1467 }
1468 print '<input id="cb'.$obj->rowid.'" class="flat checkforselect marginleftonly" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
1469 }
1470 print '</td>';
1471 if (!$i) {
1472 $totalarray['nbfield']++;
1473 }
1474 }
1475
1476 // Ref
1477 if (!empty($arrayfields['b.rowid']['checked'])) {
1478 print '<td class="nowrap left">';
1479 print $banklinestatic->getNomUrl(1);
1480 print '</td>';
1481 if (!$i) {
1482 $totalarray['nbfield']++;
1483 }
1484 }
1485
1486 // Description
1487 if (!empty($arrayfields['b.label']['checked'])) {
1488 $labeltoshow = '';
1489 $titletoshow = '';
1490 $reg = array();
1491 preg_match('/\‍((.+)\‍)/i', $objp->label, $reg); // Si texte entoure de parenthee on tente recherche de traduction
1492 if (!empty($reg[1]) && $langs->trans($reg[1]) != $reg[1]) {
1493 // Example: $reg[1] = 'CustomerInvoicePayment', 'SupplierInvoicePayment', ... (or on old version: 'WithdrawalPayment', 'BankTransferPayment')
1494 $labeltoshow = $langs->trans($reg[1]);
1495 } else {
1496 if ($objp->label == '(payment_salary)') {
1497 $labeltoshow = $langs->trans("SalaryPayment");
1498 } else {
1499 $labeltoshow = dol_escape_htmltag($objp->label);
1500 $titletoshow = $objp->label;
1501 }
1502 }
1503
1504
1505 print '<td class="tdoverflowmax250"'.($titletoshow ? ' title="'.dol_escape_htmltag($titletoshow).'"' : '').'>';
1506
1507 // Add info about links after description
1508 $cachebankaccount = array();
1509 foreach ($links as $key => $val) {
1510 print '<!-- '.$links[$key]['type'].' -->';
1511 if ($links[$key]['type'] == 'withdraw') {
1512 $banktransferstatic->id = $links[$key]['url_id'];
1513 $banktransferstatic->ref = $links[$key]['label'];
1514 print $banktransferstatic->getNomUrl(0).($labeltoshow ? ' ' : '');
1515 } elseif ($links[$key]['type'] == 'payment') {
1516 $paymentstatic->id = $links[$key]['url_id'];
1517 $paymentstatic->ref = $links[$key]['url_id']; // FIXME This is id, not ref of payment
1518 $paymentstatic->date = $db->jdate($objp->do);
1519 print $paymentstatic->getNomUrl(2).($labeltoshow ? ' ' : '');
1520 } elseif ($links[$key]['type'] == 'payment_supplier') {
1521 $paymentsupplierstatic->id = $links[$key]['url_id'];
1522 $paymentsupplierstatic->ref = $links[$key]['url_id']; // FIXME This is id, not ref of payment
1523 print $paymentsupplierstatic->getNomUrl(2).($labeltoshow ? ' ' : '');
1524 } elseif ($links[$key]['type'] == 'payment_sc') {
1525 $paymentscstatic->id = $links[$key]['url_id'];
1526 $paymentscstatic->ref = $links[$key]['url_id'];
1527 $paymentscstatic->label = $links[$key]['label'];
1528 print $paymentscstatic->getNomUrl(2).($labeltoshow ? ' ' : '');
1529 } elseif ($links[$key]['type'] == 'payment_vat') {
1530 $paymentvatstatic->id = $links[$key]['url_id'];
1531 $paymentvatstatic->ref = $links[$key]['url_id'];
1532 print $paymentvatstatic->getNomUrl(2).($labeltoshow ? ' ' : '');
1533 } elseif ($links[$key]['type'] == 'payment_salary') {
1534 $paymentsalstatic->id = $links[$key]['url_id'];
1535 $paymentsalstatic->ref = $links[$key]['url_id'];
1536 $paymentsalstatic->label = $links[$key]['label'];
1537 print $paymentsalstatic->getNomUrl(2).($labeltoshow ? ' ' : '');
1538 } elseif ($links[$key]['type'] == 'payment_loan') {
1539 print '<a href="'.DOL_URL_ROOT.'/loan/payment/card.php?id='.$links[$key]['url_id'].'">';
1540 print ' '.img_object($langs->trans('ShowPayment'), 'payment').' ';
1541 print '</a>'.($labeltoshow ? ' ' : '');
1542 } elseif ($links[$key]['type'] == 'payment_donation') {
1543 $paymentdonationstatic->id = $links[$key]['url_id'];
1544 $paymentdonationstatic->ref = $links[$key]['url_id'];
1545 print $paymentdonationstatic->getNomUrl(2).($labeltoshow ? ' ' : '');
1546 } elseif ($links[$key]['type'] == 'payment_expensereport') {
1547 $paymentexpensereportstatic->id = $links[$key]['url_id'];
1548 $paymentexpensereportstatic->ref = $links[$key]['url_id'];
1549 print $paymentexpensereportstatic->getNomUrl(2).($labeltoshow ? ' ' : '');
1550 } elseif ($links[$key]['type'] == 'payment_various') {
1551 $paymentvariousstatic->id = $links[$key]['url_id'];
1552 $paymentvariousstatic->ref = $links[$key]['url_id'];
1553 print $paymentvariousstatic->getNomUrl(2).($labeltoshow ? ' ' : '');
1554 } elseif ($links[$key]['type'] == 'banktransfert') {
1555 // Do not show link to transfer since there is no transfer card (avoid confusion). Can already be accessed from transaction detail.
1556 if ($objp->amount > 0) {
1557 $banklinestatic->fetch($links[$key]['url_id']);
1558 $bankstatic->id = $banklinestatic->fk_account;
1559 $bankstatic->label = $banklinestatic->bank_account_ref;
1560 print $langs->trans("TransferFrom").' ';
1561 print $bankstatic->getNomUrl(1, 'transactions');
1562 print ' '.$langs->trans("toward").' ';
1563 $bankstatic->id = $objp->bankid;
1564 $bankstatic->label = $objp->bankref;
1565 print $bankstatic->getNomUrl(1, '');
1566 print($labeltoshow ? ' - ' : '');
1567 } else {
1568 $bankstatic->id = $objp->bankid;
1569 $bankstatic->label = $objp->bankref;
1570 print $langs->trans("TransferFrom").' ';
1571 print $bankstatic->getNomUrl(1, '');
1572 print ' '.$langs->trans("toward").' ';
1573 $banklinestatic->fetch($links[$key]['url_id']);
1574 $bankstatic->id = $banklinestatic->fk_account;
1575 $bankstatic->label = $banklinestatic->bank_account_ref;
1576 print $bankstatic->getNomUrl(1, 'transactions');
1577 print($labeltoshow ? ' - ' : '');
1578 }
1579 //var_dump($links);
1580 } elseif ($links[$key]['type'] == 'company') {
1581 } elseif ($links[$key]['type'] == 'user') {
1582 } elseif ($links[$key]['type'] == 'member') {
1583 } elseif ($links[$key]['type'] == 'sc') {
1584 } elseif ($links[$key]['type'] == 'vat') {
1585 } elseif ($links[$key]['type'] == 'salary') {
1586 // Information is already shown using the payment_salary link. No need of this link.
1587 } else {
1588 // Show link with label $links[$key]['label']
1589 print '<a href="'.$links[$key]['url'].$links[$key]['url_id'].'">';
1590 if (preg_match('/^\‍((.*)\‍)$/i', $links[$key]['label'], $reg)) {
1591 // Label generique car entre parentheses. On l'affiche en le traduisant
1592 if ($reg[1] == 'paiement') {
1593 $reg[1] = 'Payment';
1594 }
1595 print $langs->trans($reg[1]);
1596 } else {
1597 print $links[$key]['label'];
1598 }
1599 print '</a>'.($labeltoshow ? ' - ' : '');
1600 }
1601 }
1602
1603 print $labeltoshow; // Already escaped
1604
1605 print '</td>';
1606 if (!$i) {
1607 $totalarray['nbfield']++;
1608 }
1609 }
1610
1611 // Date ope
1612 if (!empty($arrayfields['b.dateo']['checked'])) {
1613 print '<td align="center" class="nowrap">';
1614 print '<span class="spanforajaxedit" id="dateoperation_'.$objp->rowid.'">'.dol_print_date($db->jdate($objp->do), "day")."</span>";
1615 print '&nbsp;';
1616 print '<span class="inline-block">';
1617 print '<a class="ajaxforbankoperationchange" href="'.$_SERVER['PHP_SELF'].'?action=doprev&amp;account='.$objp->bankid.'&amp;rowid='.$objp->rowid.'">';
1618 print img_edit_remove()."</a> ";
1619 print '<a class="ajaxforbankoperationchange" href="'.$_SERVER['PHP_SELF'].'?action=donext&amp;account='.$objp->bankid.'&amp;rowid='.$objp->rowid.'">';
1620 print img_edit_add()."</a>";
1621 print '</span>';
1622 print "</td>\n";
1623 if (!$i) {
1624 $totalarray['nbfield']++;
1625 }
1626 }
1627
1628 // Date value
1629 if (!empty($arrayfields['b.datev']['checked'])) {
1630 print '<td align="center" class="nowrap">';
1631 print '<span class="spanforajaxedit" id="datevalue_'.$objp->rowid.'">'.dol_print_date($db->jdate($objp->dv), "day")."</span>";
1632 print '&nbsp;';
1633 print '<span class="inline-block">';
1634 print '<a class="ajaxforbankoperationchange" href="'.$_SERVER['PHP_SELF'].'?action=dvprev&amp;account='.$objp->bankid.'&amp;rowid='.$objp->rowid.'">';
1635 print img_edit_remove()."</a> ";
1636 print '<a class="ajaxforbankoperationchange" href="'.$_SERVER['PHP_SELF'].'?action=dvnext&amp;account='.$objp->bankid.'&amp;rowid='.$objp->rowid.'">';
1637 print img_edit_add()."</a>";
1638 print '</span>';
1639 print "</td>\n";
1640 if (!$i) {
1641 $totalarray['nbfield']++;
1642 }
1643 }
1644
1645 // Payment type
1646 if (!empty($arrayfields['type']['checked'])) {
1647 print '<td class="tdoverflowmax100">';
1648 $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);
1649 if ($labeltype == 'SOLD') {
1650 print '&nbsp;'; //$langs->trans("InitialBankBalance");
1651 } else {
1652 print $labeltype;
1653 }
1654 print "</td>\n";
1655 if (!$i) {
1656 $totalarray['nbfield']++;
1657 }
1658 }
1659
1660 // Num cheque
1661 if (!empty($arrayfields['b.num_chq']['checked'])) {
1662 print '<td class="nowrap" align="center">'.($objp->num_chq ? dol_escape_htmltag($objp->num_chq) : "")."</td>\n";
1663 if (!$i) {
1664 $totalarray['nbfield']++;
1665 }
1666 }
1667
1668 // Third party
1669 if (!empty($arrayfields['bu.label']['checked'])) {
1670 print '<td class="tdoverflowmax150">';
1671
1672 $companylinked_id = 0;
1673 $userlinked_id = 0;
1674 $type_link = "";
1675
1676 //payment line type to define user display and user or company linked
1677 foreach ($links as $key => $value) {
1678 if ($links[$key]['type'] == 'payment_sc') {
1679 $type_link = 'payment_sc';
1680 }
1681 if ($links[$key]['type'] == 'payment_salary') {
1682 $type_link = 'payment_salary';
1683 }
1684
1685 if ($links[$key]['type'] == 'company') {
1686 $companylinked_id = $links[$key]['url_id'];
1687 }
1688 if ($links[$key]['type'] == 'user') {
1689 $userlinked_id = $links[$key]['url_id'];
1690 }
1691 }
1692
1693 if ($companylinked_id) {
1694 // TODO Add a cache of loaded companies here ?
1695 $companystatic->fetch($companylinked_id);
1696 print $companystatic->getNomUrl(1);
1697 } elseif ($userlinked_id &&
1698 (($type_link == 'payment_salary' && $user->hasRight('salaries', 'read'))
1699 || ($type_link == 'payment_sc' && $user->hasRight('tax', 'charges', 'lire')))) {
1700 // Get object user from cache or load it
1701 if (!empty($conf->cache['user'][$userlinked_id])) {
1702 $tmpuser = $conf->cache['user'][$userlinked_id];
1703 } else {
1704 $tmpuser = new User($db);
1705 $tmpuser->fetch($userlinked_id);
1706 $conf->cache['user'][$userlinked_id] = $tmpuser;
1707 }
1708 print $tmpuser->getNomUrl(1);
1709 } else {
1710 print '&nbsp;';
1711 }
1712
1713 print '</td>';
1714 if (!$i) {
1715 $totalarray['nbfield']++;
1716 }
1717 }
1718
1719 // Bank account
1720 if (!empty($arrayfields['ba.ref']['checked'])) {
1721 print '<td class="nowrap">';
1722 print $bankaccount->getNomUrl(1);
1723 print "</td>\n";
1724 if (!$i) {
1725 $totalarray['nbfield']++;
1726 }
1727 }
1728
1729 // Debit
1730 if (!empty($arrayfields['b.debit']['checked'])) {
1731 print '<td class="nowrap right"><span class="amount">';
1732 if ($objp->amount < 0) {
1733 print price($objp->amount * -1);
1734 $totalarray['totaldeb'] += $objp->amount;
1735 }
1736 print "</span></td>\n";
1737 if (!$i) {
1738 $totalarray['nbfield']++;
1739 }
1740 if (!$i) {
1741 $totalarray['totaldebfield'] = $totalarray['nbfield'];
1742 }
1743 }
1744
1745 // Credit
1746 if (!empty($arrayfields['b.credit']['checked'])) {
1747 print '<td class="nowrap right"><span class="amount">';
1748 if ($objp->amount > 0) {
1749 print price($objp->amount);
1750 $totalarray['totalcred'] += $objp->amount;
1751 }
1752 print "</span></td>\n";
1753 if (!$i) {
1754 $totalarray['nbfield']++;
1755 }
1756 if (!$i) {
1757 $totalarray['totalcredfield'] = $totalarray['nbfield'];
1758 }
1759 }
1760
1761 // Balance before
1762 if (!empty($arrayfields['balancebefore']['checked'])) {
1763 if ($mode_balance_ok) {
1764 if ($balancebefore >= 0) {
1765 print '<td class="nowrap right">&nbsp;'.price($balancebefore).'</td>';
1766 } else {
1767 print '<td class="error nowrap right">&nbsp;'.price($balancebefore).'</td>';
1768 }
1769 } else {
1770 print '<td class="right">-</td>';
1771 }
1772 if (!$i) {
1773 $totalarray['nbfield']++;
1774 }
1775 }
1776
1777 // Balance after
1778 if (!empty($arrayfields['balance']['checked'])) {
1779 if ($mode_balance_ok) {
1780 if ($balance >= 0) {
1781 print '<td class="nowrap right">&nbsp;'.price($balance).'</td>';
1782 } else {
1783 print '<td class="error nowrap right">&nbsp;'.price($balance).'</td>';
1784 }
1785 } else {
1786 print '<td class="right">-</td>';
1787 }
1788 if (!$i) {
1789 $totalarray['nbfield']++;
1790 }
1791 }
1792
1793 if (!empty($arrayfields['b.num_releve']['checked'])) {
1794 print '<td class="nowraponall" align="center">';
1795 // Transaction reconciliated or edit link
1796 if ($bankaccount->canBeConciliated() > 0) {
1797 if ($objp->num_releve) {
1798 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>';
1799 }
1800 if (!$objp->conciliated && $action == 'reconcile') {
1801 if ($objp->num_releve) {
1802 print '&nbsp;';
1803 }
1804 print '<input class="flat" name="rowid['.$objp->rowid.']" type="checkbox" value="'.$objp->rowid.'" size="1"'.(!empty($_POST['rowid'][$objp->rowid]) ? ' checked' : '').'>';
1805 }
1806 }
1807 print '</td>';
1808 if (!$i) {
1809 $totalarray['nbfield']++;
1810 $posconciliatecol = $totalarray['nbfield'];
1811 }
1812 }
1813
1814 if (!empty($arrayfields['b.conciliated']['checked'])) {
1815 print '<td class="nowraponall" align="center">';
1816 print yn($objp->conciliated);
1817 print '</td>';
1818 if (!$i) {
1819 $totalarray['nbfield']++;
1820 }
1821 }
1822
1823 if (!empty($arrayfields['b.fk_bordereau']['checked'])) {
1824 $bordereaustatic->fetch($objp->fk_bordereau);
1825 print '<td class="nowraponall" align="center">';
1826 print $bordereaustatic->getNomUrl();
1827 print '</td>';
1828 if (!$i) {
1829 $totalarray['nbfield']++;
1830 }
1831 }
1832
1833 // Extra fields
1834 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
1835 // Fields from hook
1836 $parameters=array('arrayfields'=>$arrayfields, 'object'=>$object, 'obj'=>$objp, 'i'=>$i, 'totalarray'=>&$totalarray);
1837 $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $objecttmpect may have been modified by hook
1838 print $hookmanager->resPrint;
1839
1840 // Action edit/delete and select
1841 print '<td class="nowraponall" align="center">';
1842 // Transaction reconciliated or edit link
1843 if ($objp->conciliated && $bankaccount->canBeConciliated() > 0) { // If line not conciliated and account can be conciliated
1844 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.'">';
1845 print img_edit();
1846 print '</a>';
1847 } else {
1848 if ($user->hasRight('banque', 'modifier') || $user->hasRight('banque', 'consolidate')) {
1849 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.'">';
1850 print img_edit();
1851 print '</a>';
1852 } else {
1853 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.'">';
1854 print img_view();
1855 print '</a>';
1856 }
1857 if ($bankaccount->canBeConciliated() > 0 && empty($objp->conciliated)) {
1858 if ($db->jdate($objp->dv) < ($now - $conf->bank->rappro->warning_delay)) {
1859 print ' '.img_warning($langs->trans("ReconciliationLate"));
1860 }
1861 }
1862 if ($user->hasRight('banque', 'modifier')) {
1863 print '<a href="'.$_SERVER["PHP_SELF"].'?action=delete&token='.newToken().'&rowid='.$objp->rowid.'&page='.$page.$param.($sortfield ? '&sortfield='.$sortfield : '').($sortorder ? '&sortorder='.$sortorder : '').'">';
1864 print img_delete('', 'class="marginleftonly"');
1865 print '</a>';
1866 }
1867 }
1868 print '</td>';
1869 if (!$i) {
1870 $totalarray['nbfield']++;
1871 }
1872
1873 // Action column
1874 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1875 print '<td>';
1876 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
1877 $selected = 0;
1878 if (in_array($objp->rowid, $arrayofselected)) {
1879 $selected = 1;
1880 }
1881 print '<input id="cb'.$objp->rowid.'" class="flat checkforselect marginleftonly" type="checkbox" name="toselect[]" value="'.$objp->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
1882 }
1883 print '</td>';
1884 if (!$i) {
1885 $totalarray['nbfield']++;
1886 }
1887 }
1888
1889 print "</tr>\n";
1890
1891 $i++;
1892 }
1893
1894 // Show total line
1895 if (isset($totalarray['totaldebfield']) || isset($totalarray['totalcredfield'])) {
1896 print '<tr class="liste_total">';
1897 $i = 0;
1898 while ($i < $totalarray['nbfield']) {
1899 $i++;
1900 if ($i == 1) {
1901 if ($num < $limit && empty($offset)) {
1902 print '<td class="left">'.$langs->trans("Total").'</td>';
1903 } else {
1904 print '<td class="left tdoverflowmax50" title="'.$langs->trans("Totalforthispage").'">'.$langs->trans("Totalforthispage").'</td>';
1905 }
1906 } elseif ($totalarray['totaldebfield'] == $i) {
1907 print '<td class="right"><span class="amount">'.price(-1 * $totalarray['totaldeb']).'</span></td>';
1908 } elseif ($totalarray['totalcredfield'] == $i) {
1909 print '<td class="right"><span class="amount">'.price($totalarray['totalcred']).'</span></td>';
1910 } elseif ($i == $posconciliatecol) {
1911 print '<td class="center">';
1912 if ($user->hasRight('banque', 'consolidate') && $action == 'reconcile') {
1913 print '<input class="button" name="confirm_reconcile" type="submit" value="'.$langs->trans("Conciliate").'">';
1914 }
1915 print '</td>';
1916 } else {
1917 print '<td></td>';
1918 }
1919 }
1920 print '</tr>';
1921 }
1922
1923 // If no record found
1924 if ($num == 0) {
1925 $colspan = 1;
1926 foreach ($arrayfields as $key => $val) {
1927 if (!empty($val['checked'])) {
1928 $colspan++;
1929 }
1930 }
1931 print '<tr><td colspan="'.($colspan + 1).'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
1932 }
1933
1934 print "</table>";
1935 print "</div>";
1936
1937 print '</form>';
1938 $db->free($resql);
1939} else {
1940 dol_print_error($db);
1941}
1942
1943// End of page
1944llxFooter();
1945$db->close();
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:37
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.
Classe permettant la gestion des paiements des charges La tva collectee n'est calculee que sur les fa...
Class to manage donations.
Definition don.class.php:40
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.
Classe 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_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='rowid', $fieldref='ref', $morehtmlref='', $moreparam='', $nodbprefix=0, $morehtmlleft='', $morehtmlstatus='', $onlybanner=0, $morehtmlright='')
Show tab footer of a card.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
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 '.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
img_view($titlealt='default', $float=0, $other='class="valignmiddle"')
Show logo view card.
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by second index function, which produces ascending (default) or descending output...
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.
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.
print_barre_liste($titre, $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.
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 editer/modifier 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...
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.