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 }
185
186 // Mass actions
187 $objectclass = 'Account';
188 $objectlabel = 'FinancialAccount';
189 $uploaddir = $conf->bank->dir_output;
190 include DOL_DOCUMENT_ROOT . '/core/actions_massactions.inc.php';
191}
192
193/*
194 * View
195 */
196
197$form = new FormCategory($db);
198
199$title = $langs->trans('BankAccounts');
200$help_url = 'EN:Module_Banks_and_Cash|FR:Module_Banques_et_Caisses|ES:M&oacute;dulo_Bancos_y_Cajas';
201
202// Load array of financial accounts (opened by default)
203$accounts = array();
204
205
206// Build and execute select
207// --------------------------------------------------------------------
208$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";
209// Add fields from extrafields
210if (!empty($extrafields->attributes[$object->table_element]['label'])) {
211 foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
212 $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : '');
213 }
214}
215// Add fields from hooks
216$parameters = array();
217$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
218$sql .= $hookmanager->resPrint;
219$sql = preg_replace('/,\s*$/', '', $sql);
220
221$sqlfields = $sql; // $sql fields to remove for count total
222
223$sql .= " FROM ".MAIN_DB_PREFIX."bank_account as b";
224if (!empty($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
225 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (b.rowid = ef.fk_object)";
226}
227$sql .= " WHERE b.entity IN (".getEntity('bank_account').")";
228if ($search_status === 'opened') {
229 $sql .= " AND clos = 0";
230}
231if ($search_status === 'closed') {
232 $sql .= " AND clos = 1";
233}
234if ($search_ref != '') {
235 $sql .= natural_search('b.ref', $search_ref);
236}
237if ($search_label != '') {
238 $sql .= natural_search('b.label', $search_label);
239}
240if ($search_number != '') {
241 $sql .= natural_search('b.number', $search_number);
242}
243// Search for tag/category ($searchCategoryBankList is an array of ID)
244$searchCategoryBankList = $search_category_list;
245$searchCategoryBankOperator = 0;
246if (!empty($searchCategoryBankList)) {
247 $searchCategoryBankSqlList = array();
248 $listofcategoryid = '';
249 foreach ($searchCategoryBankList as $searchCategoryBank) {
250 if (intval($searchCategoryBank) == -2) {
251 $searchCategoryBankSqlList[] = "NOT EXISTS (SELECT ck.fk_account FROM ".MAIN_DB_PREFIX."categorie_account as ck WHERE b.rowid = ck.fk_account)";
252 } elseif (intval($searchCategoryBank) > 0) {
253 if ($searchCategoryBankOperator == 0) {
254 $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).")";
255 } else {
256 $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryBank);
257 }
258 }
259 }
260 if ($listofcategoryid) {
261 $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)."))";
262 }
263 if ($searchCategoryBankOperator == 1) {
264 if (!empty($searchCategoryBankSqlList)) {
265 $sql .= " AND (".implode(' OR ', $searchCategoryBankSqlList).")";
266 }
267 } else {
268 if (!empty($searchCategoryBankSqlList)) {
269 $sql .= " AND (".implode(' AND ', $searchCategoryBankSqlList).")";
270 }
271 }
272}
273// Add where from extra fields
274include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
275// Add where from hooks
276$parameters = array();
277$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
278$sql .= $hookmanager->resPrint;
279
280// Count total nb of records
281$nbtotalofrecords = '';
282if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
283 /* The fast and low memory method to get and count full list converts the sql into a sql count */
284 $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql);
285 $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount);
286 $resql = $db->query($sqlforcount);
287 if ($resql) {
288 $objforcount = $db->fetch_object($resql);
289 $nbtotalofrecords = $objforcount->nbtotalofrecords;
290 } else {
292 }
293
294 if (($page * $limit) > (int) $nbtotalofrecords) { // if total resultset is smaller than the paging size (filtering), goto and load page 0
295 $page = 0;
296 $offset = 0;
297 }
298 $db->free($resql);
299}
300
301// Complete request and execute it with limit
302$sql .= $db->order($sortfield, $sortorder);
303if ($limit) {
304 $sql .= $db->plimit($limit + 1, $offset);
305}
306
307$num = 0;
308$resql = $db->query($sql);
309if ($resql) {
310 $num = $db->num_rows($resql);
311 $i = 0;
312 while ($i < $num) {
313 $objp = $db->fetch_object($resql);
314 $accounts[$objp->rowid] = $objp->courant;
315 $i++;
316 }
317 $db->free($resql);
318} else {
320}
321
322
323
324llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'bodyforlist');
325
326
327$arrayofselected = is_array($toselect) ? $toselect : array();
328
329$param = '';
330if (!empty($mode)) {
331 $param .= '&mode='.urlencode($mode);
332}
333if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
334 $param .= '&contextpage='.urlencode($contextpage);
335}
336if ($limit > 0 && $limit != $conf->liste_limit) {
337 $param .= '&limit='.((int) $limit);
338}
339if ($optioncss != '') {
340 $param .= '&optioncss='.urlencode($optioncss);
341}
342if ($search_ref != '') {
343 $param .= '&search_ref='.urlencode($search_ref);
344}
345if ($search_label != '') {
346 $param .= '&search_label='.urlencode($search_label);
347}
348if ($search_number != '') {
349 $param .= '&search_number='.urlencode($search_number);
350}
351if ($search_status != '' && $search_status != '-1') {
352 $param .= '&search_status='.urlencode($search_status);
353}
354if ($show_files) {
355 $param .= '&show_files='.urlencode((string) ($show_files));
356}
357// Add $param from extra fields
358include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
359// Add $param from hooks
360$parameters = array('param' => &$param);
361$reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
362$param .= $hookmanager->resPrint;
363
364// List of mass actions available
365$arrayofmassactions = array(
366// 'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
367// 'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
368);
369if (!empty($permissiontodelete)) {
370 $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
371}
372if (isModEnabled('category') && $user->hasRight('banque', 'modifier')) {
373 $arrayofmassactions['preaffecttag'] = img_picto('', 'category', 'class="pictofixedwidth"').$langs->trans("AffectTag");
374}
375if (in_array($massaction, array('presend', 'predelete','preaffecttag'))) {
376 $arrayofmassactions = array();
377}
378$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
379
380print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n";
381if ($optioncss != '') {
382 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
383}
384print '<input type="hidden" name="token" value="'.newToken().'">';
385print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
386print '<input type="hidden" name="action" value="list">';
387print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
388print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
389print '<input type="hidden" name="page" value="'.$page.'">';
390print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
391print '<input type="hidden" name="page_y" value="">';
392print '<input type="hidden" name="search_status" value="'.$search_status.'">';
393print '<input type="hidden" name="mode" value="'.$mode.'">';
394
395
396$newcardbutton = '';
397$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'));
398$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'));
399$newcardbutton .= dolGetButtonTitleSeparator();
400$newcardbutton .= dolGetButtonTitle($langs->trans('NewFinancialAccount'), '', 'fa fa-plus-circle', 'card.php?action=create', '', $user->hasRight('banque', 'configurer'));
401
402print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'bank_account', 0, $newcardbutton, '', $limit, 1);
403
404$topicmail = "Information";
405//$modelmail="subscription";
406$objecttmp = new Account($db);
407$trackid = 'bank'.$object->id;
408include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
409
410//if ($sall) {
411// foreach ($fieldstosearchall as $key => $val) {
412// $fieldstosearchall[$key] = $langs->trans($val);
413// }
414// print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'</div>';
415//}
416
417$moreforfilter = '';
418
419if (isModEnabled('category') && $user->hasRight('categorie', 'lire')) {
420 $moreforfilter .= $form->getFilterBox(Categorie::TYPE_ACCOUNT, $search_category_list);
421}
422
423// Bank accounts
424$parameters = array();
425$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
426if (empty($reshook)) {
427 $moreforfilter .= $hookmanager->resPrint;
428} else {
429 $moreforfilter = $hookmanager->resPrint;
430}
431
432if (!empty($moreforfilter)) {
433 print '<div class="liste_titre liste_titre_bydiv centpercent">';
434 print $moreforfilter;
435 print '</div>';
436}
437
438$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
439$htmlofselectarray = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, $conf->main_checkbox_left_column); // This also change content of $arrayfields with user setup
440$selectedfields = ($mode != 'kanban' ? $htmlofselectarray : '');
441$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
442
443print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you don't need reserved height for your table
444print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
445
446// Fields title search
447// --------------------------------------------------------------------
448print '<tr class="liste_titre_filter">';
449// Action column
450if ($conf->main_checkbox_left_column) {
451 print '<td class="liste_titre center maxwidthsearch">';
452 $searchpicto = $form->showFilterButtons('left');
453 print $searchpicto;
454 print '</td>';
455}
456// Ref
457if (!empty($arrayfields['b.ref']['checked'])) {
458 print '<td class="liste_titre">';
459 print '<input class="flat" size="6" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
460 print '</td>';
461}
462// Label
463if (!empty($arrayfields['b.label']['checked'])) {
464 print '<td class="liste_titre">';
465 print '<input class="flat" size="6" type="text" name="search_label" value="'.dol_escape_htmltag($search_label).'">';
466 print '</td>';
467}
468// Account type
469if (!empty($arrayfields['accountype']['checked'])) {
470 print '<td class="liste_titre">';
471 print '</td>';
472}
473// Bank number
474if (!empty($arrayfields['b.number']['checked'])) {
475 print '<td class="liste_titre">';
476 print '<input class="flat" size="6" type="text" name="search_number" value="'.dol_escape_htmltag($search_number).'">';
477 print '</td>';
478}
479// Account number
480if (!empty($arrayfields['b.account_number']['checked'])) {
481 print '<td class="liste_titre">';
482 print '</td>';
483}
484// Accountancy journal
485if (!empty($arrayfields['b.fk_accountancy_journal']['checked'])) {
486 print '<td class="liste_titre">';
487 print '</td>';
488}
489// Transactions to reconcile
490if (!empty($arrayfields['toreconcile']['checked'])) {
491 print '<td class="liste_titre">';
492 print '</td>';
493}
494// Currency
495if (!empty($arrayfields['b.currency_code']['checked'])) {
496 print '<td class="liste_titre">';
497 print '</td>';
498}
499// Extra fields
500include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
501
502// Fields from hook
503$parameters = array('arrayfields' => $arrayfields);
504$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
505print $hookmanager->resPrint;
506// Date creation
507if (!empty($arrayfields['b.datec']['checked'])) {
508 print '<td class="liste_titre">';
509 print '</td>';
510}
511// Date modification
512if (!empty($arrayfields['b.tms']['checked'])) {
513 print '<td class="liste_titre">';
514 print '</td>';
515}
516// Status
517if (!empty($arrayfields['b.clos']['checked'])) {
518 print '<td class="liste_titre center parentonrightofpage">';
519 $array = array(
520 'opened' => $langs->trans("Opened"),
521 'closed' => $langs->trans("Closed")
522 );
523 print $form->selectarray("search_status", $array, $search_status, 1, 0, 0, '', 0, 0, 0, '', 'search_status minwidth75 maxwidth125 onrightofpage', 1);
524 print '</td>';
525}
526// Balance
527if (!empty($arrayfields['balance']['checked'])) {
528 print '<td class="liste_titre"></td>';
529}
530// Action column
531if (!$conf->main_checkbox_left_column) {
532 print '<td class="liste_titre center maxwidthsearch">';
533 $searchpicto = $form->showFilterButtons();
534 print $searchpicto;
535 print '</td>';
536}
537print '</tr>'."\n";
538
539$totalarray = array();
540$totalarray['nbfield'] = 0;
541
542// Fields title label
543// --------------------------------------------------------------------
544print '<tr class="liste_titre">';
545// Action column
546if ($conf->main_checkbox_left_column) {
547 print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
548 $totalarray['nbfield']++;
549}
550if (!empty($arrayfields['b.ref']['checked'])) {
551 // False positive @phan-suppress-next-line PhanTypeInvalidDimOffset
552 print_liste_field_titre($arrayfields['b.ref']['label'], $_SERVER["PHP_SELF"], 'b.ref', '', $param, '', $sortfield, $sortorder);
553 $totalarray['nbfield']++;
554}
555if (!empty($arrayfields['b.label']['checked'])) {
556 print_liste_field_titre($arrayfields['b.label']['label'], $_SERVER["PHP_SELF"], 'b.label', '', $param, '', $sortfield, $sortorder);
557 $totalarray['nbfield']++;
558}
559if (!empty($arrayfields['accountype']['checked'])) {
560 print_liste_field_titre($arrayfields['accountype']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder);
561 $totalarray['nbfield']++;
562}
563if (!empty($arrayfields['b.number']['checked'])) {
564 print_liste_field_titre($arrayfields['b.number']['label'], $_SERVER["PHP_SELF"], 'b.number', '', $param, '', $sortfield, $sortorder);
565 $totalarray['nbfield']++;
566}
567if (!empty($arrayfields['b.account_number']['checked'])) {
568 print_liste_field_titre($arrayfields['b.account_number']['label'], $_SERVER["PHP_SELF"], 'b.account_number', '', $param, '', $sortfield, $sortorder);
569 $totalarray['nbfield']++;
570}
571if (!empty($arrayfields['b.fk_accountancy_journal']['checked'])) {
572 print_liste_field_titre($arrayfields['b.fk_accountancy_journal']['label'], $_SERVER["PHP_SELF"], 'b.fk_accountancy_journal', '', $param, '', $sortfield, $sortorder);
573 $totalarray['nbfield']++;
574}
575if (!empty($arrayfields['b.currency_code']['checked'])) {
576 print_liste_field_titre($arrayfields['b.currency_code']['label'], $_SERVER["PHP_SELF"], 'b.currency_code', '', $param, '', $sortfield, $sortorder, 'center ');
577 $totalarray['nbfield']++;
578}
579if (!empty($arrayfields['toreconcile']['checked'])) {
580 print_liste_field_titre($arrayfields['toreconcile']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center ');
581 $totalarray['nbfield']++;
582}
583// Extra fields
584include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
585// Hook fields
586$parameters = array('arrayfields' => $arrayfields, 'param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder);
587$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
588print $hookmanager->resPrint;
589if (!empty($arrayfields['b.datec']['checked'])) {
590 print_liste_field_titre($arrayfields['b.datec']['label'], $_SERVER["PHP_SELF"], "b.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
591 $totalarray['nbfield']++;
592}
593if (!empty($arrayfields['b.tms']['checked'])) {
594 print_liste_field_titre($arrayfields['b.tms']['label'], $_SERVER["PHP_SELF"], "b.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
595 $totalarray['nbfield']++;
596}
597if (!empty($arrayfields['b.clos']['checked'])) {
598 print_liste_field_titre($arrayfields['b.clos']['label'], $_SERVER["PHP_SELF"], 'b.clos', '', $param, '', $sortfield, $sortorder, 'center ');
599 $totalarray['nbfield']++;
600}
601if (!empty($arrayfields['balance']['checked'])) {
602 print_liste_field_titre($arrayfields['balance']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right ');
603 $totalarray['nbfield']++;
604}
605// Action column
606if (!$conf->main_checkbox_left_column) {
607 print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
608 $totalarray['nbfield']++;
609}
610print '</tr>'."\n";
611
612
613// Loop on record
614// --------------------------------------------------------------------
615$i = 0;
616$savnbfield = $totalarray['nbfield'];
617$totalarray = array();
618$totalarray['nbfield'] = 0;
619$totalarray['val'] = array('balance' => 0);
620$total = array();
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="'.dol_escape_htmltag($objecttmp->label).'">'.dol_escape_htmltag($objecttmp->label).'</td>';
693 if (!$i) {
694 $totalarray['nbfield']++;
695 }
696 }
697
698 // Account type
699 if (!empty($arrayfields['accountype']['checked'])) {
700 print '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($objecttmp->type_lib[$objecttmp->type]).'">';
701 print $objecttmp->type_lib[$objecttmp->type];
702 print '</td>';
703 if (!$i) {
704 $totalarray['nbfield']++;
705 }
706 }
707
708 // Number
709 if (!empty($arrayfields['b.number']['checked'])) {
710 print '<td>'.dol_escape_htmltag($objecttmp->number).'</td>';
711 if (!$i) {
712 $totalarray['nbfield']++;
713 }
714 }
715
716 // Account number
717 if (!empty($arrayfields['b.account_number']['checked'])) {
718 print '<td class="tdoverflowmax250">';
719 if (isModEnabled('accounting')) {
720 if (empty($objecttmp->account_number)) {
721 print img_warning($langs->trans("Mandatory"));
722 } else {
723 $accountingaccount = new AccountingAccount($db);
724 $accountingaccount->fetch(0, $objecttmp->account_number, 1);
725 print '<span title="'.dol_escape_htmltag($accountingaccount->account_number.' - '.$accountingaccount->label).'">';
726 print $accountingaccount->getNomUrl(0, 1, 1, '', 0);
727 print '</span>';
728 }
729 } else {
730 print '<span title="'.dol_escape_htmltag($objecttmp->account_number).'">'.$objecttmp->account_number.'</span>';
731 }
732 print '</td>';
733 if (!$i) {
734 $totalarray['nbfield']++;
735 }
736 }
737
738 // Accountancy journal
739 if (!empty($arrayfields['b.fk_accountancy_journal']['checked'])) {
740 if (isModEnabled('accounting')) {
741 if (empty($objecttmp->fk_accountancy_journal)) {
742 $s = img_warning($langs->trans("Mandatory"));
743 } else {
744 $accountingjournal = new AccountingJournal($db);
745 $accountingjournal->fetch($objecttmp->fk_accountancy_journal);
746 $s = $accountingjournal->getNomUrl(0, 1, 1, '', 1);
747 }
748 } else {
749 $s = '';
750 }
751 print '<td class="tdoverflowmax125" title="'.dolPrintHTMLForAttribute(dol_string_nohtmltag($s)).'">';
752 print $s;
753 print '</td>';
754 if (!$i) {
755 $totalarray['nbfield']++;
756 }
757 }
758
759 // Currency
760 if (!empty($arrayfields['b.currency_code']['checked'])) {
761 print '<td class="center nowraponall">';
762 print $objecttmp->currency_code;
763 print '</td>';
764 if (!$i) {
765 $totalarray['nbfield']++;
766 }
767 }
768
769 // Transactions to reconcile
770 if (!empty($arrayfields['toreconcile']['checked'])) {
771 $conciliate = $objecttmp->canBeConciliated();
772
773 $labeltoshow = '';
774 if ($conciliate == -2) {
775 $labeltoshow = $langs->trans("CashAccount");
776 } elseif ($conciliate == -3) {
777 $labeltoshow = $langs->trans("Closed");
778 } elseif (empty($objecttmp->rappro)) {
779 $labeltoshow = $langs->trans("ConciliationDisabled");
780 }
781
782 print '<td class="center tdoverflowmax125"'.($labeltoshow ? ' title="'.dolPrintHTML($labeltoshow).'"' : '').'>';
783 if ($conciliate == -2) {
784 print '<span class="opacitymedium" title="'.$langs->trans("CashAccount").'">'.$langs->trans("Never").'</span>';
785 } elseif ($conciliate == -3) {
786 print '<span class="opacitymedium" title="'.$langs->trans("Closed").'">'.$langs->trans("Never").'</span>';
787 } elseif (empty($objecttmp->rappro)) {
788 print '<span class="opacitymedium" title="'.$langs->trans("ConciliationDisabled").'">'.$langs->trans("Never").'</span>';
789 } else {
790 $result = $objecttmp->load_board($user, $objecttmp->id);
791 if (is_numeric($result) && $result < 0) {
792 setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
793 } else {
794 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">';
795 print '<span class="badge badge-info classfortooltip" title="'.dol_htmlentities($langs->trans("TransactionsToConciliate")).'">';
796 print $result->nbtodo;
797 print '</span>';
798 print '</a>';
799 if ($result->nbtodolate) {
800 print '<span title="'.dol_htmlentities($langs->trans("Late")).'" class="classfortooltip badge badge-warning marginleftonlyshort">';
801 print '<i class="fa fa-exclamation-triangle"></i> '.$result->nbtodolate;
802 print '</span>';
803 }
804 }
805 }
806
807 print '</td>';
808 if (!$i) {
809 $totalarray['nbfield']++;
810 }
811 }
812
813 // Extra fields
814 if (is_array($objecttmp->array_options)) {
815 $obj = new stdClass();
816 foreach ($objecttmp->array_options as $k => $v) {
817 $obj->$k = $v;
818 }
819 } else {
820 $obj = null;
821 }
822 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
823 // Fields from hook
824 $parameters = array('arrayfields' => $arrayfields, 'obj' => $obj, 'i' => $i, 'totalarray' => &$totalarray);
825 $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $objecttmp, $action); // Note that $action and $objecttmpect may have been modified by hook
826 print $hookmanager->resPrint;
827 // Date creation
828 if (!empty($arrayfields['b.datec']['checked'])) {
829 print '<td class="center nowraponall">';
830 print dol_print_date($objecttmp->date_creation, 'dayhour');
831 print '</td>';
832 if (!$i) {
833 $totalarray['nbfield']++;
834 }
835 }
836 // Date modification
837 if (!empty($arrayfields['b.tms']['checked'])) {
838 print '<td class="center nowraponall">';
839 print dol_print_date($objecttmp->date_modification, 'dayhour');
840 print '</td>';
841 if (!$i) {
842 $totalarray['nbfield']++;
843 }
844 }
845
846 // Status
847 if (!empty($arrayfields['b.clos']['checked'])) {
848 print '<td class="center">'.$objecttmp->getLibStatut(5).'</td>';
849 if (!$i) {
850 $totalarray['nbfield']++;
851 }
852 }
853
854 // Balance
855 if (!empty($arrayfields['balance']['checked'])) {
856 print '<td class="nowraponall right">';
857 print '<a href="'.DOL_URL_ROOT.'/compta/bank/bankentries_list.php?id='.$objecttmp->id.'">';
858 print '<span class="amount">'.price(price2num($solde, 'MT'), 0, $langs, 1, -1, -1, $objecttmp->currency_code).'</span>';
859 print '</a>';
860 print '</td>';
861 if (!$i) {
862 $totalarray['nbfield']++;
863 }
864 if (!$i) {
865 $totalarray['pos'][$totalarray['nbfield']] = 'balance';
866 }
867 $totalarray['val']['balance'] += $solde;
868 }
869
870 // Action column
871 if (!$conf->main_checkbox_left_column) {
872 print '<td class="nowrap center">';
873 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
874 $selected = 0;
875 if (in_array($objecttmp->id, $arrayofselected)) {
876 $selected = 1;
877 }
878 print '<input id="cb'.$objecttmp->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$objecttmp->id.'"'.($selected ? ' checked="checked"' : '').'>';
879 }
880 print '</td>';
881 if (!$i) {
882 $totalarray['nbfield']++;
883 }
884 }
885
886 print '</tr>'."\n";
887
888 if (empty($total[$objecttmp->currency_code])) {
889 $total[$objecttmp->currency_code] = $solde;
890 } else {
891 $total[$objecttmp->currency_code] += $solde;
892 }
893 }
894 $i++;
895}
896
897// If no record found
898if (!$found) {
899 $colspan = 1;
900 foreach ($arrayfields as $key => $val) {
901 if (!empty($val['checked'])) {
902 $colspan++;
903 }
904 }
905 print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
906}
907
908// Show total line
909if ($lastcurrencycode != 'various') { // If there is several currency, $lastcurrencycode is set to 'various' before
910 // Show total line
911 include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
912}
913
914print '</table>'."\n";
915print '</div>'."\n";
916
917print '</form>'."\n";
918
919// End of page
920llxFooter();
921$db->close();
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
$totalarray
Definition list.php:501
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:
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
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).
isModEnabled($module)
Is Dolibarr module enabled.
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.
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.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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...
Definition html.lib.php:172
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.