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