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