dolibarr  20.0.0-alpha
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-2023 Alexandre Spangaro <aspangaro@easya.solutions>
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
38 require '../../main.inc.php';
39 require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php';
40 require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
41 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
42 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
43 require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php';
44 
45 // Load translation files required by the page
46 $langs->loadLangs(array('companies', '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', 'aZ');
53 
54 $socid = GETPOSTINT('socid');
55 
56 $search_ref = GETPOST('search_ref', 'alpha');
57 $search_date_startday = GETPOSTINT('search_date_startday');
58 $search_date_startmonth = GETPOSTINT('search_date_startmonth');
59 $search_date_startyear = GETPOSTINT('search_date_startyear');
60 $search_date_endday = GETPOSTINT('search_date_endday');
61 $search_date_endmonth = GETPOSTINT('search_date_endmonth');
62 $search_date_endyear = GETPOSTINT('search_date_endyear');
63 $search_date_start = dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear); // Use tzserver
64 $search_date_end = dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear);
65 $search_company = GETPOST('search_company', 'alpha');
66 $search_payment_type = GETPOST('search_payment_type', 'alpha');
67 $search_cheque_num = GETPOST('search_cheque_num', 'alpha');
68 $search_bank_account = GETPOST('search_bank_account', 'int');
69 $search_amount = GETPOST('search_amount', 'alpha'); // alpha because we must be able to search on '< x'
70 $search_sale = GETPOSTINT('search_sale');
71 
72 $limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
73 $sortfield = GETPOST('sortfield', 'aZ09comma');
74 $sortorder = GETPOST('sortorder', 'aZ09comma');
75 $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOSTINT('page');
76 
77 if (empty($page) || $page == -1) {
78  $page = 0; // If $page is not defined, or '' or -1
79 }
80 $offset = $limit * $page;
81 $pageprev = $page - 1;
82 $pagenext = $page + 1;
83 
84 if (!$sortorder) {
85  $sortorder = "DESC";
86 }
87 if (!$sortfield) {
88  $sortfield = "p.datep";
89 }
90 
91 $search_all = trim(GETPOSTISSET("search_all") ? GETPOST("search_all", 'alpha') : GETPOST('sall'));
92 
93 // List of fields to search into when doing a "search in all"
94 $fieldstosearchall = array(
95  'p.ref' => "RefPayment",
96  's.nom' => "ThirdParty",
97  'p.num_paiement' => "Numero",
98  'p.amount' => "Amount",
99 );
100 
101 $arrayfields = array(
102  'p.ref' => array('label' => "RefPayment", 'checked' => 1, 'position' => 10),
103  'p.datep' => array('label' => "Date", 'checked' => 1, 'position' => 20),
104  's.nom' => array('label' => "ThirdParty", 'checked' => 1, 'position' => 30),
105  'c.libelle' => array('label' => "Type", 'checked' => 1, 'position' => 40),
106  'p.num_paiement' => array('label' => "Numero", 'checked' => 1, 'position' => 50, 'tooltip' => "ChequeOrTransferNumber"),
107  'ba.label' => array('label' => "BankAccount", 'checked' => 1, 'position' => 60, 'enable' => (isModEnabled("bank"))),
108  'p.amount' => array('label' => "Amount", 'checked' => 1, 'position' => 70),
109 );
110 $arrayfields = dol_sort_array($arrayfields, 'position');
111 '@phan-var-force array<string,array{label:string,checked?:int<0,1>,position?:int,help?:string}> $arrayfields'; // dol_sort_array looses type for Phan
112 
113 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
114 $hookmanager->initHooks(array('paymentsupplierlist'));
115 $object = new PaiementFourn($db);
116 
117 if (!$user->hasRight('societe', 'client', 'voir')) {
118  $search_sale = $user->id;
119 }
120 
121 // Security check
122 if ($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);
132 if (!isModEnabled('supplier_invoice')) {
133  accessforbidden();
134 }
135 if ((!$user->hasRight("fournisseur", "facture", "lire") && !getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD'))
136  || (!$user->hasRight("supplier_invoice", "lire") && getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD'))) {
137  accessforbidden();
138 }
139 
140 
141 /*
142  * Actions
143  */
144 
145 $parameters = array('socid' => $socid);
146 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
147 if ($reshook < 0) {
148  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
149 }
150 
151 if (empty($reshook)) {
152  include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
153 
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_company = '';
165  $search_payment_type = '';
166  $search_cheque_num = '';
167  $search_bank_account = '';
168  $search_amount = '';
169  $option = '';
170  $toselect = array();
171  $search_array_options = array();
172  }
173 }
174 
175 /*
176  * View
177  */
178 
179 llxHeader('', $langs->trans('ListPayment'));
180 
181 $form = new Form($db);
182 $formother = new FormOther($db);
183 $accountstatic = new Account($db);
184 $companystatic = new Societe($db);
185 $paymentfournstatic = new PaiementFourn($db);
186 
187 $sql = 'SELECT p.rowid, p.ref, p.datep, p.fk_bank, p.statut, p.num_paiement as num_payment, p.amount';
188 $sql .= ', c.code as paiement_type, c.libelle as paiement_libelle';
189 $sql .= ', ba.rowid as bid, ba.ref as bref, ba.label as blabel, ba.number, ba.account_number as account_number, ba.iban_prefix, ba.bic, ba.currency_code, ba.fk_accountancy_journal as accountancy_journal';
190 $sql .= ', s.rowid as socid, s.nom as name, s.email';
191 // We need an aggregate because we added a left join to get the thirdparty. In real world, it should be the same thirdparty if payment is same (but not in database structure)
192 // so SUM(pf.amount) should be equal to p.amount but if we filter on $socid, it may differ
193 $sql .= ", SUM(pf.amount) as totalamount, COUNT(f.rowid) as nbinvoices";
194 
195 $sqlfields = $sql; // $sql fields to remove for count total
196 
197 $sql .= ' FROM '.MAIN_DB_PREFIX.'paiementfourn AS p';
198 $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement AS c ON p.fk_paiement = c.id';
199 $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON p.fk_bank = b.rowid';
200 $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank_account as ba ON b.fk_account = ba.rowid';
201 
202 $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn_facturefourn AS pf ON p.rowid = pf.fk_paiementfourn';
203 $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'facture_fourn AS f ON f.rowid = pf.fk_facturefourn';
204 $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe AS s ON s.rowid = f.fk_soc';
205 
206 $sql .= ' WHERE f.entity IN ('.getEntity('supplier_invoice').')'; // TODO We should use p.entity that does not exists yet in this table
207 if ($socid > 0) {
208  $sql .= " AND EXISTS (SELECT f.fk_soc FROM ".MAIN_DB_PREFIX."facture_fourn as f, ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf";
209  $sql .= " WHERE p.rowid = pf.fk_paiementfourn AND pf.fk_facturefourn = f.rowid AND f.fk_soc = ".((int) $socid).")";
210 }
211 
212 // Search criteria
213 if ($search_ref) {
214  $sql .= natural_search('p.ref', $search_ref);
215 }
216 if ($search_date_start) {
217  $sql .= " AND p.datep >= '" . $db->idate($search_date_start) . "'";
218 }
219 if ($search_date_end) {
220  $sql .= " AND p.datep <= '" . $db->idate($search_date_end) . "'";
221 }
222 
223 if ($search_company) {
224  $sql .= natural_search('s.nom', $search_company);
225 }
226 if ($search_payment_type != '') {
227  $sql .= " AND c.code = '".$db->escape($search_payment_type)."'";
228 }
229 if ($search_cheque_num != '') {
230  $sql .= natural_search('p.num_paiement', $search_cheque_num);
231 }
232 if ($search_amount) {
233  $sql .= " AND (".natural_search('p.amount', $search_amount, 1, 1);
234  $sql .= " OR ";
235  $sql .= natural_search('pf.amount', $search_amount, 1, 1);
236  $sql .= ")";
237 }
238 if ($search_bank_account > 0) {
239  $sql .= ' AND b.fk_account = '.((int) $search_bank_account);
240 }
241 if ($search_all) {
242  $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
243 }
244 // Search on sale representative
245 if ($search_sale && $search_sale != '-1') {
246  if ($search_sale == -2) {
247  $sql .= " AND NOT EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc WHERE sc.fk_soc = f.fk_soc)";
248  } elseif ($search_sale > 0) {
249  $sql .= " AND EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc WHERE sc.fk_soc = f.fk_soc AND sc.fk_user = ".((int) $search_sale).")";
250  }
251 }
252 
253 // Add where from extra fields
254 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
255 
256 $sql .= ' GROUP BY p.rowid, p.ref, p.datep, p.fk_bank, p.statut, p.num_paiement, p.amount, s.rowid, s.nom, s.email, c.code, c.libelle,';
257 $sql .= ' ba.rowid, ba.ref, ba.label, ba.number, ba.account_number, ba.iban_prefix, ba.bic, ba.currency_code, ba.fk_accountancy_journal';
258 
259 // Count total nb of records
260 $nbtotalofrecords = '';
261 if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
262  /* The fast and low memory method to get and count full list converts the sql into a sql count */
263  $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(DISTINCT p.rowid) as nbtotalofrecords', $sql);
264  $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount);
265  $resql = $db->query($sqlforcount);
266  if ($resql) {
267  $objforcount = $db->fetch_object($resql);
268  $nbtotalofrecords = $objforcount->nbtotalofrecords;
269  } else {
270  dol_print_error($db);
271  }
272 
273  if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
274  $page = 0;
275  $offset = 0;
276  }
277  $db->free($resql);
278 }
279 
280 // Complete request and execute it with limit
281 $sql .= $db->order($sortfield, $sortorder);
282 if ($limit) {
283  $sql .= $db->plimit($limit + 1, $offset);
284 }
285 //print $sql;
286 
287 $resql = $db->query($sql);
288 if (!$resql) {
289  dol_print_error($db);
290  llxFooter();
291  $db->close();
292  exit;
293 }
294 
295 $num = $db->num_rows($resql);
296 $i = 0;
297 
298 $param = '';
299 if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
300  $param .= '&contextpage='.urlencode($contextpage);
301 }
302 if ($limit > 0 && $limit != $conf->liste_limit) {
303  $param .= '&limit='.((int) $limit);
304 }
305 if ($optioncss != '') {
306  $param .= '&optioncss='.urlencode($optioncss);
307 }
308 
309 if ($search_ref) {
310  $param .= '&search_ref='.urlencode($search_ref);
311 }
312 if ($search_date_startday) {
313  $param .= '&search_date_startday='.urlencode((string) ($search_date_startday));
314 }
315 if ($search_date_startmonth) {
316  $param .= '&search_date_startmonth='.urlencode((string) ($search_date_startmonth));
317 }
318 if ($search_date_startyear) {
319  $param .= '&search_date_startyear='.urlencode((string) ($search_date_startyear));
320 }
321 if ($search_date_endday) {
322  $param .= '&search_date_endday='.urlencode((string) ($search_date_endday));
323 }
324 if ($search_date_endmonth) {
325  $param .= '&search_date_endmonth='.urlencode((string) ($search_date_endmonth));
326 }
327 if ($search_date_endyear) {
328  $param .= '&search_date_endyear='.urlencode((string) ($search_date_endyear));
329 }
330 if ($search_company) {
331  $param .= '&search_company='.urlencode($search_company);
332 }
333 if ($search_payment_type) {
334  $param .= '&search_company='.urlencode($search_payment_type);
335 }
336 if ($search_cheque_num) {
337  $param .= '&search_cheque_num='.urlencode($search_cheque_num);
338 }
339 if ($search_amount) {
340  $param .= '&search_amount='.urlencode($search_amount);
341 }
342 
343 // Add $param from extra fields
344 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
345 
346 print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
347 if ($optioncss != '') {
348  print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
349 }
350 print '<input type="hidden" name="token" value="'.newToken().'">';
351 print '<input type="hidden" name="action" value="list">';
352 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
353 print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
354 print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
355 print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
356 
357 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
358 print_barre_liste($langs->trans('SupplierPayments'), $page, $_SERVER['PHP_SELF'], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'supplier_invoice', 0, '', '', $limit, 0, 0, 1);
359 
360 if ($search_all) {
361  foreach ($fieldstosearchall as $key => $val) {
362  $fieldstosearchall[$key] = $langs->trans($val);
363  }
364  print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).implode(', ', $fieldstosearchall).'</div>';
365 }
366 
367 $moreforfilter = '';
368 
369 $parameters = array();
370 $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook
371 if (empty($reshook)) {
372  $moreforfilter .= $hookmanager->resPrint;
373 } else {
374  $moreforfilter = $hookmanager->resPrint;
375 }
376 
377 if ($moreforfilter) {
378  print '<div class="liste_titre liste_titre_bydiv centpercent">';
379  print $moreforfilter;
380  print '</div>';
381 }
382 
383 $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
384 $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')); // This also change content of $arrayfields
385 if (!empty($massactionbutton)) {
386  $selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
387 }
388 
389 print '<div class="div-table-responsive">';
390 print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : '').'">';
391 
392 // Fields title search
393 // --------------------------------------------------------------------
394 print '<tr class="liste_titre_filter">';
395 
396 // Action column
397 if (getDolGlobalInt('MAIN_CHECKBOX_LEFT_COLUMN')) {
398  print '<td class="liste_titre center maxwidthsearch">';
399  $searchpicto = $form->showFilterButtons('left');
400  print $searchpicto;
401  print '</td>';
402 }
403 
404 // #
405 if (getDolGlobalString('MAIN_VIEW_LINE_NUMBER_IN_LIST')) {
406  print '<td class="liste_titre">';
407  print '</td>';
408 }
409 
410 // Filter: Ref
411 if (!empty($arrayfields['p.ref']['checked'])) {
412  print '<td class="liste_titre left">';
413  print '<input class="flat" type="text" size="4" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
414  print '</td>';
415 }
416 
417 // Filter: Date
418 if (!empty($arrayfields['p.datep']['checked'])) {
419  print '<td class="liste_titre center">';
420  print '<div class="nowrapfordate">';
421  print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
422  print '</div>';
423  print '<div class="nowrapfordate">';
424  print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
425  print '</div>';
426  print '</td>';
427 }
428 
429 // Filter: Thirdparty
430 if (!empty($arrayfields['s.nom']['checked'])) {
431  print '<td class="liste_titre">';
432  print '<input class="flat" type="text" size="6" name="search_company" value="'.dol_escape_htmltag($search_company).'">';
433  print '</td>';
434 }
435 
436 // Filter: Payment type
437 if (!empty($arrayfields['c.libelle']['checked'])) {
438  print '<td class="liste_titre">';
439  $form->select_types_paiements($search_payment_type, 'search_payment_type', '', 2, 1, 1);
440  print '</td>';
441 }
442 
443 // Filter: Cheque number (fund transfer)
444 if (!empty($arrayfields['p.num_paiement']['checked'])) {
445  print '<td class="liste_titre">';
446  print '<input class="flat" type="text" size="4" name="search_cheque_num" value="'.dol_escape_htmltag($search_cheque_num).'">';
447  print '</td>';
448 }
449 
450 // Filter: Bank account
451 if (!empty($arrayfields['ba.label']['checked'])) {
452  print '<td class="liste_titre">';
453  $form->select_comptes($search_bank_account, 'search_bank_account', 0, '', 1);
454  print '</td>';
455 }
456 
457 // Filter: Amount
458 if (!empty($arrayfields['p.amount']['checked'])) {
459  print '<td class="liste_titre right">';
460  print '<input class="flat" type="text" size="4" name="search_amount" value="'.dol_escape_htmltag($search_amount).'">';
461  print '</td>';
462 }
463 
464 // Fields from hook
465 $parameters = array('arrayfields' => $arrayfields);
466 $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
467 print $hookmanager->resPrint;
468 
469 // Action column
470 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
471  print '<td class="liste_titre center maxwidthsearch">';
472  $searchpicto = $form->showFilterButtons();
473  print $searchpicto;
474  print '</td>';
475 }
476 
477 print '</tr>'."\n";
478 
479 $totalarray = array();
480 $totalarray['nbfield'] = 0;
481 
482 // Fields title label
483 // --------------------------------------------------------------------
484 print '<tr class="liste_titre">';
485 // Action column
486 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
487  print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
488  $totalarray['nbfield']++;
489 }
490 if (getDolGlobalString('MAIN_VIEW_LINE_NUMBER_IN_LIST')) {
491  print_liste_field_titre('#', $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder);
492  $totalarray['nbfield']++;
493 }
494 if (!empty($arrayfields['p.ref']['checked'])) {
495  print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], 'p.rowid', '', $param, '', $sortfield, $sortorder);
496  $totalarray['nbfield']++;
497 }
498 if (!empty($arrayfields['p.datep']['checked'])) {
499  print_liste_field_titre($arrayfields['p.datep']['label'], $_SERVER["PHP_SELF"], 'p.datep', '', $param, '', $sortfield, $sortorder, 'center ');
500  $totalarray['nbfield']++;
501 }
502 if (!empty($arrayfields['s.nom']['checked'])) {
503  print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], 's.nom', '', $param, '', $sortfield, $sortorder);
504  $totalarray['nbfield']++;
505 }
506 if (!empty($arrayfields['c.libelle']['checked'])) {
507  print_liste_field_titre($arrayfields['c.libelle']['label'], $_SERVER["PHP_SELF"], 'c.libelle', '', $param, '', $sortfield, $sortorder);
508  $totalarray['nbfield']++;
509 }
510 if (!empty($arrayfields['p.num_paiement']['checked'])) {
511  print_liste_field_titre($arrayfields['p.num_paiement']['label'], $_SERVER["PHP_SELF"], "p.num_paiement", '', $param, '', $sortfield, $sortorder, '', $arrayfields['p.num_paiement']['tooltip']);
512  $totalarray['nbfield']++;
513 }
514 if (!empty($arrayfields['ba.label']['checked'])) {
515  print_liste_field_titre($arrayfields['ba.label']['label'], $_SERVER["PHP_SELF"], 'ba.label', '', $param, '', $sortfield, $sortorder);
516  $totalarray['nbfield']++;
517 }
518 if (!empty($arrayfields['p.amount']['checked'])) {
519  print_liste_field_titre($arrayfields['p.amount']['label'], $_SERVER["PHP_SELF"], 'p.amount', '', $param, '', $sortfield, $sortorder, 'right ');
520  $totalarray['nbfield']++;
521 }
522 
523 // Hook fields
524 $parameters = array('arrayfields' => $arrayfields, 'param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder);
525 $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
526 print $hookmanager->resPrint;
527 
528 // Action column
529 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
530  print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
531  $totalarray['nbfield']++;
532 }
533 print '</tr>';
534 
535 print '</tr>'."\n";
536 
537 // Detect if we need a fetch on each output line
538 $needToFetchEachLine = 0;
539 if (isset($extrafields->attributes[$object->table_element]['computed']) && is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) {
540  foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) {
541  if (!is_null($val) && preg_match('/\$object/', $val)) {
542  $needToFetchEachLine++; // There is at least one compute field that use $object
543  }
544  }
545 }
546 
547 
548 // Loop on record
549 // --------------------------------------------------------------------
550 $i = 0;
551 $savnbfield = $totalarray['nbfield'];
552 $totalarray = array();
553 $totalarray['nbfield'] = 0;
554 $imaxinloop = ($limit ? min($num, $limit) : $num);
555 while ($i < $imaxinloop) {
556  $objp = $db->fetch_object($resql);
557  if (empty($objp)) {
558  break; // Should not happen
559  }
560 
561  $paymentfournstatic->id = $objp->rowid;
562  $paymentfournstatic->ref = $objp->ref;
563  $paymentfournstatic->datepaye = $db->jdate($objp->datep);
564  $paymentfournstatic->amount = $objp->amount;
565 
566  $companystatic->id = $objp->socid;
567  $companystatic->name = $objp->name;
568  $companystatic->email = $objp->email;
569 
570  if ($mode == 'kanban') {
571  if ($i == 0) {
572  print '<tr class="trkanban"><td colspan="'.$savnbfield.'">';
573  print '<div class="box-flex-container kanban">';
574  }
575  // Output Kanban
576  $selected = -1;
577  if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
578  $selected = 0;
579  if (in_array($object->id, $arrayofselected)) {
580  $selected = 1;
581  }
582  }
583  //print $object->getKanbanView('', array('thirdparty'=>$object->thirdparty, 'selected' => $selected));
584  print $object->getKanbanView('', array('selected' => $selected));
585  if ($i == ($imaxinloop - 1)) {
586  print '</div>';
587  print '</td></tr>';
588  }
589  } else {
590  // Show line of result
591  $j = 0;
592  print '<tr data-rowid="'.$object->id.'" class="oddeven">';
593 
594  // Action column
595  if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
596  print '<td class="nowrap center">';
597  if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
598  $selected = 0;
599  if (in_array($object->id, $arrayofselected)) {
600  $selected = 1;
601  }
602  print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
603  }
604  print '</td>';
605  if (!$i) {
606  $totalarray['nbfield']++;
607  }
608  }
609 
610  // No
611  if (getDolGlobalString('MAIN_VIEW_LINE_NUMBER_IN_LIST')) {
612  print '<td class="nowraponall">'.(($offset * $limit) + $i).'</td>';
613  if (!$i) {
614  $totalarray['nbfield']++;
615  }
616  }
617 
618  // Ref
619  if (!empty($arrayfields['p.ref']['checked'])) {
620  print '<td class="nowraponall">'.$paymentfournstatic->getNomUrl(1).'</td>';
621  if (!$i) {
622  $totalarray['nbfield']++;
623  }
624  }
625 
626  // Date
627  if (!empty($arrayfields['p.datep']['checked'])) {
628  $dateformatforpayment = 'dayhour';
629  print '<td class="nowraponall center">'.dol_print_date($db->jdate($objp->datep), $dateformatforpayment).'</td>';
630  if (!$i) {
631  $totalarray['nbfield']++;
632  }
633  }
634 
635  // Thirdparty
636  if (!empty($arrayfields['s.nom']['checked'])) {
637  print '<td class="tdoverflowmax125">';
638  if ($objp->socid > 0) {
639  print $companystatic->getNomUrl(1, '', 24);
640  }
641  print '</td>';
642  if (!$i) {
643  $totalarray['nbfield']++;
644  }
645  }
646 
647  // Pyament type
648  if (!empty($arrayfields['c.libelle']['checked'])) {
649  $payment_type = $langs->trans("PaymentType".$objp->paiement_type) != "PaymentType".$objp->paiement_type ? $langs->trans("PaymentType".$objp->paiement_type) : $objp->paiement_libelle;
650  print '<td>'.$payment_type.' '.dol_trunc($objp->num_payment, 32).'</td>';
651  if (!$i) {
652  $totalarray['nbfield']++;
653  }
654  }
655 
656  // Cheque number (fund transfer)
657  if (!empty($arrayfields['p.num_paiement']['checked'])) {
658  print '<td>'.$objp->num_payment.'</td>';
659  if (!$i) {
660  $totalarray['nbfield']++;
661  }
662  }
663 
664  // Bank account
665  if (!empty($arrayfields['ba.label']['checked'])) {
666  print '<td class="tdoverflowmax125">';
667  if ($objp->bid) {
668  $accountstatic->id = $objp->bid;
669  $accountstatic->ref = $objp->bref;
670  $accountstatic->label = $objp->blabel;
671  $accountstatic->number = $objp->number;
672  $accountstatic->iban = $objp->iban_prefix;
673  $accountstatic->bic = $objp->bic;
674  $accountstatic->currency_code = $objp->currency_code;
675  $accountstatic->account_number = $objp->account_number;
676 
677  $accountingjournal = new AccountingJournal($db);
678  $accountingjournal->fetch($objp->accountancy_journal);
679  $accountstatic->accountancy_journal = $accountingjournal->code;
680 
681  print $accountstatic->getNomUrl(1);
682  }
683  print '</td>';
684  if (!$i) {
685  $totalarray['nbfield']++;
686  }
687  }
688 
689  // Amount
690  if (!empty($arrayfields['p.amount']['checked'])) {
691  print '<td class="right">';
692  if ($objp->nbinvoices > 1 || ($objp->totalamount && $objp->amount != $objp->totalamount)) {
693  print $form->textwithpicto('', $langs->trans("PaymentMadeForSeveralInvoices"));
694  }
695  print '<span class="amount">'.price($objp->amount).'</span>';
696  print '</td>';
697  if (!$i) {
698  $totalarray['nbfield']++;
699  $totalarray['pos'][$totalarray['nbfield']] = 'amount';
700  }
701  if (empty($totalarray['val']['amount'])) {
702  $totalarray['val']['amount'] = $objp->amount;
703  } else {
704  $totalarray['val']['amount'] += $objp->amount;
705  }
706  }
707 
708  if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
709  print '<td class="nowrap center">';
710  if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
711  $selected = 0;
712  if (in_array($object->id, $arrayofselected)) {
713  $selected = 1;
714  }
715  print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
716  }
717  print '</td>';
718  if (!$i) {
719  $totalarray['nbfield']++;
720  }
721  }
722 
723  print '</tr>'."\n";
724  }
725  $i++;
726 }
727 
728 // Show total line
729 include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
730 
731 // If no record found
732 if ($num == 0) {
733  $colspan = 1;
734  foreach ($arrayfields as $key => $val) {
735  if (!empty($val['checked'])) {
736  $colspan++;
737  }
738  }
739  print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
740 }
741 
742 $db->free($resql);
743 
744 $parameters = array('arrayfields' => $arrayfields, 'sql' => $sql);
745 $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
746 print $hookmanager->resPrint;
747 
748 print '</table>'."\n";
749 print '</div>'."\n";
750 
751 print '</form>'."\n";
752 
753 // End of page
754 llxFooter();
755 $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: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.
Class permettant la generation de composants html autre Only common components are here.
Class to manage payments for supplier invoices.
Class to manage third parties objects (customers, suppliers, prospects...)
if(isModEnabled('invoice') && $user->hasRight('facture', 'lire')) if((isModEnabled('fournisseur') &&!getDolGlobalString('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') && $user->hasRight('tax', 'charges', 'lire')) if(isModEnabled('invoice') &&isModEnabled('order') && $user->hasRight("commande", "lire") &&!getDolGlobalString('WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER')) $sql
Social contributions to pay.
Definition: index.php:744
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 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.
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.
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip='', $forcenowrapcolumntitle=0)
Get 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_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.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
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.