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