dolibarr 25.0.0-alpha
list.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2004-2019 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
5 * Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
6 * Copyright (C) 2018 Ferran Marcet <fmarcet@2byte.es>
7 * Copyright (C) 2020 Tobias Sekan <tobias.sekan@startmail.com>
8 * Copyright (C) 2024-2026 MDW <mdeweerd@users.noreply.github.com>
9 * Copyright (C) 2024 Alexandre Spangaro <alexandre@inovea-conseil.com>
10 * Copyright (C) 2024-2026 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';
42require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcategory.class.php';
43require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php';
44require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php';
45require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php';
46require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
47if (isModEnabled('accounting')) {
48 require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php';
49}
50if (isModEnabled('accounting')) {
51 require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php';
52}
53if (isModEnabled('category')) {
54 require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
55}
56
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:int');
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
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// Add hook to complete $arrayfield
138$parameters = array('arrayfields' => &$arrayfields);
139$reshook = $hookmanager->executeHooks('completeArrayFields', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
140
141$object->fields = dol_sort_array($object->fields, 'position');
142$arrayfields = dol_sort_array($arrayfields, 'position');
143
144$permissiontoadd = $user->hasRight('banque', 'modifier');
145$permissiontodelete = $user->hasRight('banque', 'configurer');
146
147$allowed = 0;
148if ($user->hasRight('accounting', 'chartofaccount')) {
149 $allowed = 1; // Dictionary with list of banks accounting account allowed to manager of chart account
150}
151if (!$allowed) {
152 $result = restrictedArea($user, 'banque');
153}
154
155
156/*
157 * Actions
158 */
159
160if (GETPOST('cancel', 'alpha')) {
161 $action = 'list';
162 $massaction = '';
163}
164if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
165 $massaction = '';
166}
167
168$parameters = array('socid' => $socid);
169$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
170if ($reshook < 0) {
171 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
172}
173
174if (empty($reshook)) {
175 include DOL_DOCUMENT_ROOT . '/core/actions_changeselectedfields.inc.php';
176
177 // Purge search criteria
178 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
179 $search_ref = '';
180 $search_label = '';
181 $search_number = '';
182 $search_status = '';
183 $search_category_list = array();
184 $search_array_options = array();
185 }
186
187 // Mass actions
188 $objectclass = 'Account';
189 $objectlabel = 'FinancialAccount';
190 $uploaddir = $conf->bank->dir_output;
191 include DOL_DOCUMENT_ROOT . '/core/actions_massactions.inc.php';
192}
193
194/*
195 * View
196 */
197
198$form = new FormCategory($db);
199
200$title = $langs->trans('BankAccounts');
201$help_url = 'EN:Module_Banks_and_Cash|FR:Module_Banques_et_Caisses|ES:M&oacute;dulo_Bancos_y_Cajas';
202
203// Load array of financial accounts (opened by default)
204$accounts = array();
205
206
207// Build and execute select
208// --------------------------------------------------------------------
209$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";
210// Add fields from extrafields
211if (!empty($extrafields->attributes[$object->table_element]['label'])) {
212 foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
213 $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : '');
214 }
215}
216// Add fields from hooks
217$parameters = array();
218$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
219$sql .= $hookmanager->resPrint;
220$sql = preg_replace('/,\s*$/', '', $sql);
221
222$sqlfields = $sql; // $sql fields to remove for count total
223
224$sql .= " FROM ".MAIN_DB_PREFIX."bank_account as b";
225if (!empty($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
226 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (b.rowid = ef.fk_object)";
227}
228$sql .= " WHERE b.entity IN (".getEntity('bank_account').")";
229if ($search_status === 'opened') {
230 $sql .= " AND clos = 0";
231}
232if ($search_status === 'closed') {
233 $sql .= " AND clos = 1";
234}
235if ($search_ref != '') {
236 $sql .= natural_search('b.ref', $search_ref);
237}
238if ($search_label != '') {
239 $sql .= natural_search('b.label', $search_label);
240}
241if ($search_number != '') {
242 $sql .= natural_search('b.number', $search_number);
243}
244// Search for tag/category ($searchCategoryBankList is an array of ID)
245$searchCategoryBankList = $search_category_list;
246$searchCategoryBankOperator = 0;
247if (!empty($searchCategoryBankList)) {
248 $searchCategoryBankSqlList = array();
249 $listofcategoryid = '';
250 foreach ($searchCategoryBankList as $searchCategoryBank) {
251 if (intval($searchCategoryBank) == -2) {
252 $searchCategoryBankSqlList[] = "NOT EXISTS (SELECT ck.fk_account FROM ".MAIN_DB_PREFIX."categorie_account as ck WHERE b.rowid = ck.fk_account)";
253 } elseif (intval($searchCategoryBank) > 0) {
254 if ($searchCategoryBankOperator == 0) {
255 $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).")";
256 } else {
257 $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryBank);
258 }
259 }
260 }
261 if ($listofcategoryid) {
262 $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)."))";
263 }
264 if ($searchCategoryBankOperator == 1) {
265 if (!empty($searchCategoryBankSqlList)) {
266 $sql .= " AND (".implode(' OR ', $searchCategoryBankSqlList).")";
267 }
268 } else {
269 if (!empty($searchCategoryBankSqlList)) {
270 $sql .= " AND (".implode(' AND ', $searchCategoryBankSqlList).")";
271 }
272 }
273}
274// Add where from extra fields
275include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
276// Add where from hooks
277$parameters = array();
278$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
279$sql .= $hookmanager->resPrint;
280
281// Count total nb of records
282$nbtotalofrecords = '';
283if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
284 /* The fast and low memory method to get and count full list converts the sql into a sql count */
285 $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql);
286 $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount);
287 $resql = $db->query($sqlforcount);
288 if ($resql) {
289 $objforcount = $db->fetch_object($resql);
290 $nbtotalofrecords = $objforcount->nbtotalofrecords;
291 } else {
292 dol_print_error($db);
293 }
294
295 if (($page * $limit) > (int) $nbtotalofrecords) { // if total resultset is smaller than the paging size (filtering), goto and load page 0
296 $page = 0;
297 $offset = 0;
298 }
299 $db->free($resql);
300}
301
302// Complete request and execute it with limit
303$sql .= $db->order($sortfield, $sortorder);
304if ($limit) {
305 $sql .= $db->plimit($limit + 1, $offset);
306}
307
308$num = 0;
309$resql = $db->query($sql);
310if ($resql) {
311 $num = $db->num_rows($resql);
312 $i = 0;
313 while ($i < $num) {
314 $objp = $db->fetch_object($resql);
315 $accounts[$objp->rowid] = $objp->courant;
316 $i++;
317 }
318 $db->free($resql);
319} else {
320 dol_print_error($db);
321}
322
323
324
325llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'bodyforlist');
326
327
328$arrayofselected = is_array($toselect) ? $toselect : array();
329
330$param = '';
331if (!empty($mode)) {
332 $param .= '&mode='.urlencode($mode);
333}
334if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
335 $param .= '&contextpage='.urlencode($contextpage);
336}
337if ($limit > 0 && $limit != $conf->liste_limit) {
338 $param .= '&limit='.((int) $limit);
339}
340if ($optioncss != '') {
341 $param .= '&optioncss='.urlencode($optioncss);
342}
343if ($search_ref != '') {
344 $param .= '&search_ref='.urlencode($search_ref);
345}
346if ($search_label != '') {
347 $param .= '&search_label='.urlencode($search_label);
348}
349if ($search_number != '') {
350 $param .= '&search_number='.urlencode($search_number);
351}
352if ($search_status != '' && $search_status != '-1') {
353 $param .= '&search_status='.urlencode($search_status);
354}
355if ($show_files) {
356 $param .= '&show_files='.urlencode((string) ($show_files));
357}
358// Add $param from extra fields
359include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
360// Add $param from hooks
361$parameters = array('param' => &$param);
362$reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
363$param .= $hookmanager->resPrint;
364
365// List of mass actions available
366$arrayofmassactions = array(
367// 'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
368// 'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
369);
370if (!empty($permissiontodelete)) {
371 $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
372}
373if (isModEnabled('category') && $user->hasRight('banque', 'modifier')) {
374 $arrayofmassactions['preaffecttag'] = img_picto('', 'category', 'class="pictofixedwidth"').$langs->trans("AffectTag");
375}
376if (in_array($massaction, array('presend', 'predelete','preaffecttag'))) {
377 $arrayofmassactions = array();
378}
379$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
380
381print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n";
382if ($optioncss != '') {
383 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
384}
385print '<input type="hidden" name="token" value="'.newToken().'">';
386print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
387print '<input type="hidden" name="action" value="list">';
388print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
389print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
390print '<input type="hidden" name="page" value="'.$page.'">';
391print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
392print '<input type="hidden" name="page_y" value="">';
393print '<input type="hidden" name="search_status" value="'.$search_status.'">';
394print '<input type="hidden" name="mode" value="'.$mode.'">';
395
396
397$newcardbutton = '';
398$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'));
399$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'));
400$newcardbutton .= dolGetButtonTitleSeparator();
401$newcardbutton .= dolGetButtonTitle($langs->trans('NewFinancialAccount'), '', 'fa fa-plus-circle', 'card.php?action=create', '', $user->hasRight('banque', 'configurer'));
402
403print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'bank_account', 0, $newcardbutton, '', $limit, 1);
404
405$topicmail = "Information";
406//$modelmail="subscription";
407$objecttmp = new Account($db);
408$trackid = 'bank'.$object->id;
409include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
410
411//if ($sall) {
412// foreach ($fieldstosearchall as $key => $val) {
413// $fieldstosearchall[$key] = $langs->trans($val);
414// }
415// print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'</div>';
416//}
417
418$moreforfilter = '';
419
420if (isModEnabled('category') && $user->hasRight('categorie', 'lire')) {
421 $moreforfilter .= $form->getFilterBox(Categorie::TYPE_ACCOUNT, $search_category_list);
422}
423
424// Bank accounts
425$parameters = array();
426$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
427if (empty($reshook)) {
428 $moreforfilter .= $hookmanager->resPrint;
429} else {
430 $moreforfilter = $hookmanager->resPrint;
431}
432
433if (!empty($moreforfilter)) {
434 print '<div class="liste_titre liste_titre_bydiv centpercent">';
435 print $moreforfilter;
436 print '</div>';
437}
438
439$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
440$htmlofselectarray = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, $conf->main_checkbox_left_column); // This also change content of $arrayfields with user setup
441$selectedfields = ($mode != 'kanban' ? $htmlofselectarray : '');
442$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
443
444print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you don't need reserved height for your table
445print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
446
447// Fields title search
448// --------------------------------------------------------------------
449print '<tr class="liste_titre_filter">';
450// Action column
451if ($conf->main_checkbox_left_column) {
452 print '<td class="liste_titre center maxwidthsearch">';
453 $searchpicto = $form->showFilterButtons('left');
454 print $searchpicto;
455 print '</td>';
456}
457// Ref
458if (!empty($arrayfields['b.ref']['checked'])) {
459 print '<td class="liste_titre">';
460 print '<input class="flat" size="6" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
461 print '</td>';
462}
463// Label
464if (!empty($arrayfields['b.label']['checked'])) {
465 print '<td class="liste_titre">';
466 print '<input class="flat" size="6" type="text" name="search_label" value="'.dol_escape_htmltag($search_label).'">';
467 print '</td>';
468}
469// Account type
470if (!empty($arrayfields['accountype']['checked'])) {
471 print '<td class="liste_titre">';
472 print '</td>';
473}
474// Bank number
475if (!empty($arrayfields['b.number']['checked'])) {
476 print '<td class="liste_titre">';
477 print '<input class="flat" size="6" type="text" name="search_number" value="'.dol_escape_htmltag($search_number).'">';
478 print '</td>';
479}
480// Account number
481if (!empty($arrayfields['b.account_number']['checked'])) {
482 print '<td class="liste_titre">';
483 print '</td>';
484}
485// Accountancy journal
486if (!empty($arrayfields['b.fk_accountancy_journal']['checked'])) {
487 print '<td class="liste_titre">';
488 print '</td>';
489}
490// Transactions to reconcile
491if (!empty($arrayfields['toreconcile']['checked'])) {
492 print '<td class="liste_titre">';
493 print '</td>';
494}
495// Currency
496if (!empty($arrayfields['b.currency_code']['checked'])) {
497 print '<td class="liste_titre">';
498 print '</td>';
499}
500// Extra fields
501include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
502
503// Fields from hook
504$parameters = array('arrayfields' => $arrayfields);
505$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
506print $hookmanager->resPrint;
507// Date creation
508if (!empty($arrayfields['b.datec']['checked'])) {
509 print '<td class="liste_titre">';
510 print '</td>';
511}
512// Date modification
513if (!empty($arrayfields['b.tms']['checked'])) {
514 print '<td class="liste_titre">';
515 print '</td>';
516}
517// Status
518if (!empty($arrayfields['b.clos']['checked'])) {
519 print '<td class="liste_titre center parentonrightofpage">';
520 $array = array(
521 'opened' => $langs->trans("Opened"),
522 'closed' => $langs->trans("Closed")
523 );
524 print $form->selectarray("search_status", $array, $search_status, 1, 0, 0, '', 0, 0, 0, '', 'search_status minwidth75 maxwidth125 onrightofpage', 1);
525 print '</td>';
526}
527// Balance
528if (!empty($arrayfields['balance']['checked'])) {
529 print '<td class="liste_titre"></td>';
530}
531// Action column
532if (!$conf->main_checkbox_left_column) {
533 print '<td class="liste_titre center maxwidthsearch">';
534 $searchpicto = $form->showFilterButtons();
535 print $searchpicto;
536 print '</td>';
537}
538print '</tr>'."\n";
539
540$totalarray = array();
541$totalarray['nbfield'] = 0;
542
543// Fields title label
544// --------------------------------------------------------------------
545print '<tr class="liste_titre">';
546// Action column
547if ($conf->main_checkbox_left_column) {
548 print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
549 $totalarray['nbfield']++;
550}
551if (!empty($arrayfields['b.ref']['checked'])) {
552 // False positive @phan-suppress-next-line PhanTypeInvalidDimOffset
553 print_liste_field_titre($arrayfields['b.ref']['label'], $_SERVER["PHP_SELF"], 'b.ref', '', $param, '', $sortfield, $sortorder);
554 $totalarray['nbfield']++;
555}
556if (!empty($arrayfields['b.label']['checked'])) {
557 print_liste_field_titre($arrayfields['b.label']['label'], $_SERVER["PHP_SELF"], 'b.label', '', $param, '', $sortfield, $sortorder);
558 $totalarray['nbfield']++;
559}
560if (!empty($arrayfields['accountype']['checked'])) {
561 print_liste_field_titre($arrayfields['accountype']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder);
562 $totalarray['nbfield']++;
563}
564if (!empty($arrayfields['b.number']['checked'])) {
565 print_liste_field_titre($arrayfields['b.number']['label'], $_SERVER["PHP_SELF"], 'b.number', '', $param, '', $sortfield, $sortorder);
566 $totalarray['nbfield']++;
567}
568if (!empty($arrayfields['b.account_number']['checked'])) {
569 print_liste_field_titre($arrayfields['b.account_number']['label'], $_SERVER["PHP_SELF"], 'b.account_number', '', $param, '', $sortfield, $sortorder);
570 $totalarray['nbfield']++;
571}
572if (!empty($arrayfields['b.fk_accountancy_journal']['checked'])) {
573 print_liste_field_titre($arrayfields['b.fk_accountancy_journal']['label'], $_SERVER["PHP_SELF"], 'b.fk_accountancy_journal', '', $param, '', $sortfield, $sortorder);
574 $totalarray['nbfield']++;
575}
576if (!empty($arrayfields['b.currency_code']['checked'])) {
577 print_liste_field_titre($arrayfields['b.currency_code']['label'], $_SERVER["PHP_SELF"], 'b.currency_code', '', $param, '', $sortfield, $sortorder, 'center ');
578 $totalarray['nbfield']++;
579}
580if (!empty($arrayfields['toreconcile']['checked'])) {
581 print_liste_field_titre($arrayfields['toreconcile']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center ');
582 $totalarray['nbfield']++;
583}
584// Extra fields
585include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
586// Hook fields
587$parameters = array('arrayfields' => $arrayfields, 'param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder);
588$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
589print $hookmanager->resPrint;
590if (!empty($arrayfields['b.datec']['checked'])) {
591 print_liste_field_titre($arrayfields['b.datec']['label'], $_SERVER["PHP_SELF"], "b.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
592 $totalarray['nbfield']++;
593}
594if (!empty($arrayfields['b.tms']['checked'])) {
595 print_liste_field_titre($arrayfields['b.tms']['label'], $_SERVER["PHP_SELF"], "b.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
596 $totalarray['nbfield']++;
597}
598if (!empty($arrayfields['b.clos']['checked'])) {
599 print_liste_field_titre($arrayfields['b.clos']['label'], $_SERVER["PHP_SELF"], 'b.clos', '', $param, '', $sortfield, $sortorder, 'center ');
600 $totalarray['nbfield']++;
601}
602if (!empty($arrayfields['balance']['checked'])) {
603 print_liste_field_titre($arrayfields['balance']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right ');
604 $totalarray['nbfield']++;
605}
606// Action column
607if (!$conf->main_checkbox_left_column) {
608 print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
609 $totalarray['nbfield']++;
610}
611print '</tr>'."\n";
612
613
614// Loop on record
615// --------------------------------------------------------------------
616$i = 0;
617$savnbfield = $totalarray['nbfield'];
618$totalarray = array();
619$totalarray['nbfield'] = 0;
620$totalarray['val'] = array('balance' => 0);
621$found = 0;
622$lastcurrencycode = '';
623$imaxinloop = ($limit ? min($num, $limit) : $num);
624
625foreach ($accounts as $key => $type) {
626 if ($i >= $limit) {
627 break;
628 }
629
630 $found++;
631
632 $result = $objecttmp->fetch($key);
633
634 $solde = $objecttmp->solde(1);
635
636 if (!empty($lastcurrencycode) && $lastcurrencycode != $objecttmp->currency_code) {
637 $lastcurrencycode = 'various'; // We found several different currencies
638 }
639 if ($lastcurrencycode != 'various') {
640 $lastcurrencycode = $objecttmp->currency_code;
641 }
642
643 if ($mode == 'kanban') {
644 if ($i == 0) {
645 print '<tr class="trkanban"><td colspan="'.$savnbfield.'">';
646 print '<div class="box-flex-container kanban">';
647 }
648 // Output Kanban
649 $selected = -1;
650 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
651 $selected = 0;
652 if (in_array($object->id, $arrayofselected)) {
653 $selected = 1;
654 }
655 }
656 //print $object->getKanbanView('', array('thirdparty'=>$object->thirdparty, 'selected' => $selected));
657 print $objecttmp->getKanbanView('', array('selected' => $selected));
658 if ($i == ($imaxinloop - 1)) {
659 print '</div>';
660 print '</td></tr>';
661 }
662 } else {
663 // Show line of result
664 $j = 0;
665 print '<tr data-rowid="'.$objecttmp->id.'" class="oddeven row-with-select">';
666
667 // Action column
668 if ($conf->main_checkbox_left_column) {
669 print '<td class="nowrap center">';
670 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
671 $selected = 0;
672 if (in_array($objecttmp->id, $arrayofselected)) {
673 $selected = 1;
674 }
675 print '<input id="cb'.$objecttmp->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$objecttmp->id.'"'.($selected ? ' checked="checked"' : '').'>';
676 }
677 print '</td>';
678 if (!$i) {
679 $totalarray['nbfield']++;
680 }
681 }
682 // Ref
683 if (!empty($arrayfields['b.ref']['checked'])) {
684 print '<td class="nowraponall">'.$objecttmp->getNomUrl(1).'</td>';
685 if (!$i) {
686 $totalarray['nbfield']++;
687 }
688 }
689
690 // Label
691 if (!empty($arrayfields['b.label']['checked'])) {
692 print '<td class="tdoverflowmax200" title="'.dolPrintHTMLForAttribute($objecttmp->label).'">';
693 print '<span class="spantitle">';
694 print dolPrintHTML($objecttmp->label);
695 print '</span>';
696 print '</td>';
697 if (!$i) {
698 $totalarray['nbfield']++;
699 }
700 }
701
702 // Account type
703 if (!empty($arrayfields['accountype']['checked'])) {
704 print '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($objecttmp->type_lib[$objecttmp->type]).'">';
705 print $objecttmp->type_lib[$objecttmp->type];
706 print '</td>';
707 if (!$i) {
708 $totalarray['nbfield']++;
709 }
710 }
711
712 // Number
713 if (!empty($arrayfields['b.number']['checked'])) {
714 print '<td>'.dol_escape_htmltag($objecttmp->number).'</td>';
715 if (!$i) {
716 $totalarray['nbfield']++;
717 }
718 }
719
720 // Account number
721 if (!empty($arrayfields['b.account_number']['checked'])) {
722 print '<td class="tdoverflowmax250">';
723 if (isModEnabled('accounting')) {
724 if (empty($objecttmp->account_number)) {
725 print img_warning($langs->trans("Mandatory"));
726 } else {
727 $accountingaccount = new AccountingAccount($db);
728 $accountingaccount->fetch(0, $objecttmp->account_number, 1);
729 print '<span title="'.dol_escape_htmltag($accountingaccount->account_number.' - '.$accountingaccount->label).'">';
730 print $accountingaccount->getNomUrl(0, 1, 1, '', 0);
731 print '</span>';
732 }
733 } else {
734 print '<span title="'.dol_escape_htmltag($objecttmp->account_number).'">'.$objecttmp->account_number.'</span>';
735 }
736 print '</td>';
737 if (!$i) {
738 $totalarray['nbfield']++;
739 }
740 }
741
742 // Accountancy journal
743 if (!empty($arrayfields['b.fk_accountancy_journal']['checked'])) {
744 if (isModEnabled('accounting')) {
745 if (empty($objecttmp->fk_accountancy_journal)) {
746 $s = img_warning($langs->trans("Mandatory"));
747 } else {
748 $accountingjournal = new AccountingJournal($db);
749 $accountingjournal->fetch($objecttmp->fk_accountancy_journal);
750 $s = $accountingjournal->getNomUrl(0, 1, 1, '', 1);
751 }
752 } else {
753 $s = '';
754 }
755 print '<td class="tdoverflowmax125" title="'.dolPrintHTMLForAttribute(dol_string_nohtmltag($s)).'">';
756 print $s;
757 print '</td>';
758 if (!$i) {
759 $totalarray['nbfield']++;
760 }
761 }
762
763 // Currency
764 if (!empty($arrayfields['b.currency_code']['checked'])) {
765 print '<td class="center nowraponall">';
766 print $objecttmp->currency_code;
767 print '</td>';
768 if (!$i) {
769 $totalarray['nbfield']++;
770 }
771 }
772
773 // Transactions to reconcile
774 if (!empty($arrayfields['toreconcile']['checked'])) {
775 $conciliate = $objecttmp->canBeConciliated();
776
777 $labeltoshow = '';
778 if ($conciliate == -2) {
779 $labeltoshow = $langs->trans("CashAccount");
780 } elseif ($conciliate == -3) {
781 $labeltoshow = $langs->trans("Closed");
782 } elseif (empty($objecttmp->rappro)) {
783 $labeltoshow = $langs->trans("ConciliationDisabled");
784 }
785
786 print '<td class="center tdoverflowmax125"'.($labeltoshow ? ' title="'.dolPrintHTML($labeltoshow).'"' : '').'>';
787 if ($conciliate == -2) {
788 print '<span class="opacitymedium" title="'.$langs->trans("CashAccount").'">'.$langs->trans("Never").'</span>';
789 } elseif ($conciliate == -3) {
790 print '<span class="opacitymedium" title="'.$langs->trans("Closed").'">'.$langs->trans("Never").'</span>';
791 } elseif (empty($objecttmp->rappro)) {
792 print '<span class="opacitymedium" title="'.$langs->trans("ConciliationDisabled").'">'.$langs->trans("Never").'</span>';
793 } else {
794 $result = $objecttmp->load_board($user, $objecttmp->id);
795 if (is_numeric($result) && $result < 0) {
796 setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
797 } else {
798 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">';
799 print '<span class="badge badge-info classfortooltip" title="'.dol_htmlentities($langs->trans("TransactionsToConciliate")).'">';
800 print $result->nbtodo;
801 print '</span>';
802 print '</a>';
803 if ($result->nbtodolate) {
804 print '<span title="'.dol_htmlentities($langs->trans("Late")).'" class="classfortooltip badge badge-warning marginleftonlyshort">';
805 print '<i class="fa fa-exclamation-triangle"></i> '.$result->nbtodolate;
806 print '</span>';
807 }
808 }
809 }
810
811 print '</td>';
812 if (!$i) {
813 $totalarray['nbfield']++;
814 }
815 }
816
817 // Extra fields
818 if (is_array($objecttmp->array_options)) {
819 $obj = new stdClass();
820 foreach ($objecttmp->array_options as $k => $v) {
821 $obj->$k = $v;
822 }
823 } else {
824 $obj = null;
825 }
826 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
827 // Fields from hook
828 $parameters = array('arrayfields' => $arrayfields, 'obj' => $obj, 'i' => $i, 'totalarray' => &$totalarray);
829 $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $objecttmp, $action); // Note that $action and $objecttmpect may have been modified by hook
830 print $hookmanager->resPrint;
831 // Date creation
832 if (!empty($arrayfields['b.datec']['checked'])) {
833 print '<td class="center nowraponall">';
834 print dol_print_date($objecttmp->date_creation, 'dayhour');
835 print '</td>';
836 if (!$i) {
837 $totalarray['nbfield']++;
838 }
839 }
840 // Date modification
841 if (!empty($arrayfields['b.tms']['checked'])) {
842 print '<td class="center nowraponall">';
843 print dol_print_date($objecttmp->date_modification, 'dayhour');
844 print '</td>';
845 if (!$i) {
846 $totalarray['nbfield']++;
847 }
848 }
849
850 // Status
851 if (!empty($arrayfields['b.clos']['checked'])) {
852 print '<td class="center">'.$objecttmp->getLibStatut(5).'</td>';
853 if (!$i) {
854 $totalarray['nbfield']++;
855 }
856 }
857
858 // Balance
859 if (!empty($arrayfields['balance']['checked'])) {
860 print '<td class="nowraponall right">';
861 print '<a href="'.DOL_URL_ROOT.'/compta/bank/bankentries_list.php?id='.$objecttmp->id.'">';
862 print '<span class="amount">'.price(price2num($solde, 'MT'), 0, $langs, 1, -1, -1, $objecttmp->currency_code).'</span>';
863 print '</a>';
864 print '</td>';
865 if (!$i) {
866 $totalarray['nbfield']++;
867 }
868 if (!$i) {
869 $totalarray['pos'][$totalarray['nbfield']] = 'balance';
870 $totalarray['pospercurrency'][$totalarray['nbfield']] = 'balance';
871 }
872 $totalarray['val']['balance'] += $solde;
873 // Balances can't be summed across different currencies, so also keep a per-currency
874 // breakdown ($totalarray['valpercurrency']); list_print_total.tpl.php shows it as
875 // additional "Total <CCY>" lines once there is more than one currency in the list.
876 $totalarray['valpercurrency'][$objecttmp->currency_code]['balance'] = ($totalarray['valpercurrency'][$objecttmp->currency_code]['balance'] ?? 0) + $solde;
877 }
878
879 // Action column
880 if (!$conf->main_checkbox_left_column) {
881 print '<td class="nowrap center">';
882 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
883 $selected = 0;
884 if (in_array($objecttmp->id, $arrayofselected)) {
885 $selected = 1;
886 }
887 print '<input id="cb'.$objecttmp->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$objecttmp->id.'"'.($selected ? ' checked="checked"' : '').'>';
888 }
889 print '</td>';
890 if (!$i) {
891 $totalarray['nbfield']++;
892 }
893 }
894
895 print '</tr>'."\n";
896 }
897 $i++;
898}
899
900// If no record found
901if (!$found) {
902 $colspan = 1;
903 foreach ($arrayfields as $key => $val) {
904 if (!empty($val['checked'])) {
905 $colspan++;
906 }
907 }
908 print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
909}
910
911// Show total line
912if ($lastcurrencycode == 'various') {
913 // Summing balances of accounts in different currencies is meaningless, so the main "Total"
914 // line leaves the balance cell empty instead of showing a nonsensical combined figure;
915 // list_print_total.tpl.php still prints one "Total <CCY>" line per currency below it, using
916 // $totalarray['valpercurrency'] (independent of 'pos', so removing it here does not affect
917 // the per-currency lines).
918 $posKey = array_search('balance', $totalarray['pos'] ?? array(), true);
919 if ($posKey !== false) {
920 unset($totalarray['pos'][$posKey]);
921 }
922 unset($totalarray['val']['balance']);
923}
924include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
925
926print '</table>'."\n";
927print '</div>'."\n";
928
929print '</form>'."\n";
930
931// End of page
932llxFooter();
933$db->close();
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
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 forms for categories.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto='UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
natural_search($fields, $value, $mode=0, $nofirstand=0, $sqltoadd='')
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_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...
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
isModEnabled($module)
Is Dolibarr module enabled.
print_liste_field_titre($name, $file="", $field="", $begin="", $param="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
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.
dolGetButtonTitleSeparator($moreClass="")
Add space between dolGetButtonTitle.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $nodie=0, $mode='')
Check permissions of a user to show a page and an object.