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