dolibarr 21.0.0-beta
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
62$socid = GETPOSTINT('socid');
63
64// Security check
65if ($user->socid) {
66 $socid = $user->socid;
67}
68
69$search_ref = GETPOST('search_ref', 'alpha');
70$search_date_startday = GETPOSTINT('search_date_startday');
71$search_date_startmonth = GETPOSTINT('search_date_startmonth');
72$search_date_startyear = GETPOSTINT('search_date_startyear');
73$search_date_endday = GETPOSTINT('search_date_endday');
74$search_date_endmonth = GETPOSTINT('search_date_endmonth');
75$search_date_endyear = GETPOSTINT('search_date_endyear');
76$search_date_start = dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear); // Use tzserver
77$search_date_end = dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear);
78$search_user = GETPOST('search_user', 'alpha');
79$search_payment_type = GETPOST('search_payment_type');
80$search_cheque_num = GETPOST('search_cheque_num', 'alpha');
81$search_bank_account = GETPOST('search_bank_account', 'int');
82$search_amount = GETPOST('search_amount', 'alpha'); // alpha because we must be able to search on '< x'
83
84$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
85$sortfield = GETPOST('sortfield', 'aZ09comma');
86$sortorder = GETPOST('sortorder', 'aZ09comma');
87$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT('page');
88if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
89 // If $page is not defined, or '' or -1 or if we click on clear filters
90 $page = 0;
91}
92$offset = $limit * $page;
93$pageprev = $page - 1;
94$pagenext = $page + 1;
95
96if (!$sortorder) {
97 $sortorder = "DESC";
98}
99if (!$sortfield) {
100 $sortfield = "pndf.datep";
101}
102
103$search_all = trim(GETPOST('search_all', 'alphanohtml'));
104
105// List of fields to search into when doing a "search in all"
106$fieldstosearchall = array(
107 'pndf.rowid' => "RefPayment",
108 'u.login' => "User",
109 'pndf.num_payment' => "Numero",
110 'pndf.amount' => "Amount",
111);
112
113$arrayfields = array(
114 'pndf.rowid' => array('label' => "RefPayment", 'checked' => 1, 'position' => 10),
115 'pndf.datep' => array('label' => "Date", 'checked' => 1, 'position' => 20),
116 'u.login' => array('label' => "User", 'checked' => 1, 'position' => 30),
117 'c.libelle' => array('label' => "Type", 'checked' => 1, 'position' => 40),
118 'pndf.num_payment' => array('label' => "Numero", 'checked' => 1, 'position' => 50, 'tooltip' => "ChequeOrTransferNumber"),
119 'ba.label' => array('label' => "BankAccount", 'checked' => 1, 'position' => 60, 'enable' => (isModEnabled("bank"))),
120 'pndf.amount' => array('label' => "Amount", 'checked' => 1, 'position' => 70),
121);
122$arrayfields = dol_sort_array($arrayfields, 'position');
123'@phan-var-force array<string,array{label:string,checked?:int<0,1>,position?:int,help?:string}> $arrayfields'; // dol_sort_array looses type for Phan
124
125// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
126$hookmanager->initHooks(array('paymentexpensereportlist'));
128
129// Security check
130if ($user->socid) {
131 $socid = $user->socid;
132}
133
134// doesn't work :-(
135// restrictedArea($user, 'fournisseur');
136// doesn't work :-(
137// require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php';
138// $object = new PaiementFourn($db);
139// restrictedArea($user, $object->element);
140if (!$user->hasRight('expensereport', 'lire')) {
142}
143
144
145/*
146 * Actions
147 */
148
149$childids = $user->getAllChildIds(1);
150
151$parameters = array('socid' => $socid);
152$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
153if ($reshook < 0) {
154 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
155}
156
157if (empty($reshook)) {
158 // Selection of new fields
159 include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
160
161 // Purge search criteria
162 if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
163 $search_ref = '';
164 $search_date_startday = '';
165 $search_date_startmonth = '';
166 $search_date_startyear = '';
167 $search_date_endday = '';
168 $search_date_endmonth = '';
169 $search_date_endyear = '';
170 $search_date_start = '';
171 $search_date_end = '';
172 $search_user = '';
173 $search_payment_type = '';
174 $search_cheque_num = '';
175 $search_bank_account = '';
176 $search_amount = '';
177 }
178}
179
180/*
181 * View
182 */
183
184$form = new Form($db);
185$formother = new FormOther($db);
186$accountstatic = new Account($db);
187$userstatic = new User($db);
188$paymentexpensereportstatic = new PaymentExpenseReport($db);
189
190$title = $langs->trans('ListPayment');
191
192// Build and execute select
193// --------------------------------------------------------------------
194$sql = 'SELECT pndf.rowid, pndf.rowid as ref, pndf.datep, pndf.amount as pamount, pndf.num_payment';
195$sql .= ', u.rowid as userid, u.login, u.email, u.lastname, u.firstname, u.photo';
196$sql .= ', c.code as paiement_type, c.libelle as paiement_libelle';
197$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';
198$sql .= ', SUM(pndf.amount)';
199// Add fields from hooks
200$parameters = array();
201$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
202$sql .= $hookmanager->resPrint;
203$sql = preg_replace('/,\s*$/', '', $sql);
204
205$sqlfields = $sql; // $sql fields to remove for count total
206
207$sql .= ' FROM '.MAIN_DB_PREFIX.'payment_expensereport AS pndf';
208$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'expensereport AS ndf ON ndf.rowid=pndf.fk_expensereport';
209$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement AS c ON pndf.fk_typepayment = c.id';
210$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'user AS u ON u.rowid = ndf.fk_user_author';
211$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON pndf.fk_bank = b.rowid';
212$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank_account as ba ON b.fk_account = ba.rowid';
213$sql .= ' WHERE ndf.entity IN ('.getEntity("expensereport").')';
214
215// RESTRICT RIGHTS
216if (!$user->hasRight('expensereport', 'readall') && !$user->hasRight('expensereport', 'lire_tous')
217 && (!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') || !$user->hasRight('expensereport', 'writeall_advance'))) {
218 $sql .= " AND ndf.fk_user_author IN (".$db->sanitize(implode(',', $childids)).")\n";
219}
220
221if ($search_ref) {
222 $sql .= natural_search('pndf.rowid', $search_ref);
223}
224if ($search_date_start) {
225 $sql .= " AND pndf.datep >= '" . $db->idate($search_date_start) . "'";
226}
227if ($search_date_end) {
228 $sql .= " AND pndf.datep <= '" . $db->idate($search_date_end) . "'";
229}
230
231if ($search_user) {
232 $sql .= natural_search(array('u.login', 'u.lastname', 'u.firstname'), $search_user);
233}
234if ($search_payment_type != '') {
235 $sql .= " AND c.code = '".$db->escape($search_payment_type)."'";
236}
237if ($search_cheque_num != '') {
238 $sql .= natural_search('pndf.num_payment', $search_cheque_num);
239}
240if ($search_amount) {
241 $sql .= natural_search('pndf.amount', $search_amount, 1);
242}
243if ($search_bank_account > 0) {
244 $sql .= ' AND b.fk_account = '.((int) $search_bank_account);
245}
246if ($search_all) {
247 $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
248}
249
250// Add where from extra fields
251include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
252// Add where from hooks
253$parameters = array();
254$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
255$sql .= $hookmanager->resPrint;
256
257$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,';
258$sql .= ' ba.rowid, ba.ref, ba.label, ba.number, ba.account_number, ba.iban_prefix, ba.bic, ba.currency_code, ba.fk_accountancy_journal';
259
260// Count total nb of records
261$nbtotalofrecords = '';
262if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
263 /* The fast and low memory method to get and count full list converts the sql into a sql count */
264 $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql);
265 $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount);
266
267 $resql = $db->query($sqlforcount);
268 if ($resql) {
269 $objforcount = $db->fetch_object($resql);
270 $nbtotalofrecords = $objforcount->nbtotalofrecords;
271 } else {
272 dol_print_error($db);
273 }
274
275 if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller than the paging size (filtering), goto and load page 0
276 $page = 0;
277 $offset = 0;
278 }
279 $db->free($resql);
280}
281
282// Complete request and execute it with limit
283$sql .= $db->order($sortfield, $sortorder);
284if ($limit) {
285 $sql .= $db->plimit($limit + 1, $offset);
286}
287
288$resql = $db->query($sql);
289if (!$resql) {
290 dol_print_error($db);
291 exit;
292}
293
294$num = $db->num_rows($resql);
295$i = 0;
296
297
298
299// Output page
300// --------------------------------------------------------------------
301
302llxHeader('', $title, '', '', 0, 0, '', '', '', 'bodyforlist');
303
304$arrayofselected = is_array($toselect) ? $toselect : array();
305
306$param = '';
307if (!empty($mode)) {
308 $param .= '&mode='.urlencode($mode);
309}
310if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
311 $param .= '&contextpage='.urlencode($contextpage);
312}
313if ($limit > 0 && $limit != $conf->liste_limit) {
314 $param .= '&limit='.((int) $limit);
315}
316if ($optioncss != '') {
317 $param .= '&optioncss='.urlencode($optioncss);
318}
319
320if ($search_ref) {
321 $param .= '&search_ref='.urlencode($search_ref);
322}
323if ($search_date_startday) {
324 $param .= '&search_date_startday='.urlencode((string) ($search_date_startday));
325}
326if ($search_date_startmonth) {
327 $param .= '&search_date_startmonth='.urlencode((string) ($search_date_startmonth));
328}
329if ($search_date_startyear) {
330 $param .= '&search_date_startyear='.urlencode((string) ($search_date_startyear));
331}
332if ($search_date_endday) {
333 $param .= '&search_date_endday='.urlencode((string) ($search_date_endday));
334}
335if ($search_date_endmonth) {
336 $param .= '&search_date_endmonth='.urlencode((string) ($search_date_endmonth));
337}
338if ($search_date_endyear) {
339 $param .= '&search_date_endyear='.urlencode((string) ($search_date_endyear));
340}
341if ($search_user) {
342 $param .= '&search_user='.urlencode($search_user);
343}
344if ($search_payment_type) {
345 $param .= '&search_payment_type='.urlencode($search_payment_type);
346}
347if ($search_cheque_num) {
348 $param .= '&search_cheque_num='.urlencode($search_cheque_num);
349}
350if ($search_amount) {
351 $param .= '&search_amount='.urlencode($search_amount);
352}
353if ($search_bank_account) {
354 $param .= '&search_bank_account='.urlencode((string) ($search_bank_account));
355}
356
357// Add $param from extra fields
358include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
359// Add $param from hooks
360$parameters = array('param' => &$param);
361$reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
362$param .= $hookmanager->resPrint;
363
364// List of mass actions available
365$arrayofmassactions = array(
366 //'validate'=>img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("Validate"),
367 //'generate_doc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"),
368 //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
369 //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
370);
371
372if (GETPOSTINT('nomassaction') || in_array($massaction, array('presend', 'predelete'))) {
373 $arrayofmassactions = array();
374}
375$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
376
377print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n";
378if ($optioncss != '') {
379 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
380}
381print '<input type="hidden" name="token" value="'.newToken().'">';
382print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
383print '<input type="hidden" name="action" value="list">';
384print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
385print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
386print '<input type="hidden" name="page" value="'.$page.'">';
387print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
388print '<input type="hidden" name="page_y" value="">';
389print '<input type="hidden" name="mode" value="'.$mode.'">';
390
391$newcardbutton = '';
392$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'));
393$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'));
394
395// @phan-suppress-next-line PhanPluginSuspiciousParamOrder
396print_barre_liste($langs->trans('ExpenseReportPayments'), $page, $_SERVER['PHP_SELF'], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'expensereport', 0, $newcardbutton, '', $limit, 0, 0, 1);
397
398if ($search_all) {
399 $setupstring = '';
400 foreach ($fieldstosearchall as $key => $val) {
401 $fieldstosearchall[$key] = $langs->trans($val);
402 $setupstring .= $key."=".$val.";";
403 }
404 print '<!-- Search done like if EXPENSEREPORT_PAYMENT_QUICKSEARCH_ON_FIELDS = '.$setupstring.' -->'."\n";
405 print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).implode(', ', $fieldstosearchall).'</div>';
406}
407
408$moreforfilter = '';
409
410$parameters = array();
411$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
412if (empty($reshook)) {
413 $moreforfilter .= $hookmanager->resPrint;
414} else {
415 $moreforfilter = $hookmanager->resPrint;
416}
417
418if (!empty($moreforfilter)) {
419 print '<div class="liste_titre liste_titre_bydiv centpercent">';
420 print $moreforfilter;
421 print '</div>';
422}
423
424$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
425$htmlofselectarray = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')); // This also change content of $arrayfields with user setup
426$selectedfields = ($mode != 'kanban' ? $htmlofselectarray : '');
427$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
428
429print '<div class="div-table-responsive">';
430print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : '').'">';
431
432// Fields title search
433// --------------------------------------------------------------------
434print '<tr class="liste_titre_filter">';
435
436// Action column
437if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
438 print '<td class="liste_titre center maxwidthsearch">';
439 $searchpicto = $form->showFilterButtons('left');
440 print $searchpicto;
441 print '</td>';
442}
443
444// Filter: Ref
445if (!empty($arrayfields['pndf.rowid']['checked'])) {
446 print '<td class="liste_titre left">';
447 print '<input class="flat" type="text" size="4" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
448 print '</td>';
449}
450
451// Filter: Date
452if (!empty($arrayfields['pndf.datep']['checked'])) {
453 print '<td class="liste_titre center">';
454 print '<div class="nowrapfordate">';
455 print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
456 print '</div>';
457 print '<div class="nowrapfordate">';
458 print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
459 print '</div>';
460 print '</td>';
461}
462
463// Filter: Thirdparty
464if (!empty($arrayfields['u.login']['checked'])) {
465 print '<td class="liste_titre">';
466 print '<input class="flat width75" type="text" name="search_user" value="'.dol_escape_htmltag($search_user).'">';
467 print '</td>';
468}
469
470// Filter: Payment type
471if (!empty($arrayfields['c.libelle']['checked'])) {
472 print '<td class="liste_titre">';
473 $form->select_types_paiements($search_payment_type, 'search_payment_type', '', 2, 1, 1);
474 print '</td>';
475}
476
477// Filter: Cheque number (fund transfer)
478if (!empty($arrayfields['pndf.num_payment']['checked'])) {
479 print '<td class="liste_titre">';
480 print '<input class="flat" type="text" size="4" name="search_cheque_num" value="'.dol_escape_htmltag($search_cheque_num).'">';
481 print '</td>';
482}
483
484// Filter: Bank account
485if (!empty($arrayfields['ba.label']['checked'])) {
486 print '<td class="liste_titre">';
487 $form->select_comptes($search_bank_account, 'search_bank_account', 0, '', 1);
488 print '</td>';
489}
490
491// Filter: Amount
492if (!empty($arrayfields['pndf.amount']['checked'])) {
493 print '<td class="liste_titre right">';
494 print '<input class="flat" type="text" size="4" name="search_amount" value="'.dol_escape_htmltag($search_amount).'">';
495 print '</td>';
496}
497
498// Fields from hook
499$parameters = array('arrayfields' => $arrayfields);
500$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
501print $hookmanager->resPrint;
502
503// Action column
504if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
505 print '<td class="liste_titre center maxwidthsearch">';
506 $searchpicto = $form->showFilterButtons();
507 print $searchpicto;
508 print '</td>';
509}
510
511print '</tr>'."\n";
512
513$totalarray = array();
514$totalarray['nbfield'] = 0;
515
516// Fields title label
517// --------------------------------------------------------------------
518print '<tr class="liste_titre">';
519// Action column
520if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
521 print_liste_field_titre($selectedfields, $_SERVER['PHP_SELF'], '', '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ');
522 $totalarray['nbfield']++;
523}
524if (!empty($arrayfields['i']['checked'])) {
525 print_liste_field_titre('#', $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder);
526 $totalarray['nbfield']++;
527}
528if (!empty($arrayfields['pndf.rowid']['checked'])) {
529 // @phan-suppress-next-line PhanTypeInvalidDimOffset
530 print_liste_field_titre($arrayfields['pndf.rowid']['label'], $_SERVER["PHP_SELF"], 'pndf.rowid', '', $param, '', $sortfield, $sortorder);
531 $totalarray['nbfield']++;
532}
533if (!empty($arrayfields['pndf.datep']['checked'])) {
534 print_liste_field_titre($arrayfields['pndf.datep']['label'], $_SERVER["PHP_SELF"], 'pndf.datep', '', $param, '', $sortfield, $sortorder, 'center ');
535 $totalarray['nbfield']++;
536}
537if (!empty($arrayfields['u.login']['checked'])) {
538 print_liste_field_titre($arrayfields['u.login']['label'], $_SERVER["PHP_SELF"], 'u.lastname', '', $param, '', $sortfield, $sortorder);
539 $totalarray['nbfield']++;
540}
541if (!empty($arrayfields['c.libelle']['checked'])) {
542 print_liste_field_titre($arrayfields['c.libelle']['label'], $_SERVER["PHP_SELF"], 'c.libelle', '', $param, '', $sortfield, $sortorder);
543 $totalarray['nbfield']++;
544}
545if (!empty($arrayfields['pndf.num_payment']['checked'])) {
546 print_liste_field_titre($arrayfields['pndf.num_payment']['label'], $_SERVER["PHP_SELF"], "pndf.num_payment", '', $param, '', $sortfield, $sortorder, '', $arrayfields['pndf.num_payment']['tooltip']);
547 $totalarray['nbfield']++;
548}
549if (!empty($arrayfields['ba.label']['checked'])) {
550 print_liste_field_titre($arrayfields['ba.label']['label'], $_SERVER["PHP_SELF"], 'ba.label', '', $param, '', $sortfield, $sortorder);
551 $totalarray['nbfield']++;
552}
553if (!empty($arrayfields['pndf.amount']['checked'])) {
554 print_liste_field_titre($arrayfields['pndf.amount']['label'], $_SERVER["PHP_SELF"], 'pndf.amount', '', $param, '', $sortfield, $sortorder, 'right ');
555 $totalarray['nbfield']++;
556}
557
558// Hook fields
559$parameters = array('arrayfields' => $arrayfields, 'param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder, 'totalarray' => &$totalarray);
560$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
561print $hookmanager->resPrint;
562// Action column
563if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
564 print_liste_field_titre($selectedfields, $_SERVER['PHP_SELF'], '', '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ');
565 $totalarray['nbfield']++;
566}
567print '</tr>'."\n";
568
569$checkedCount = 0;
570foreach ($arrayfields as $column) {
571 if ($column['checked']) {
572 $checkedCount++;
573 }
574}
575
576// Loop on record
577// --------------------------------------------------------------------
578$i = 0;
579$savnbfield = $totalarray['nbfield'];
580$totalarray = array();
581$totalarray['nbfield'] = 0;
582$imaxinloop = ($limit ? min($num, $limit) : $num);
583while ($i < $imaxinloop) {
584 $objp = $db->fetch_object($resql);
585 if (empty($objp)) {
586 break; // Should not happen
587 }
588
589 $paymentexpensereportstatic->id = $objp->rowid;
590 $paymentexpensereportstatic->ref = $objp->ref;
591 $paymentexpensereportstatic->datep = $db->jdate($objp->datep);
592 $paymentexpensereportstatic->amount = $objp->pamount;
593 $paymentexpensereportstatic->fk_typepayment = $objp->paiement_type;
594
595 if ($objp->bid) {
596 $accountstatic->fetch($objp->bid);
597 $paymentexpensereportstatic->fk_bank = $accountstatic->id;
598 } else {
599 $paymentexpensereportstatic->fk_bank = 0;
600 }
601
602 $userstatic->id = $objp->userid;
603 $userstatic->lastname = $objp->lastname;
604 $userstatic->firstname = $objp->firstname;
605 $userstatic->login = $objp->login;
606 $userstatic->email = $objp->email;
607 $userstatic->photo = $objp->photo;
608
609 if ($mode == 'kanban') {
610 if ($i == 0) {
611 print '<tr class="trkanban"><td colspan="'.$savnbfield.'">';
612 print '<div class="box-flex-container kanban">';
613 }
614 // Output Kanban
615 print $paymentexpensereportstatic->getKanbanView('', array('selected' => in_array($objp->id, $arrayofselected)));
616 if ($i == ($imaxinloop - 1)) {
617 print '</div>';
618 print '</td></tr>';
619 }
620 } else {
621 // Show line of result
622 $j = 0;
623 print '<tr data-rowid="'.$object->id.'" class="oddeven">';
624
625 // Action column
626 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
627 print '<td class="nowrap center">';
628 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
629 $selected = 0;
630 if (in_array($object->id, $arrayofselected)) {
631 $selected = 1;
632 }
633 print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
634 }
635 print '</td>';
636 if (!$i) {
637 $totalarray['nbfield']++;
638 }
639 }
640
641 // No of line (not ref or ID)
642 if (!empty($arrayfields['i']['checked'])) {
643 print '<td>#'.(($offset * $limit) + $i).'</td>';
644 if (!$i) {
645 $totalarray['nbfield']++;
646 }
647 }
648
649 // Ref
650 if (!empty($arrayfields['pndf.rowid']['checked'])) {
651 print '<td class="nowrap">'.$paymentexpensereportstatic->getNomUrl(1).'</td>';
652 if (!$i) {
653 $totalarray['nbfield']++;
654 }
655 }
656
657 // Date
658 if (!empty($arrayfields['pndf.datep']['checked'])) {
659 $dateformatforpayment = 'dayhour';
660 print '<td class="nowrap center">'.dol_print_date($db->jdate($objp->datep), $dateformatforpayment).'</td>';
661 if (!$i) {
662 $totalarray['nbfield']++;
663 }
664 }
665
666 // Thirdparty
667 if (!empty($arrayfields['u.login']['checked'])) {
668 print '<td>';
669 if ($userstatic->id > 0) {
670 print $userstatic->getNomUrl(-1);
671 }
672 print '</td>';
673 if (!$i) {
674 $totalarray['nbfield']++;
675 }
676 }
677
678 // Pyament type
679 if (!empty($arrayfields['c.libelle']['checked'])) {
680 $payment_type = $langs->trans("PaymentType".$objp->paiement_type) != "PaymentType".$objp->paiement_type ? $langs->trans("PaymentType".$objp->paiement_type) : $objp->paiement_libelle;
681 print '<td>'.$payment_type.' '.dol_trunc($objp->num_payment, 32).'</td>';
682 if (!$i) {
683 $totalarray['nbfield']++;
684 }
685 }
686
687 // Cheque number (fund transfer)
688 if (!empty($arrayfields['pndf.num_payment']['checked'])) {
689 print '<td>'.$objp->num_payment.'</td>';
690 if (!$i) {
691 $totalarray['nbfield']++;
692 }
693 }
694
695 // Bank account
696 if (!empty($arrayfields['ba.label']['checked'])) {
697 print '<td>';
698 if ($objp->bid) {
699 $accountstatic->id = $objp->bid;
700 $accountstatic->ref = $objp->bref;
701 $accountstatic->label = $objp->blabel;
702 $accountstatic->number = $objp->number;
703 $accountstatic->iban = $objp->iban_prefix;
704 $accountstatic->bic = $objp->bic;
705 $accountstatic->currency_code = $objp->currency_code;
706 $accountstatic->account_number = $objp->account_number;
707
708 $accountingjournal = new AccountingJournal($db);
709 $accountingjournal->fetch($objp->accountancy_journal);
710 $accountstatic->accountancy_journal = $accountingjournal->code;
711
712 print $accountstatic->getNomUrl(1);
713 } else {
714 print '&nbsp;';
715 }
716 print '</td>';
717 if (!$i) {
718 $totalarray['nbfield']++;
719 }
720 }
721
722 // Amount
723 if (!empty($arrayfields['pndf.amount']['checked'])) {
724 print '<td class="right"><span class="amount">'.price($objp->pamount).'</span></td>';
725 if (!$i) {
726 $totalarray['nbfield']++;
727 }
728 $totalarray['pos'][$checkedCount] = 'amount';
729 if (empty($totalarray['val']['amount'])) {
730 $totalarray['val']['amount'] = $objp->pamount;
731 } else {
732 $totalarray['val']['amount'] += $objp->pamount;
733 }
734 }
735
736 // Action column
737 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
738 print '<td class="nowrap center">';
739 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
740 $selected = 0;
741 if (in_array($object->id, $arrayofselected)) {
742 $selected = 1;
743 }
744 print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
745 }
746 print '</td>';
747 if (!$i) {
748 $totalarray['nbfield']++;
749 }
750 }
751
752 print '</tr>'."\n";
753 }
754
755 $i++;
756}
757
758// Show total line
759include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
760
761// If no record found
762if ($num == 0) {
763 $colspan = 1;
764 foreach ($arrayfields as $key => $val) {
765 if (!empty($val['checked'])) {
766 $colspan++;
767 }
768 }
769 print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
770}
771
772$db->free($resql);
773
774$parameters = array('arrayfields' => $arrayfields, 'sql' => $sql);
775$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
776print $hookmanager->resPrint;
777
778print '</table>'."\n";
779print '</div>'."\n";
780
781print '</form>'."\n";
782
783// End of page
784llxFooter();
785$db->close();
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:66
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.
llxFooter()
Footer empty.
Definition document.php:107
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.