dolibarr 21.0.3
list.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2003-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
4 * Copyright (C) 2004-2020 Laurent Destailleur <eldy@users.sourceforge.net>
5 * Copyright (C) 2004 Christophe Combelles <ccomb@free.fr>
6 * Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
7 * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
8 * Copyright (C) 2014 Teddy Andreotti <125155@supinfo.com>
9 * Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
10 * Copyright (C) 2015 Juanjo Menent <jmenent@2byte.es>
11 * Copyright (C) 2017-2021 Alexandre Spangaro <aspangaro@open-dsi.fr>
12 * Copyright (C) 2018-2024 Frédéric France <frederic.france@free.fr>
13 * Copyright (C) 2020 Tobias Sekan <tobias.sekan@startmail.com>
14 * Copyright (C) 2021 Ferran Marcet <fmarcet@2byte.es>
15 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
16 *
17 * This program is free software; you can redistribute it and/or modify
18 * it under the terms of the GNU General Public License as published by
19 * the Free Software Foundation; either version 3 of the License, or
20 * (at your option) any later version.
21 *
22 * This program is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
26 *
27 * You should have received a copy of the GNU General Public License
28 * along with this program. If not, see <https://www.gnu.org/licenses/>.
29 */
30
37// Load Dolibarr environment
38require '../../main.inc.php';
39require_once DOL_DOCUMENT_ROOT.'/expensereport/class/paymentexpensereport.class.php';
40require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
41require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
42require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
43require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php';
44
53// Load translation files required by the page
54$langs->loadLangs(array('trips', 'bills', 'banks', 'compta'));
55
56$action = GETPOST('action', 'alpha');
57$massaction = GETPOST('massaction', 'alpha');
58$optioncss = GETPOST('optioncss', 'alpha');
59$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'vendorpaymentlist';
60$mode = GETPOST('mode', 'alpha');
61$toselect = GETPOSTISSET('toselect') ? GETPOST('toselect', 'array:int') : array();
62
63$socid = GETPOSTINT('socid');
64
65// Security check
66if ($user->socid) {
67 $socid = $user->socid;
68}
69
70$search_ref = GETPOST('search_ref', 'alpha');
71$search_date_startday = GETPOSTINT('search_date_startday');
72$search_date_startmonth = GETPOSTINT('search_date_startmonth');
73$search_date_startyear = GETPOSTINT('search_date_startyear');
74$search_date_endday = GETPOSTINT('search_date_endday');
75$search_date_endmonth = GETPOSTINT('search_date_endmonth');
76$search_date_endyear = GETPOSTINT('search_date_endyear');
77$search_date_start = dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear); // Use tzserver
78$search_date_end = dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear);
79$search_user = GETPOST('search_user', 'alpha');
80$search_payment_type = GETPOST('search_payment_type');
81$search_cheque_num = GETPOST('search_cheque_num', 'alpha');
82$search_bank_account = GETPOST('search_bank_account', 'int');
83$search_amount = GETPOST('search_amount', 'alpha'); // alpha because we must be able to search on '< x'
84
85$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
86$sortfield = GETPOST('sortfield', 'aZ09comma');
87$sortorder = GETPOST('sortorder', 'aZ09comma');
88$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT('page');
89if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
90 // If $page is not defined, or '' or -1 or if we click on clear filters
91 $page = 0;
92}
93$offset = $limit * $page;
94$pageprev = $page - 1;
95$pagenext = $page + 1;
96
97if (!$sortorder) {
98 $sortorder = "DESC";
99}
100if (!$sortfield) {
101 $sortfield = "pndf.datep";
102}
103
104$search_all = trim(GETPOST('search_all', 'alphanohtml'));
105
106// List of fields to search into when doing a "search in all"
107$fieldstosearchall = array(
108 'pndf.rowid' => "RefPayment",
109 'u.login' => "User",
110 'pndf.num_payment' => "Numero",
111 'pndf.amount' => "Amount",
112);
113
114$arrayfields = array(
115 'pndf.rowid' => array('label' => "RefPayment", 'checked' => 1, 'position' => 10),
116 'pndf.datep' => array('label' => "Date", 'checked' => 1, 'position' => 20),
117 'u.login' => array('label' => "User", 'checked' => 1, 'position' => 30),
118 'c.libelle' => array('label' => "Type", 'checked' => 1, 'position' => 40),
119 'pndf.num_payment' => array('label' => "Numero", 'checked' => 1, 'position' => 50, 'tooltip' => "ChequeOrTransferNumber"),
120 'ba.label' => array('label' => "BankAccount", 'checked' => 1, 'position' => 60, 'enable' => (isModEnabled("bank"))),
121 'pndf.amount' => array('label' => "Amount", 'checked' => 1, 'position' => 70),
122);
123$arrayfields = dol_sort_array($arrayfields, 'position');
124'@phan-var-force array<string,array{label:string,checked?:int<0,1>,position?:int,help?:string}> $arrayfields'; // dol_sort_array looses type for Phan
125
126// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
127$hookmanager->initHooks(array('paymentexpensereportlist'));
129
130// Security check
131if ($user->socid) {
132 $socid = $user->socid;
133}
134
135// doesn't work :-(
136// restrictedArea($user, 'fournisseur');
137// doesn't work :-(
138// require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php';
139// $object = new PaiementFourn($db);
140// restrictedArea($user, $object->element);
141if (!$user->hasRight('expensereport', 'lire')) {
143}
144
145
146/*
147 * Actions
148 */
149
150$childids = $user->getAllChildIds(1);
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 // Selection of new fields
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_date_startday = '';
166 $search_date_startmonth = '';
167 $search_date_startyear = '';
168 $search_date_endday = '';
169 $search_date_endmonth = '';
170 $search_date_endyear = '';
171 $search_date_start = '';
172 $search_date_end = '';
173 $search_user = '';
174 $search_payment_type = '';
175 $search_cheque_num = '';
176 $search_bank_account = '';
177 $search_amount = '';
178 }
179}
180
181/*
182 * View
183 */
184
185$form = new Form($db);
186$formother = new FormOther($db);
187$accountstatic = new Account($db);
188$userstatic = new User($db);
189$paymentexpensereportstatic = new PaymentExpenseReport($db);
190
191$title = $langs->trans('ListPayment');
192
193// Build and execute select
194// --------------------------------------------------------------------
195$sql = 'SELECT pndf.rowid, pndf.rowid as ref, pndf.datep, pndf.amount as pamount, pndf.num_payment';
196$sql .= ', u.rowid as userid, u.login, u.email, u.lastname, u.firstname, u.photo';
197$sql .= ', c.code as paiement_type, c.libelle as paiement_libelle';
198$sql .= ', ba.rowid as bid, ba.ref as bref, ba.label as blabel, ba.number, ba.account_number as account_number, ba.iban_prefix, ba.bic, ba.currency_code, ba.fk_accountancy_journal as accountancy_journal';
199$sql .= ', SUM(pndf.amount)';
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.'payment_expensereport AS pndf';
209$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'expensereport AS ndf ON ndf.rowid=pndf.fk_expensereport';
210$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement AS c ON pndf.fk_typepayment = c.id';
211$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'user AS u ON u.rowid = ndf.fk_user_author';
212$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON pndf.fk_bank = b.rowid';
213$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank_account as ba ON b.fk_account = ba.rowid';
214$sql .= ' WHERE ndf.entity IN ('.getEntity("expensereport").')';
215
216// RESTRICT RIGHTS
217if (!$user->hasRight('expensereport', 'readall') && !$user->hasRight('expensereport', 'lire_tous')
218 && (!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') || !$user->hasRight('expensereport', 'writeall_advance'))) {
219 $sql .= " AND ndf.fk_user_author IN (".$db->sanitize(implode(',', $childids)).")\n";
220}
221
222if ($search_ref) {
223 $sql .= natural_search('pndf.rowid', $search_ref);
224}
225if ($search_date_start) {
226 $sql .= " AND pndf.datep >= '" . $db->idate($search_date_start) . "'";
227}
228if ($search_date_end) {
229 $sql .= " AND pndf.datep <= '" . $db->idate($search_date_end) . "'";
230}
231
232if ($search_user) {
233 $sql .= natural_search(array('u.login', 'u.lastname', 'u.firstname'), $search_user);
234}
235if ($search_payment_type != '') {
236 $sql .= " AND c.code = '".$db->escape($search_payment_type)."'";
237}
238if ($search_cheque_num != '') {
239 $sql .= natural_search('pndf.num_payment', $search_cheque_num);
240}
241if ($search_amount) {
242 $sql .= natural_search('pndf.amount', $search_amount, 1);
243}
244if ($search_bank_account > 0) {
245 $sql .= ' AND b.fk_account = '.((int) $search_bank_account);
246}
247if ($search_all) {
248 $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
249}
250
251// Add where from extra fields
252include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
253// Add where from hooks
254$parameters = array();
255$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
256$sql .= $hookmanager->resPrint;
257
258$sql .= ' GROUP BY pndf.rowid, pndf.datep, pndf.amount, pndf.num_payment, u.rowid, u.login, u.email, u.lastname, u.firstname, u.photo, c.code, c.libelle,';
259$sql .= ' ba.rowid, ba.ref, ba.label, ba.number, ba.account_number, ba.iban_prefix, ba.bic, ba.currency_code, ba.fk_accountancy_journal';
260
261// Count total nb of records
262$nbtotalofrecords = '';
263if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
264 /* The fast and low memory method to get and count full list converts the sql into a sql count */
265 $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql);
266 $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount);
267
268 $resql = $db->query($sqlforcount);
269 if ($resql) {
270 $objforcount = $db->fetch_object($resql);
271 $nbtotalofrecords = $objforcount->nbtotalofrecords;
272 } else {
273 dol_print_error($db);
274 }
275
276 if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller than the paging size (filtering), goto and load page 0
277 $page = 0;
278 $offset = 0;
279 }
280 $db->free($resql);
281}
282
283// Complete request and execute it with limit
284$sql .= $db->order($sortfield, $sortorder);
285if ($limit) {
286 $sql .= $db->plimit($limit + 1, $offset);
287}
288
289$resql = $db->query($sql);
290if (!$resql) {
291 dol_print_error($db);
292 exit;
293}
294
295$num = $db->num_rows($resql);
296$i = 0;
297
298
299
300// Output page
301// --------------------------------------------------------------------
302
303llxHeader('', $title, '', '', 0, 0, '', '', '', 'bodyforlist');
304
305$arrayofselected = is_array($toselect) ? $toselect : array();
306
307$param = '';
308if (!empty($mode)) {
309 $param .= '&mode='.urlencode($mode);
310}
311if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
312 $param .= '&contextpage='.urlencode($contextpage);
313}
314if ($limit > 0 && $limit != $conf->liste_limit) {
315 $param .= '&limit='.((int) $limit);
316}
317if ($optioncss != '') {
318 $param .= '&optioncss='.urlencode($optioncss);
319}
320
321if ($search_ref) {
322 $param .= '&search_ref='.urlencode($search_ref);
323}
324if ($search_date_startday) {
325 $param .= '&search_date_startday='.urlencode((string) ($search_date_startday));
326}
327if ($search_date_startmonth) {
328 $param .= '&search_date_startmonth='.urlencode((string) ($search_date_startmonth));
329}
330if ($search_date_startyear) {
331 $param .= '&search_date_startyear='.urlencode((string) ($search_date_startyear));
332}
333if ($search_date_endday) {
334 $param .= '&search_date_endday='.urlencode((string) ($search_date_endday));
335}
336if ($search_date_endmonth) {
337 $param .= '&search_date_endmonth='.urlencode((string) ($search_date_endmonth));
338}
339if ($search_date_endyear) {
340 $param .= '&search_date_endyear='.urlencode((string) ($search_date_endyear));
341}
342if ($search_user) {
343 $param .= '&search_user='.urlencode($search_user);
344}
345if ($search_payment_type) {
346 $param .= '&search_payment_type='.urlencode($search_payment_type);
347}
348if ($search_cheque_num) {
349 $param .= '&search_cheque_num='.urlencode($search_cheque_num);
350}
351if ($search_amount) {
352 $param .= '&search_amount='.urlencode($search_amount);
353}
354if ($search_bank_account) {
355 $param .= '&search_bank_account='.urlencode((string) ($search_bank_account));
356}
357
358// Add $param from extra fields
359include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
360// Add $param from hooks
361$parameters = array('param' => &$param);
362$reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
363$param .= $hookmanager->resPrint;
364
365// List of mass actions available
366$arrayofmassactions = array(
367 //'validate'=>img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("Validate"),
368 //'generate_doc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"),
369 //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
370 //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
371);
372
373if (GETPOSTINT('nomassaction') || in_array($massaction, array('presend', 'predelete'))) {
374 $arrayofmassactions = array();
375}
376$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
377
378print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n";
379if ($optioncss != '') {
380 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
381}
382print '<input type="hidden" name="token" value="'.newToken().'">';
383print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
384print '<input type="hidden" name="action" value="list">';
385print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
386print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
387print '<input type="hidden" name="page" value="'.$page.'">';
388print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
389print '<input type="hidden" name="page_y" value="">';
390print '<input type="hidden" name="mode" value="'.$mode.'">';
391
392$newcardbutton = '';
393$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'));
394$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'));
395
396// @phan-suppress-next-line PhanPluginSuspiciousParamOrder
397print_barre_liste($langs->trans('ExpenseReportPayments'), $page, $_SERVER['PHP_SELF'], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'expensereport', 0, $newcardbutton, '', $limit, 0, 0, 1);
398
399if ($search_all) {
400 $setupstring = '';
401 foreach ($fieldstosearchall as $key => $val) {
402 $fieldstosearchall[$key] = $langs->trans($val);
403 $setupstring .= $key."=".$val.";";
404 }
405 print '<!-- Search done like if EXPENSEREPORT_PAYMENT_QUICKSEARCH_ON_FIELDS = '.$setupstring.' -->'."\n";
406 print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).implode(', ', $fieldstosearchall).'</div>';
407}
408
409$moreforfilter = '';
410
411$parameters = array();
412$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
413if (empty($reshook)) {
414 $moreforfilter .= $hookmanager->resPrint;
415} else {
416 $moreforfilter = $hookmanager->resPrint;
417}
418
419if (!empty($moreforfilter)) {
420 print '<div class="liste_titre liste_titre_bydiv centpercent">';
421 print $moreforfilter;
422 print '</div>';
423}
424
425$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
426$htmlofselectarray = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')); // This also change content of $arrayfields with user setup
427$selectedfields = ($mode != 'kanban' ? $htmlofselectarray : '');
428$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
429
430print '<div class="div-table-responsive">';
431print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : '').'">';
432
433// Fields title search
434// --------------------------------------------------------------------
435print '<tr class="liste_titre_filter">';
436
437// Action column
438if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
439 print '<td class="liste_titre center maxwidthsearch">';
440 $searchpicto = $form->showFilterButtons('left');
441 print $searchpicto;
442 print '</td>';
443}
444
445// Filter: Ref
446if (!empty($arrayfields['pndf.rowid']['checked'])) {
447 print '<td class="liste_titre left">';
448 print '<input class="flat" type="text" size="4" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
449 print '</td>';
450}
451
452// Filter: Date
453if (!empty($arrayfields['pndf.datep']['checked'])) {
454 print '<td class="liste_titre center">';
455 print '<div class="nowrapfordate">';
456 print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
457 print '</div>';
458 print '<div class="nowrapfordate">';
459 print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
460 print '</div>';
461 print '</td>';
462}
463
464// Filter: Thirdparty
465if (!empty($arrayfields['u.login']['checked'])) {
466 print '<td class="liste_titre">';
467 print '<input class="flat width75" type="text" name="search_user" value="'.dol_escape_htmltag($search_user).'">';
468 print '</td>';
469}
470
471// Filter: Payment type
472if (!empty($arrayfields['c.libelle']['checked'])) {
473 print '<td class="liste_titre">';
474 $form->select_types_paiements($search_payment_type, 'search_payment_type', '', 2, 1, 1);
475 print '</td>';
476}
477
478// Filter: Cheque number (fund transfer)
479if (!empty($arrayfields['pndf.num_payment']['checked'])) {
480 print '<td class="liste_titre">';
481 print '<input class="flat" type="text" size="4" name="search_cheque_num" value="'.dol_escape_htmltag($search_cheque_num).'">';
482 print '</td>';
483}
484
485// Filter: Bank account
486if (!empty($arrayfields['ba.label']['checked'])) {
487 print '<td class="liste_titre">';
488 $form->select_comptes($search_bank_account, 'search_bank_account', 0, '', 1);
489 print '</td>';
490}
491
492// Filter: Amount
493if (!empty($arrayfields['pndf.amount']['checked'])) {
494 print '<td class="liste_titre right">';
495 print '<input class="flat" type="text" size="4" name="search_amount" value="'.dol_escape_htmltag($search_amount).'">';
496 print '</td>';
497}
498
499// Fields from hook
500$parameters = array('arrayfields' => $arrayfields);
501$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
502print $hookmanager->resPrint;
503
504// Action column
505if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
506 print '<td class="liste_titre center maxwidthsearch">';
507 $searchpicto = $form->showFilterButtons();
508 print $searchpicto;
509 print '</td>';
510}
511
512print '</tr>'."\n";
513
514$totalarray = array();
515$totalarray['nbfield'] = 0;
516
517// Fields title label
518// --------------------------------------------------------------------
519print '<tr class="liste_titre">';
520// Action column
521if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
522 print_liste_field_titre($selectedfields, $_SERVER['PHP_SELF'], '', '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ');
523 $totalarray['nbfield']++;
524}
525if (!empty($arrayfields['i']['checked'])) {
526 print_liste_field_titre('#', $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder);
527 $totalarray['nbfield']++;
528}
529if (!empty($arrayfields['pndf.rowid']['checked'])) {
530 // @phan-suppress-next-line PhanTypeInvalidDimOffset
531 print_liste_field_titre($arrayfields['pndf.rowid']['label'], $_SERVER["PHP_SELF"], 'pndf.rowid', '', $param, '', $sortfield, $sortorder);
532 $totalarray['nbfield']++;
533}
534if (!empty($arrayfields['pndf.datep']['checked'])) {
535 print_liste_field_titre($arrayfields['pndf.datep']['label'], $_SERVER["PHP_SELF"], 'pndf.datep', '', $param, '', $sortfield, $sortorder, 'center ');
536 $totalarray['nbfield']++;
537}
538if (!empty($arrayfields['u.login']['checked'])) {
539 print_liste_field_titre($arrayfields['u.login']['label'], $_SERVER["PHP_SELF"], 'u.lastname', '', $param, '', $sortfield, $sortorder);
540 $totalarray['nbfield']++;
541}
542if (!empty($arrayfields['c.libelle']['checked'])) {
543 print_liste_field_titre($arrayfields['c.libelle']['label'], $_SERVER["PHP_SELF"], 'c.libelle', '', $param, '', $sortfield, $sortorder);
544 $totalarray['nbfield']++;
545}
546if (!empty($arrayfields['pndf.num_payment']['checked'])) {
547 print_liste_field_titre($arrayfields['pndf.num_payment']['label'], $_SERVER["PHP_SELF"], "pndf.num_payment", '', $param, '', $sortfield, $sortorder, '', $arrayfields['pndf.num_payment']['tooltip']);
548 $totalarray['nbfield']++;
549}
550if (!empty($arrayfields['ba.label']['checked'])) {
551 print_liste_field_titre($arrayfields['ba.label']['label'], $_SERVER["PHP_SELF"], 'ba.label', '', $param, '', $sortfield, $sortorder);
552 $totalarray['nbfield']++;
553}
554if (!empty($arrayfields['pndf.amount']['checked'])) {
555 print_liste_field_titre($arrayfields['pndf.amount']['label'], $_SERVER["PHP_SELF"], 'pndf.amount', '', $param, '', $sortfield, $sortorder, 'right ');
556 $totalarray['nbfield']++;
557}
558
559// Hook fields
560$parameters = array('arrayfields' => $arrayfields, 'param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder, 'totalarray' => &$totalarray);
561$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
562print $hookmanager->resPrint;
563// Action column
564if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
565 print_liste_field_titre($selectedfields, $_SERVER['PHP_SELF'], '', '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ');
566 $totalarray['nbfield']++;
567}
568print '</tr>'."\n";
569
570$checkedCount = 0;
571foreach ($arrayfields as $column) {
572 if ($column['checked']) {
573 $checkedCount++;
574 }
575}
576
577// Loop on record
578// --------------------------------------------------------------------
579$i = 0;
580$savnbfield = $totalarray['nbfield'];
581$totalarray = array();
582$totalarray['nbfield'] = 0;
583$imaxinloop = ($limit ? min($num, $limit) : $num);
584while ($i < $imaxinloop) {
585 $objp = $db->fetch_object($resql);
586 if (empty($objp)) {
587 break; // Should not happen
588 }
589
590 $paymentexpensereportstatic->id = $objp->rowid;
591 $paymentexpensereportstatic->ref = $objp->ref;
592 $paymentexpensereportstatic->datep = $db->jdate($objp->datep);
593 $paymentexpensereportstatic->amount = $objp->pamount;
594 $paymentexpensereportstatic->fk_typepayment = $objp->paiement_type;
595
596 if ($objp->bid) {
597 $accountstatic->fetch($objp->bid);
598 $paymentexpensereportstatic->fk_bank = $accountstatic->id;
599 } else {
600 $paymentexpensereportstatic->fk_bank = 0;
601 }
602
603 $userstatic->id = $objp->userid;
604 $userstatic->lastname = $objp->lastname;
605 $userstatic->firstname = $objp->firstname;
606 $userstatic->login = $objp->login;
607 $userstatic->email = $objp->email;
608 $userstatic->photo = $objp->photo;
609
610 if ($mode == 'kanban') {
611 if ($i == 0) {
612 print '<tr class="trkanban"><td colspan="'.$savnbfield.'">';
613 print '<div class="box-flex-container kanban">';
614 }
615 // Output Kanban
616 print $paymentexpensereportstatic->getKanbanView('', array('selected' => in_array($objp->id, $arrayofselected)));
617 if ($i == ($imaxinloop - 1)) {
618 print '</div>';
619 print '</td></tr>';
620 }
621 } else {
622 // Show line of result
623 $j = 0;
624 print '<tr data-rowid="'.$object->id.'" class="oddeven">';
625
626 // Action column
627 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
628 print '<td class="nowrap center">';
629 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
630 $selected = 0;
631 if (in_array($object->id, $arrayofselected)) {
632 $selected = 1;
633 }
634 print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
635 }
636 print '</td>';
637 if (!$i) {
638 $totalarray['nbfield']++;
639 }
640 }
641
642 // No of line (not ref or ID)
643 if (!empty($arrayfields['i']['checked'])) {
644 print '<td>#'.(($offset * $limit) + $i).'</td>';
645 if (!$i) {
646 $totalarray['nbfield']++;
647 }
648 }
649
650 // Ref
651 if (!empty($arrayfields['pndf.rowid']['checked'])) {
652 print '<td class="nowrap">'.$paymentexpensereportstatic->getNomUrl(1).'</td>';
653 if (!$i) {
654 $totalarray['nbfield']++;
655 }
656 }
657
658 // Date
659 if (!empty($arrayfields['pndf.datep']['checked'])) {
660 $dateformatforpayment = 'dayhour';
661 print '<td class="nowrap center">'.dol_print_date($db->jdate($objp->datep), $dateformatforpayment).'</td>';
662 if (!$i) {
663 $totalarray['nbfield']++;
664 }
665 }
666
667 // Thirdparty
668 if (!empty($arrayfields['u.login']['checked'])) {
669 print '<td>';
670 if ($userstatic->id > 0) {
671 print $userstatic->getNomUrl(-1);
672 }
673 print '</td>';
674 if (!$i) {
675 $totalarray['nbfield']++;
676 }
677 }
678
679 // Pyament type
680 if (!empty($arrayfields['c.libelle']['checked'])) {
681 $payment_type = $langs->trans("PaymentType".$objp->paiement_type) != "PaymentType".$objp->paiement_type ? $langs->trans("PaymentType".$objp->paiement_type) : $objp->paiement_libelle;
682 print '<td>'.$payment_type.' '.dol_trunc($objp->num_payment, 32).'</td>';
683 if (!$i) {
684 $totalarray['nbfield']++;
685 }
686 }
687
688 // Cheque number (fund transfer)
689 if (!empty($arrayfields['pndf.num_payment']['checked'])) {
690 print '<td>'.$objp->num_payment.'</td>';
691 if (!$i) {
692 $totalarray['nbfield']++;
693 }
694 }
695
696 // Bank account
697 if (!empty($arrayfields['ba.label']['checked'])) {
698 print '<td>';
699 if ($objp->bid) {
700 $accountstatic->id = $objp->bid;
701 $accountstatic->ref = $objp->bref;
702 $accountstatic->label = $objp->blabel;
703 $accountstatic->number = $objp->number;
704 $accountstatic->iban = $objp->iban_prefix;
705 $accountstatic->bic = $objp->bic;
706 $accountstatic->currency_code = $objp->currency_code;
707 $accountstatic->account_number = $objp->account_number;
708
709 $accountingjournal = new AccountingJournal($db);
710 $accountingjournal->fetch($objp->accountancy_journal);
711 $accountstatic->accountancy_journal = $accountingjournal->code;
712
713 print $accountstatic->getNomUrl(1);
714 } else {
715 print '&nbsp;';
716 }
717 print '</td>';
718 if (!$i) {
719 $totalarray['nbfield']++;
720 }
721 }
722
723 // Amount
724 if (!empty($arrayfields['pndf.amount']['checked'])) {
725 print '<td class="right"><span class="amount">'.price($objp->pamount).'</span></td>';
726 if (!$i) {
727 $totalarray['nbfield']++;
728 }
729 $totalarray['pos'][$checkedCount] = 'amount';
730 if (empty($totalarray['val']['amount'])) {
731 $totalarray['val']['amount'] = $objp->pamount;
732 } else {
733 $totalarray['val']['amount'] += $objp->pamount;
734 }
735 }
736
737 // Action column
738 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
739 print '<td class="nowrap center">';
740 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
741 $selected = 0;
742 if (in_array($object->id, $arrayofselected)) {
743 $selected = 1;
744 }
745 print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
746 }
747 print '</td>';
748 if (!$i) {
749 $totalarray['nbfield']++;
750 }
751 }
752
753 print '</tr>'."\n";
754 }
755
756 $i++;
757}
758
759// Show total line
760include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
761
762// If no record found
763if ($num == 0) {
764 $colspan = 1;
765 foreach ($arrayfields as $key => $val) {
766 if (!empty($val['checked'])) {
767 $colspan++;
768 }
769 }
770 print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
771}
772
773$db->free($resql);
774
775$parameters = array('arrayfields' => $arrayfields, 'sql' => $sql);
776$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
777print $hookmanager->resPrint;
778
779print '</table>'."\n";
780print '</div>'."\n";
781
782print '</form>'."\n";
783
784// End of page
785llxFooter();
786$db->close();
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:66
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:87
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:71
Class to manage bank accounts.
Class to manage accounting journals.
Class to manage generation of HTML components Only common components must be here.
Class permettant la generation de composants html autre Only common components are here.
Class to manage payments of expense report.
Class to manage Dolibarr users.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $selectlimitsuffix=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
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_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.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.