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