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