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