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