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