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