dolibarr  13.0.2
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 (!empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php';
36 if (!empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php';
37 if (!empty($conf->categorie->enabled)) require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
38 
39 // Load translation files required by the page
40 $langs->loadLangs(array('banks', 'categories', 'accountancy', 'compta'));
41 
42 $action = GETPOST('action', 'aZ09');
43 $massaction = GETPOST('massaction', 'alpha');
44 $show_files = GETPOST('show_files', 'int');
45 $confirm = GETPOST('confirm', 'alpha');
46 $toselect = GETPOST('toselect', 'array');
47 $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'bankaccountlist'; // To manage different context of search
48 
49 $search_ref = GETPOST('search_ref', 'alpha');
50 $search_label = GETPOST('search_label', 'alpha');
51 $search_number = GETPOST('search_number', 'alpha');
52 $search_status = GETPOST('search_status') ?GETPOST('search_status', 'alpha') : 'opened'; // 'all' or ''='opened'
53 $optioncss = GETPOST('optioncss', 'alpha');
54 
55 if (!empty($conf->categorie->enabled))
56 {
57  $search_category_list = GETPOST("search_category_".Categorie::TYPE_ACCOUNT."_list", "array");
58 }
59 
60 // Security check
61 if ($user->socid) $socid = $user->socid;
62 if (!empty($user->rights->accounting->chartofaccount)) $allowed = 1; // Dictionary with list of banks accounting account allowed to manager of chart account
63 if (!$allowed) $result = restrictedArea($user, 'banque');
64 
65 $diroutputmassaction = $conf->bank->dir_output.'/temp/massgeneration/'.$user->id;
66 
67 $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
68 $sortfield = GETPOST("sortfield", 'alpha');
69 $sortorder = GETPOST("sortorder", 'alpha');
70 $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
71 if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
72 $offset = $limit * $page;
73 $pageprev = $page - 1;
74 $pagenext = $page + 1;
75 if (!$sortfield) $sortfield = 'b.label';
76 if (!$sortorder) $sortorder = 'ASC';
77 
78 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
79 $object = new Account($db);
80 $hookmanager->initHooks(array('bankaccountlist'));
81 $extrafields = new ExtraFields($db);
82 
83 // fetch optionals attributes and labels
84 $extrafields->fetch_name_optionals_label($object->table_element);
85 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
86 
87 // List of fields to search into when doing a "search in all"
88 $fieldstosearchall = array(
89  'b.ref'=>'Ref',
90  'b.label'=>'Label',
91 );
92 
93 $checkedtypetiers = 0;
94 $arrayfields = array(
95  'b.ref'=>array('label'=>$langs->trans("BankAccounts"), 'checked'=>1, 'position'=>10),
96  'b.label'=>array('label'=>$langs->trans("Label"), 'checked'=>1, 'position'=>12),
97  'accountype'=>array('label'=>$langs->trans("Type"), 'checked'=>1, 'position'=>14),
98  'b.number'=>array('label'=>$langs->trans("AccountIdShort"), 'checked'=>1, 'position'=>16),
99  'b.account_number'=>array('label'=>$langs->trans("AccountAccounting"), 'checked'=>(!empty($conf->accounting->enabled) || !empty($conf->accounting->enabled)), 'position'=>18),
100  'b.fk_accountancy_journal'=>array('label'=>$langs->trans("AccountancyJournal"), 'checked'=>(!empty($conf->accounting->enabled) || !empty($conf->accounting->enabled)), 'position'=>20),
101  'toreconcile'=>array('label'=>$langs->trans("TransactionsToConciliate"), 'checked'=>1, 'position'=>50),
102  'b.currency_code'=>array('label'=>$langs->trans("Currency"), 'checked'=>0, 'position'=>22),
103  'b.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500),
104  'b.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500),
105  'b.clos'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000),
106  'balance'=>array('label'=>$langs->trans("Balance"), 'checked'=>1, 'position'=>1010),
107 );
108 // Extra fields
109 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
110 
111 $object->fields = dol_sort_array($object->fields, 'position');
112 $arrayfields = dol_sort_array($arrayfields, 'position');
113 
114 
115 /*
116  * Actions
117  */
118 
119 if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; }
120 if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; }
121 
122 $parameters = array('socid'=>$socid);
123 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
124 if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
125 
126 include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
127 
128 // Purge search criteria
129 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
130 {
131  $search_ref = '';
132  $search_label = '';
133  $search_number = '';
134  $search_status = '';
135 }
136 
137 
138 /*
139  * View
140  */
141 
142 $form = new FormCategory($db);
143 
144 $title = $langs->trans('BankAccounts');
145 
146 // Load array of financial accounts (opened by default)
147 $accounts = array();
148 
149 $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";
150 // Add fields from extrafields
151 if (!empty($extrafields->attributes[$object->table_element]['label'])) {
152  foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : '');
153 }
154 // Add fields from hooks
155 $parameters = array();
156 $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook
157 $sql .= $hookmanager->resPrint;
158 $sql .= " FROM ".MAIN_DB_PREFIX."bank_account as b";
159 if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (b.rowid = ef.fk_object)";
160 
161 if (!empty($conf->categorie->enabled))
162 {
163  $sql .= Categorie::getFilterJoinQuery(Categorie::TYPE_ACCOUNT, "b.rowid");
164 }
165 
166 $sql .= " WHERE b.entity IN (".getEntity('bank_account').")";
167 if ($search_status == 'opened') $sql .= " AND clos = 0";
168 if ($search_status == 'closed') $sql .= " AND clos = 1";
169 
170 if (!empty($conf->categorie->enabled))
171 {
172  $sql .= Categorie::getFilterSelectQuery(Categorie::TYPE_ACCOUNT, "b.rowid", $search_category_list);
173 }
174 
175 if ($search_ref != '') $sql .= natural_search('b.ref', $search_ref);
176 if ($search_label != '') $sql .= natural_search('b.label', $search_label);
177 if ($search_number != '') $sql .= natural_search('b.number', $search_number);
178 // Add where from extra fields
179 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
180 // Add where from hooks
181 $parameters = array();
182 $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook
183 $sql .= $hookmanager->resPrint;
184 
185 $sql .= $db->order($sortfield, $sortorder);
186 
187 // Count total nb of records
188 $nbtotalofrecords = '';
189 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
190 {
191  $result = $db->query($sql);
192  $nbtotalofrecords = $db->num_rows($result);
193 }
194 
195 $sql .= $db->plimit($limit + 1, $offset);
196 
197 $resql = $db->query($sql);
198 if ($resql)
199 {
200  $num = $db->num_rows($resql);
201  $i = 0;
202  while ($i < $num)
203  {
204  $objp = $db->fetch_object($resql);
205  $accounts[$objp->rowid] = $objp->courant;
206  $i++;
207  }
208  $db->free($resql);
209 } else dol_print_error($db);
210 
211 
212 
213 $help_url = 'EN:Module_Banks_and_Cash|FR:Module_Banques_et_Caisses|ES:M&oacute;dulo_Bancos_y_Cajas';
214 
215 llxHeader('', $title, $help_url);
216 
217 
218 $arrayofselected = is_array($toselect) ? $toselect : array();
219 
220 $param = '';
221 if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
222 if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
223 if ($search_ref != '') $param .= '&search_ref='.urlencode($search_ref);
224 if ($search_label != '') $param .= '&search_label='.urlencode($search_label);
225 if ($search_number != '') $param .= '&search_number='.urlencode($search_number);
226 if ($search_status != '') $param .= '&search_status='.urlencode($search_status);
227 if ($show_files) $param .= '&show_files='.urlencode($show_files);
228 if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss);
229 // Add $param from extra fields
230 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
231 
232 // List of mass actions available
233 $arrayofmassactions = array(
234 // 'presend'=>$langs->trans("SendByMail"),
235 // 'builddoc'=>$langs->trans("PDFMerge"),
236 );
237 if ($user->rights->banque->supprimer) $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
238 if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array();
239 $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
240 
241 $newcardbutton = dolGetButtonTitle($langs->trans('NewFinancialAccount'), '', 'fa fa-plus-circle', 'card.php?action=create', '', $user->rights->banque->configurer);
242 
243 // Lines of title fields
244 print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
245 if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
246 print '<input type="hidden" name="token" value="'.newToken().'">';
247 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
248 print '<input type="hidden" name="action" value="list">';
249 print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
250 print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
251 print '<input type="hidden" name="page" value="'.$page.'">';
252 print '<input type="hidden" name="search_status" value="'.$search_status.'">';
253 
254 print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'bank_account', 0, $newcardbutton, '', $limit, 1);
255 
256 $topicmail = "Information";
257 //$modelmail="subscription";
258 $objecttmp = new Account($db);
259 $trackid = 'bank'.$object->id;
260 include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
261 
262 if ($sall)
263 {
264  foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val);
265  print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'</div>';
266 }
267 
268 $moreforfilter = '';
269 
270 if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire)
271 {
272  $moreforfilter .= $form->getFilterBox(Categorie::TYPE_ACCOUNT, $search_category_list);
273 }
274 
275 // Bank accounts
276 $parameters = array();
277 $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook
278 if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint;
279 else $moreforfilter = $hookmanager->resPrint;
280 
281 if (!empty($moreforfilter))
282 {
283  print '<div class="liste_titre liste_titre_bydiv centpercent">';
284  print $moreforfilter;
285  print '</div>';
286 }
287 
288 $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
289 $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
290 
291 print '<div class="div-table-responsive">';
292 print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
293 
294 print '<tr class="liste_titre_filter">';
295 
296 // Ref
297 if (!empty($arrayfields['b.ref']['checked']))
298 {
299  print '<td class="liste_titre">';
300  print '<input class="flat" size="6" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
301  print '</td>';
302 }
303 // Label
304 if (!empty($arrayfields['b.label']['checked']))
305 {
306  print '<td class="liste_titre">';
307  print '<input class="flat" size="6" type="text" name="search_label" value="'.dol_escape_htmltag($search_label).'">';
308  print '</td>';
309 }
310 // Account type
311 if (!empty($arrayfields['accountype']['checked']))
312 {
313  print '<td class="liste_titre">';
314  print '</td>';
315 }
316 // Bank number
317 if (!empty($arrayfields['b.number']['checked']))
318 {
319  print '<td class="liste_titre">';
320  print '<input class="flat" size="6" type="text" name="search_number" value="'.dol_escape_htmltag($search_number).'">';
321  print '</td>';
322 }
323 // Account number
324 if (!empty($arrayfields['b.account_number']['checked']))
325 {
326  print '<td class="liste_titre">';
327  print '</td>';
328 }
329 // Accountancy journal
330 if (!empty($arrayfields['b.fk_accountancy_journal']['checked']))
331 {
332  print '<td class="liste_titre">';
333  print '</td>';
334 }
335 // Transactions to reconcile
336 if (!empty($arrayfields['toreconcile']['checked']))
337 {
338  print '<td class="liste_titre">';
339  print '</td>';
340 }
341 // Currency
342 if (!empty($arrayfields['b.currency_code']['checked']))
343 {
344  print '<td class="liste_titre">';
345  print '</td>';
346 }
347 // Extra fields
348 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
349 
350 // Fields from hook
351 $parameters = array('arrayfields'=>$arrayfields);
352 $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
353 print $hookmanager->resPrint;
354 // Date creation
355 if (!empty($arrayfields['b.datec']['checked']))
356 {
357  print '<td class="liste_titre">';
358  print '</td>';
359 }
360 // Date modification
361 if (!empty($arrayfields['b.tms']['checked']))
362 {
363  print '<td class="liste_titre">';
364  print '</td>';
365 }
366 // Status
367 if (!empty($arrayfields['b.clos']['checked']))
368 {
369  print '<td class="liste_titre center">';
370  $array = array(
371  'opened'=>$langs->trans("Opened"),
372  'closed'=>$langs->trans("Closed")
373  );
374  print $form->selectarray("search_status", $array, $search_status, 1, 0, 0, '', 0, 0, 0, '', '', 1);
375  print '</td>';
376 }
377 // Balance
378 if (!empty($arrayfields['balance']['checked']))
379 {
380  print '<td class="liste_titre"></td>';
381 }
382 // Action column
383 print '<td class="liste_titre valignmiddle">';
384 $searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0, 'checkforselect', 1);
385 print $searchpicto;
386 print '</td>';
387 print '</tr>';
388 
389 // Fields title
390 print '<tr class="liste_titre">';
391 if (!empty($arrayfields['b.ref']['checked'])) print_liste_field_titre($arrayfields['b.ref']['label'], $_SERVER["PHP_SELF"], 'b.ref', '', $param, '', $sortfield, $sortorder);
392 if (!empty($arrayfields['b.label']['checked'])) print_liste_field_titre($arrayfields['b.label']['label'], $_SERVER["PHP_SELF"], 'b.label', '', $param, '', $sortfield, $sortorder);
393 if (!empty($arrayfields['accountype']['checked'])) print_liste_field_titre($arrayfields['accountype']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder);
394 if (!empty($arrayfields['b.number']['checked'])) print_liste_field_titre($arrayfields['b.number']['label'], $_SERVER["PHP_SELF"], 'b.number', '', $param, '', $sortfield, $sortorder);
395 if (!empty($arrayfields['b.account_number']['checked'])) print_liste_field_titre($arrayfields['b.account_number']['label'], $_SERVER["PHP_SELF"], 'b.account_number', '', $param, '', $sortfield, $sortorder);
396 if (!empty($arrayfields['b.fk_accountancy_journal']['checked'])) print_liste_field_titre($arrayfields['b.fk_accountancy_journal']['label'], $_SERVER["PHP_SELF"], 'b.fk_accountancy_journal', '', $param, '', $sortfield, $sortorder);
397 if (!empty($arrayfields['b.currency_code']['checked'])) print_liste_field_titre($arrayfields['b.currency_code']['label'], $_SERVER["PHP_SELF"], 'b.currency_code', '', $param, '', $sortfield, $sortorder, 'center ');
398 if (!empty($arrayfields['toreconcile']['checked'])) print_liste_field_titre($arrayfields['toreconcile']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center ');
399 // Extra fields
400 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
401 // Hook fields
402 $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
403 $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
404 print $hookmanager->resPrint;
405 if (!empty($arrayfields['b.datec']['checked'])) print_liste_field_titre($arrayfields['b.datec']['label'], $_SERVER["PHP_SELF"], "b.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
406 if (!empty($arrayfields['b.tms']['checked'])) print_liste_field_titre($arrayfields['b.tms']['label'], $_SERVER["PHP_SELF"], "b.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
407 if (!empty($arrayfields['b.clos']['checked'])) print_liste_field_titre($arrayfields['b.clos']['label'], $_SERVER["PHP_SELF"], 'b.clos', '', $param, '', $sortfield, $sortorder, 'center ');
408 if (!empty($arrayfields['balance']['checked'])) print_liste_field_titre($arrayfields['balance']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right ');
409 print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
410 print "</tr>\n";
411 
412 
413 $totalarray = array(); $found = 0; $i = 0; $lastcurrencycode = '';
414 
415 foreach ($accounts as $key=>$type)
416 {
417  if ($i >= $limit) break;
418 
419  $found++;
420 
421  $result = $objecttmp->fetch($key);
422 
423  $solde = $objecttmp->solde(1);
424 
425  if (!empty($lastcurrencycode) && $lastcurrencycode != $objecttmp->currency_code)
426  {
427  $lastcurrencycode = 'various'; // We found several different currencies
428  }
429  if ($lastcurrencycode != 'various')
430  {
431  $lastcurrencycode = $objecttmp->currency_code;
432  }
433 
434  print '<tr class="oddeven">';
435 
436  // Ref
437  if (!empty($arrayfields['b.ref']['checked']))
438  {
439  print '<td class="nowrap">'.$objecttmp->getNomUrl(1).'</td>';
440  if (!$i) $totalarray['nbfield']++;
441  }
442 
443  // Label
444  if (!empty($arrayfields['b.label']['checked']))
445  {
446  print '<td>'.$objecttmp->label.'</td>';
447  if (!$i) $totalarray['nbfield']++;
448  }
449 
450  // Account type
451  if (!empty($arrayfields['accountype']['checked']))
452  {
453  print '<td>';
454  print $objecttmp->type_lib[$objecttmp->type];
455  print '</td>';
456  if (!$i) $totalarray['nbfield']++;
457  }
458 
459  // Number
460  if (!empty($arrayfields['b.number']['checked']))
461  {
462  print '<td>'.$objecttmp->number.'</td>';
463  if (!$i) $totalarray['nbfield']++;
464  }
465 
466  // Account number
467  if (!empty($arrayfields['b.account_number']['checked']))
468  {
469  print '<td>';
470  if (!empty($conf->accounting->enabled) && !empty($objecttmp->account_number))
471  {
472  $accountingaccount = new AccountingAccount($db);
473  $accountingaccount->fetch('', $objecttmp->account_number, 1);
474  print $accountingaccount->getNomUrl(0, 1, 1, '', 1);
475  } else {
476  print $objecttmp->account_number;
477  }
478  print '</td>';
479  if (!$i) $totalarray['nbfield']++;
480  }
481 
482  // Accountancy journal
483  if (!empty($arrayfields['b.fk_accountancy_journal']['checked']))
484  {
485  print '<td>';
486  if (!empty($conf->accounting->enabled) && !empty($objecttmp->fk_accountancy_journal))
487  {
488  $accountingjournal = new AccountingJournal($db);
489  $accountingjournal->fetch($objecttmp->fk_accountancy_journal);
490  print $accountingjournal->getNomUrl(0, 1, 1, '', 1);
491  } else {
492  print '';
493  }
494  print '</td>';
495  if (!$i) $totalarray['nbfield']++;
496  }
497 
498  // Currency
499  if (!empty($arrayfields['b.currency_code']['checked']))
500  {
501  print '<td class="center">';
502  print $objecttmp->currency_code;
503  print '</td>';
504  if (!$i) $totalarray['nbfield']++;
505  }
506 
507  // Transactions to reconcile
508  if (!empty($arrayfields['toreconcile']['checked']))
509  {
510  print '<td class="center">';
511 
512  $conciliate = $objecttmp->canBeConciliated();
513  if ($conciliate == -2) print '<span class="opacitymedium">'.$langs->trans("CashAccount").'</span>';
514  elseif ($conciliate == -3) print '<span class="opacitymedium">'.$langs->trans("Closed").'</span>';
515  elseif (empty($objecttmp->rappro)) {
516  print '<span class="opacitymedium">'.$langs->trans("ConciliationDisabled").'</span>';
517  } else {
518  $result = $objecttmp->load_board($user, $objecttmp->id);
519  if ($result < 0) {
520  setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
521  } else {
522  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">';
523  print '<span class="badge badge-info classfortooltip" title="'.dol_htmlentities($langs->trans("TransactionsToConciliate")).'">';
524  print $result->nbtodo;
525  print '</span>';
526  print '</a>';
527  if ($result->nbtodolate) {
528  print '<span title="'.dol_htmlentities($langs->trans("Late")).'" class="classfortooltip badge badge-danger marginleftonlyshort">';
529  print '<i class="fa fa-exclamation-triangle"></i> '.$result->nbtodolate;
530  print '</span>';
531  }
532  }
533  }
534 
535  print '</td>';
536  if (!$i) $totalarray['nbfield']++;
537  }
538 
539  // Extra fields
540  if (is_array($objecttmp->array_options)) {
541  $obj = new stdClass();
542  foreach ($objecttmp->array_options as $k => $v) {
543  $obj->$k = $v;
544  }
545  }
546  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
547  // Fields from hook
548  $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
549  $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $objecttmp); // Note that $action and $objecttmpect may have been modified by hook
550  print $hookmanager->resPrint;
551  // Date creation
552  if (!empty($arrayfields['b.datec']['checked']))
553  {
554  print '<td class="center">';
555  print dol_print_date($objecttmp->date_creation, 'dayhour');
556  print '</td>';
557  if (!$i) $totalarray['nbfield']++;
558  }
559  // Date modification
560  if (!empty($arrayfields['b.tms']['checked']))
561  {
562  print '<td class="center">';
563  print dol_print_date($objecttmp->date_update, 'dayhour');
564  print '</td>';
565  if (!$i) $totalarray['nbfield']++;
566  }
567 
568  // Status
569  if (!empty($arrayfields['b.clos']['checked']))
570  {
571  print '<td class="center">'.$objecttmp->getLibStatut(5).'</td>';
572  if (!$i) $totalarray['nbfield']++;
573  }
574 
575  // Balance
576  if (!empty($arrayfields['balance']['checked']))
577  {
578  print '<td class="nowraponall right">';
579  print '<a href="'.DOL_URL_ROOT.'/compta/bank/bankentries_list.php?id='.$objecttmp->id.'">'.price($solde, 0, $langs, 1, -1, -1, $objecttmp->currency_code).'</a>';
580  print '</td>';
581  if (!$i) $totalarray['nbfield']++;
582  if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'balance';
583  $totalarray['val']['balance'] += $solde;
584  }
585 
586  // Action column
587  print '<td class="nowrap center">';
588  if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
589  {
590  $selected = 0;
591  if (in_array($objecttmp->id, $arrayofselected)) $selected = 1;
592  print '<input id="cb'.$objecttmp->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$objecttmp->id.'"'.($selected ? ' checked="checked"' : '').'>';
593  }
594  print '</td>';
595  if (!$i) $totalarray['nbfield']++;
596 
597  print '</tr>';
598 
599  $total[$objecttmp->currency_code] += $solde;
600 
601  $i++;
602 }
603 
604 // If no record found
605 if (!$found)
606 {
607  $colspan = 1;
608  foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; }
609  print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>';
610 }
611 
612 // Show total line
613 if ($lastcurrencycode != 'various') // If there is several currency, $lastcurrencycode is set to 'various' before
614 {
615  // Show total line
616  include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
617 }
618 
619 print '</table>';
620 print "</div>";
621 
622 print "</form>";
623 
624 // End of page
625 llxFooter();
626 $db->close();
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
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.
static getFilterSelectQuery($type, $rowIdName, $searchList)
Return the addtional SQL SELECT query for filtering a list by a category.
static getFilterJoinQuery($type, $rowIdName)
Return the addtional SQL JOIN query for filtering a list by a category.
Class to manage bank accounts.
price($amount, $form=0, $outlangs= '', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code= '')
Function to format a value into an amount for visual output Function used into PDF and HTML pages...
llxHeader()
Empty header.
Definition: wrapper.php:45
Class to manage standard extra fields.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
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.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname.
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
restrictedArea($user, $features, $objectid=0, $tableandshare= '', $feature2= '', $dbt_keyfield= 'fk_soc', $dbt_select= 'rowid', $isdraft=0)
Check permissions of a user to show a page and an object.
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...
print $_SERVER["PHP_SELF"]
Edit parameters.
Class to manage forms for categories.
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
Draft customers invoices.
Definition: index.php:89
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
Definition: index.php:1232
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
Class to manage accounting accounts.
Class to manage accounting accounts.
llxFooter()
Empty footer.
Definition: wrapper.php:59