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