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