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