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