dolibarr  17.0.4
list.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2004-2019 Laurent Destailleur <eldy@users.sourceforge.net>
4  * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
5  * Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
6  * Copyright (C) 2018 Ferran Marcet <fmarcet@2byte.es>
7  * Copyright (C) 2020 Tobias Sekan <tobias.sekan@startmail.com>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 3 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program. If not, see <https://www.gnu.org/licenses/>.
21  */
22 
29 // Load Dolibarr environment
30 require '../../main.inc.php';
31 require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php';
32 require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php';
33 require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php';
34 require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
35 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcategory.class.php';
36 if (isModEnabled('accounting')) {
37  require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php';
38 }
39 if (isModEnabled('accounting')) {
40  require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php';
41 }
42 if (isModEnabled('categorie')) {
43  require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
44 }
45 
46 // Load translation files required by the page
47 $langs->loadLangs(array('banks', 'categories', 'accountancy', 'compta'));
48 
49 $action = GETPOST('action', 'aZ09');
50 $massaction = GETPOST('massaction', 'alpha');
51 $show_files = GETPOST('show_files', 'int');
52 $confirm = GETPOST('confirm', 'alpha');
53 $toselect = GETPOST('toselect', 'array');
54 $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'bankaccountlist'; // To manage different context of search
55 
56 $search_ref = GETPOST('search_ref', 'alpha');
57 $search_label = GETPOST('search_label', 'alpha');
58 $search_number = GETPOST('search_number', 'alpha');
59 $search_status = GETPOST('search_status') ?GETPOST('search_status', 'alpha') : 'opened'; // 'all' or ''='opened'
60 $optioncss = GETPOST('optioncss', 'alpha');
61 
62 $search_category_list ="";
63 if (isModEnabled('categorie')) {
64  $search_category_list = GETPOST("search_category_".Categorie::TYPE_ACCOUNT."_list", "array");
65 }
66 
67 $socid = 0;
68 // Security check
69 if ($user->socid) {
70  $socid = $user->socid;
71 }
72 
73 $allowed = 0;
74 if ($user->hasRight('accounting', 'chartofaccount')) {
75  $allowed = 1; // Dictionary with list of banks accounting account allowed to manager of chart account
76 }
77 if (!$allowed) {
78  $result = restrictedArea($user, 'banque');
79 }
80 
81 $diroutputmassaction = $conf->bank->dir_output.'/temp/massgeneration/'.$user->id;
82 
83 $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
84 $sortfield = GETPOST('sortfield', 'aZ09comma');
85 $sortorder = GETPOST('sortorder', 'aZ09comma');
86 $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
87 if (empty($page) || $page == -1) {
88  $page = 0;
89 } // If $page is not defined, or '' or -1
90 $offset = $limit * $page;
91 $pageprev = $page - 1;
92 $pagenext = $page + 1;
93 if (!$sortfield) {
94  $sortfield = 'b.label';
95 }
96 if (!$sortorder) {
97  $sortorder = 'ASC';
98 }
99 
100 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
101 $object = new Account($db);
102 $extrafields = new ExtraFields($db);
103 $hookmanager->initHooks(array('bankaccountlist'));
104 
105 // fetch optionals attributes and labels
106 $extrafields->fetch_name_optionals_label($object->table_element);
107 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
108 
109 // List of fields to search into when doing a "search in all"
110 $fieldstosearchall = array(
111  'b.ref'=>'Ref',
112  'b.label'=>'Label',
113 );
114 
115 $checkedtypetiers = 0;
116 $arrayfields = array(
117  'b.ref'=>array('label'=>$langs->trans("BankAccounts"), 'checked'=>1, 'position'=>10),
118  'b.label'=>array('label'=>$langs->trans("Label"), 'checked'=>1, 'position'=>12),
119  'accountype'=>array('label'=>$langs->trans("Type"), 'checked'=>1, 'position'=>14),
120  'b.number'=>array('label'=>$langs->trans("AccountIdShort"), 'checked'=>1, 'position'=>16),
121  'b.account_number'=>array('label'=>$langs->trans("AccountAccounting"), 'checked'=>(isModEnabled('accounting')), 'position'=>18),
122  'b.fk_accountancy_journal'=>array('label'=>$langs->trans("AccountancyJournal"), 'checked'=>(isModEnabled('accounting')), 'position'=>20),
123  'toreconcile'=>array('label'=>$langs->trans("TransactionsToConciliate"), 'checked'=>1, 'position'=>50),
124  'b.currency_code'=>array('label'=>$langs->trans("Currency"), 'checked'=>0, 'position'=>22),
125  'b.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500),
126  'b.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500),
127  'b.clos'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000),
128  'balance'=>array('label'=>$langs->trans("Balance"), 'checked'=>1, 'position'=>1010),
129 );
130 // Extra fields
131 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
132 
133 $object->fields = dol_sort_array($object->fields, 'position');
134 $arrayfields = dol_sort_array($arrayfields, 'position');
135 
136 $permissiontoadd = $user->rights->banque->modifier;
137 $permissiontodelete = $user->rights->banque->configurer;
138 
139 /*
140  * Actions
141  */
142 
143 if (GETPOST('cancel', 'alpha')) {
144  $action = 'list';
145  $massaction = '';
146 }
147 if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
148  $massaction = '';
149 }
150 
151 $parameters = array('socid'=>$socid);
152 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
153 if ($reshook < 0) {
154  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
155 }
156 
157 if (empty($reshook)) {
158  include DOL_DOCUMENT_ROOT . '/core/actions_changeselectedfields.inc.php';
159 
160  // Purge search criteria
161  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
162  $search_ref = '';
163  $search_label = '';
164  $search_number = '';
165  $search_status = '';
166  $search_category_list = array();
167  }
168 
169  // Mass actions
170  $objectclass = 'Account';
171  $objectlabel = 'FinancialAccount';
172  $uploaddir = $conf->banque->dir_output;
173  include DOL_DOCUMENT_ROOT . '/core/actions_massactions.inc.php';
174 }
175 
176 /*
177  * View
178  */
179 
180 $form = new FormCategory($db);
181 
182 $title = $langs->trans('BankAccounts');
183 
184 // Load array of financial accounts (opened by default)
185 $accounts = array();
186 
187 $sql = "SELECT b.rowid, b.label, b.courant, b.rappro, b.account_number, b.fk_accountancy_journal, b.currency_code, b.datec as date_creation, b.tms as date_update";
188 // Add fields from extrafields
189 if (!empty($extrafields->attributes[$object->table_element]['label'])) {
190  foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
191  $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : '');
192  }
193 }
194 // Add fields from hooks
195 $parameters = array();
196 $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
197 $sql .= $hookmanager->resPrint;
198 
199 $sqlfields = $sql; // $sql fields to remove for count total
200 
201 $sql .= " FROM ".MAIN_DB_PREFIX."bank_account as b";
202 if (!empty($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
203  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (b.rowid = ef.fk_object)";
204 }
205 $sql .= " WHERE b.entity IN (".getEntity('bank_account').")";
206 if ($search_status == 'opened') {
207  $sql .= " AND clos = 0";
208 }
209 if ($search_status == 'closed') {
210  $sql .= " AND clos = 1";
211 }
212 if ($search_ref != '') {
213  $sql .= natural_search('b.ref', $search_ref);
214 }
215 if ($search_label != '') {
216  $sql .= natural_search('b.label', $search_label);
217 }
218 if ($search_number != '') {
219  $sql .= natural_search('b.number', $search_number);
220 }
221 // Search for tag/category ($searchCategoryBankList is an array of ID)
222 $searchCategoryBankList = $search_category_list;
223 $searchCategoryBankOperator = 0;
224 if (!empty($searchCategoryBankList)) {
225  $searchCategoryBankSqlList = array();
226  $listofcategoryid = '';
227  foreach ($searchCategoryBankList as $searchCategoryBank) {
228  if (intval($searchCategoryBank) == -2) {
229  $searchCategoryBankSqlList[] = "NOT EXISTS (SELECT ck.fk_account FROM ".MAIN_DB_PREFIX."categorie_account as ck WHERE b.rowid = ck.fk_account)";
230  } elseif (intval($searchCategoryBank) > 0) {
231  if ($searchCategoryBankOperator == 0) {
232  $searchCategoryBankSqlList[] = " EXISTS (SELECT ck.fk_account FROM ".MAIN_DB_PREFIX."categorie_account as ck WHERE b.rowid = ck.fk_account AND ck.fk_categorie = ".((int) $searchCategoryBank).")";
233  } else {
234  $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryBank);
235  }
236  }
237  }
238  if ($listofcategoryid) {
239  $searchCategoryBankSqlList[] = " EXISTS (SELECT ck.fk_account FROM ".MAIN_DB_PREFIX."categorie_account as ck WHERE b.rowid = ck.fk_account AND ck.fk_categorie IN (".$db->sanitize($listofcategoryid)."))";
240  }
241  if ($searchCategoryBankOperator == 1) {
242  if (!empty($searchCategoryBankSqlList)) {
243  $sql .= " AND (".implode(' OR ', $searchCategoryBankSqlList).")";
244  }
245  } else {
246  if (!empty($searchCategoryBankSqlList)) {
247  $sql .= " AND (".implode(' AND ', $searchCategoryBankSqlList).")";
248  }
249  }
250 }
251 // Add where from extra fields
252 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
253 // Add where from hooks
254 $parameters = array();
255 $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
256 $sql .= $hookmanager->resPrint;
257 
258 // Count total nb of records
259 $nbtotalofrecords = '';
260 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
261  /* The fast and low memory method to get and count full list converts the sql into a sql count */
262  $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql);
263  $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount);
264  $resql = $db->query($sqlforcount);
265  if ($resql) {
266  $objforcount = $db->fetch_object($resql);
267  $nbtotalofrecords = $objforcount->nbtotalofrecords;
268  } else {
269  dol_print_error($db);
270  }
271 
272  if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
273  $page = 0;
274  $offset = 0;
275  }
276  $db->free($resql);
277 }
278 
279 $sql .= $db->order($sortfield, $sortorder);
280 if ($limit) {
281  $sql .= $db->plimit($limit + 1, $offset);
282 }
283 
284 $resql = $db->query($sql);
285 if ($resql) {
286  $num = $db->num_rows($resql);
287  $i = 0;
288  while ($i < $num) {
289  $objp = $db->fetch_object($resql);
290  $accounts[$objp->rowid] = $objp->courant;
291  $i++;
292  }
293  $db->free($resql);
294 } else {
295  dol_print_error($db);
296 }
297 
298 
299 
300 $help_url = 'EN:Module_Banks_and_Cash|FR:Module_Banques_et_Caisses|ES:M&oacute;dulo_Bancos_y_Cajas';
301 
302 llxHeader('', $title, $help_url);
303 
304 
305 $arrayofselected = is_array($toselect) ? $toselect : array();
306 
307 $param = '';
308 if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
309  $param .= '&contextpage='.urlencode($contextpage);
310 }
311 if ($limit > 0 && $limit != $conf->liste_limit) {
312  $param .= '&limit='.urlencode($limit);
313 }
314 if ($search_ref != '') {
315  $param .= '&search_ref='.urlencode($search_ref);
316 }
317 if ($search_label != '') {
318  $param .= '&search_label='.urlencode($search_label);
319 }
320 if ($search_number != '') {
321  $param .= '&search_number='.urlencode($search_number);
322 }
323 if ($search_status != '') {
324  $param .= '&search_status='.urlencode($search_status);
325 }
326 if ($show_files) {
327  $param .= '&show_files='.urlencode($show_files);
328 }
329 if ($optioncss != '') {
330  $param .= '&optioncss='.urlencode($optioncss);
331 }
332 // Add $param from extra fields
333 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
334 // Add $param from hooks
335 $parameters = array();
336 $reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
337 $param .= $hookmanager->resPrint;
338 
339 // List of mass actions available
340 $arrayofmassactions = array(
341 // 'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
342 // 'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
343 );
344 if ($permissiontodelete) {
345  $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
346 }
347 if (isModEnabled('category') && $user->rights->banque->modifier) {
348  $arrayofmassactions['preaffecttag'] = img_picto('', 'category', 'class="pictofixedwidth"').$langs->trans("AffectTag");
349 }
350 if (in_array($massaction, array('presend', 'predelete','preaffecttag'))) {
351  $arrayofmassactions = array();
352 }
353 $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
354 
355 print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n";
356 if ($optioncss != '') {
357  print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
358 }
359 print '<input type="hidden" name="token" value="'.newToken().'">';
360 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
361 print '<input type="hidden" name="action" value="list">';
362 print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
363 print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
364 print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
365 
366 print '<input type="hidden" name="page" value="'.$page.'">';
367 print '<input type="hidden" name="search_status" value="'.$search_status.'">';
368 
369 $newcardbutton = dolGetButtonTitle($langs->trans('NewFinancialAccount'), '', 'fa fa-plus-circle', 'card.php?action=create', '', $user->rights->banque->configurer);
370 
371 print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'bank_account', 0, $newcardbutton, '', $limit, 1);
372 
373 $topicmail = "Information";
374 //$modelmail="subscription";
375 $objecttmp = new Account($db);
376 $trackid = 'bank'.$object->id;
377 include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
378 
379 //if ($sall) {
380 // foreach ($fieldstosearchall as $key => $val) {
381 // $fieldstosearchall[$key] = $langs->trans($val);
382 // }
383 // print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'</div>';
384 //}
385 
386 $moreforfilter = '';
387 
388 if (isModEnabled('categorie') && $user->rights->categorie->lire) {
389  $moreforfilter .= $form->getFilterBox(Categorie::TYPE_ACCOUNT, $search_category_list);
390 }
391 
392 // Bank accounts
393 $parameters = array();
394 $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
395 if (empty($reshook)) {
396  $moreforfilter .= $hookmanager->resPrint;
397 } else {
398  $moreforfilter = $hookmanager->resPrint;
399 }
400 
401 if (!empty($moreforfilter)) {
402  print '<div class="liste_titre liste_titre_bydiv centpercent">';
403  print $moreforfilter;
404  print '</div>';
405 }
406 
407 $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
408 $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')); // This also change content of $arrayfields
409 $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
410 
411 print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
412 print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
413 
414 // Fields title search
415 // --------------------------------------------------------------------
416 print '<tr class="liste_titre">';
417 // Action column
418 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
419  print '<td class="liste_titre maxwidthsearch">';
420  $searchpicto = $form->showFilterButtons('left');
421  print $searchpicto;
422  print '</td>';
423 }
424 // Ref
425 if (!empty($arrayfields['b.ref']['checked'])) {
426  print '<td class="liste_titre">';
427  print '<input class="flat" size="6" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
428  print '</td>';
429 }
430 // Label
431 if (!empty($arrayfields['b.label']['checked'])) {
432  print '<td class="liste_titre">';
433  print '<input class="flat" size="6" type="text" name="search_label" value="'.dol_escape_htmltag($search_label).'">';
434  print '</td>';
435 }
436 // Account type
437 if (!empty($arrayfields['accountype']['checked'])) {
438  print '<td class="liste_titre">';
439  print '</td>';
440 }
441 // Bank number
442 if (!empty($arrayfields['b.number']['checked'])) {
443  print '<td class="liste_titre">';
444  print '<input class="flat" size="6" type="text" name="search_number" value="'.dol_escape_htmltag($search_number).'">';
445  print '</td>';
446 }
447 // Account number
448 if (!empty($arrayfields['b.account_number']['checked'])) {
449  print '<td class="liste_titre">';
450  print '</td>';
451 }
452 // Accountancy journal
453 if (!empty($arrayfields['b.fk_accountancy_journal']['checked'])) {
454  print '<td class="liste_titre">';
455  print '</td>';
456 }
457 // Transactions to reconcile
458 if (!empty($arrayfields['toreconcile']['checked'])) {
459  print '<td class="liste_titre">';
460  print '</td>';
461 }
462 // Currency
463 if (!empty($arrayfields['b.currency_code']['checked'])) {
464  print '<td class="liste_titre">';
465  print '</td>';
466 }
467 // Extra fields
468 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
469 
470 // Fields from hook
471 $parameters = array('arrayfields'=>$arrayfields);
472 $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
473 print $hookmanager->resPrint;
474 // Date creation
475 if (!empty($arrayfields['b.datec']['checked'])) {
476  print '<td class="liste_titre">';
477  print '</td>';
478 }
479 // Date modification
480 if (!empty($arrayfields['b.tms']['checked'])) {
481  print '<td class="liste_titre">';
482  print '</td>';
483 }
484 // Status
485 if (!empty($arrayfields['b.clos']['checked'])) {
486  print '<td class="liste_titre center">';
487  $array = array(
488  'opened'=>$langs->trans("Opened"),
489  'closed'=>$langs->trans("Closed")
490  );
491  print $form->selectarray("search_status", $array, $search_status, 1, 0, 0, '', 0, 0, 0, '', 'search_status maxwidth125 onrightofpage', 1);
492  print '</td>';
493 }
494 // Balance
495 if (!empty($arrayfields['balance']['checked'])) {
496  print '<td class="liste_titre"></td>';
497 }
498 // Action column
499 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
500  print '<td class="liste_titre maxwidthsearch">';
501  $searchpicto = $form->showFilterButtons();
502  print $searchpicto;
503  print '</td>';
504 }
505 print '</tr>'."\n";
506 
507 // Fields title label
508 // --------------------------------------------------------------------
509 print '<tr class="liste_titre">';
510 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
511  print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
512 }
513 if (!empty($arrayfields['b.ref']['checked'])) {
514  print_liste_field_titre($arrayfields['b.ref']['label'], $_SERVER["PHP_SELF"], 'b.ref', '', $param, '', $sortfield, $sortorder);
515 }
516 if (!empty($arrayfields['b.label']['checked'])) {
517  print_liste_field_titre($arrayfields['b.label']['label'], $_SERVER["PHP_SELF"], 'b.label', '', $param, '', $sortfield, $sortorder);
518 }
519 if (!empty($arrayfields['accountype']['checked'])) {
520  print_liste_field_titre($arrayfields['accountype']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder);
521 }
522 if (!empty($arrayfields['b.number']['checked'])) {
523  print_liste_field_titre($arrayfields['b.number']['label'], $_SERVER["PHP_SELF"], 'b.number', '', $param, '', $sortfield, $sortorder);
524 }
525 if (!empty($arrayfields['b.account_number']['checked'])) {
526  print_liste_field_titre($arrayfields['b.account_number']['label'], $_SERVER["PHP_SELF"], 'b.account_number', '', $param, '', $sortfield, $sortorder);
527 }
528 if (!empty($arrayfields['b.fk_accountancy_journal']['checked'])) {
529  print_liste_field_titre($arrayfields['b.fk_accountancy_journal']['label'], $_SERVER["PHP_SELF"], 'b.fk_accountancy_journal', '', $param, '', $sortfield, $sortorder);
530 }
531 if (!empty($arrayfields['b.currency_code']['checked'])) {
532  print_liste_field_titre($arrayfields['b.currency_code']['label'], $_SERVER["PHP_SELF"], 'b.currency_code', '', $param, '', $sortfield, $sortorder, 'center ');
533 }
534 if (!empty($arrayfields['toreconcile']['checked'])) {
535  print_liste_field_titre($arrayfields['toreconcile']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center ');
536 }
537 // Extra fields
538 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
539 // Hook fields
540 $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
541 $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
542 print $hookmanager->resPrint;
543 if (!empty($arrayfields['b.datec']['checked'])) {
544  print_liste_field_titre($arrayfields['b.datec']['label'], $_SERVER["PHP_SELF"], "b.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
545 }
546 if (!empty($arrayfields['b.tms']['checked'])) {
547  print_liste_field_titre($arrayfields['b.tms']['label'], $_SERVER["PHP_SELF"], "b.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
548 }
549 if (!empty($arrayfields['b.clos']['checked'])) {
550  print_liste_field_titre($arrayfields['b.clos']['label'], $_SERVER["PHP_SELF"], 'b.clos', '', $param, '', $sortfield, $sortorder, 'center ');
551 }
552 if (!empty($arrayfields['balance']['checked'])) {
553  print_liste_field_titre($arrayfields['balance']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right ');
554 }
555 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
556  print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
557 }
558 print "</tr>\n";
559 
560 
561 $totalarray = array();
562 $totalarray['nbfield'] = 0;
563 $totalarray['val'] = array('balance'=>0);
564 $total = array();
565 $found = 0;
566 $i = 0;
567 $lastcurrencycode = '';
568 
569 foreach ($accounts as $key => $type) {
570  if ($i >= $limit) {
571  break;
572  }
573 
574  $found++;
575 
576  $result = $objecttmp->fetch($key);
577 
578  $solde = $objecttmp->solde(1);
579 
580  if (!empty($lastcurrencycode) && $lastcurrencycode != $objecttmp->currency_code) {
581  $lastcurrencycode = 'various'; // We found several different currencies
582  }
583  if ($lastcurrencycode != 'various') {
584  $lastcurrencycode = $objecttmp->currency_code;
585  }
586 
587  print '<tr class="oddeven">';
588  // Action column
589  if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
590  print '<td class="nowrap center">';
591  if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
592  $selected = 0;
593  if (in_array($objecttmp->id, $arrayofselected)) {
594  $selected = 1;
595  }
596  print '<input id="cb'.$objecttmp->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$objecttmp->id.'"'.($selected ? ' checked="checked"' : '').'>';
597  }
598  print '</td>';
599  }
600  // Ref
601  if (!empty($arrayfields['b.ref']['checked'])) {
602  print '<td class="nowraponall">'.$objecttmp->getNomUrl(1).'</td>';
603  if (!$i) {
604  $totalarray['nbfield']++;
605  }
606  }
607 
608  // Label
609  if (!empty($arrayfields['b.label']['checked'])) {
610  print '<td class="tdoverflowmax200" title="'.dol_escape_htmltag($objecttmp->label).'">'.dol_escape_htmltag($objecttmp->label).'</td>';
611  if (!$i) {
612  $totalarray['nbfield']++;
613  }
614  }
615 
616  // Account type
617  if (!empty($arrayfields['accountype']['checked'])) {
618  print '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($objecttmp->type_lib[$objecttmp->type]).'">';
619  print $objecttmp->type_lib[$objecttmp->type];
620  print '</td>';
621  if (!$i) {
622  $totalarray['nbfield']++;
623  }
624  }
625 
626  // Number
627  if (!empty($arrayfields['b.number']['checked'])) {
628  print '<td>'.dol_escape_htmltag($objecttmp->number).'</td>';
629  if (!$i) {
630  $totalarray['nbfield']++;
631  }
632  }
633 
634  // Account number
635  if (!empty($arrayfields['b.account_number']['checked'])) {
636  print '<td class="tdoverflowmax250">';
637  if (isModEnabled('accounting') && !empty($objecttmp->account_number)) {
638  $accountingaccount = new AccountingAccount($db);
639  $accountingaccount->fetch('', $objecttmp->account_number, 1);
640  print '<span title="'.dol_escape_htmltag($accountingaccount->account_number.' - '.$accountingaccount->label).'">';
641  print $accountingaccount->getNomUrl(0, 1, 1, '', 0);
642  print '</span>';
643  } else {
644  print '<span title="'.dol_escape_htmltag($objecttmp->account_number).'">'.$objecttmp->account_number.'</span>';
645  }
646  print '</td>';
647  if (!$i) {
648  $totalarray['nbfield']++;
649  }
650  }
651 
652  // Accountancy journal
653  if (!empty($arrayfields['b.fk_accountancy_journal']['checked'])) {
654  print '<td class="tdoverflowmax125">';
655  if (isModEnabled('accounting')) {
656  if (empty($objecttmp->fk_accountancy_journal)) {
657  print img_warning($langs->trans("Mandatory"));
658  } else {
659  $accountingjournal = new AccountingJournal($db);
660  $accountingjournal->fetch($objecttmp->fk_accountancy_journal);
661  print $accountingjournal->getNomUrl(0, 1, 1, '', 1);
662  }
663  } else {
664  print '';
665  }
666  print '</td>';
667  if (!$i) {
668  $totalarray['nbfield']++;
669  }
670  }
671 
672  // Currency
673  if (!empty($arrayfields['b.currency_code']['checked'])) {
674  print '<td class="center nowraponall">';
675  print $objecttmp->currency_code;
676  print '</td>';
677  if (!$i) {
678  $totalarray['nbfield']++;
679  }
680  }
681 
682  // Transactions to reconcile
683  if (!empty($arrayfields['toreconcile']['checked'])) {
684  $conciliate = $objecttmp->canBeConciliated();
685 
686  $labeltoshow = '';
687  if ($conciliate == -2) {
688  $labeltoshow = $langs->trans("CashAccount");
689  } elseif ($conciliate == -3) {
690  $labeltoshow = $langs->trans("Closed");
691  } elseif (empty($objecttmp->rappro)) {
692  $labeltoshow = $langs->trans("ConciliationDisabled");
693  }
694 
695  print '<td class="center tdoverflowmax125"'.($labeltoshow ? ' title="'.dol_escape_htmltag($labeltoshow).'"' : '').'>';
696  if ($conciliate == -2) {
697  print '<span class="opacitymedium">'.$langs->trans("CashAccount").'</span>';
698  } elseif ($conciliate == -3) {
699  print '<span class="opacitymedium">'.$langs->trans("Closed").'</span>';
700  } elseif (empty($objecttmp->rappro)) {
701  print '<span class="opacitymedium">'.$langs->trans("ConciliationDisabled").'</span>';
702  } else {
703  $result = $objecttmp->load_board($user, $objecttmp->id);
704  if (is_numeric($result) && $result < 0) {
705  setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
706  } else {
707  print '<a href="'.DOL_URL_ROOT.'/compta/bank/bankentries_list.php?action=reconcile&sortfield=b.datev,b.dateo,b.rowid&sortorder=asc,asc,asc&id='.$objecttmp->id.'&search_account='.$objecttmp->id.'&search_conciliated=0&contextpage=banktransactionlist">';
708  print '<span class="badge badge-info classfortooltip" title="'.dol_htmlentities($langs->trans("TransactionsToConciliate")).'">';
709  print $result->nbtodo;
710  print '</span>';
711  print '</a>';
712  if ($result->nbtodolate) {
713  print '<span title="'.dol_htmlentities($langs->trans("Late")).'" class="classfortooltip badge badge-danger marginleftonlyshort">';
714  print '<i class="fa fa-exclamation-triangle"></i> '.$result->nbtodolate;
715  print '</span>';
716  }
717  }
718  }
719 
720  print '</td>';
721  if (!$i) {
722  $totalarray['nbfield']++;
723  }
724  }
725 
726  // Extra fields
727  if (is_array($objecttmp->array_options)) {
728  $obj = new stdClass();
729  foreach ($objecttmp->array_options as $k => $v) {
730  $obj->$k = $v;
731  }
732  }
733  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
734  // Fields from hook
735  $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
736  $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $objecttmp, $action); // Note that $action and $objecttmpect may have been modified by hook
737  print $hookmanager->resPrint;
738  // Date creation
739  if (!empty($arrayfields['b.datec']['checked'])) {
740  print '<td class="center nowraponall">';
741  print dol_print_date($objecttmp->date_creation, 'dayhour');
742  print '</td>';
743  if (!$i) {
744  $totalarray['nbfield']++;
745  }
746  }
747  // Date modification
748  if (!empty($arrayfields['b.tms']['checked'])) {
749  print '<td class="center nowraponall">';
750  print dol_print_date($objecttmp->date_update, 'dayhour');
751  print '</td>';
752  if (!$i) {
753  $totalarray['nbfield']++;
754  }
755  }
756 
757  // Status
758  if (!empty($arrayfields['b.clos']['checked'])) {
759  print '<td class="center">'.$objecttmp->getLibStatut(5).'</td>';
760  if (!$i) {
761  $totalarray['nbfield']++;
762  }
763  }
764 
765  // Balance
766  if (!empty($arrayfields['balance']['checked'])) {
767  print '<td class="nowraponall right">';
768  print '<a href="'.DOL_URL_ROOT.'/compta/bank/bankentries_list.php?id='.$objecttmp->id.'">';
769  print '<span class="amount">'.price($solde, 0, $langs, 1, -1, -1, $objecttmp->currency_code).'</span>';
770  print '</a>';
771  print '</td>';
772  if (!$i) {
773  $totalarray['nbfield']++;
774  }
775  if (!$i) {
776  $totalarray['pos'][$totalarray['nbfield']] = 'balance';
777  }
778  $totalarray['val']['balance'] += $solde;
779  }
780 
781  // Action column
782  if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
783  print '<td class="nowrap center">';
784  if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
785  $selected = 0;
786  if (in_array($objecttmp->id, $arrayofselected)) {
787  $selected = 1;
788  }
789  print '<input id="cb'.$objecttmp->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$objecttmp->id.'"'.($selected ? ' checked="checked"' : '').'>';
790  }
791  print '</td>';
792  }
793  if (!$i) {
794  $totalarray['nbfield']++;
795  }
796 
797  print '</tr>';
798 
799  if (empty($total[$objecttmp->currency_code])) {
800  $total[$objecttmp->currency_code] = $solde;
801  } else {
802  $total[$objecttmp->currency_code] += $solde;
803  }
804 
805  $i++;
806 }
807 
808 // If no record found
809 if (!$found) {
810  $colspan = 1;
811  foreach ($arrayfields as $key => $val) {
812  if (!empty($val['checked'])) {
813  $colspan++;
814  }
815  }
816  print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>';
817 }
818 
819 // Show total line
820 if ($lastcurrencycode != 'various') { // If there is several currency, $lastcurrencycode is set to 'various' before
821  // Show total line
822  include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
823 }
824 
825 print '</table>';
826 print "</div>";
827 
828 print "</form>";
829 
830 // End of page
831 llxFooter();
832 $db->close();
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save" &&empty($cancel)) $help_url
View.
Definition: agenda.php:118
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:56
llxFooter()
Empty footer.
Definition: wrapper.php:70
Class to manage bank accounts.
Class to manage accounting accounts.
Class to manage accounting accounts.
Class to manage standard extra fields.
Class to manage forms for categories.
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
Definition: index.php:745
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:143
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
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.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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.
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...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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...
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
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.
if(!function_exists('utf8_encode')) if(!function_exists('utf8_decode')) getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
isModEnabled($module)
Is Dolibarr module enabled.
$nbtotalofrecords
Count total nb of records.
Definition: list.php:329
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.