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 
601 // Add fields from hooks
602 $parameters = array();
603 $reshook = $hookmanager->executeHooks('printFieldListJoin', $parameters); // Note that $action and $object may have been modified by hook
604 $sql .= $hookmanager->resPrint;
605 
606 $sql .= " WHERE b.fk_account = ba.rowid";
607 $sql .= " AND ba.entity IN (".getEntity('bank_account').")";
608 if ($search_account > 0) {
609  $sql .= " AND b.fk_account = ".((int) $search_account);
610 }
611 // Search period criteria
612 if (dol_strlen($search_dt_start) > 0) {
613  $sql .= " AND b.dateo >= '".$db->idate($search_dt_start)."'";
614 }
615 if (dol_strlen($search_dt_end) > 0) {
616  $sql .= " AND b.dateo <= '".$db->idate($search_dt_end)."'";
617 }
618 // Search period criteria
619 if (dol_strlen($search_dv_start) > 0) {
620  $sql .= " AND b.datev >= '".$db->idate($search_dv_start)."'";
621 }
622 if (dol_strlen($search_dv_end) > 0) {
623  $sql .= " AND b.datev <= '".$db->idate($search_dv_end)."'";
624 }
625 if ($search_ref) {
626  $sql .= natural_search("b.rowid", $search_ref, 1);
627 }
628 if ($search_req_nb) {
629  $sql .= natural_search("b.num_chq", $search_req_nb);
630 }
631 if ($search_num_releve) {
632  $sql .= natural_search("b.num_releve", $search_num_releve);
633 }
634 if ($search_conciliated != '' && $search_conciliated != '-1') {
635  $sql .= " AND b.rappro = ".((int) $search_conciliated);
636 }
637 if ($search_fk_bordereau > 0) {
638  $sql .= " AND b.fk_bordereau = " . ((int) $search_fk_bordereau);
639 }
640 if ($search_thirdparty_user) {
641  $sql.= " AND (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."user AS subUser ON (bu.type = 'user' AND bu.url_id = subUser.rowid)";
645  $sql.= " WHERE ". natural_search(array("subUser.firstname", "subUser.lastname"), $search_thirdparty_user, '', 1).")";
646 
647  $sql.= " OR b.rowid IN ";
648  $sql.= " ( SELECT bu.fk_bank FROM ".MAIN_DB_PREFIX."bank_url AS bu";
649  $sql.= " JOIN ".MAIN_DB_PREFIX."bank AS b2 ON b2.rowid = bu.fk_bank";
650  $sql.= " JOIN ".MAIN_DB_PREFIX."societe AS subSoc ON (bu.type = 'company' AND bu.url_id = subSoc.rowid)";
651  $sql.= " WHERE ". natural_search(array("subSoc.nom"), $search_thirdparty_user, '', 1);
652  $sql.= "))";
653 }
654 if ($search_description) {
655  $search_description_to_use = $search_description;
656  $arrayoffixedlabels = array(
657  'payment_salary',
658  'CustomerInvoicePayment', 'CustomerInvoicePaymentBack',
659  'SupplierInvoicePayment', 'SupplierInvoicePaymentBack',
660  'DonationPayment',
661  'ExpenseReportPayment',
662  'SocialContributionPayment',
663  'SubscriptionPayment',
664  'WithdrawalPayment'
665  );
666  foreach ($arrayoffixedlabels as $keyforlabel) {
667  $translatedlabel = $langs->transnoentitiesnoconv($keyforlabel);
668  if (preg_match('/'.$search_description.'/i', $translatedlabel)) {
669  $search_description_to_use .= "|".$keyforlabel;
670  }
671  }
672  $sql .= natural_search("b.label", $search_description_to_use); // Warning some text are just translation keys, not translated strings
673 }
674 
675 if ($search_bid > 0) {
676  $sql .= " AND b.rowid = l.lineid AND l.fk_categ = ".((int) $search_bid);
677 }
678 if (!empty($search_type)) {
679  $sql .= " AND b.fk_type = '".$db->escape($search_type)."'";
680 }
681 // Search criteria amount
682 if ($search_debit) {
683  $sql .= natural_search('ABS(b.amount)', $search_debit, 1);
684  $sql .= ' AND b.amount <= 0';
685 }
686 if ($search_credit) {
687  $sql .= natural_search('b.amount', $search_credit, 1);
688  $sql .= ' AND b.amount >= 0';
689 }
690 // Add where from extra fields
691 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
692 
693 // Add where from hooks
694 $parameters = array();
695 $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook
696 $sql .= $hookmanager->resPrint;
697 
698 $sql .= $db->order($sortfield, $sortorder);
699 
700 $nbtotalofrecords = '';
701 $nbtotalofpages = 0;
702 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
703  $result = $db->query($sql);
704  $nbtotalofrecords = $db->num_rows($result);
705  $nbtotalofpages = ceil($nbtotalofrecords / $limit);
706 }
707 
708 if (($id > 0 || !empty($ref)) && ((string) $page == '')) {
709  // We open a list of transaction of a dedicated account and no page was set by defaut
710  // We force on last page.
711  $page = ($nbtotalofpages - 1);
712  $offset = $limit * $page;
713  if ($page < 0) {
714  $page = 0;
715  }
716 }
717 if ($page >= $nbtotalofpages) {
718  // If we made a search and result has low page than the page number we were on
719  $page = ($nbtotalofpages - 1);
720  $offset = $limit * $page;
721  if ($page < 0) {
722  $page = 0;
723  }
724 }
725 
726 
727 // If not account defined $mode_balance_ok=false
728 if (empty($search_account)) {
729  $mode_balance_ok = false;
730 }
731 // If a search is done $mode_balance_ok=false
732 if (!empty($search_ref)) {
733  $mode_balance_ok = false;
734 }
735 if (!empty($search_description)) {
736  $mode_balance_ok = false;
737 }
738 if (!empty($search_type)) {
739  $mode_balance_ok = false;
740 }
741 if (!empty($search_debit)) {
742  $mode_balance_ok = false;
743 }
744 if (!empty($search_credit)) {
745  $mode_balance_ok = false;
746 }
747 if (!empty($search_thirdparty_user)) {
748  $mode_balance_ok = false;
749 }
750 if ($search_conciliated != '' && $search_conciliated != '-1') {
751  $mode_balance_ok = false;
752 }
753 if (!empty($search_num_releve)) {
754  $mode_balance_ok = false;
755 }
756 if (!empty($search_fk_bordereau)) {
757  $mode_balance_ok = false;
758 }
759 
760 $sql .= $db->plimit($limit + 1, $offset);
761 //print $sql;
762 dol_syslog('compta/bank/bankentries_list.php', LOG_DEBUG);
763 $resql = $db->query($sql);
764 if ($resql) {
765  $num = $db->num_rows($resql);
766 
767  $arrayofselected = (!empty($toselect) && is_array($toselect)) ? $toselect : array();
768 
769  // List of mass actions available
770  $arrayofmassactions = array(
771  //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
772  //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
773  );
774  //if ($user->rights->bank->supprimer) $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
775  if (in_array($massaction, array('presend', 'predelete'))) {
776  $arrayofmassactions = array();
777  }
778  $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
779 
780  // Confirmation delete
781  if ($action == 'delete') {
782  $text = $langs->trans('ConfirmDeleteTransaction');
783  print $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id.'&rowid='.GETPOST("rowid", 'int'), $langs->trans('DeleteTransaction'), $text, 'confirm_delete', null, '', 1);
784  }
785 
786  // Lines of title fields
787  print '<form method="post" action="'.$_SERVER["PHP_SELF"].'" name="search_form">'."\n";
788  if ($optioncss != '') {
789  print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
790  }
791  print '<input type="hidden" name="token" value="'.newToken().'">';
792  print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
793  print '<input type="hidden" name="action" value="'.($action != 'delete' ? $action : 'search').'">';
794  if (!empty($view)) {
795  print '<input type="hidden" name="view" value="'.dol_escape_htmltag($view).'">';
796  }
797  print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
798  print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
799  print '<input type="hidden" name="page" value="'.$page.'">';
800  print '<input type="hidden" name="id" value="'.$id.'">';
801  print '<input type="hidden" name="ref" value="'.$ref.'">';
802  if (GETPOST('bid')) {
803  print '<input type="hidden" name="bid" value="'.GETPOST("bid", 'int').'">';
804  }
805 
806  // Form to reconcile
807  if ($user->rights->banque->consolidate && $action == 'reconcile') {
808  print '<div class="valignmiddle inline-block" style="padding-right: 20px;">';
809  print '<strong>'.$langs->trans("InputReceiptNumber").'</strong>: ';
810  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
811  print '</div>';
812  if (is_array($options) && count($options)) {
813  print $langs->trans("EventualyAddCategory").': ';
814  print Form::selectarray('cat', $options, GETPOST('cat'), 1);
815  }
816  print '<br><div style="margin-top: 5px;"><span class="opacitymedium">'.$langs->trans("ThenCheckLinesAndConciliate").'</span> ';
817  print '<input class="button" name="confirm_savestatement" type="submit" value="'.$langs->trans("SaveStatementOnly").'">';
818  print ' '.$langs->trans("or").' ';
819  print '<input class="button" name="confirm_reconcile" type="submit" value="'.$langs->trans("Conciliate").'">';
820  print ' '.$langs->trans("or").' ';
821  print '<input type="submit" name="cancel" class="button button-cancel" value="'.$langs->trans("Cancel").'">';
822  print '</div>';
823 
824  // Show last bank statements
825  $nbmax = 12; // We show last 12 receipts (so we can have more than one year)
826  $liste = "";
827  $sql = "SELECT DISTINCT num_releve FROM ".MAIN_DB_PREFIX."bank";
828  $sql .= " WHERE fk_account = ".((int) $object->id)." AND num_releve IS NOT NULL";
829  $sql .= $db->order("num_releve", "DESC");
830  $sql .= $db->plimit($nbmax + 1);
831  print '<br>';
832  print $langs->trans("LastAccountStatements").' : ';
833  $resqlr = $db->query($sql);
834  if ($resqlr) {
835  $numr = $db->num_rows($resqlr);
836  $i = 0;
837  $last_ok = 0;
838  while (($i < $numr) && ($i < $nbmax)) {
839  $objr = $db->fetch_object($resqlr);
840  if (!$last_ok) {
841  $last_releve = $objr->num_releve;
842  $last_ok = 1;
843  }
844  $i++;
845  $liste = '<a href="'.DOL_URL_ROOT.'/compta/bank/releve.php?account='.$id.'&amp;num='.$objr->num_releve.'">'.$objr->num_releve.'</a> &nbsp; '.$liste;
846  }
847  if ($numr >= $nbmax) {
848  $liste = "... &nbsp; ".$liste;
849  }
850  print $liste;
851  if ($numr <= 0) {
852  print '<b>'.$langs->trans("None").'</b>';
853  }
854  } else {
855  dol_print_error($db);
856  }
857 
858  // Using BANK_REPORT_LAST_NUM_RELEVE to automatically report last num (or not)
859  if (!empty($conf->global->BANK_REPORT_LAST_NUM_RELEVE)) {
860  print '
861  <script type="text/javascript">
862  $("#num_releve").val("' . $last_releve.'");
863  </script>
864  ';
865  }
866  print '<br><br>';
867  }
868 
869  // Form to add a transaction with no invoice
870  if (!empty($user->rights->banque->modifier) && $action == 'addline' && !empty($conf->global->BANK_USE_OLD_VARIOUS_PAYMENT)) {
871  print load_fiche_titre($langs->trans("AddBankRecordLong"), '', '');
872 
873  print '<table class="noborder centpercent">';
874 
875  print '<tr class="liste_titre">';
876  print '<td>'.$langs->trans("Description").'</td>';
877  print '<td>'.$langs->trans("Date").'</td>';
878  print '<td>&nbsp;</td>';
879  print '<td>'.$langs->trans("Type").'</td>';
880  print '<td>'.$langs->trans("Numero").'</td>';
881  print '<td class=right>'.$langs->trans("BankAccount").'</td>';
882  print '<td class=right>'.$langs->trans("Debit").'</td>';
883  print '<td class=right>'.$langs->trans("Credit").'</td>';
884  /*if (isModEnabled('accounting'))
885  {
886  print '<td class="center">';
887  print $langs->trans("AccountAccounting");
888  print '</td>';
889  }*/
890  print '<td align="center">&nbsp;</td>';
891  print '</tr>';
892 
893  print '<tr>';
894  print '<td>';
895  print '<input name="label" class="flat minwidth200" type="text" value="'.GETPOST("label", "alpha").'">';
896  if (is_array($options) && count($options)) {
897  print '<br>'.$langs->trans("Rubrique").': ';
898  print Form::selectarray('cat1', $options, GETPOST('cat1'), 1);
899  }
900  print '</td>';
901  print '<td class="nowrap">';
902  print $form->selectDate(empty($dateop) ?-1 : $dateop, 'op', 0, 0, 0, 'transaction');
903  print '</td>';
904  print '<td>&nbsp;</td>';
905  print '<td class="nowrap">';
906  $form->select_types_paiements((GETPOST('operation') ?GETPOST('operation') : ($object->courant == Account::TYPE_CASH ? 'LIQ' : '')), 'operation', '1,2', 2, 1);
907  print '</td>';
908  print '<td>';
909  print '<input name="num_chq" class="flat" type="text" size="4" value="'.GETPOST("num_chq", "alpha").'">';
910  print '</td>';
911  //if (! $search_account > 0)
912  //{
913  print '<td class=right>';
914  $form->select_comptes(GETPOST('add_account', 'int') ?GETPOST('add_account', 'int') : $search_account, 'add_account', 0, '', 1, ($id > 0 || !empty($ref) ? ' disabled="disabled"' : ''));
915  print '</td>';
916  //}
917  print '<td class="right"><input name="adddebit" class="flat" type="text" size="4" value="'.GETPOST("adddebit", "alpha").'"></td>';
918  print '<td class="right"><input name="addcredit" class="flat" type="text" size="4" value="'.GETPOST("addcredit", "alpha").'"></td>';
919  /*if (isModEnabled('accounting'))
920  {
921  print '<td class="center">';
922  print $formaccounting->select_account($search_accountancy_code, 'search_accountancy_code', 1, null, 1, 1, '');
923  print '</td>';
924  }*/
925  print '<td class="center">';
926  print '<input type="submit" name="save" class="button buttongen marginbottomonly button-add" value="'.$langs->trans("Add").'"><br>';
927  print '<input type="submit" name="cancel" class="button buttongen marginbottomonly button-cancel" value="'.$langs->trans("Cancel").'">';
928  print '</td></tr>';
929 
930  print '</table>';
931  print '<br>';
932  }
933 
934  // Code to adjust value date with plus and less picto using an Ajax call instead of a full reload of page
935  $urlajax = DOL_URL_ROOT.'/core/ajax/bankconciliate.php?token='.currentToken();
936  print '
937  <script type="text/javascript">
938  $(function() {
939  $("a.ajaxforbankoperationchange").each(function(){
940  var current = $(this);
941  current.click(function()
942  {
943  var url = "'.$urlajax.'&"+current.attr("href").split("?")[1];
944  $.get(url, function(data)
945  {
946  console.log(url)
947  console.log(data)
948  current.parent().parent().find(".spanforajaxedit").replaceWith(data);
949  });
950  return false;
951  });
952  });
953  });
954  </script>
955  ';
956 
957  $i = 0;
958 
959  // Title
960  $bankcateg = new BankCateg($db);
961 
962  $newcardbutton = '';
963  if ($action != 'addline' && $action != 'reconcile') {
964  if (empty($conf->global->BANK_DISABLE_DIRECT_INPUT)) {
965  if (empty($conf->global->BANK_USE_OLD_VARIOUS_PAYMENT)) { // Default is to record miscellaneous direct entries using miscellaneous payments
966  $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);
967  } else // If direct entries is not done using miscellaneous payments
968  {
969  $newcardbutton = dolGetButtonTitle($langs->trans('AddBankRecord'), '', 'fa fa-plus-circle', $_SERVER["PHP_SELF"].'?action=addline&token='.newToken().'&page='.$page.$param, '', $user->rights->banque->modifier);
970  }
971  } else {
972  $newcardbutton = dolGetButtonTitle($langs->trans('AddBankRecord'), '', 'fa fa-plus-circle', $_SERVER["PHP_SELF"].'?action=addline&token='.newToken().'&page='.$page.$param, '', -1);
973  }
974  }
975 
976  $morehtml = '';
977  /*$morehtml = '<div class="inline-block '.(($buttonreconcile || $newcardbutton) ? 'marginrightonly' : '').'">';
978  $morehtml .= '<label for="pageplusone">'.$langs->trans("Page")."</label> "; // ' Page ';
979  $morehtml .= '<input type="text" name="pageplusone" id="pageplusone" class="flat right width25 pageplusone" value="'.($page + 1).'">';
980  $morehtml .= '/'.$nbtotalofpages.' ';
981  $morehtml .= '</div>';
982  */
983 
984  if ($action != 'addline' && $action != 'reconcile') {
985  $morehtml .= $buttonreconcile;
986  }
987 
988  $morehtml .= '<!-- Add New button -->'.$newcardbutton;
989 
990  $picto = 'bank_account';
991  if ($id > 0 || !empty($ref)) {
992  $picto = '';
993  }
994 
995  print_barre_liste($langs->trans("BankTransactions"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, $picto, 0, $morehtml, '', $limit, 0, 0, 1);
996 
997  // We can add page now to param
998  if ($page != '') {
999  $param .= '&page='.urlencode($page);
1000  }
1001 
1002  $moreforfilter = '';
1003 
1004  $moreforfilter .= '<div class="divsearchfield">';
1005  $moreforfilter .= $langs->trans('DateOperationShort');
1006  $moreforfilter .= ($conf->browser->layout == 'phone' ? '<br>' : ' ');
1007  $moreforfilter .= '<div class="nowrap inline-block">';
1008  $moreforfilter .= $form->selectDate($search_dt_start, 'search_start_dt', 0, 0, 1, "search_form", 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
1009  $moreforfilter .= '</div>';
1010  $moreforfilter .= ($conf->browser->layout == 'phone' ? '' : ' ');
1011  $moreforfilter .= '<div class="nowrap inline-block">';
1012  $moreforfilter .= $form->selectDate($search_dt_end, 'search_end_dt', 0, 0, 1, "search_form", 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
1013  $moreforfilter .= '</div>';
1014  $moreforfilter .= '</div>';
1015 
1016  $moreforfilter .= '<div class="divsearchfield">';
1017  $moreforfilter .= $langs->trans('DateValueShort');
1018  $moreforfilter .= ($conf->browser->layout == 'phone' ? '<br>' : ' ');
1019  $moreforfilter .= '<div class="nowrap inline-block">';
1020  $moreforfilter .= $form->selectDate($search_dv_start, 'search_start_dv', 0, 0, 1, "search_form", 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
1021  $moreforfilter .= '</div>';
1022  $moreforfilter .= ($conf->browser->layout == 'phone' ? '' : ' ');
1023  $moreforfilter .= '<div class="nowrap inline-block">';
1024  $moreforfilter .= $form->selectDate($search_dv_end, 'search_end_dv', 0, 0, 1, "search_form", 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
1025  $moreforfilter .= '</div>';
1026  $moreforfilter .= '</div>';
1027 
1028  if (isModEnabled('categorie')) {
1029  // Categories
1030  if (isModEnabled('categorie') && !empty($user->rights->categorie->lire)) {
1031  $langs->load('categories');
1032 
1033  // Bank line
1034  $moreforfilter .= '<div class="divsearchfield">';
1035  $tmptitle = $langs->trans('RubriquesTransactions');
1036  $cate_arbo = $form->select_all_categories(Categorie::TYPE_BANK_LINE, $search_bid, 'parent', null, null, 1);
1037  $moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"').$form->selectarray('search_bid', $cate_arbo, $search_bid, $tmptitle, 0, 0, '', 0, 0, 0, '', '', 1);
1038  $moreforfilter .= '</div>';
1039  }
1040  }
1041 
1042  $parameters = array();
1043  $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook
1044  if (empty($reshook)) {
1045  $moreforfilter .= $hookmanager->resPrint;
1046  } else {
1047  $moreforfilter = $hookmanager->resPrint;
1048  }
1049 
1050  if ($moreforfilter) {
1051  print '<div class="liste_titre liste_titre_bydiv centpercent">';
1052  print $moreforfilter;
1053  print '</div>'."\n";
1054  }
1055 
1056  $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
1057  $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
1058  // When action is 'reconcile', we force to have the column num_releve always enabled (otherwise we can't make reconciliation).
1059  if ($action == 'reconcile') {
1060  $arrayfields['b.num_releve']['checked'] = 1;
1061  }
1062 
1063  print '<div class="div-table-responsive">';
1064  print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
1065 
1066 
1067  print '<tr class="liste_titre_filter">';
1068  if (!empty($arrayfields['b.rowid']['checked'])) {
1069  print '<td class="liste_titre">';
1070  print '<input type="text" class="flat" name="search_ref" size="2" value="'.dol_escape_htmltag($search_ref).'">';
1071  print '</td>';
1072  }
1073  if (!empty($arrayfields['b.label']['checked'])) {
1074  print '<td class="liste_titre">';
1075  print '<input type="text" class="flat maxwidth100" name="search_description" value="'.dol_escape_htmltag($search_description).'">';
1076  print '</td>';
1077  }
1078  if (!empty($arrayfields['b.dateo']['checked'])) {
1079  print '<td class="liste_titre">&nbsp;</td>';
1080  }
1081  if (!empty($arrayfields['b.datev']['checked'])) {
1082  print '<td class="liste_titre">&nbsp;</td>';
1083  }
1084  if (!empty($arrayfields['type']['checked'])) {
1085  print '<td class="liste_titre" align="center">';
1086  $form->select_types_paiements(empty($search_type) ? '' : $search_type, 'search_type', '', 2, 1, 1, 0, 1, 'maxwidth100');
1087  print '</td>';
1088  }
1089  // Numero
1090  if (!empty($arrayfields['b.num_chq']['checked'])) {
1091  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>';
1092  }
1093  // Checked
1094  if (!empty($arrayfields['bu.label']['checked'])) {
1095  print '<td class="liste_titre"><input type="text" class="flat maxwidth75" name="search_thirdparty" value="'.dol_escape_htmltag($search_thirdparty_user).'"></td>';
1096  }
1097  // Ref
1098  if (!empty($arrayfields['ba.ref']['checked'])) {
1099  print '<td class="liste_titre">';
1100  $form->select_comptes($search_account, 'search_account', 0, '', 1, ($id > 0 || !empty($ref) ? ' disabled="disabled"' : ''), 0, 'maxwidth100');
1101  print '</td>';
1102  }
1103  // Debit
1104  if (!empty($arrayfields['b.debit']['checked'])) {
1105  print '<td class="liste_titre right">';
1106  print '<input type="text" class="flat width50" name="search_debit" value="'.dol_escape_htmltag($search_debit).'">';
1107  print '</td>';
1108  }
1109  // Credit
1110  if (!empty($arrayfields['b.credit']['checked'])) {
1111  print '<td class="liste_titre right">';
1112  print '<input type="text" class="flat width50" name="search_credit" value="'.dol_escape_htmltag($search_credit).'">';
1113  print '</td>';
1114  }
1115  // Balance before
1116  if (!empty($arrayfields['balancebefore']['checked'])) {
1117  print '<td class="liste_titre right">';
1118  $htmltext = $langs->trans("BalanceVisibilityDependsOnSortAndFilters", $langs->transnoentitiesnoconv("DateValue"));
1119  print $form->textwithpicto('', $htmltext, 1);
1120  print '</td>';
1121  }
1122  // Balance
1123  if (!empty($arrayfields['balance']['checked'])) {
1124  print '<td class="liste_titre right">';
1125  $htmltext = $langs->trans("BalanceVisibilityDependsOnSortAndFilters", $langs->transnoentitiesnoconv("DateValue"));
1126  print $form->textwithpicto('', $htmltext, 1);
1127  print '</td>';
1128  }
1129  // Numero statement
1130  if (!empty($arrayfields['b.num_releve']['checked'])) {
1131  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>';
1132  }
1133  // Conciliated
1134  if (!empty($arrayfields['b.conciliated']['checked'])) {
1135  print '<td class="liste_titre" align="center">';
1136  print $form->selectyesno('search_conciliated', $search_conciliated, 1, false, 1, 1);
1137  print '</td>';
1138  }
1139  // Bordereau
1140  if (!empty($arrayfields['b.fk_bordereau']['checked'])) {
1141  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>';
1142  }
1143 
1144  // Actions and select
1145  print '<td class="liste_titre" align="middle">';
1146  $searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0, 'checkforselect', 1);
1147  print $searchpicto;
1148  print '</td>';
1149  print "</tr>\n";
1150 
1151  // Fields title
1152  print '<tr class="liste_titre">';
1153  if (!empty($arrayfields['b.rowid']['checked'])) {
1154  print_liste_field_titre($arrayfields['b.rowid']['label'], $_SERVER['PHP_SELF'], 'b.rowid', '', $param, '', $sortfield, $sortorder);
1155  }
1156  if (!empty($arrayfields['b.label']['checked'])) {
1157  print_liste_field_titre($arrayfields['b.label']['label'], $_SERVER['PHP_SELF'], 'b.label', '', $param, '', $sortfield, $sortorder);
1158  }
1159  if (!empty($arrayfields['b.dateo']['checked'])) {
1160  print_liste_field_titre($arrayfields['b.dateo']['label'], $_SERVER['PHP_SELF'], 'b.dateo', '', $param, '', $sortfield, $sortorder, "center ");
1161  }
1162  if (!empty($arrayfields['b.datev']['checked'])) {
1163  print_liste_field_titre($arrayfields['b.datev']['label'], $_SERVER['PHP_SELF'], 'b.datev,b.dateo,b.rowid', '', $param, 'align="center"', $sortfield, $sortorder);
1164  }
1165  if (!empty($arrayfields['type']['checked'])) {
1166  print_liste_field_titre($arrayfields['type']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'align="center"', $sortfield, $sortorder);
1167  }
1168  if (!empty($arrayfields['b.num_chq']['checked'])) {
1169  print_liste_field_titre($arrayfields['b.num_chq']['label'], $_SERVER['PHP_SELF'], 'b.num_chq', '', $param, '', $sortfield, $sortorder, "center ");
1170  }
1171  if (!empty($arrayfields['bu.label']['checked'])) {
1172  print_liste_field_titre($arrayfields['bu.label']['label'], $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder);
1173  }
1174  if (!empty($arrayfields['ba.ref']['checked'])) {
1175  print_liste_field_titre($arrayfields['ba.ref']['label'], $_SERVER['PHP_SELF'], 'ba.ref', '', $param, '', $sortfield, $sortorder);
1176  }
1177  if (!empty($arrayfields['b.debit']['checked'])) {
1178  print_liste_field_titre($arrayfields['b.debit']['label'], $_SERVER['PHP_SELF'], 'b.amount', '', $param, '', $sortfield, $sortorder, "right ");
1179  }
1180  if (!empty($arrayfields['b.credit']['checked'])) {
1181  print_liste_field_titre($arrayfields['b.credit']['label'], $_SERVER['PHP_SELF'], 'b.amount', '', $param, '', $sortfield, $sortorder, "right ");
1182  }
1183  if (!empty($arrayfields['balancebefore']['checked'])) {
1184  print_liste_field_titre($arrayfields['balancebefore']['label'], $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, "right ");
1185  }
1186  if (!empty($arrayfields['balance']['checked'])) {
1187  print_liste_field_titre($arrayfields['balance']['label'], $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, "right ");
1188  }
1189  if (!empty($arrayfields['b.num_releve']['checked'])) {
1190  print_liste_field_titre($arrayfields['b.num_releve']['label'], $_SERVER['PHP_SELF'], 'b.num_releve', '', $param, '', $sortfield, $sortorder, "center ");
1191  }
1192  if (!empty($arrayfields['b.conciliated']['checked'])) {
1193  print_liste_field_titre($arrayfields['b.conciliated']['label'], $_SERVER['PHP_SELF'], 'b.rappro', '', $param, '', $sortfield, $sortorder, "center ");
1194  }
1195  if (!empty($arrayfields['b.fk_bordereau']['checked'])) {
1196  print_liste_field_titre($arrayfields['b.fk_bordereau']['label'], $_SERVER['PHP_SELF'], 'b.fk_bordereau', '', $param, '', $sortfield, $sortorder, "center ");
1197  }
1198 
1199  // Extra fields
1200  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
1201  // Hook fields
1202  $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
1203  $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
1204  print $hookmanager->resPrint;
1205  // Actions and select
1206  print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ');
1207  print "</tr>\n";
1208 
1209  $balance = 0; // For balance
1210  $balancebefore = 0; // For balance
1211  $balancecalculated = false;
1212  $posconciliatecol = 0;
1213  $cachebankaccount = array();
1214 
1215  // Loop on each record
1216  $sign = 1;
1217 
1218  while ($i < min($num, $limit)) {
1219  $objp = $db->fetch_object($resql);
1220  $links = $bankaccountstatic->get_url($objp->rowid);
1221 
1222  // If we are in a situation where we need/can show balance, we calculate the start of balance
1223  if (!$balancecalculated && (!empty($arrayfields['balancebefore']['checked']) || !empty($arrayfields['balance']['checked'])) && ($mode_balance_ok || $search_conciliated === '0')) {
1224  if (!$search_account) {
1225  dol_print_error('', 'account is not defined but $mode_balance_ok is true');
1226  exit;
1227  }
1228 
1229  // Loop on each record before
1230  $sign = 1;
1231  $i = 0;
1232  $sqlforbalance = 'SELECT SUM(b.amount) as previoustotal';
1233  $sqlforbalance .= " FROM ";
1234  $sqlforbalance .= " ".MAIN_DB_PREFIX."bank_account as ba,";
1235  $sqlforbalance .= " ".MAIN_DB_PREFIX."bank as b";
1236  $sqlforbalance .= " WHERE b.fk_account = ba.rowid";
1237  $sqlforbalance .= " AND ba.entity IN (".getEntity('bank_account').")";
1238  $sqlforbalance .= " AND b.fk_account = ".((int) $search_account);
1239  $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."))))";
1240  $resqlforbalance = $db->query($sqlforbalance);
1241  //print $sqlforbalance;
1242  if ($resqlforbalance) {
1243  $objforbalance = $db->fetch_object($resqlforbalance);
1244  if ($objforbalance) {
1245  // If sort is desc,desc,desc then total of previous date + amount is the balancebefore of the previous line before the line to show
1246  if ($sortfield == 'b.datev,b.dateo,b.rowid' && ($sortorder == 'desc' || $sortorder == 'desc,desc' || $sortorder == 'desc,desc,desc')) {
1247  $balancebefore = $objforbalance->previoustotal + ($sign * $objp->amount);
1248  } else {
1249  // If sort is asc,asc,asc then total of previous date is balance of line before the next line to show
1250  $balance = $objforbalance->previoustotal;
1251  }
1252  }
1253  } else {
1254  dol_print_error($db);
1255  }
1256 
1257  $balancecalculated = true;
1258 
1259  // Output a line with start balance
1260  if ($user->rights->banque->consolidate && $action == 'reconcile') {
1261  $tmpnbfieldbeforebalance = 0;
1262  $tmpnbfieldafterbalance = 0;
1263  $balancefieldfound = 0;
1264  foreach ($arrayfields as $key => $val) {
1265  if ($key == 'balancebefore' || $key == 'balance') {
1266  $balancefieldfound++;
1267  continue;
1268  }
1269  if (!empty($arrayfields[$key]['checked'])) {
1270  if (!$balancefieldfound) {
1271  $tmpnbfieldbeforebalance++;
1272  } else {
1273  $tmpnbfieldafterbalance++;
1274  }
1275  }
1276  }
1277  // Extra fields
1278  $element = 'banktransaction';
1279  if (is_array($extrafields->attributes[$element]['label']) && count($extrafields->attributes[$element]['label'])) {
1280  foreach ($extrafields->attributes[$element]['label'] as $key => $val) {
1281  if (!empty($arrayfields["ef.".$key]['checked'])) {
1282  if (!empty($arrayfields[$key]['checked'])) {
1283  if (!$balancefieldfound) {
1284  $tmpnbfieldbeforebalance++;
1285  } else {
1286  $tmpnbfieldafterbalance++;
1287  }
1288  }
1289  }
1290  }
1291  }
1292 
1293  print '<tr class="oddeven trforbreak">';
1294  if ($tmpnbfieldbeforebalance) {
1295  print '<td colspan="'.$tmpnbfieldbeforebalance.'">';
1296  print '&nbsp;';
1297  print '</td>';
1298  }
1299 
1300  if (!empty($arrayfields['balancebefore']['checked'])) {
1301  print '<td class="right">';
1302  if ($search_conciliated !== '0') {
1303  print price(price2num($balance, 'MT'), 1, $langs);
1304  }
1305  print '</td>';
1306  }
1307  if (!empty($arrayfields['balance']['checked'])) {
1308  print '<td class="right">';
1309  if ($search_conciliated !== '0') {
1310  print price(price2num($balance, 'MT'), 1, $langs);
1311  }
1312  print '</td>';
1313  }
1314  if (!empty($arrayfields['b.num_releve']['checked'])) {
1315  print '<td class="center">';
1316  print '<input type="checkbox" id="selectAll" title="'.dol_escape_htmltag($langs->trans("SelectAll")).'" />';
1317  print ' <script type="text/javascript">
1318  $("input#selectAll").change(function() {
1319  $("input[type=checkbox][name^=rowid]").prop("checked", $(this).is(":checked"));
1320  });
1321  </script>';
1322  print '</td>';
1323  }
1324  print '<td colspan="'.($tmpnbfieldafterbalance + 1).'">';
1325  print '&nbsp;';
1326  print '</td>';
1327  print '</tr>';
1328  }
1329  }
1330 
1331  if ($sortfield == 'b.datev,b.dateo,b.rowid' && ($sortorder == 'desc' || $sortorder == 'desc,desc' || $sortorder == 'desc,desc,desc')) {
1332  $balance = price2num($balancebefore, 'MT'); // balance = balancebefore of previous line (sort is desc)
1333  $balancebefore = price2num($balancebefore - ($sign * $objp->amount), 'MT');
1334  } else {
1335  $balancebefore = price2num($balance, 'MT'); // balancebefore = balance of previous line (sort is asc)
1336  $balance = price2num($balance + ($sign * $objp->amount), 'MT');
1337  }
1338 
1339  if (empty($cachebankaccount[$objp->bankid])) {
1340  $bankaccounttmp = new Account($db);
1341  $bankaccounttmp->fetch($objp->bankid);
1342  $cachebankaccount[$objp->bankid] = $bankaccounttmp;
1343  $bankaccount = $bankaccounttmp;
1344  } else {
1345  $bankaccount = $cachebankaccount[$objp->bankid];
1346  }
1347 
1348  if (empty($conf->global->BANK_COLORIZE_MOVEMENT)) {
1349  $backgroundcolor = "class='oddeven'";
1350  } else {
1351  if ($objp->amount < 0) {
1352  $color = '#' . getDolGlobalString('BANK_COLORIZE_MOVEMENT_COLOR1', 'fca955');
1353  $backgroundcolor = 'style="background: '.$color.';"';
1354  } else {
1355  $color = '#' . getDolGlobalString('BANK_COLORIZE_MOVEMENT_COLOR2', '7fdb86');
1356  $backgroundcolor = 'style="background: '.$color.';"';
1357  }
1358  }
1359 
1360  $banklinestatic->id = $objp->rowid;
1361  $banklinestatic->ref = $objp->rowid;
1362 
1363  print '<tr class="oddeven" '.$backgroundcolor.'>';
1364 
1365  // Ref
1366  if (!empty($arrayfields['b.rowid']['checked'])) {
1367  print '<td class="nowrap left">';
1368  print $banklinestatic->getNomUrl(1);
1369  print '</td>';
1370  if (!$i) {
1371  $totalarray['nbfield']++;
1372  }
1373  }
1374 
1375  // Description
1376  if (!empty($arrayfields['b.label']['checked'])) {
1377  $labeltoshow = '';
1378  $titletoshow = '';
1379  $reg = array();
1380  preg_match('/\((.+)\)/i', $objp->label, $reg); // Si texte entoure de parenthee on tente recherche de traduction
1381  if (!empty($reg[1]) && $langs->trans($reg[1]) != $reg[1]) {
1382  $labeltoshow = $langs->trans($reg[1]);
1383  } else {
1384  if ($objp->label == '(payment_salary)') {
1385  $labeltoshow = $langs->trans("SalaryPayment");
1386  } else {
1387  $labeltoshow = dol_escape_htmltag($objp->label);
1388  $titletoshow = $objp->label;
1389  }
1390  }
1391 
1392 
1393  print '<td class="tdoverflowmax250"'.($titletoshow ? ' title="'.dol_escape_htmltag($titletoshow).'"' : '').'>';
1394 
1395  // Add info about links after description
1396  $cachebankaccount = array();
1397  foreach ($links as $key => $val) {
1398  print '<!-- '.$links[$key]['type'].' -->';
1399  if ($links[$key]['type'] == 'withdraw') {
1400  $banktransferstatic->id = $links[$key]['url_id'];
1401  $banktransferstatic->ref = $links[$key]['label'];
1402  print $banktransferstatic->getNomUrl(0).' ';
1403  } elseif ($links[$key]['type'] == 'payment') {
1404  $paymentstatic->id = $links[$key]['url_id'];
1405  $paymentstatic->ref = $links[$key]['url_id']; // FIXME This is id, not ref of payment
1406  $paymentstatic->date = $db->jdate($objp->do);
1407  print $paymentstatic->getNomUrl(2).' ';
1408  } elseif ($links[$key]['type'] == 'payment_supplier') {
1409  $paymentsupplierstatic->id = $links[$key]['url_id'];
1410  $paymentsupplierstatic->ref = $links[$key]['url_id']; // FIXME This is id, not ref of payment
1411  print $paymentsupplierstatic->getNomUrl(2).' ';
1412  } elseif ($links[$key]['type'] == 'payment_sc') {
1413  $paymentscstatic->id = $links[$key]['url_id'];
1414  $paymentscstatic->ref = $links[$key]['url_id'];
1415  $paymentscstatic->label = $links[$key]['label'];
1416  print $paymentscstatic->getNomUrl(2).' ';
1417  } elseif ($links[$key]['type'] == 'payment_vat') {
1418  $paymentvatstatic->id = $links[$key]['url_id'];
1419  $paymentvatstatic->ref = $links[$key]['url_id'];
1420  print $paymentvatstatic->getNomUrl(2).' ';
1421  } elseif ($links[$key]['type'] == 'payment_salary') {
1422  $paymentsalstatic->id = $links[$key]['url_id'];
1423  $paymentsalstatic->ref = $links[$key]['url_id'];
1424  $paymentsalstatic->label = $links[$key]['label'];
1425  print $paymentsalstatic->getNomUrl(2).' ';
1426  } elseif ($links[$key]['type'] == 'payment_loan') {
1427  print '<a href="'.DOL_URL_ROOT.'/loan/payment/card.php?id='.$links[$key]['url_id'].'">';
1428  print ' '.img_object($langs->trans('ShowPayment'), 'payment').' ';
1429  print '</a> ';
1430  } elseif ($links[$key]['type'] == 'payment_donation') {
1431  $paymentdonationstatic->id = $links[$key]['url_id'];
1432  $paymentdonationstatic->ref = $links[$key]['url_id'];
1433  print $paymentdonationstatic->getNomUrl(2).' ';
1434  } elseif ($links[$key]['type'] == 'payment_expensereport') {
1435  $paymentexpensereportstatic->id = $links[$key]['url_id'];
1436  $paymentexpensereportstatic->ref = $links[$key]['url_id'];
1437  print $paymentexpensereportstatic->getNomUrl(2).' ';
1438  } elseif ($links[$key]['type'] == 'payment_various') {
1439  $paymentvariousstatic->id = $links[$key]['url_id'];
1440  $paymentvariousstatic->ref = $links[$key]['url_id'];
1441  print $paymentvariousstatic->getNomUrl(2).' ';
1442  } elseif ($links[$key]['type'] == 'banktransfert') {
1443  // Do not show link to transfer since there is no transfer card (avoid confusion). Can already be accessed from transaction detail.
1444  if ($objp->amount > 0) {
1445  $banklinestatic->fetch($links[$key]['url_id']);
1446  $bankstatic->id = $banklinestatic->fk_account;
1447  $bankstatic->label = $banklinestatic->bank_account_ref;
1448  print $langs->trans("TransferFrom").' ';
1449  print $bankstatic->getNomUrl(1, 'transactions');
1450  print ' '.$langs->trans("toward").' ';
1451  $bankstatic->id = $objp->bankid;
1452  $bankstatic->label = $objp->bankref;
1453  print $bankstatic->getNomUrl(1, '');
1454  print ' - ';
1455  } else {
1456  $bankstatic->id = $objp->bankid;
1457  $bankstatic->label = $objp->bankref;
1458  print $langs->trans("TransferFrom").' ';
1459  print $bankstatic->getNomUrl(1, '');
1460  print ' '.$langs->trans("toward").' ';
1461  $banklinestatic->fetch($links[$key]['url_id']);
1462  $bankstatic->id = $banklinestatic->fk_account;
1463  $bankstatic->label = $banklinestatic->bank_account_ref;
1464  print $bankstatic->getNomUrl(1, 'transactions');
1465  print ' - ';
1466  }
1467  //var_dump($links);
1468  } elseif ($links[$key]['type'] == 'company') {
1469  } elseif ($links[$key]['type'] == 'user') {
1470  } elseif ($links[$key]['type'] == 'member') {
1471  } elseif ($links[$key]['type'] == 'sc') {
1472  } elseif ($links[$key]['type'] == 'vat') {
1473  } elseif ($links[$key]['type'] == 'salary') {
1474  // Information is already shown using the payment_salary link. No need of this link.
1475  } else {
1476  // Show link with label $links[$key]['label']
1477  print '<a href="'.$links[$key]['url'].$links[$key]['url_id'].'">';
1478  if (preg_match('/^\((.*)\)$/i', $links[$key]['label'], $reg)) {
1479  // Label generique car entre parentheses. On l'affiche en le traduisant
1480  if ($reg[1] == 'paiement') {
1481  $reg[1] = 'Payment';
1482  }
1483  print $langs->trans($reg[1]);
1484  } else {
1485  print $links[$key]['label'];
1486  }
1487  print '</a>'.($labeltoshow ? ' - ' : '');
1488  }
1489  }
1490 
1491  print $labeltoshow; // Already escaped
1492 
1493  print '</td>';
1494  if (!$i) {
1495  $totalarray['nbfield']++;
1496  }
1497  }
1498 
1499  // Date ope
1500  if (!empty($arrayfields['b.dateo']['checked'])) {
1501  print '<td align="center" class="nowrap">';
1502  print '<span class="spanforajaxedit" id="dateoperation_'.$objp->rowid.'">'.dol_print_date($db->jdate($objp->do), "day")."</span>";
1503  print '&nbsp;';
1504  print '<span class="inline-block">';
1505  print '<a class="ajaxforbankoperationchange" href="'.$_SERVER['PHP_SELF'].'?action=doprev&amp;account='.$objp->bankid.'&amp;rowid='.$objp->rowid.'">';
1506  print img_edit_remove()."</a> ";
1507  print '<a class="ajaxforbankoperationchange" href="'.$_SERVER['PHP_SELF'].'?action=donext&amp;account='.$objp->bankid.'&amp;rowid='.$objp->rowid.'">';
1508  print img_edit_add()."</a>";
1509  print '</span>';
1510  print "</td>\n";
1511  if (!$i) {
1512  $totalarray['nbfield']++;
1513  }
1514  }
1515 
1516  // Date value
1517  if (!empty($arrayfields['b.datev']['checked'])) {
1518  print '<td align="center" class="nowrap">';
1519  print '<span class="spanforajaxedit" id="datevalue_'.$objp->rowid.'">'.dol_print_date($db->jdate($objp->dv), "day")."</span>";
1520  print '&nbsp;';
1521  print '<span class="inline-block">';
1522  print '<a class="ajaxforbankoperationchange" href="'.$_SERVER['PHP_SELF'].'?action=dvprev&amp;account='.$objp->bankid.'&amp;rowid='.$objp->rowid.'">';
1523  print img_edit_remove()."</a> ";
1524  print '<a class="ajaxforbankoperationchange" href="'.$_SERVER['PHP_SELF'].'?action=dvnext&amp;account='.$objp->bankid.'&amp;rowid='.$objp->rowid.'">';
1525  print img_edit_add()."</a>";
1526  print '</span>';
1527  print "</td>\n";
1528  if (!$i) {
1529  $totalarray['nbfield']++;
1530  }
1531  }
1532 
1533  // Payment type
1534  if (!empty($arrayfields['type']['checked'])) {
1535  print '<td class="tdoverflowmax100 center">';
1536  $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);
1537  if ($labeltype == 'SOLD') {
1538  print '&nbsp;'; //$langs->trans("InitialBankBalance");
1539  } else {
1540  print $labeltype;
1541  }
1542  print "</td>\n";
1543  if (!$i) {
1544  $totalarray['nbfield']++;
1545  }
1546  }
1547 
1548  // Num cheque
1549  if (!empty($arrayfields['b.num_chq']['checked'])) {
1550  print '<td class="nowrap" align="center">'.($objp->num_chq ? dol_escape_htmltag($objp->num_chq) : "")."</td>\n";
1551  if (!$i) {
1552  $totalarray['nbfield']++;
1553  }
1554  }
1555 
1556  // Third party
1557  if (!empty($arrayfields['bu.label']['checked'])) {
1558  print '<td class="tdoverflowmax150">';
1559 
1560  $companylinked_id = 0;
1561  $userlinked_id = 0;
1562 
1563  //payment line type to define user display and user or company linked
1564  foreach ($links as $key => $value) {
1565  if ($links[$key]['type'] == 'payment_sc') {
1566  $type_link = 'payment_sc';
1567  }
1568  if ($links[$key]['type'] == 'payment_salary') {
1569  $type_link = 'payment_salary';
1570  }
1571 
1572  if ($links[$key]['type'] == 'company') {
1573  $companylinked_id = $links[$key]['url_id'];
1574  }
1575  if ($links[$key]['type'] == 'user') {
1576  $userlinked_id = $links[$key]['url_id'];
1577  }
1578  }
1579 
1580  if ($companylinked_id) {
1581  // TODO Add a cache of loaded companies here ?
1582  $companystatic->fetch($companylinked_id);
1583  print $companystatic->getNomUrl(1);
1584  } elseif ($userlinked_id &&
1585  (($type_link == 'payment_salary' && !empty($user->rights->salaries->read))
1586  || ($type_link == 'payment_sc' && !empty($user->rights->tax->charges->lire)))) {
1587  // Get object user from cache or load it
1588  if (!empty($conf->cache['user'][$userlinked_id])) {
1589  $tmpuser = $conf->cache['user'][$userlinked_id];
1590  } else {
1591  $tmpuser = new User($db);
1592  $tmpuser->fetch($userlinked_id);
1593  $conf->cache['user'][$userlinked_id] = $tmpuser;
1594  }
1595  print $tmpuser->getNomUrl(1);
1596  } else {
1597  print '&nbsp;';
1598  }
1599 
1600  print '</td>';
1601  if (!$i) {
1602  $totalarray['nbfield']++;
1603  }
1604  }
1605 
1606  // Bank account
1607  if (!empty($arrayfields['ba.ref']['checked'])) {
1608  print '<td class="nowrap">';
1609  print $bankaccount->getNomUrl(1);
1610  print "</td>\n";
1611  if (!$i) {
1612  $totalarray['nbfield']++;
1613  }
1614  }
1615 
1616  // Debit
1617  if (!empty($arrayfields['b.debit']['checked'])) {
1618  print '<td class="nowrap right"><span class="amount">';
1619  if ($objp->amount < 0) {
1620  print price($objp->amount * -1);
1621  $totalarray['totaldeb'] += $objp->amount;
1622  }
1623  print "</span></td>\n";
1624  if (!$i) {
1625  $totalarray['nbfield']++;
1626  }
1627  if (!$i) {
1628  $totalarray['totaldebfield'] = $totalarray['nbfield'];
1629  }
1630  }
1631 
1632  // Credit
1633  if (!empty($arrayfields['b.credit']['checked'])) {
1634  print '<td class="nowrap right"><span class="amount">';
1635  if ($objp->amount > 0) {
1636  print price($objp->amount);
1637  $totalarray['totalcred'] += $objp->amount;
1638  }
1639  print "</span></td>\n";
1640  if (!$i) {
1641  $totalarray['nbfield']++;
1642  }
1643  if (!$i) {
1644  $totalarray['totalcredfield'] = $totalarray['nbfield'];
1645  }
1646  }
1647 
1648  // Balance before
1649  if (!empty($arrayfields['balancebefore']['checked'])) {
1650  if ($mode_balance_ok) {
1651  if ($balancebefore >= 0) {
1652  print '<td class="nowrap right">&nbsp;'.price($balancebefore).'</td>';
1653  } else {
1654  print '<td class="error nowrap right">&nbsp;'.price($balancebefore).'</td>';
1655  }
1656  } else {
1657  print '<td class="right">-</td>';
1658  }
1659  if (!$i) {
1660  $totalarray['nbfield']++;
1661  }
1662  }
1663 
1664  // Balance after
1665  if (!empty($arrayfields['balance']['checked'])) {
1666  if ($mode_balance_ok) {
1667  if ($balance >= 0) {
1668  print '<td class="nowrap right">&nbsp;'.price($balance).'</td>';
1669  } else {
1670  print '<td class="error nowrap right">&nbsp;'.price($balance).'</td>';
1671  }
1672  } else {
1673  print '<td class="right">-</td>';
1674  }
1675  if (!$i) {
1676  $totalarray['nbfield']++;
1677  }
1678  }
1679 
1680  if (!empty($arrayfields['b.num_releve']['checked'])) {
1681  print '<td class="nowraponall" align="center">';
1682  // Transaction reconciliated or edit link
1683  if ($bankaccount->canBeConciliated() > 0) {
1684  if ($objp->num_releve) {
1685  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>';
1686  }
1687  if (!$objp->conciliated && $action == 'reconcile') {
1688  if ($objp->num_releve) {
1689  print '&nbsp;';
1690  }
1691  print '<input class="flat" name="rowid['.$objp->rowid.']" type="checkbox" value="'.$objp->rowid.'" size="1"'.(!empty($_POST['rowid'][$objp->rowid]) ? ' checked' : '').'>';
1692  }
1693  }
1694  print '</td>';
1695  if (!$i) {
1696  $totalarray['nbfield']++;
1697  $posconciliatecol = $totalarray['nbfield'];
1698  }
1699  }
1700 
1701  if (!empty($arrayfields['b.conciliated']['checked'])) {
1702  print '<td class="nowraponall" align="center">';
1703  print yn($objp->conciliated);
1704  print '</td>';
1705  if (!$i) {
1706  $totalarray['nbfield']++;
1707  }
1708  }
1709 
1710  if (!empty($arrayfields['b.fk_bordereau']['checked'])) {
1711  $bordereaustatic->fetch($objp->fk_bordereau);
1712  print '<td class="nowraponall" align="center">';
1713  print $bordereaustatic->getNomUrl();
1714  print '</td>';
1715  if (!$i) {
1716  $totalarray['nbfield']++;
1717  }
1718  }
1719 
1720  // Fields from hook
1721  $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$objp, 'i'=>$i, 'totalarray'=>&$totalarray);
1722  $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters, $objecttmp); // Note that $action and $objecttmpect may have been modified by hook
1723  print $hookmanager->resPrint;
1724 
1725  // Action edit/delete and select
1726  print '<td class="nowraponall" align="center">';
1727  // Transaction reconciliated or edit link
1728  if ($objp->conciliated && $bankaccount->canBeConciliated() > 0) { // If line not conciliated and account can be conciliated
1729  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.'">';
1730  print img_edit();
1731  print '</a>';
1732  } else {
1733  if ($user->rights->banque->modifier || $user->rights->banque->consolidate) {
1734  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.'">';
1735  print img_edit();
1736  print '</a>';
1737  } else {
1738  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.'">';
1739  print img_view();
1740  print '</a>';
1741  }
1742  if ($bankaccount->canBeConciliated() > 0 && empty($objp->conciliated)) {
1743  if ($db->jdate($objp->dv) < ($now - $conf->bank->rappro->warning_delay)) {
1744  print ' '.img_warning($langs->trans("ReconciliationLate"));
1745  }
1746  }
1747  if ($user->rights->banque->modifier) {
1748  print '<a href="'.$_SERVER["PHP_SELF"].'?action=delete&token='.newToken().'&rowid='.$objp->rowid.'&page='.$page.$param.($sortfield ? '&sortfield='.$sortfield : '').($sortorder ? '&sortorder='.$sortorder : '').'">';
1749  print img_delete('', 'class="marginleftonly"');
1750  print '</a>';
1751  }
1752  }
1753 
1754  // Action column
1755  if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
1756  $selected = 0;
1757  if (in_array($obj->rowid, $arrayofselected)) {
1758  $selected = 1;
1759  }
1760  print '<input id="cb'.$obj->rowid.'" class="flat checkforselect marginleftonly" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
1761  }
1762  print '</td>';
1763  if (!$i) {
1764  $totalarray['nbfield']++;
1765  }
1766 
1767  print "</tr>";
1768 
1769  $i++;
1770  }
1771 
1772  // Show total line
1773  if (isset($totalarray['totaldebfield']) || isset($totalarray['totalcredfield'])) {
1774  print '<tr class="liste_total">';
1775  $i = 0;
1776  while ($i < $totalarray['nbfield']) {
1777  $i++;
1778  if ($i == 1) {
1779  if ($num < $limit && empty($offset)) {
1780  print '<td class="left">'.$langs->trans("Total").'</td>';
1781  } else {
1782  print '<td class="left tdoverflowmax50" title="'.$langs->trans("Totalforthispage").'">'.$langs->trans("Totalforthispage").'</td>';
1783  }
1784  } elseif ($totalarray['totaldebfield'] == $i) {
1785  print '<td class="right"><span class="amount">'.price(-1 * $totalarray['totaldeb']).'</span></td>';
1786  } elseif ($totalarray['totalcredfield'] == $i) {
1787  print '<td class="right"><span class="amount">'.price($totalarray['totalcred']).'</span></td>';
1788  } elseif ($i == $posconciliatecol) {
1789  print '<td class="center">';
1790  if ($user->rights->banque->consolidate && $action == 'reconcile') {
1791  print '<input class="button" name="confirm_reconcile" type="submit" value="'.$langs->trans("Conciliate").'">';
1792  }
1793  print '</td>';
1794  } else {
1795  print '<td></td>';
1796  }
1797  }
1798  print '</tr>';
1799  }
1800 
1801  // If no record found
1802  if ($num == 0) {
1803  $colspan = 1;
1804  foreach ($arrayfields as $key => $val) {
1805  if (!empty($val['checked'])) {
1806  $colspan++;
1807  }
1808  }
1809  print '<tr><td colspan="'.($colspan + 1).'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>';
1810  }
1811 
1812  print "</table>";
1813  print "</div>";
1814 
1815  print '</form>';
1816  $db->free($resql);
1817 } else {
1818  dol_print_error($db);
1819 }
1820 
1821 // End of page
1822 llxFooter();
1823 $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:6491
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:1468
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:5204
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:4844
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:8385
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:4389
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:2046
price2num
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
Definition: functions.lib.php:5661
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:2514
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:3880
PaymentVarious
Class to manage various payments.
Definition: paymentvarious.class.php:32
Account\TYPE_CASH
const TYPE_CASH
Cash account.
Definition: account.class.php:346
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:4429
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:10605
img_edit_add
img_edit_add($titlealt='default', $other='')
Show logo +.
Definition: functions.lib.php:4353
dol_syslog
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
Definition: functions.lib.php:1603
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:5257
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:1822
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:3747
newToken
newToken()
Return the value of token currently saved into session with name 'newtoken'.
Definition: functions.lib.php:10878
dol_get_fiche_end
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Definition: functions.lib.php:2018
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:4370
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:4408
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:5026
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:9420
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:7879
AccountLine
Class to manage bank transaction lines.
Definition: account.class.php:1779
dol_now
dol_now($mode='auto')
Return date for now.
Definition: functions.lib.php:2845
$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:5541
setEventMessages
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
Definition: functions.lib.php:8137
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:2757
currentToken
currentToken()
Return the value of token currently saved into session with name 'token'.
Definition: functions.lib.php:10889
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