dolibarr  19.0.0-dev
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
37 require '../../main.inc.php';
38 require_once DOL_DOCUMENT_ROOT.'/expensereport/class/paymentexpensereport.class.php';
39 require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
40 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
41 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
42 require_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
56 if ($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 
78 if (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 
85 if (!$sortorder) {
86  $sortorder = "DESC";
87 }
88 if (!$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
118 if ($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);
128 if (empty($user->rights->expensereport->lire)) {
129  accessforbidden();
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
141 if ($reshook < 0) {
142  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
143 }
144 
145 if (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 
170 llxHeader('', $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
192 if (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 
197 if ($search_ref) {
198  $sql .= natural_search('pndf.rowid', $search_ref);
199 }
200 if ($search_date_start) {
201  $sql .= " AND pndf.datep >= '" . $db->idate($search_date_start) . "'";
202 }
203 if ($search_date_end) {
204  $sql .=" AND pndf.datep <= '" . $db->idate($search_date_end) . "'";
205 }
206 
207 if ($search_user) {
208  $sql .= natural_search(array('u.login', 'u.lastname', 'u.firstname'), $search_user);
209 }
210 if ($search_payment_type != '') {
211  $sql .= " AND c.code='".$db->escape($search_payment_type)."'";
212 }
213 if ($search_cheque_num != '') {
214  $sql .= natural_search('pndf.num_payment', $search_cheque_num);
215 }
216 if ($search_amount) {
217  $sql .= natural_search('pndf.amount', $search_amount, 1);
218 }
219 if ($search_bank_account > 0) {
220  $sql .= ' AND b.fk_account = '.((int) $search_bank_account);
221 }
222 if ($search_all) {
223  $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
224 }
225 
226 // Add where from extra fields
227 include 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 = '';
235 if (!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);
247 if (!$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 = '';
258 if (!empty($mode)) {
259  $param .= '&mode='.urlencode($mode);
260 }
261 if (!empty($contextpage) && $contextpage != $_SERVER['PHP_SELF']) {
262  $param .= '&contextpage='.urlencode($contextpage);
263 }
264 if ($limit > 0 && $limit != $conf->liste_limit) {
265  $param .= '&limit='.((int) $limit);
266 }
267 if ($optioncss != '') {
268  $param .= '&optioncss='.urlencode($optioncss);
269 }
270 
271 if ($search_ref) {
272  $param .= '&search_ref='.urlencode($search_ref);
273 }
274 if ($search_date_startday) {
275  $param .= '&search_date_startday='.urlencode($search_date_startday);
276 }
277 if ($search_date_startmonth) {
278  $param .= '&search_date_startmonth='.urlencode($search_date_startmonth);
279 }
280 if ($search_date_startyear) {
281  $param .= '&search_date_startyear='.urlencode($search_date_startyear);
282 }
283 if ($search_date_endday) {
284  $param .= '&search_date_endday='.urlencode($search_date_endday);
285 }
286 if ($search_date_endmonth) {
287  $param .= '&search_date_endmonth='.urlencode($search_date_endmonth);
288 }
289 if ($search_date_endyear) {
290  $param .= '&search_date_endyear='.urlencode($search_date_endyear);
291 }
292 if ($search_user) {
293  $param .= '&search_user='.urlencode($search_user);
294 }
295 if ($search_payment_type) {
296  $param .= '&search_payment_type='.urlencode($search_payment_type);
297 }
298 if ($search_cheque_num) {
299  $param .= '&search_cheque_num='.urlencode($search_cheque_num);
300 }
301 if ($search_amount) {
302  $param .= '&search_amount='.urlencode($search_amount);
303 }
304 
305 if ($search_bank_account) {
306  $param .= '&search_bank_account='.urlencode($search_bank_account);
307 }
308 
309 // Add $param from extra fields
310 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
311 
312 print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
313 if ($optioncss != '') {
314  print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
315 }
316 print '<input type="hidden" name="token" value="'.newToken().'">';
317 print '<input type="hidden" name="action" value="list">';
318 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
319 print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
320 print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
321 print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
322 print '<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 
328 print_barre_liste($langs->trans('ExpenseReportPayments'), $page, $_SERVER['PHP_SELF'], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'expensereport', 0, $newcardbutton, '', $limit, 0, 0, 1);
329 
330 if ($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
341 if (empty($reshook)) {
342  $moreforfilter .= $hookmanager->resPrint;
343 } else {
344  $moreforfilter = $hookmanager->resPrint;
345 }
346 
347 if ($moreforfilter) {
348  print '<div class="liste_titre liste_titre_bydiv centpercent">';
349  print $moreforfilter;
350  print '</div>';
351 }
352 
353 $varpage = empty($contextpage) ? $_SERVER['PHP_SELF'] : $contextpage;
354 $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
355 if (!empty($massactionbutton)) {
356  $selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
357 }
358 
359 print '<div class="div-table-responsive">';
360 print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : '').'">';
361 
362 print '<tr class="liste_titre_filter">';
363 
364 // Filter: Ref
365 if (!empty($arrayfields['pndf.rowid']['checked'])) {
366  print '<td class="liste_titre left">';
367  print '<input class="flat" type="text" size="4" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
368  print '</td>';
369 }
370 
371 // Filter: Date
372 if (!empty($arrayfields['pndf.datep']['checked'])) {
373  print '<td class="liste_titre center">';
374  print '<div class="nowrap">';
375  print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
376  print '</div>';
377  print '<div class="nowrap">';
378  print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
379  print '</div>';
380  print '</td>';
381 }
382 
383 // Filter: Thirdparty
384 if (!empty($arrayfields['u.login']['checked'])) {
385  print '<td class="liste_titre">';
386  print '<input class="flat" type="text" size="6" name="search_user" value="'.dol_escape_htmltag($search_user).'">';
387  print '</td>';
388 }
389 
390 // Filter: Payment type
391 if (!empty($arrayfields['c.libelle']['checked'])) {
392  print '<td class="liste_titre">';
393  $form->select_types_paiements($search_payment_type, 'search_payment_type', '', 2, 1, 1);
394  print '</td>';
395 }
396 
397 // Filter: Cheque number (fund transfer)
398 if (!empty($arrayfields['pndf.num_payment']['checked'])) {
399  print '<td class="liste_titre">';
400  print '<input class="flat" type="text" size="4" name="search_cheque_num" value="'.dol_escape_htmltag($search_cheque_num).'">';
401  print '</td>';
402 }
403 
404 // Filter: Bank account
405 if (!empty($arrayfields['ba.label']['checked'])) {
406  print '<td class="liste_titre">';
407  $form->select_comptes($search_bank_account, 'search_bank_account', 0, '', 1);
408  print '</td>';
409 }
410 
411 // Filter: Amount
412 if (!empty($arrayfields['pndf.amount']['checked'])) {
413  print '<td class="liste_titre right">';
414  print '<input class="flat" type="text" size="4" name="search_amount" value="'.dol_escape_htmltag($search_amount).'">';
415  print '</td>';
416 }
417 
418 // Fields from hook
419 $parameters = array('arrayfields'=>$arrayfields);
420 $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
421 print $hookmanager->resPrint;
422 
423 // Buttons
424 print '<td class="liste_titre maxwidthsearch">';
425 print $form->showFilterAndCheckAddButtons(0);
426 print '</td>';
427 
428 print '</tr>';
429 
430 $totalarray = array();
431 $totalarray['nbfield'] = 0;
432 
433 print '<tr class="liste_titre">';
434 if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) {
435  print_liste_field_titre('#', $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder);
436 }
437 if (!empty($arrayfields['pndf.rowid']['checked'])) {
438  print_liste_field_titre($arrayfields['pndf.rowid']['label'], $_SERVER["PHP_SELF"], 'pndf.rowid', '', $param, '', $sortfield, $sortorder);
439 }
440 if (!empty($arrayfields['pndf.datep']['checked'])) {
441  print_liste_field_titre($arrayfields['pndf.datep']['label'], $_SERVER["PHP_SELF"], 'pndf.datep', '', $param, '', $sortfield, $sortorder, 'center ');
442 }
443 if (!empty($arrayfields['u.login']['checked'])) {
444  print_liste_field_titre($arrayfields['u.login']['label'], $_SERVER["PHP_SELF"], 'u.lastname', '', $param, '', $sortfield, $sortorder);
445 }
446 if (!empty($arrayfields['c.libelle']['checked'])) {
447  print_liste_field_titre($arrayfields['c.libelle']['label'], $_SERVER["PHP_SELF"], 'c.libelle', '', $param, '', $sortfield, $sortorder);
448 }
449 if (!empty($arrayfields['pndf.num_payment']['checked'])) {
450  print_liste_field_titre($arrayfields['pndf.num_payment']['label'], $_SERVER["PHP_SELF"], "pndf.num_payment", '', $param, '', $sortfield, $sortorder, '', $arrayfields['pndf.num_payment']['tooltip']);
451 }
452 if (!empty($arrayfields['ba.label']['checked'])) {
453  print_liste_field_titre($arrayfields['ba.label']['label'], $_SERVER["PHP_SELF"], 'ba.label', '', $param, '', $sortfield, $sortorder);
454 }
455 if (!empty($arrayfields['pndf.amount']['checked'])) {
456  print_liste_field_titre($arrayfields['pndf.amount']['label'], $_SERVER["PHP_SELF"], 'pndf.amount', '', $param, '', $sortfield, $sortorder, 'right ');
457 }
458 
459 // Hook fields
460 $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
461 $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
462 print $hookmanager->resPrint;
463 
464 print_liste_field_titre($selectedfields, $_SERVER['PHP_SELF'], '', '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ');
465 print '</tr>';
466 
467 $checkedCount = 0;
468 foreach ($arrayfields as $column) {
469  if ($column['checked']) {
470  $checkedCount++;
471  }
472 }
473 
474 // Loop on record
475 // --------------------------------------------------------------------
476 $i = 0;
477 $savnbfield = $totalarray['nbfield'];
478 $totalarray = array();
479 $totalarray['nbfield'] = 0;
480 $imaxinloop = ($limit ? min($num, $limit) : $num);
481 while ($i < $imaxinloop) {
482  $objp = $db->fetch_object($resql);
483 
484  $paymentexpensereportstatic->id = $objp->rowid;
485  $paymentexpensereportstatic->ref = $objp->ref;
486  $paymentexpensereportstatic->datep = $db->jdate($objp->datep);
487  $paymentexpensereportstatic->amount = $objp->pamount;
488  $paymentexpensereportstatic->fk_typepayment = $objp->paiement_type;
489 
490  if ($objp->bid) {
491  $accountstatic->fetch($objp->bid);
492  $paymentexpensereportstatic->fk_bank = $accountstatic->getNomUrl(1);
493  } else {
494  $paymentexpensereportstatic->fk_bank = null;
495  }
496 
497  $userstatic->id = $objp->userid;
498  $userstatic->lastname = $objp->lastname;
499  $userstatic->firstname = $objp->firstname;
500 
501  if ($mode == 'kanban') {
502  if ($i == 0) {
503  print '<tr class="trkanban"><td colspan="'.$savnbfield.'">';
504  print '<div class="box-flex-container kanban">';
505  }
506  // Output Kanban
507  print $paymentexpensereportstatic->getKanbanView('', array('selected' => in_array($objp->id, $arrayofselected)));
508  if ($i == ($imaxinloop - 1)) {
509  print '</div>';
510  print '</td></tr>';
511  }
512  } else {
513  print '<tr class="oddeven">';
514 
515  // No
516  if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) {
517  print '<td>'.(($offset * $limit) + $i).'</td>';
518  if (!$i) {
519  $totalarray['nbfield']++;
520  }
521  }
522 
523  // Ref
524  if (!empty($arrayfields['pndf.rowid']['checked'])) {
525  print '<td class="nowrap">'.$paymentexpensereportstatic->getNomUrl(1).'</td>';
526  if (!$i) {
527  $totalarray['nbfield']++;
528  }
529  }
530 
531  // Date
532  if (!empty($arrayfields['pndf.datep']['checked'])) {
533  $dateformatforpayment = 'dayhour';
534  print '<td class="nowrap center">'.dol_print_date($db->jdate($objp->datep), $dateformatforpayment).'</td>';
535  if (!$i) {
536  $totalarray['nbfield']++;
537  }
538  }
539 
540  // Thirdparty
541  if (!empty($arrayfields['u.login']['checked'])) {
542  print '<td>';
543  if ($userstatic->id > 0) {
544  print $userstatic->getNomUrl(1);
545  }
546  print '</td>';
547  if (!$i) {
548  $totalarray['nbfield']++;
549  }
550  }
551 
552  // Pyament type
553  if (!empty($arrayfields['c.libelle']['checked'])) {
554  $payment_type = $langs->trans("PaymentType".$objp->paiement_type) != ("PaymentType".$objp->paiement_type) ? $langs->trans("PaymentType".$objp->paiement_type) : $objp->paiement_libelle;
555  print '<td>'.$payment_type.' '.dol_trunc($objp->num_payment, 32).'</td>';
556  if (!$i) {
557  $totalarray['nbfield']++;
558  }
559  }
560 
561  // Cheque number (fund transfer)
562  if (!empty($arrayfields['pndf.num_payment']['checked'])) {
563  print '<td>'.$objp->num_payment.'</td>';
564  if (!$i) {
565  $totalarray['nbfield']++;
566  }
567  }
568 
569  // Bank account
570  if (!empty($arrayfields['ba.label']['checked'])) {
571  print '<td>';
572  if ($objp->bid) {
573  $accountstatic->id = $objp->bid;
574  $accountstatic->ref = $objp->bref;
575  $accountstatic->label = $objp->blabel;
576  $accountstatic->number = $objp->number;
577  $accountstatic->iban = $objp->iban_prefix;
578  $accountstatic->bic = $objp->bic;
579  $accountstatic->currency_code = $objp->currency_code;
580  $accountstatic->account_number = $objp->account_number;
581 
582  $accountingjournal = new AccountingJournal($db);
583  $accountingjournal->fetch($objp->accountancy_journal);
584  $accountstatic->accountancy_journal = $accountingjournal->code;
585 
586  print $accountstatic->getNomUrl(1);
587  } else {
588  print '&nbsp;';
589  }
590  print '</td>';
591  if (!$i) {
592  $totalarray['nbfield']++;
593  }
594  }
595 
596  // Amount
597  if (!empty($arrayfields['pndf.amount']['checked'])) {
598  print '<td class="right"><span class="amount">'.price($objp->pamount).'</span></td>';
599  if (!$i) {
600  $totalarray['nbfield']++;
601  }
602  $totalarray['pos'][$checkedCount] = 'amount';
603  if (empty($totalarray['val']['amount'])) {
604  $totalarray['val']['amount'] = $objp->pamount;
605  } else {
606  $totalarray['val']['amount'] += $objp->pamount;
607  }
608  }
609 
610  // Buttons
611  print '<td></td>';
612  if (!$i) {
613  $totalarray['nbfield']++;
614  }
615 
616  print '</tr>';
617  }
618  $i++;
619 }
620 
621 // Show total line
622 include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
623 
624 print '</table>';
625 print '</div>';
626 print '</form>';
627 
628 // End of page
629 llxFooter();
630 $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 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.
Definition: user.class.php:48
if(isModEnabled('facture') && $user->hasRight('facture', 'lire')) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') && $user->hasRight('don', 'lire')) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $sql
Social contributions to pay.
Definition: index.php:746
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:143
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.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
isModEnabled($module)
Is Dolibarr module enabled.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.