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