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