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