dolibarr 20.0.2
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[$extrafieldsobjectkey]['label'])) {
602 foreach ($extrafields->attributes[$extrafieldsobjectkey]['label'] as $key => $val) {
603 $sql .= ($extrafields->attributes[$extrafieldsobjectkey]['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[$extrafieldsobjectkey]['label']) && is_array($extrafields->attributes[$extrafieldsobjectkey]['label']) && count($extrafields->attributes[$extrafieldsobjectkey]['label'])) {
617 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$extrafieldsobjectkey."_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 width100" id="num_releve" list="num_releve_list" 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 $placeholder2 = $yyyy.$mm;
966 $placeholder2 .= ' '.$langs->trans("or").' ';
967 $placeholder2 .= $yyyy.$mm.$dd;
968 if (!$placeholder) {
969 $texttoshow .= $langs->trans("InputReceiptNumberBis");
970 }
971 print $texttoshow;
972 print '<input class="flat width100" pattern="[0-9]+" title="'.dol_escape_htmltag($texttoshow.': '.$placeholder2).'" 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
973 }
974 print '</div>';
975 if (is_array($options) && count($options)) {
976 print $langs->trans("EventualyAddCategory").': ';
977 print Form::selectarray('cat', $options, GETPOST('cat'), 1);
978 }
979 print '<br><div style="margin-top: 5px;"><span class="opacitymedium">'.$langs->trans("ThenCheckLinesAndConciliate").'</span> ';
980 print '<input type="submit" class="button" name="confirm_reconcile" value="'.$langs->trans("Conciliate").'">';
981 print ' <span class="opacitymedium">'.$langs->trans("otherwise").'</span> ';
982 print '<input type="submit" class="button small" name="confirm_savestatement" value="'.$langs->trans("SaveStatementOnly").'">';
983 print ' <span class="opacitymedium">'.$langs->trans("or").'</span> ';
984 print '<input type="submit" name="cancel" class="button button-cancel small" value="'.$langs->trans("Cancel").'">';
985 print '</div>';
986
987 // Show last bank statements
988 $nbmax = 12; // We show last 12 receipts (so we can have more than one year)
989 $listoflastreceipts = '';
990 $sql = "SELECT DISTINCT num_releve FROM ".MAIN_DB_PREFIX."bank";
991 $sql .= " WHERE fk_account = ".((int) $object->id)." AND num_releve IS NOT NULL";
992 $sql .= $db->order("num_releve", "DESC");
993 $sql .= $db->plimit($nbmax + 1);
994
995 print '<br>';
996 print $langs->trans("LastAccountStatements").' : ';
997 $resqlr = $db->query($sql);
998 if ($resqlr) {
999 $numr = $db->num_rows($resqlr);
1000 $i = 0;
1001 $last_ok = 0;
1002 while (($i < $numr) && ($i < $nbmax)) {
1003 $objr = $db->fetch_object($resqlr);
1004 if (!$last_ok) {
1005 $last_releve = $objr->num_releve;
1006 $last_ok = 1;
1007 }
1008 $i++;
1009 $newentreyinlist = '<a target="_blank" href="'.DOL_URL_ROOT.'/compta/bank/releve.php?account='.((int) $id).'&num='.urlencode($objr->num_releve).'">';
1010 $newentreyinlist .= img_picto($objr->num_releve, 'generic', 'class="paddingright"');
1011 $newentreyinlist .= dol_escape_htmltag($objr->num_releve).'</a> &nbsp; ';
1012 $listoflastreceipts = $newentreyinlist.$listoflastreceipts;
1013 }
1014 if ($numr >= $nbmax) {
1015 $listoflastreceipts = "... &nbsp; ".$listoflastreceipts;
1016 }
1017 print $listoflastreceipts;
1018 if ($numr <= 0) {
1019 print '<b>'.$langs->trans("None").'</b>';
1020 }
1021 } else {
1022 dol_print_error($db);
1023 }
1024
1025 // Using BANK_REPORT_LAST_NUM_RELEVE to automatically report last num (or not)
1026 if (getDolGlobalString('BANK_REPORT_LAST_NUM_RELEVE')) {
1027 print '
1028 <script type="text/javascript">
1029 $("#num_releve").val("' . $last_releve.'");
1030 </script>
1031 ';
1032 }
1033 print '<br><br>';
1034 }
1035
1036 // We can add page now to param
1037 if ($page != '') {
1038 $param .= '&page='.urlencode((string) ($page));
1039 }
1040
1041 $moreforfilter = '';
1042 $moreforfilter .= '<div class="divsearchfield">';
1043 $moreforfilter .= $langs->trans('DateOperationShort');
1044 $moreforfilter .= ($conf->browser->layout == 'phone' ? '<br>' : ' ');
1045 $moreforfilter .= '<div class="nowrap inline-block">';
1046 $moreforfilter .= $form->selectDate($search_dt_start, 'search_start_dt', 0, 0, 1, "search_form", 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
1047 $moreforfilter .= '</div>';
1048 $moreforfilter .= ($conf->browser->layout == 'phone' ? '' : ' ');
1049 $moreforfilter .= '<div class="nowrap inline-block">';
1050 $moreforfilter .= $form->selectDate($search_dt_end, 'search_end_dt', 0, 0, 1, "search_form", 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
1051 $moreforfilter .= '</div>';
1052 $moreforfilter .= '</div>';
1053
1054 $moreforfilter .= '<div class="divsearchfield">';
1055 $moreforfilter .= $langs->trans('DateValueShort');
1056 $moreforfilter .= ($conf->browser->layout == 'phone' ? '<br>' : ' ');
1057 $moreforfilter .= '<div class="nowrap inline-block">';
1058 $moreforfilter .= $form->selectDate($search_dv_start, 'search_start_dv', 0, 0, 1, "search_form", 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
1059 $moreforfilter .= '</div>';
1060 $moreforfilter .= ($conf->browser->layout == 'phone' ? '' : ' ');
1061 $moreforfilter .= '<div class="nowrap inline-block">';
1062 $moreforfilter .= $form->selectDate($search_dv_end, 'search_end_dv', 0, 0, 1, "search_form", 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
1063 $moreforfilter .= '</div>';
1064 $moreforfilter .= '</div>';
1065
1066 if (isModEnabled('category')) {
1067 // Categories
1068 if (isModEnabled('category') && $user->hasRight('categorie', 'lire')) {
1069 $langs->load('categories');
1070
1071 // Bank line
1072 $moreforfilter .= '<div class="divsearchfield">';
1073 $tmptitle = $langs->trans('RubriquesTransactions');
1074 $cate_arbo = $form->select_all_categories(Categorie::TYPE_BANK_LINE, $search_bid, 'parent', null, null, 1);
1075 $moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"').$form->selectarray('search_bid', $cate_arbo, $search_bid, $tmptitle, 0, 0, '', 0, 0, 0, '', '', 1);
1076 $moreforfilter .= '</div>';
1077 }
1078 }
1079
1080 $parameters = array();
1081 $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1082 if (empty($reshook)) {
1083 $moreforfilter .= $hookmanager->resPrint;
1084 } else {
1085 $moreforfilter = $hookmanager->resPrint;
1086 }
1087
1088 if ($moreforfilter) {
1089 print '<div class="liste_titre liste_titre_bydiv centpercent">';
1090 print $moreforfilter;
1091 print '</div>'."\n";
1092 }
1093
1094 $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
1095 $htmlofselectarray = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')); // This also change content of $arrayfields with user setup
1096 $selectedfields = ($mode != 'kanban' ? $htmlofselectarray : '');
1097 $selectedfields .= ($action == 'reconcile' ? $form->showCheckAddButtons('checkforselect', 1) : '');
1098
1099 // When action is 'reconcile', we force to have the column num_releve always enabled (otherwise we can't make reconciliation).
1100 if ($action == 'reconcile') {
1101 $arrayfields['b.num_releve']['checked'] = 1;
1102 }
1103
1104 print '<div class="div-table-responsive">';
1105 print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
1106
1107 // Fields title search
1108 // --------------------------------------------------------------------
1109 print '<tr class="liste_titre_filter">';
1110 // Actions and select
1111 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1112 print '<td class="liste_titre valignmiddle center">';
1113 $searchpicto = $form->showFilterButtons('left');
1114 print $searchpicto;
1115 //$searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0, 'checkforselect', 1);
1116 //print $searchpicto;
1117 print '</td>';
1118 }
1119 if (!empty($arrayfields['b.rowid']['checked'])) {
1120 print '<td class="liste_titre">';
1121 print '<input type="text" class="flat" name="search_ref" size="2" value="'.dol_escape_htmltag($search_ref).'">';
1122 print '</td>';
1123 }
1124 if (!empty($arrayfields['b.label']['checked'])) {
1125 print '<td class="liste_titre">';
1126 print '<input type="text" class="flat maxwidth100" name="search_description" value="'.dol_escape_htmltag($search_description).'">';
1127 print '</td>';
1128 }
1129 if (!empty($arrayfields['b.dateo']['checked'])) {
1130 print '<td class="liste_titre">&nbsp;</td>';
1131 }
1132 if (!empty($arrayfields['b.datev']['checked'])) {
1133 print '<td class="liste_titre">&nbsp;</td>';
1134 }
1135 if (!empty($arrayfields['type']['checked'])) {
1136 print '<td class="liste_titre center">';
1137 print $form->select_types_paiements(empty($search_type) ? '' : $search_type, 'search_type', '', 2, 1, 1, 0, 1, 'maxwidth100', 1);
1138 print '</td>';
1139 }
1140 // Numero
1141 if (!empty($arrayfields['b.num_chq']['checked'])) {
1142 print '<td class="liste_titre center"><input type="text" class="flat" name="req_nb" value="'.dol_escape_htmltag($search_req_nb).'" size="2"></td>';
1143 }
1144 // Checked
1145 if (!empty($arrayfields['bu.label']['checked'])) {
1146 print '<td class="liste_titre"><input type="text" class="flat maxwidth75" name="search_thirdparty" value="'.dol_escape_htmltag($search_thirdparty_user).'"></td>';
1147 }
1148 // Ref
1149 if (!empty($arrayfields['ba.ref']['checked'])) {
1150 print '<td class="liste_titre">';
1151 $form->select_comptes($search_account, 'search_account', 0, '', 1, ($id > 0 || !empty($ref) ? ' disabled="disabled"' : ''), 0, 'maxwidth100');
1152 print '</td>';
1153 }
1154 // Debit
1155 if (!empty($arrayfields['b.debit']['checked'])) {
1156 print '<td class="liste_titre right">';
1157 print '<input type="text" class="flat width50" name="search_debit" value="'.dol_escape_htmltag($search_debit).'">';
1158 print '</td>';
1159 }
1160 // Credit
1161 if (!empty($arrayfields['b.credit']['checked'])) {
1162 print '<td class="liste_titre right">';
1163 print '<input type="text" class="flat width50" name="search_credit" value="'.dol_escape_htmltag($search_credit).'">';
1164 print '</td>';
1165 }
1166 // Balance before
1167 if (!empty($arrayfields['balancebefore']['checked'])) {
1168 print '<td class="liste_titre right">';
1169 $htmltext = $langs->trans("BalanceVisibilityDependsOnSortAndFilters", $langs->transnoentitiesnoconv("DateValue"));
1170 print $form->textwithpicto('', $htmltext, 1);
1171 print '</td>';
1172 }
1173 // Balance
1174 if (!empty($arrayfields['balance']['checked'])) {
1175 print '<td class="liste_titre right">';
1176 $htmltext = $langs->trans("BalanceVisibilityDependsOnSortAndFilters", $langs->transnoentitiesnoconv("DateValue"));
1177 print $form->textwithpicto('', $htmltext, 1);
1178 print '</td>';
1179 }
1180 // Numero statement
1181 if (!empty($arrayfields['b.num_releve']['checked'])) {
1182 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>';
1183 }
1184 // Conciliated
1185 if (!empty($arrayfields['b.conciliated']['checked'])) {
1186 print '<td class="liste_titre center parentonrightofpage">';
1187 print $form->selectyesno('search_conciliated', $search_conciliated, 1, false, 1, 1, 'search_status onrightofpage maxwidth75');
1188 print '</td>';
1189 }
1190 // Bordereau
1191 if (!empty($arrayfields['b.fk_bordereau']['checked'])) {
1192 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>';
1193 }
1194 // Extra fields
1195 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
1196 // Action edit/delete and select
1197 print '<td class="nowraponall center"></td>';
1198
1199 // Actions and select
1200 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1201 print '<td class="liste_titre valignmiddle center">';
1202 //$searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0, 'checkforselect', 1);
1203 //print $searchpicto;
1204 $searchpicto = $form->showFilterButtons();
1205 print $searchpicto;
1206 print '</td>';
1207 }
1208 print "</tr>\n";
1209
1210 $totalarray = array();
1211 $totalarray['nbfield'] = 0;
1212
1213 // Fields title
1214 print '<tr class="liste_titre">';
1215 // Actions and select
1216 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1217 print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
1218 $totalarray['nbfield']++;
1219 }
1220 if (!empty($arrayfields['b.rowid']['checked'])) {
1221 print_liste_field_titre($arrayfields['b.rowid']['label'], $_SERVER['PHP_SELF'], 'b.rowid', '', $param, '', $sortfield, $sortorder);
1222 $totalarray['nbfield']++;
1223 }
1224 if (!empty($arrayfields['b.label']['checked'])) {
1225 print_liste_field_titre($arrayfields['b.label']['label'], $_SERVER['PHP_SELF'], 'b.label', '', $param, '', $sortfield, $sortorder);
1226 $totalarray['nbfield']++;
1227 }
1228 if (!empty($arrayfields['b.dateo']['checked'])) {
1229 print_liste_field_titre($arrayfields['b.dateo']['label'], $_SERVER['PHP_SELF'], 'b.dateo', '', $param, '', $sortfield, $sortorder, "center ");
1230 $totalarray['nbfield']++;
1231 }
1232 if (!empty($arrayfields['b.datev']['checked'])) {
1233 print_liste_field_titre($arrayfields['b.datev']['label'], $_SERVER['PHP_SELF'], 'b.datev,b.dateo,b.rowid', '', $param, '', $sortfield, $sortorder, 'center ');
1234 $totalarray['nbfield']++;
1235 }
1236 if (!empty($arrayfields['type']['checked'])) {
1237 print_liste_field_titre($arrayfields['type']['label'], $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'center ');
1238 $totalarray['nbfield']++;
1239 }
1240 if (!empty($arrayfields['b.num_chq']['checked'])) {
1241 print_liste_field_titre($arrayfields['b.num_chq']['label'], $_SERVER['PHP_SELF'], 'b.num_chq', '', $param, '', $sortfield, $sortorder, "center ");
1242 $totalarray['nbfield']++;
1243 }
1244 if (!empty($arrayfields['bu.label']['checked'])) {
1245 print_liste_field_titre($arrayfields['bu.label']['label'], $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder);
1246 $totalarray['nbfield']++;
1247 }
1248 if (!empty($arrayfields['ba.ref']['checked'])) {
1249 print_liste_field_titre($arrayfields['ba.ref']['label'], $_SERVER['PHP_SELF'], 'ba.ref', '', $param, '', $sortfield, $sortorder);
1250 $totalarray['nbfield']++;
1251 }
1252 if (!empty($arrayfields['b.debit']['checked'])) {
1253 print_liste_field_titre($arrayfields['b.debit']['label'], $_SERVER['PHP_SELF'], 'b.amount', '', $param, '', $sortfield, $sortorder, "right ");
1254 $totalarray['nbfield']++;
1255 }
1256 if (!empty($arrayfields['b.credit']['checked'])) {
1257 print_liste_field_titre($arrayfields['b.credit']['label'], $_SERVER['PHP_SELF'], 'b.amount', '', $param, '', $sortfield, $sortorder, "right ");
1258 $totalarray['nbfield']++;
1259 }
1260 if (!empty($arrayfields['balancebefore']['checked'])) {
1261 print_liste_field_titre($arrayfields['balancebefore']['label'], $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, "right ");
1262 $totalarray['nbfield']++;
1263 }
1264 if (!empty($arrayfields['balance']['checked'])) {
1265 print_liste_field_titre($arrayfields['balance']['label'], $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, "right ");
1266 $totalarray['nbfield']++;
1267 }
1268 if (!empty($arrayfields['b.num_releve']['checked'])) {
1269 print_liste_field_titre($arrayfields['b.num_releve']['label'], $_SERVER['PHP_SELF'], 'b.num_releve', '', $param, '', $sortfield, $sortorder, "center ");
1270 $totalarray['nbfield']++;
1271 }
1272 if (!empty($arrayfields['b.conciliated']['checked'])) {
1273 print_liste_field_titre($arrayfields['b.conciliated']['label'], $_SERVER['PHP_SELF'], 'b.rappro', '', $param, '', $sortfield, $sortorder, "center ");
1274 $totalarray['nbfield']++;
1275 }
1276 if (!empty($arrayfields['b.fk_bordereau']['checked'])) {
1277 print_liste_field_titre($arrayfields['b.fk_bordereau']['label'], $_SERVER['PHP_SELF'], 'b.fk_bordereau', '', $param, '', $sortfield, $sortorder, "center ");
1278 $totalarray['nbfield']++;
1279 }
1280
1281 // Extra fields
1282 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
1283 // Hook fields
1284 $parameters = array('arrayfields' => $arrayfields, 'param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder, 'totalarray' => &$totalarray);
1285 $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1286 print $hookmanager->resPrint;
1287 // Action edit/delete and select
1288 print '<td class="nowraponall center"></td>';
1289 $totalarray['nbfield']++;
1290 // Actions and select
1291 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1292 //print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
1293 print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'maxwidthsearch center ');
1294 $totalarray['nbfield']++;
1295 }
1296 print "</tr>\n";
1297
1298 $balance = 0; // For balance
1299 $balancebefore = 0; // For balance
1300 $balancecalculated = false;
1301 $posconciliatecol = 0;
1302 $cachebankaccount = array();
1303
1304 $sign = 1;
1305
1306 // Loop on each record
1307 $i = 0;
1308 $savnbfield = $totalarray['nbfield'];
1309 $totalarray = array();
1310 $totalarray['nbfield'] = 0;
1311 $totalarray['totaldeb'] = 0;
1312 $totalarray['totalcred'] = 0;
1313
1314 $imaxinloop = ($limit ? min($num, $limit) : $num);
1315 while ($i < $imaxinloop) {
1316 $objp = $db->fetch_object($resql);
1317 $links = $bankaccountstatic->get_url($objp->rowid);
1318
1319 // If we are in a situation where we need/can show balance, we calculate the start of balance
1320 if (!$balancecalculated && (!empty($arrayfields['balancebefore']['checked']) || !empty($arrayfields['balance']['checked'])) && ($mode_balance_ok || $search_conciliated === '0')) {
1321 if (!$search_account) {
1322 dol_print_error(null, 'account is not defined but $mode_balance_ok is true');
1323 exit;
1324 }
1325
1326 // Loop on each record before
1327 $sign = 1;
1328 $i = 0;
1329 $sqlforbalance = 'SELECT SUM(b.amount) as previoustotal';
1330 $sqlforbalance .= " FROM ";
1331 $sqlforbalance .= " ".MAIN_DB_PREFIX."bank_account as ba,";
1332 $sqlforbalance .= " ".MAIN_DB_PREFIX."bank as b";
1333 $sqlforbalance .= " WHERE b.fk_account = ba.rowid";
1334 $sqlforbalance .= " AND ba.entity IN (".getEntity('bank_account').")";
1335 $sqlforbalance .= " AND b.fk_account = ".((int) $search_account);
1336 // To limit record on the page
1337 $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."))))";
1338 $resqlforbalance = $db->query($sqlforbalance);
1339
1340 //print $sqlforbalance;
1341 if ($resqlforbalance) {
1342 $objforbalance = $db->fetch_object($resqlforbalance);
1343 if ($objforbalance) {
1344 // If sort is desc,desc,desc then total of previous date + amount is the balancebefore of the previous line before the line to show
1345 if ($sortfield == 'b.datev,b.dateo,b.rowid' && ($sortorder == 'desc' || $sortorder == 'desc,desc' || $sortorder == 'desc,desc,desc')) {
1346 $balancebefore = $objforbalance->previoustotal + ($sign * $objp->amount);
1347 } else {
1348 // If sort is asc,asc,asc then total of previous date is balance of line before the next line to show
1349 $balance = $objforbalance->previoustotal;
1350 }
1351 }
1352 } else {
1353 dol_print_error($db);
1354 }
1355
1356 $balancecalculated = true;
1357
1358 // Output a line with start balance
1359 if ($user->hasRight('banque', 'consolidate') && $action == 'reconcile') {
1360 $tmpnbfieldbeforebalance = 0;
1361 $tmpnbfieldafterbalance = 0;
1362 $balancefieldfound = 0;
1363 foreach ($arrayfields as $key => $val) {
1364 if ($key == 'balancebefore' || $key == 'balance') {
1365 $balancefieldfound++;
1366 continue;
1367 }
1368 if (!empty($arrayfields[$key]['checked'])) {
1369 if (!$balancefieldfound) {
1370 $tmpnbfieldbeforebalance++;
1371 } else {
1372 $tmpnbfieldafterbalance++;
1373 }
1374 }
1375 }
1376 // Extra
1377 $element = $extrafieldsobjectkey;
1378 if (!empty($extrafields->attributes[$element]['label']) && is_array($extrafields->attributes[$element]['label']) && count($extrafields->attributes[$element]['label'])) {
1379 foreach ($extrafields->attributes[$element]['label'] as $key => $val) {
1380 if (!empty($arrayfields["ef.".$key]['checked'])) {
1381 if (!empty($arrayfields[$key]['checked'])) {
1382 if (!$balancefieldfound) {
1383 $tmpnbfieldbeforebalance++;
1384 } else {
1385 $tmpnbfieldafterbalance++;
1386 }
1387 }
1388 }
1389 }
1390 }
1391
1392 print '<tr class="oddeven trforbreak">';
1393 // Action column
1394 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1395 print '<td></td>';
1396 }
1397 if ($tmpnbfieldbeforebalance) {
1398 print '<td colspan="'.$tmpnbfieldbeforebalance.'">';
1399 print '&nbsp;';
1400 print '</td>';
1401 }
1402
1403 if (!empty($arrayfields['balancebefore']['checked'])) {
1404 print '<td class="right">';
1405 if ($search_conciliated !== '0') {
1406 if ($sortfield == 'b.datev,b.dateo,b.rowid' && ($sortorder == 'desc' || $sortorder == 'desc,desc' || $sortorder == 'desc,desc,desc')) {
1407 print price(price2num($balancebefore, 'MT'), 1, $langs);
1408 } else {
1409 print price(price2num($balance, 'MT'), 1, $langs);
1410 }
1411 }
1412 print '</td>';
1413 }
1414 if (!empty($arrayfields['balance']['checked'])) {
1415 print '<td class="right">';
1416 if ($search_conciliated !== '0') { // If not filter of filter on "conciliated"
1417 if ($sortfield == 'b.datev,b.dateo,b.rowid' && ($sortorder == 'desc' || $sortorder == 'desc,desc' || $sortorder == 'desc,desc,desc')) {
1418 print price(price2num($balancebefore, 'MT'), 1, $langs);
1419 } else {
1420 print price(price2num($balance, 'MT'), 1, $langs);
1421 }
1422 }
1423 print '</td>';
1424 }
1425 if (!empty($arrayfields['b.num_releve']['checked'])) {
1426 print '<td></td>';
1427 }
1428
1429 // conciliate
1430 print '<td colspan="'.($tmpnbfieldafterbalance).'">';
1431 print '&nbsp;';
1432 print '</td>';
1433
1434 // Action column
1435 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1436 print '<td></td>';
1437 }
1438
1439 print '</tr>';
1440 }
1441 }
1442
1443 if ($sortfield == 'b.datev,b.dateo,b.rowid' && ($sortorder == 'desc' || $sortorder == 'desc,desc' || $sortorder == 'desc,desc,desc')) {
1444 $balance = price2num($balancebefore, 'MT'); // balance = balancebefore of previous line (sort is desc)
1445 $balancebefore = price2num($balancebefore - ($sign * $objp->amount), 'MT');
1446 } else {
1447 $balancebefore = price2num($balance, 'MT'); // balancebefore = balance of previous line (sort is asc)
1448 $balance = price2num($balance + ($sign * $objp->amount), 'MT');
1449 }
1450
1451 if (empty($cachebankaccount[$objp->bankid])) {
1452 $bankaccounttmp = new Account($db);
1453 $bankaccounttmp->fetch($objp->bankid);
1454 $cachebankaccount[$objp->bankid] = $bankaccounttmp;
1455 $bankaccount = $bankaccounttmp;
1456 } else {
1457 $bankaccount = $cachebankaccount[$objp->bankid];
1458 }
1459
1460 if (!getDolGlobalString('BANK_COLORIZE_MOVEMENT')) {
1461 $backgroundcolor = "class='oddeven'";
1462 } else {
1463 if ($objp->amount < 0) {
1464 $color = '#' . getDolGlobalString('BANK_COLORIZE_MOVEMENT_COLOR1', 'fca955');
1465 $backgroundcolor = 'style="background: '.$color.';"';
1466 } else {
1467 $color = '#' . getDolGlobalString('BANK_COLORIZE_MOVEMENT_COLOR2', '7fdb86');
1468 $backgroundcolor = 'style="background: '.$color.';"';
1469 }
1470 }
1471
1472 $banklinestatic->id = $objp->rowid;
1473 $banklinestatic->ref = $objp->rowid;
1474
1475 print '<tr class="oddeven" '.$backgroundcolor.'>';
1476
1477 // Action column
1478 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1479 print '<td class="center">';
1480 if (!$objp->conciliated && $action == 'reconcile') {
1481 print '<input class="flat checkforselect" name="rowid['.$objp->rowid.']" type="checkbox" name="toselect[]" value="'.$objp->rowid.'" size="1"'.(!empty($tmparray[$objp->rowid]) ? ' checked' : '').'>';
1482 }
1483 print '</td>';
1484 if (!$i) {
1485 $totalarray['nbfield']++;
1486 }
1487 }
1488
1489 // Ref
1490 if (!empty($arrayfields['b.rowid']['checked'])) {
1491 print '<td class="nowrap left">';
1492 print $banklinestatic->getNomUrl(1);
1493 print '</td>';
1494 if (!$i) {
1495 $totalarray['nbfield']++;
1496 }
1497 }
1498
1499 // Description
1500 if (!empty($arrayfields['b.label']['checked'])) {
1501 $labeltoshow = '';
1502 $titletoshow = '';
1503 $reg = array();
1504 preg_match('/\‍((.+)\‍)/i', $objp->label, $reg); // Si texte entoure de parenthee on tente recherche de traduction
1505 if (!empty($reg[1]) && $langs->trans($reg[1]) != $reg[1]) {
1506 // Example: $reg[1] = 'CustomerInvoicePayment', 'SupplierInvoicePayment', ... (or on old version: 'WithdrawalPayment', 'BankTransferPayment')
1507 $labeltoshow = $langs->trans($reg[1]);
1508 } else {
1509 if ($objp->label == '(payment_salary)') {
1510 $labeltoshow = $langs->trans("SalaryPayment");
1511 } else {
1512 $labeltoshow = dol_escape_htmltag($objp->label);
1513 $titletoshow = $objp->label;
1514 }
1515 }
1516
1517
1518 print '<td class="tdoverflowmax250"'.($titletoshow ? ' title="'.dol_escape_htmltag($titletoshow).'"' : '').'>';
1519
1520 // Add info about links after description
1521 $cachebankaccount = array();
1522 foreach ($links as $key => $val) {
1523 print '<!-- '.$links[$key]['type'].' -->';
1524 if ($links[$key]['type'] == 'withdraw') {
1525 $banktransferstatic->id = $links[$key]['url_id'];
1526 $banktransferstatic->ref = $links[$key]['label'];
1527 print $banktransferstatic->getNomUrl(0).($labeltoshow ? ' ' : '');
1528 } elseif ($links[$key]['type'] == 'payment') {
1529 $paymentstatic->id = $links[$key]['url_id'];
1530 $paymentstatic->ref = $links[$key]['url_id']; // FIXME This is id, not ref of payment
1531 $paymentstatic->date = $db->jdate($objp->do);
1532 print $paymentstatic->getNomUrl(2).($labeltoshow ? ' ' : '');
1533 } elseif ($links[$key]['type'] == 'payment_supplier') {
1534 $paymentsupplierstatic->id = $links[$key]['url_id'];
1535 $paymentsupplierstatic->ref = $links[$key]['url_id']; // FIXME This is id, not ref of payment
1536 print $paymentsupplierstatic->getNomUrl(2).($labeltoshow ? ' ' : '');
1537 } elseif ($links[$key]['type'] == 'payment_sc') {
1538 $paymentscstatic->id = $links[$key]['url_id'];
1539 $paymentscstatic->ref = $links[$key]['url_id'];
1540 $paymentscstatic->label = $links[$key]['label'];
1541 print $paymentscstatic->getNomUrl(2).($labeltoshow ? ' ' : '');
1542 } elseif ($links[$key]['type'] == 'payment_vat') {
1543 $paymentvatstatic->id = $links[$key]['url_id'];
1544 $paymentvatstatic->ref = $links[$key]['url_id'];
1545 print $paymentvatstatic->getNomUrl(2).($labeltoshow ? ' ' : '');
1546 } elseif ($links[$key]['type'] == 'payment_salary') {
1547 $paymentsalstatic->id = $links[$key]['url_id'];
1548 $paymentsalstatic->ref = $links[$key]['url_id'];
1549 $paymentsalstatic->label = $links[$key]['label'];
1550 print $paymentsalstatic->getNomUrl(2).($labeltoshow ? ' ' : '');
1551 } elseif ($links[$key]['type'] == 'payment_loan') {
1552 print '<a href="'.DOL_URL_ROOT.'/loan/payment/card.php?id='.$links[$key]['url_id'].'">';
1553 print ' '.img_object($langs->trans('ShowPayment'), 'payment').' ';
1554 print '</a>'.($labeltoshow ? ' ' : '');
1555 } elseif ($links[$key]['type'] == 'payment_donation') {
1556 $paymentdonationstatic->id = $links[$key]['url_id'];
1557 $paymentdonationstatic->ref = $links[$key]['url_id'];
1558 print $paymentdonationstatic->getNomUrl(2).($labeltoshow ? ' ' : '');
1559 } elseif ($links[$key]['type'] == 'payment_expensereport') {
1560 $paymentexpensereportstatic->id = $links[$key]['url_id'];
1561 $paymentexpensereportstatic->ref = $links[$key]['url_id'];
1562 print $paymentexpensereportstatic->getNomUrl(2).($labeltoshow ? ' ' : '');
1563 } elseif ($links[$key]['type'] == 'payment_various') {
1564 $paymentvariousstatic->id = $links[$key]['url_id'];
1565 $paymentvariousstatic->ref = $links[$key]['url_id'];
1566 print $paymentvariousstatic->getNomUrl(2).($labeltoshow ? ' ' : '');
1567 } elseif ($links[$key]['type'] == 'banktransfert') {
1568 // Do not show link to transfer since there is no transfer card (avoid confusion). Can already be accessed from transaction detail.
1569 if ($objp->amount > 0) {
1570 $banklinestatic->fetch($links[$key]['url_id']);
1571 $bankstatic->id = $banklinestatic->fk_account;
1572 $bankstatic->label = $banklinestatic->bank_account_ref;
1573 print $langs->trans("TransferFrom").' ';
1574 print $bankstatic->getNomUrl(1, 'transactions');
1575 print ' '.$langs->trans("toward").' ';
1576 $bankstatic->id = $objp->bankid;
1577 $bankstatic->label = $objp->bankref;
1578 print $bankstatic->getNomUrl(1, '');
1579 print($labeltoshow ? ' - ' : '');
1580 } else {
1581 $bankstatic->id = $objp->bankid;
1582 $bankstatic->label = $objp->bankref;
1583 print $langs->trans("TransferFrom").' ';
1584 print $bankstatic->getNomUrl(1, '');
1585 print ' '.$langs->trans("toward").' ';
1586 $banklinestatic->fetch($links[$key]['url_id']);
1587 $bankstatic->id = $banklinestatic->fk_account;
1588 $bankstatic->label = $banklinestatic->bank_account_ref;
1589 print $bankstatic->getNomUrl(1, 'transactions');
1590 print($labeltoshow ? ' - ' : '');
1591 }
1592 //var_dump($links);
1593 } elseif ($links[$key]['type'] == 'company') {
1594 } elseif ($links[$key]['type'] == 'user') {
1595 } elseif ($links[$key]['type'] == 'member') {
1596 } elseif ($links[$key]['type'] == 'sc') {
1597 } elseif ($links[$key]['type'] == 'vat') {
1598 } elseif ($links[$key]['type'] == 'salary') {
1599 // Information is already shown using the payment_salary link. No need of this link.
1600 } else {
1601 // Show link with label $links[$key]['label']
1602 print '<a href="'.$links[$key]['url'].$links[$key]['url_id'].'">';
1603 if (preg_match('/^\‍((.*)\‍)$/i', $links[$key]['label'], $reg)) {
1604 // Label generique car entre parentheses. On l'affiche en le traduisant
1605 if ($reg[1] == 'paiement') {
1606 $reg[1] = 'Payment';
1607 }
1608 print $langs->trans($reg[1]);
1609 } else {
1610 print $links[$key]['label'];
1611 }
1612 print '</a>'.($labeltoshow ? ' - ' : '');
1613 }
1614 }
1615
1616 print $labeltoshow; // Already escaped
1617
1618 print '</td>';
1619 if (!$i) {
1620 $totalarray['nbfield']++;
1621 }
1622 }
1623
1624 // Date ope
1625 if (!empty($arrayfields['b.dateo']['checked'])) {
1626 print '<td class="nowrap center">';
1627 print '<span class="spanforajaxedit" id="dateoperation_'.$objp->rowid.'">'.dol_print_date($db->jdate($objp->do), "day")."</span>";
1628 print '&nbsp;';
1629 print '<span class="inline-block">';
1630 print '<a class="ajaxforbankoperationchange" href="'.$_SERVER['PHP_SELF'].'?action=doprev&amp;account='.$objp->bankid.'&amp;rowid='.$objp->rowid.'">';
1631 print img_edit_remove()."</a> ";
1632 print '<a class="ajaxforbankoperationchange" href="'.$_SERVER['PHP_SELF'].'?action=donext&amp;account='.$objp->bankid.'&amp;rowid='.$objp->rowid.'">';
1633 print img_edit_add()."</a>";
1634 print '</span>';
1635 print "</td>\n";
1636 if (!$i) {
1637 $totalarray['nbfield']++;
1638 }
1639 }
1640
1641 // Date value
1642 if (!empty($arrayfields['b.datev']['checked'])) {
1643 print '<td class="nowrap center">';
1644 print '<span class="spanforajaxedit" id="datevalue_'.$objp->rowid.'">'.dol_print_date($db->jdate($objp->dv), "day")."</span>";
1645 print '&nbsp;';
1646 print '<span class="inline-block">';
1647 print '<a class="ajaxforbankoperationchange" href="'.$_SERVER['PHP_SELF'].'?action=dvprev&amp;account='.$objp->bankid.'&amp;rowid='.$objp->rowid.'">';
1648 print img_edit_remove()."</a> ";
1649 print '<a class="ajaxforbankoperationchange" href="'.$_SERVER['PHP_SELF'].'?action=dvnext&amp;account='.$objp->bankid.'&amp;rowid='.$objp->rowid.'">';
1650 print img_edit_add()."</a>";
1651 print '</span>';
1652 print "</td>\n";
1653 if (!$i) {
1654 $totalarray['nbfield']++;
1655 }
1656 }
1657
1658 // Payment type
1659 if (!empty($arrayfields['type']['checked'])) {
1660 print '<td class="tdoverflowmax100">';
1661 $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);
1662 if ($labeltype == 'SOLD') {
1663 print '&nbsp;'; //$langs->trans("InitialBankBalance");
1664 } else {
1665 print $labeltype;
1666 }
1667 print "</td>\n";
1668 if (!$i) {
1669 $totalarray['nbfield']++;
1670 }
1671 }
1672
1673 // Num cheque
1674 if (!empty($arrayfields['b.num_chq']['checked'])) {
1675 print '<td class="nowrap center">'.($objp->num_chq ? dol_escape_htmltag($objp->num_chq) : "")."</td>\n";
1676 if (!$i) {
1677 $totalarray['nbfield']++;
1678 }
1679 }
1680
1681 // Third party
1682 if (!empty($arrayfields['bu.label']['checked'])) {
1683 print '<td class="tdoverflowmax150">';
1684
1685 $companylinked_id = 0;
1686 $userlinked_id = 0;
1687 $type_link = "";
1688
1689 //payment line type to define user display and user or company linked
1690 foreach ($links as $key => $value) {
1691 if ($links[$key]['type'] == 'payment_sc') {
1692 $type_link = 'payment_sc';
1693 }
1694 if ($links[$key]['type'] == 'payment_salary') {
1695 $type_link = 'payment_salary';
1696 }
1697 if ($links[$key]['type'] == 'payment_expensereport') {
1698 $type_link = 'payment_expensereport';
1699 }
1700
1701 if ($links[$key]['type'] == 'company') {
1702 $companylinked_id = $links[$key]['url_id'];
1703 }
1704 if ($links[$key]['type'] == 'user') {
1705 $userlinked_id = $links[$key]['url_id'];
1706 }
1707 }
1708
1709 if ($companylinked_id) {
1710 // TODO Add a cache of loaded companies here ?
1711 $companystatic->fetch($companylinked_id);
1712 print $companystatic->getNomUrl(1);
1713 } elseif ($userlinked_id &&
1714 (($type_link == 'payment_salary' && $user->hasRight('salaries', 'read'))
1715 || ($type_link == 'payment_sc' && $user->hasRight('tax', 'charges', 'lire'))
1716 || ($type_link == 'payment_expensereport' && $user->hasRight('expensereport', 'lire')))) {
1717 // Get object user from cache or load it
1718 if (!empty($conf->cache['user'][$userlinked_id])) {
1719 $tmpuser = $conf->cache['user'][$userlinked_id];
1720 } else {
1721 $tmpuser = new User($db);
1722 $tmpuser->fetch($userlinked_id);
1723 $conf->cache['user'][$userlinked_id] = $tmpuser;
1724 }
1725 print $tmpuser->getNomUrl(-1);
1726 } else {
1727 print '&nbsp;';
1728 }
1729
1730 print '</td>';
1731 if (!$i) {
1732 $totalarray['nbfield']++;
1733 }
1734 }
1735
1736 // Bank account
1737 if (!empty($arrayfields['ba.ref']['checked'])) {
1738 print '<td class="nowrap">';
1739 print $bankaccount->getNomUrl(1);
1740 print "</td>\n";
1741 if (!$i) {
1742 $totalarray['nbfield']++;
1743 }
1744 }
1745
1746 // Debit
1747 if (!empty($arrayfields['b.debit']['checked'])) {
1748 print '<td class="nowrap right"><span class="amount">';
1749 if ($objp->amount < 0) {
1750 print price($objp->amount * -1);
1751 $totalarray['totaldeb'] += $objp->amount;
1752 }
1753 print "</span></td>\n";
1754 if (!$i) {
1755 $totalarray['nbfield']++;
1756 }
1757 if (!$i) {
1758 $totalarray['totaldebfield'] = $totalarray['nbfield'];
1759 }
1760 }
1761
1762 // Credit
1763 if (!empty($arrayfields['b.credit']['checked'])) {
1764 print '<td class="nowrap right"><span class="amount">';
1765 if ($objp->amount > 0) {
1766 print price($objp->amount);
1767 $totalarray['totalcred'] += $objp->amount;
1768 }
1769 print "</span></td>\n";
1770 if (!$i) {
1771 $totalarray['nbfield']++;
1772 }
1773 if (!$i) {
1774 $totalarray['totalcredfield'] = $totalarray['nbfield'];
1775 }
1776 }
1777
1778 // Balance before
1779 if (!empty($arrayfields['balancebefore']['checked'])) {
1780 if ($mode_balance_ok) {
1781 if ($balancebefore >= 0) {
1782 print '<td class="nowrap right">&nbsp;'.price($balancebefore).'</td>';
1783 } else {
1784 print '<td class="error nowrap right">&nbsp;'.price($balancebefore).'</td>';
1785 }
1786 } else {
1787 print '<td class="right">-</td>';
1788 }
1789 if (!$i) {
1790 $totalarray['nbfield']++;
1791 }
1792 }
1793
1794 // Balance after
1795 if (!empty($arrayfields['balance']['checked'])) {
1796 if ($mode_balance_ok) {
1797 if ($balance >= 0) {
1798 print '<td class="nowrap right">&nbsp;'.price($balance).'</td>';
1799 } else {
1800 print '<td class="error nowrap right">&nbsp;'.price($balance).'</td>';
1801 }
1802 } else {
1803 print '<td class="right">-</td>';
1804 }
1805 if (!$i) {
1806 $totalarray['nbfield']++;
1807 }
1808 }
1809
1810 if (!empty($arrayfields['b.num_releve']['checked'])) {
1811 print '<td class="nowraponall center">';
1812 // Transaction reconciliated or edit link
1813 if ($bankaccount->canBeConciliated() > 0) {
1814 if ($objp->num_releve) {
1815 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>';
1816 }
1817 }
1818 print '</td>';
1819 if (!$i) {
1820 $totalarray['nbfield']++;
1821 $posconciliatecol = $totalarray['nbfield'];
1822 }
1823 }
1824
1825 if (!empty($arrayfields['b.conciliated']['checked'])) {
1826 print '<td class="nowraponall center">';
1827 print yn($objp->conciliated);
1828 print '</td>';
1829 if (!$i) {
1830 $totalarray['nbfield']++;
1831 }
1832 }
1833
1834 if (!empty($arrayfields['b.fk_bordereau']['checked'])) {
1835 $bordereaustatic->fetch($objp->fk_bordereau);
1836 print '<td class="nowraponall center">';
1837 print $bordereaustatic->getNomUrl();
1838 print '</td>';
1839 if (!$i) {
1840 $totalarray['nbfield']++;
1841 }
1842 }
1843
1844 // Extra fields
1845 $obj = $objp; // Because extrafield template use $obj and not $objp as object variable name
1846 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
1847 // Fields from hook
1848 $parameters = array('arrayfields' => $arrayfields, 'object'=>$object, 'obj' => $objp, 'i' => $i, 'totalarray' => &$totalarray);
1849 $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $objecttmpect may have been modified by hook
1850 print $hookmanager->resPrint;
1851
1852 // Action edit/delete and select
1853 print '<td class="nowraponall center">';
1854 // Transaction reconciliated or edit link
1855 if ($objp->conciliated && $bankaccount->canBeConciliated() > 0) { // If line not conciliated and account can be conciliated
1856 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.'">';
1857 print img_edit();
1858 print '</a>';
1859 } else {
1860 if ($user->hasRight('banque', 'modifier') || $user->hasRight('banque', 'consolidate')) {
1861 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.'">';
1862 print img_edit();
1863 print '</a>';
1864 } else {
1865 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.'">';
1866 print img_view();
1867 print '</a>';
1868 }
1869 if ($bankaccount->canBeConciliated() > 0 && empty($objp->conciliated)) {
1870 if ($db->jdate($objp->dv) < ($now - $conf->bank->rappro->warning_delay)) {
1871 print ' '.img_warning($langs->trans("ReconciliationLate"));
1872 }
1873 }
1874 if ($user->hasRight('banque', 'modifier')) {
1875 print '<a href="'.$_SERVER["PHP_SELF"].'?action=delete&token='.newToken().'&rowid='.$objp->rowid.'&page='.$page.$param.($sortfield ? '&sortfield='.$sortfield : '').($sortorder ? '&sortorder='.$sortorder : '').'">';
1876 print img_delete('', 'class="marginleftonly"');
1877 print '</a>';
1878 }
1879 }
1880 print '</td>';
1881 if (!$i) {
1882 $totalarray['nbfield']++;
1883 }
1884
1885 // Action column
1886 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1887 print '<td class="center">';
1888 if (!$objp->conciliated && $action == 'reconcile') {
1889 print '<input class="flat checkforselect" name="rowid['.$objp->rowid.']" type="checkbox" value="'.$objp->rowid.'" size="1"'.(!empty($tmparray[$objp->rowid]) ? ' checked' : '').'>';
1890 }
1891 print '</td>';
1892 if (!$i) {
1893 $totalarray['nbfield']++;
1894 }
1895 }
1896
1897 print "</tr>\n";
1898
1899 $i++;
1900 }
1901
1902 // Show total line
1903 if (isset($totalarray['totaldebfield']) || isset($totalarray['totalcredfield'])) {
1904 print '<tr class="liste_total">';
1905 $i = 0;
1906 while ($i < $totalarray['nbfield']) {
1907 $i++;
1908 if ($i == 1) {
1909 if ($num < $limit && empty($offset)) {
1910 print '<td class="left">'.$langs->trans("Total").'</td>';
1911 } else {
1912 print '<td class="left tdoverflowmax50" title="'.$langs->trans("Totalforthispage").'">'.$langs->trans("Totalforthispage").'</td>';
1913 }
1914 } elseif ($totalarray['totaldebfield'] == $i) {
1915 print '<td class="right"><span class="amount">'.price(-1 * $totalarray['totaldeb']).'</span></td>';
1916 } elseif ($totalarray['totalcredfield'] == $i) {
1917 print '<td class="right"><span class="amount">'.price($totalarray['totalcred']).'</span></td>';
1918 } elseif ($i == $posconciliatecol) {
1919 print '<td class="center">';
1920 /*if ($user->hasRight('banque', 'consolidate') && $action == 'reconcile') {
1921 print '<input class="button smallpaddingimp" name="confirm_reconcile" type="submit" value="'.$langs->trans("Conciliate").'">';
1922 }*/
1923 print '</td>';
1924 } else {
1925 print '<td></td>';
1926 }
1927 }
1928 print '</tr>';
1929 }
1930
1931 // If no record found
1932 if ($num == 0) {
1933 $colspan = 1;
1934 foreach ($arrayfields as $key => $val) {
1935 if (!empty($val['checked'])) {
1936 $colspan++;
1937 }
1938 }
1939 print '<tr><td colspan="'.($colspan + 1).'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
1940 }
1941
1942 print "</table>";
1943 print "</div>";
1944
1945 print '</form>';
1946 $db->free($resql);
1947} else {
1948 dol_print_error($db);
1949}
1950
1951// End of page
1952llxFooter();
1953$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:137
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.