dolibarr 19.0.4
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 *
16 * This program is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License as published by
18 * the Free Software Foundation; either version 3 of the License, or
19 * (at your option) any later version.
20 *
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
25 *
26 * You should have received a copy of the GNU General Public License
27 * along with this program. If not, see <https://www.gnu.org/licenses/>.
28 */
29
36// Load Dolibarr environment
37require '../../main.inc.php';
38require_once DOL_DOCUMENT_ROOT.'/expensereport/class/paymentexpensereport.class.php';
39require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
40require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
41require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
42require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php';
43
44// Load translation files required by the page
45$langs->loadLangs(array('expensereports', 'bills', 'banks', 'compta'));
46
47$action = GETPOST('action', 'alpha');
48$massaction = GETPOST('massaction', 'alpha');
49$optioncss = GETPOST('optioncss', 'alpha');
50$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'vendorpaymentlist';
51$mode = GETPOST('mode', 'alpha');
52
53$socid = GETPOST('socid', 'int');
54
55// Security check
56if ($user->socid) {
57 $socid = $user->socid;
58}
59
60$search_ref = GETPOST('search_ref', 'alpha');
61$search_date_startday = GETPOST('search_date_startday', 'int');
62$search_date_startmonth = GETPOST('search_date_startmonth', 'int');
63$search_date_startyear = GETPOST('search_date_startyear', 'int');
64$search_date_endday = GETPOST('search_date_endday', 'int');
65$search_date_endmonth = GETPOST('search_date_endmonth', 'int');
66$search_date_endyear = GETPOST('search_date_endyear', 'int');
67$search_date_start = dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear); // Use tzserver
68$search_date_end = dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear);
69$search_user = GETPOST('search_user', 'alpha');
70$search_payment_type = GETPOST('search_payment_type');
71$search_cheque_num = GETPOST('search_cheque_num', 'alpha');
72$search_bank_account = GETPOST('search_bank_account', 'int');
73$search_amount = GETPOST('search_amount', 'alpha'); // alpha because we must be able to search on '< x'
74
75$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
76$sortfield = GETPOST('sortfield', 'aZ09comma');
77$sortorder = GETPOST('sortorder', 'aZ09comma');
78$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST('page', 'int');
79
80if (empty($page) || $page == -1) {
81 $page = 0; // If $page is not defined, or '' or -1
82}
83$offset = $limit * $page;
84$pageprev = $page - 1;
85$pagenext = $page + 1;
86
87if (!$sortorder) {
88 $sortorder = "DESC";
89}
90if (!$sortfield) {
91 $sortfield = "pndf.datep";
92}
93
94$search_all = trim(GETPOSTISSET("search_all") ? GETPOST("search_all", 'alpha') : GETPOST('sall'));
95
96// List of fields to search into when doing a "search in all"
97$fieldstosearchall = array(
98 'pndf.rowid'=>"RefPayment",
99 'u.login'=>"User",
100 'pndf.num_payment'=>"Numero",
101 'pndf.amount'=>"Amount",
102);
103
104$arrayfields = array(
105 'pndf.rowid' =>array('label'=>"RefPayment", 'checked'=>1, 'position'=>10),
106 'pndf.datep' =>array('label'=>"Date", 'checked'=>1, 'position'=>20),
107 'u.login' =>array('label'=>"User", 'checked'=>1, 'position'=>30),
108 'c.libelle' =>array('label'=>"Type", 'checked'=>1, 'position'=>40),
109 'pndf.num_payment' =>array('label'=>"Numero", 'checked'=>1, 'position'=>50, 'tooltip'=>"ChequeOrTransferNumber"),
110 'ba.label' =>array('label'=>"Account", 'checked'=>1, 'position'=>60, 'enable'=>(isModEnabled("banque"))),
111 'pndf.amount' =>array('label'=>"Amount", 'checked'=>1, 'position'=>70),
112);
113$arrayfields = dol_sort_array($arrayfields, 'position');
114
115// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
116$hookmanager->initHooks(array('paymentexpensereportlist'));
117$object = new PaymentExpenseReport($db);
118
119// Security check
120if ($user->socid) {
121 $socid = $user->socid;
122}
123
124// doesn't work :-(
125// restrictedArea($user, 'fournisseur');
126// doesn't work :-(
127// require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php';
128// $object = new PaiementFourn($db);
129// restrictedArea($user, $object->element);
130if (!$user->hasRight('expensereport', 'lire')) {
132}
133
134
135/*
136 * Actions
137 */
138
139$childids = $user->getAllChildIds(1);
140
141$parameters = array('socid'=>$socid);
142$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
143if ($reshook < 0) {
144 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
145}
146
147if (empty($reshook)) {
148 include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
149
150 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
151 $search_ref = '';
152 $search_date_startday = '';
153 $search_date_startmonth = '';
154 $search_date_startyear = '';
155 $search_date_endday = '';
156 $search_date_endmonth = '';
157 $search_date_endyear = '';
158 $search_date_start = '';
159 $search_date_end = '';
160 $search_user = '';
161 $search_payment_type = '';
162 $search_cheque_num = '';
163 $search_bank_account = '';
164 $search_amount = '';
165 }
166}
167
168/*
169 * View
170 */
171
172llxHeader('', $langs->trans('ListPayment'));
173
174$form = new Form($db);
175$formother = new FormOther($db);
176$accountstatic = new Account($db);
177$userstatic = new User($db);
178$paymentexpensereportstatic = new PaymentExpenseReport($db);
179
180$sql = 'SELECT pndf.rowid, pndf.rowid as ref, pndf.datep, pndf.amount as pamount, pndf.num_payment';
181$sql .= ', u.rowid as userid, u.login, u.lastname, u.firstname';
182$sql .= ', c.code as paiement_type, c.libelle as paiement_libelle';
183$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';
184$sql .= ', SUM(pndf.amount)';
185$sql .= ' FROM '.MAIN_DB_PREFIX.'payment_expensereport AS pndf';
186$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'expensereport AS ndf ON ndf.rowid=pndf.fk_expensereport';
187$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement AS c ON pndf.fk_typepayment = c.id';
188$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'user AS u ON u.rowid = ndf.fk_user_author';
189$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON pndf.fk_bank = b.rowid';
190$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank_account as ba ON b.fk_account = ba.rowid';
191$sql .= ' WHERE ndf.entity IN ('.getEntity("expensereport").')';
192
193// RESTRICT RIGHTS
194if (!$user->hasRight('expensereport', 'readall') && !$user->hasRight('expensereport', 'lire_tous')
195 && (!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') || !$user->hasRight('expensereport', 'writeall_advance'))) {
196 $sql .= " AND ndf.fk_user_author IN (".$db->sanitize(join(',', $childids)).")\n";
197}
198
199if ($search_ref) {
200 $sql .= natural_search('pndf.rowid', $search_ref);
201}
202if ($search_date_start) {
203 $sql .= " AND pndf.datep >= '" . $db->idate($search_date_start) . "'";
204}
205if ($search_date_end) {
206 $sql .=" AND pndf.datep <= '" . $db->idate($search_date_end) . "'";
207}
208
209if ($search_user) {
210 $sql .= natural_search(array('u.login', 'u.lastname', 'u.firstname'), $search_user);
211}
212if ($search_payment_type != '') {
213 $sql .= " AND c.code='".$db->escape($search_payment_type)."'";
214}
215if ($search_cheque_num != '') {
216 $sql .= natural_search('pndf.num_payment', $search_cheque_num);
217}
218if ($search_amount) {
219 $sql .= natural_search('pndf.amount', $search_amount, 1);
220}
221if ($search_bank_account > 0) {
222 $sql .= ' AND b.fk_account = '.((int) $search_bank_account);
223}
224if ($search_all) {
225 $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
226}
227
228// Add where from extra fields
229include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
230
231$sql .= ' GROUP BY pndf.rowid, pndf.datep, pndf.amount, pndf.num_payment, u.rowid, u.login, u.lastname, u.firstname, c.code, c.libelle,';
232$sql .= ' ba.rowid, ba.ref, ba.label, ba.number, ba.account_number, ba.iban_prefix, ba.bic, ba.currency_code, ba.fk_accountancy_journal';
233
234$sql .= $db->order($sortfield, $sortorder);
235
236$nbtotalofrecords = '';
237if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
238 $result = $db->query($sql);
239 $nbtotalofrecords = $db->num_rows($result);
240 if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
241 $page = 0;
242 $offset = 0;
243 }
244}
245
246$sql .= $db->plimit($limit + 1, $offset);
247
248$resql = $db->query($sql);
249if (!$resql) {
250 dol_print_error($db);
251 llxFooter();
252 $db->close();
253 exit;
254}
255
256$num = $db->num_rows($resql);
257$i = 0;
258
259$param = '';
260if (!empty($mode)) {
261 $param .= '&mode='.urlencode($mode);
262}
263if (!empty($contextpage) && $contextpage != $_SERVER['PHP_SELF']) {
264 $param .= '&contextpage='.urlencode($contextpage);
265}
266if ($limit > 0 && $limit != $conf->liste_limit) {
267 $param .= '&limit='.((int) $limit);
268}
269if ($optioncss != '') {
270 $param .= '&optioncss='.urlencode($optioncss);
271}
272
273if ($search_ref) {
274 $param .= '&search_ref='.urlencode($search_ref);
275}
276if ($search_date_startday) {
277 $param .= '&search_date_startday='.urlencode($search_date_startday);
278}
279if ($search_date_startmonth) {
280 $param .= '&search_date_startmonth='.urlencode($search_date_startmonth);
281}
282if ($search_date_startyear) {
283 $param .= '&search_date_startyear='.urlencode($search_date_startyear);
284}
285if ($search_date_endday) {
286 $param .= '&search_date_endday='.urlencode($search_date_endday);
287}
288if ($search_date_endmonth) {
289 $param .= '&search_date_endmonth='.urlencode($search_date_endmonth);
290}
291if ($search_date_endyear) {
292 $param .= '&search_date_endyear='.urlencode($search_date_endyear);
293}
294if ($search_user) {
295 $param .= '&search_user='.urlencode($search_user);
296}
297if ($search_payment_type) {
298 $param .= '&search_payment_type='.urlencode($search_payment_type);
299}
300if ($search_cheque_num) {
301 $param .= '&search_cheque_num='.urlencode($search_cheque_num);
302}
303if ($search_amount) {
304 $param .= '&search_amount='.urlencode($search_amount);
305}
306
307if ($search_bank_account) {
308 $param .= '&search_bank_account='.urlencode($search_bank_account);
309}
310
311// Add $param from extra fields
312include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
313
314print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
315if ($optioncss != '') {
316 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
317}
318print '<input type="hidden" name="token" value="'.newToken().'">';
319print '<input type="hidden" name="action" value="list">';
320print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
321print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
322print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
323print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
324print '<input type="hidden" name="mode" value="'.$mode.'">';
325
326$newcardbutton = '';
327$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'));
328$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'));
329
330print_barre_liste($langs->trans('ExpenseReportPayments'), $page, $_SERVER['PHP_SELF'], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'expensereport', 0, $newcardbutton, '', $limit, 0, 0, 1);
331
332if ($search_all) {
333 foreach ($fieldstosearchall as $key => $val) {
334 $fieldstosearchall[$key] = $langs->trans($val);
335 }
336 print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'</div>';
337}
338
339$moreforfilter = '';
340
341$parameters = array();
342$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook
343if (empty($reshook)) {
344 $moreforfilter .= $hookmanager->resPrint;
345} else {
346 $moreforfilter = $hookmanager->resPrint;
347}
348
349if ($moreforfilter) {
350 print '<div class="liste_titre liste_titre_bydiv centpercent">';
351 print $moreforfilter;
352 print '</div>';
353}
354
355$arrayofmassactions = array();
356
357$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
358$selectedfields = ($mode != 'kanban' ? $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN', '')) : ''); // This also change content of $arrayfields
359$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
360
361print '<div class="div-table-responsive">';
362print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : '').'">';
363
364print '<tr class="liste_titre_filter">';
365
366// Action column
367if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
368 print '<td class="liste_titre maxwidthsearch">';
369 print $form->showFilterAndCheckAddButtons(0);
370 print '</td>';
371}
372
373// Filter: Ref
374if (!empty($arrayfields['pndf.rowid']['checked'])) {
375 print '<td class="liste_titre left">';
376 print '<input class="flat" type="text" size="4" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
377 print '</td>';
378}
379
380// Filter: Date
381if (!empty($arrayfields['pndf.datep']['checked'])) {
382 print '<td class="liste_titre center">';
383 print '<div class="nowrapfordate">';
384 print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
385 print '</div>';
386 print '<div class="nowrapfordate">';
387 print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
388 print '</div>';
389 print '</td>';
390}
391
392// Filter: Thirdparty
393if (!empty($arrayfields['u.login']['checked'])) {
394 print '<td class="liste_titre">';
395 print '<input class="flat" type="text" size="6" name="search_user" value="'.dol_escape_htmltag($search_user).'">';
396 print '</td>';
397}
398
399// Filter: Payment type
400if (!empty($arrayfields['c.libelle']['checked'])) {
401 print '<td class="liste_titre">';
402 $form->select_types_paiements($search_payment_type, 'search_payment_type', '', 2, 1, 1);
403 print '</td>';
404}
405
406// Filter: Cheque number (fund transfer)
407if (!empty($arrayfields['pndf.num_payment']['checked'])) {
408 print '<td class="liste_titre">';
409 print '<input class="flat" type="text" size="4" name="search_cheque_num" value="'.dol_escape_htmltag($search_cheque_num).'">';
410 print '</td>';
411}
412
413// Filter: Bank account
414if (!empty($arrayfields['ba.label']['checked'])) {
415 print '<td class="liste_titre">';
416 $form->select_comptes($search_bank_account, 'search_bank_account', 0, '', 1);
417 print '</td>';
418}
419
420// Filter: Amount
421if (!empty($arrayfields['pndf.amount']['checked'])) {
422 print '<td class="liste_titre right">';
423 print '<input class="flat" type="text" size="4" name="search_amount" value="'.dol_escape_htmltag($search_amount).'">';
424 print '</td>';
425}
426
427// Fields from hook
428$parameters = array('arrayfields'=>$arrayfields);
429$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
430print $hookmanager->resPrint;
431
432// Action column
433if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
434 print '<td class="liste_titre maxwidthsearch">';
435 print $form->showFilterAndCheckAddButtons(0);
436 print '</td>';
437}
438
439print '</tr>';
440
441$totalarray = array();
442$totalarray['nbfield'] = 0;
443
444print '<tr class="liste_titre">';
445// Action column
446if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
447 print_liste_field_titre($selectedfields, $_SERVER['PHP_SELF'], '', '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ');
448 $totalarray['nbfield']++;
449}
450if (getDolGlobalString('MAIN_VIEW_LINE_NUMBER_IN_LIST')) {
451 print_liste_field_titre('#', $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder);
452 $totalarray['nbfield']++;
453}
454if (!empty($arrayfields['pndf.rowid']['checked'])) {
455 print_liste_field_titre($arrayfields['pndf.rowid']['label'], $_SERVER["PHP_SELF"], 'pndf.rowid', '', $param, '', $sortfield, $sortorder);
456 $totalarray['nbfield']++;
457}
458if (!empty($arrayfields['pndf.datep']['checked'])) {
459 print_liste_field_titre($arrayfields['pndf.datep']['label'], $_SERVER["PHP_SELF"], 'pndf.datep', '', $param, '', $sortfield, $sortorder, 'center ');
460 $totalarray['nbfield']++;
461}
462if (!empty($arrayfields['u.login']['checked'])) {
463 print_liste_field_titre($arrayfields['u.login']['label'], $_SERVER["PHP_SELF"], 'u.lastname', '', $param, '', $sortfield, $sortorder);
464 $totalarray['nbfield']++;
465}
466if (!empty($arrayfields['c.libelle']['checked'])) {
467 print_liste_field_titre($arrayfields['c.libelle']['label'], $_SERVER["PHP_SELF"], 'c.libelle', '', $param, '', $sortfield, $sortorder);
468 $totalarray['nbfield']++;
469}
470if (!empty($arrayfields['pndf.num_payment']['checked'])) {
471 print_liste_field_titre($arrayfields['pndf.num_payment']['label'], $_SERVER["PHP_SELF"], "pndf.num_payment", '', $param, '', $sortfield, $sortorder, '', $arrayfields['pndf.num_payment']['tooltip']);
472 $totalarray['nbfield']++;
473}
474if (!empty($arrayfields['ba.label']['checked'])) {
475 print_liste_field_titre($arrayfields['ba.label']['label'], $_SERVER["PHP_SELF"], 'ba.label', '', $param, '', $sortfield, $sortorder);
476 $totalarray['nbfield']++;
477}
478if (!empty($arrayfields['pndf.amount']['checked'])) {
479 print_liste_field_titre($arrayfields['pndf.amount']['label'], $_SERVER["PHP_SELF"], 'pndf.amount', '', $param, '', $sortfield, $sortorder, 'right ');
480 $totalarray['nbfield']++;
481}
482
483// Hook fields
484$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder, 'totalarray'=>&$totalarray);
485$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
486print $hookmanager->resPrint;
487// Action column
488if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
489 print_liste_field_titre($selectedfields, $_SERVER['PHP_SELF'], '', '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ');
490 $totalarray['nbfield']++;
491}
492print '</tr>';
493
494$checkedCount = 0;
495foreach ($arrayfields as $column) {
496 if ($column['checked']) {
497 $checkedCount++;
498 }
499}
500
501// Loop on record
502// --------------------------------------------------------------------
503$i = 0;
504$savnbfield = $totalarray['nbfield'];
505$totalarray = array();
506$totalarray['nbfield'] = 0;
507$imaxinloop = ($limit ? min($num, $limit) : $num);
508while ($i < $imaxinloop) {
509 $objp = $db->fetch_object($resql);
510
511 $paymentexpensereportstatic->id = $objp->rowid;
512 $paymentexpensereportstatic->ref = $objp->ref;
513 $paymentexpensereportstatic->datep = $db->jdate($objp->datep);
514 $paymentexpensereportstatic->amount = $objp->pamount;
515 $paymentexpensereportstatic->fk_typepayment = $objp->paiement_type;
516
517 if ($objp->bid) {
518 $accountstatic->fetch($objp->bid);
519 $paymentexpensereportstatic->fk_bank = $accountstatic->getNomUrl(1);
520 } else {
521 $paymentexpensereportstatic->fk_bank = null;
522 }
523
524 $userstatic->id = $objp->userid;
525 $userstatic->lastname = $objp->lastname;
526 $userstatic->firstname = $objp->firstname;
527
528 if ($mode == 'kanban') {
529 if ($i == 0) {
530 print '<tr class="trkanban"><td colspan="'.$savnbfield.'">';
531 print '<div class="box-flex-container kanban">';
532 }
533 // Output Kanban
534 print $paymentexpensereportstatic->getKanbanView('', array('selected' => in_array($objp->id, $arrayofselected)));
535 if ($i == ($imaxinloop - 1)) {
536 print '</div>';
537 print '</td></tr>';
538 }
539 } else {
540 print '<tr class="oddeven">';
541
542 // Action column
543 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
544 print '<td></td>';
545 if (!$i) {
546 $totalarray['nbfield']++;
547 }
548 }
549
550 // No
551 if (getDolGlobalString('MAIN_VIEW_LINE_NUMBER_IN_LIST')) {
552 print '<td>'.(($offset * $limit) + $i).'</td>';
553 if (!$i) {
554 $totalarray['nbfield']++;
555 }
556 }
557
558 // Ref
559 if (!empty($arrayfields['pndf.rowid']['checked'])) {
560 print '<td class="nowrap">'.$paymentexpensereportstatic->getNomUrl(1).'</td>';
561 if (!$i) {
562 $totalarray['nbfield']++;
563 }
564 }
565
566 // Date
567 if (!empty($arrayfields['pndf.datep']['checked'])) {
568 $dateformatforpayment = 'dayhour';
569 print '<td class="nowrap center">'.dol_print_date($db->jdate($objp->datep), $dateformatforpayment).'</td>';
570 if (!$i) {
571 $totalarray['nbfield']++;
572 }
573 }
574
575 // Thirdparty
576 if (!empty($arrayfields['u.login']['checked'])) {
577 print '<td>';
578 if ($userstatic->id > 0) {
579 print $userstatic->getNomUrl(1);
580 }
581 print '</td>';
582 if (!$i) {
583 $totalarray['nbfield']++;
584 }
585 }
586
587 // Pyament type
588 if (!empty($arrayfields['c.libelle']['checked'])) {
589 $payment_type = $langs->trans("PaymentType".$objp->paiement_type) != "PaymentType".$objp->paiement_type ? $langs->trans("PaymentType".$objp->paiement_type) : $objp->paiement_libelle;
590 print '<td>'.$payment_type.' '.dol_trunc($objp->num_payment, 32).'</td>';
591 if (!$i) {
592 $totalarray['nbfield']++;
593 }
594 }
595
596 // Cheque number (fund transfer)
597 if (!empty($arrayfields['pndf.num_payment']['checked'])) {
598 print '<td>'.$objp->num_payment.'</td>';
599 if (!$i) {
600 $totalarray['nbfield']++;
601 }
602 }
603
604 // Bank account
605 if (!empty($arrayfields['ba.label']['checked'])) {
606 print '<td>';
607 if ($objp->bid) {
608 $accountstatic->id = $objp->bid;
609 $accountstatic->ref = $objp->bref;
610 $accountstatic->label = $objp->blabel;
611 $accountstatic->number = $objp->number;
612 $accountstatic->iban = $objp->iban_prefix;
613 $accountstatic->bic = $objp->bic;
614 $accountstatic->currency_code = $objp->currency_code;
615 $accountstatic->account_number = $objp->account_number;
616
617 $accountingjournal = new AccountingJournal($db);
618 $accountingjournal->fetch($objp->accountancy_journal);
619 $accountstatic->accountancy_journal = $accountingjournal->code;
620
621 print $accountstatic->getNomUrl(1);
622 } else {
623 print '&nbsp;';
624 }
625 print '</td>';
626 if (!$i) {
627 $totalarray['nbfield']++;
628 }
629 }
630
631 // Amount
632 if (!empty($arrayfields['pndf.amount']['checked'])) {
633 print '<td class="right"><span class="amount">'.price($objp->pamount).'</span></td>';
634 if (!$i) {
635 $totalarray['nbfield']++;
636 }
637 $totalarray['pos'][$checkedCount] = 'amount';
638 if (empty($totalarray['val']['amount'])) {
639 $totalarray['val']['amount'] = $objp->pamount;
640 } else {
641 $totalarray['val']['amount'] += $objp->pamount;
642 }
643 }
644
645 // Action column
646 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
647 print '<td></td>';
648 if (!$i) {
649 $totalarray['nbfield']++;
650 }
651 }
652
653 print '</tr>';
654 }
655 $i++;
656}
657
658// Show total line
659include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
660
661print '</table>';
662print '</div>';
663print '</form>';
664
665// End of page
666llxFooter();
667$db->close();
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Definition wrapper.php:55
llxFooter()
Empty footer.
Definition wrapper.php:69
Class to manage bank accounts.
Class to manage accounting journals.
Class to manage generation of HTML components Only common components must be here.
Classe 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 informations (by default a local PHP server timestamp) Re...
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
natural_search($fields, $value, $mode=0, $nofirstand=0)
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
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 second index function, which produces ascending (default) or descending output...
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
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.