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