dolibarr 22.0.5
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-2024 Frédéric France <frederic.france@free.fr>
13 * Copyright (C) 2020 Tobias Sekan <tobias.sekan@startmail.com>
14 * Copyright (C) 2021 Ferran Marcet <fmarcet@2byte.es>
15 * Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
16 *
17 * This program is free software; you can redistribute it and/or modify
18 * it under the terms of the GNU General Public License as published by
19 * the Free Software Foundation; either version 3 of the License, or
20 * (at your option) any later version.
21 *
22 * This program is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
26 *
27 * You should have received a copy of the GNU General Public License
28 * along with this program. If not, see <https://www.gnu.org/licenses/>.
29 */
30
37// Load Dolibarr environment
38require '../../main.inc.php';
39require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php';
40require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
41require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
42require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
43require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php';
44
53// Load translation files required by the page
54$langs->loadLangs(array('companies', 'bills', 'banks', 'compta'));
55
56$action = GETPOST('action', 'alpha');
57$massaction = GETPOST('massaction', 'alpha');
58$optioncss = GETPOST('optioncss', 'alpha');
59$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'vendorpaymentlist';
60$mode = GETPOST('mode', 'aZ');
61
62$socid = GETPOSTINT('socid');
63
64$search_ref = GETPOST('search_ref', 'alpha');
65$search_date_startday = GETPOSTINT('search_date_startday');
66$search_date_startmonth = GETPOSTINT('search_date_startmonth');
67$search_date_startyear = GETPOSTINT('search_date_startyear');
68$search_date_endday = GETPOSTINT('search_date_endday');
69$search_date_endmonth = GETPOSTINT('search_date_endmonth');
70$search_date_endyear = GETPOSTINT('search_date_endyear');
71$search_date_start = dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear); // Use tzserver
72$search_date_end = dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear);
73$search_company = GETPOST('search_company', 'alpha');
74$search_payment_type = GETPOST('search_payment_type', 'alpha');
75$search_cheque_num = GETPOST('search_cheque_num', 'alpha');
76$search_bank_account = GETPOST('search_bank_account', 'int');
77$search_amount = GETPOST('search_amount', 'alpha'); // alpha because we must be able to search on '< x'
78$search_sale = GETPOSTINT('search_sale');
79
80$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
81$sortfield = GETPOST('sortfield', 'aZ09comma');
82$sortorder = GETPOST('sortorder', 'aZ09comma');
83$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT('page');
84
85if (empty($page) || $page == -1) {
86 $page = 0; // If $page is not defined, or '' or -1
87}
88$offset = $limit * $page;
89$pageprev = $page - 1;
90$pagenext = $page + 1;
91
92if (!$sortorder) {
93 $sortorder = "DESC";
94}
95if (!$sortfield) {
96 // rowid is needed as a tiebreaker: many payments share the same date, and without it
97 // the order of those rows is undefined, so paging can repeat or skip records.
98 $sortfield = "p.datep,p.rowid";
99}
100
101$search_all = trim(GETPOST('search_all', 'alphanohtml'));
102
103// List of fields to search into when doing a "search in all"
104$fieldstosearchall = array(
105 'p.ref' => "RefPayment",
106 's.nom' => "ThirdParty",
107 'p.num_paiement' => "Numero",
108 'p.amount' => "Amount",
109);
110
111$arrayfields = array(
112 'p.ref' => array('label' => "RefPayment", 'checked' => '1', 'position' => 10),
113 'p.datep' => array('label' => "Date", 'checked' => '1', 'position' => 20),
114 's.nom' => array('label' => "ThirdParty", 'checked' => '1', 'position' => 30),
115 'c.libelle' => array('label' => "Type", 'checked' => '1', 'position' => 40),
116 'p.num_paiement' => array('label' => "Numero", 'checked' => '1', 'position' => 50, 'tooltip' => "ChequeOrTransferNumber"),
117 'ba.label' => array('label' => "BankAccount", 'checked' => '1', 'position' => 60, 'enabled' => (string) (int) (isModEnabled("bank"))),
118 'p.amount' => array('label' => "Amount", 'checked' => '1', 'position' => 70),
119);
120$arrayfields = dol_sort_array($arrayfields, 'position');
121
122// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
123$hookmanager->initHooks(array('paymentsupplierlist'));
124$object = new PaiementFourn($db);
125
126if (!$user->hasRight('societe', 'client', 'voir')) {
127 $search_sale = $user->id;
128}
129
130// Security check
131if ($user->socid) {
132 $socid = $user->socid;
133}
134
135// doesn't work :-(
136// restrictedArea($user, 'fournisseur');
137// doesn't work :-(
138// require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php';
139// $object = new PaiementFourn($db);
140// restrictedArea($user, $object->element);
141if (!isModEnabled('supplier_invoice')) {
143}
144if ((!$user->hasRight("fournisseur", "facture", "lire") && !getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD'))
145 || (!$user->hasRight("supplier_invoice", "lire") && getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD'))) {
147}
148
149$arrayofselected = !empty($arrayofselected) && is_array($arrayofselected) ? $arrayofselected : array();
150
151
152/*
153 * Actions
154 */
155
156$parameters = array('socid' => $socid);
157$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
158if ($reshook < 0) {
159 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
160}
161
162if (empty($reshook)) {
163 include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
164
165 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
166 $search_ref = '';
167 $search_date_startday = '';
168 $search_date_startmonth = '';
169 $search_date_startyear = '';
170 $search_date_endday = '';
171 $search_date_endmonth = '';
172 $search_date_endyear = '';
173 $search_date_start = '';
174 $search_date_end = '';
175 $search_company = '';
176 $search_payment_type = '';
177 $search_cheque_num = '';
178 $search_bank_account = '';
179 $search_amount = '';
180 $option = '';
181 $toselect = array();
182 $search_array_options = array();
183 }
184}
185
186
187/*
188 * View
189 */
190
191$title = $langs->trans('ListPayment');
192$help_url = '';
193
194llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'bodyforlist');
195
196$form = new Form($db);
197$formother = new FormOther($db);
198$accountstatic = new Account($db);
199$companystatic = new Societe($db);
200$paymentfournstatic = new PaiementFourn($db);
201
202$sql = 'SELECT p.rowid, p.ref, p.datep, p.fk_bank, p.statut, p.num_paiement as num_payment, p.amount';
203$sql .= ', c.code as paiement_type, c.libelle as paiement_libelle';
204$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';
205$sql .= ', s.rowid as socid, s.nom as name, s.email';
206// 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)
207// so SUM(pf.amount) should be equal to p.amount but if we filter on $socid, it may differ
208$sql .= ", SUM(pf.amount) as totalamount, COUNT(f.rowid) as nbinvoices";
209
210$sqlfields = $sql; // $sql fields to remove for count total
211
212$sql .= ' FROM '.MAIN_DB_PREFIX.'paiementfourn AS p';
213$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement AS c ON p.fk_paiement = c.id';
214$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON p.fk_bank = b.rowid';
215$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank_account as ba ON b.fk_account = ba.rowid';
216
217$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn_facturefourn AS pf ON p.rowid = pf.fk_paiementfourn';
218$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'facture_fourn AS f ON f.rowid = pf.fk_facturefourn';
219$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe AS s ON s.rowid = f.fk_soc';
220
221$sql .= ' WHERE f.entity IN ('.getEntity('supplier_invoice').')'; // TODO We should use p.entity that does not exists yet in this table
222if ($socid > 0) {
223 $sql .= " AND EXISTS (SELECT f.fk_soc FROM ".MAIN_DB_PREFIX."facture_fourn as f, ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf";
224 $sql .= " WHERE p.rowid = pf.fk_paiementfourn AND pf.fk_facturefourn = f.rowid AND f.fk_soc = ".((int) $socid).")";
225}
226
227// Search criteria
228if ($search_ref) {
229 $sql .= natural_search('p.ref', $search_ref);
230}
231if ($search_date_start) {
232 $sql .= " AND p.datep >= '" . $db->idate($search_date_start) . "'";
233}
234if ($search_date_end) {
235 $sql .= " AND p.datep <= '" . $db->idate($search_date_end) . "'";
236}
237
238if ($search_company) {
239 $sql .= natural_search('s.nom', $search_company);
240}
241if ($search_payment_type != '') {
242 $sql .= " AND c.code = '".$db->escape($search_payment_type)."'";
243}
244if ($search_cheque_num != '') {
245 $sql .= natural_search('p.num_paiement', $search_cheque_num);
246}
247if ($search_amount) {
248 $sql .= " AND (".natural_search('p.amount', $search_amount, 1, 1);
249 $sql .= " OR ";
250 $sql .= natural_search('pf.amount', $search_amount, 1, 1);
251 $sql .= ")";
252}
253if ($search_bank_account > 0) {
254 $sql .= ' AND b.fk_account = '.((int) $search_bank_account);
255}
256if ($search_all) {
257 $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
258}
259// Search on sale representative
260if ($search_sale && $search_sale != '-1') {
261 if ($search_sale == -2) {
262 $sql .= " AND NOT EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc WHERE sc.fk_soc = f.fk_soc)";
263 } elseif ($search_sale > 0) {
264 $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).")";
265 }
266}
267
268// Add where from extra fields
269include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
270
271$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,';
272$sql .= ' ba.rowid, ba.ref, ba.label, ba.number, ba.account_number, ba.iban_prefix, ba.bic, ba.currency_code, ba.fk_accountancy_journal';
273
274// Count total nb of records
275$nbtotalofrecords = '';
276if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
277 /* The fast and low memory method to get and count full list converts the sql into a sql count */
278 $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(DISTINCT p.rowid) as nbtotalofrecords', $sql);
279 $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount);
280 $resql = $db->query($sqlforcount);
281 if ($resql) {
282 $objforcount = $db->fetch_object($resql);
283 $nbtotalofrecords = $objforcount->nbtotalofrecords;
284 } else {
285 dol_print_error($db);
286 }
287
288 if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
289 $page = 0;
290 $offset = 0;
291 }
292 $db->free($resql);
293}
294
295// Complete request and execute it with limit
296$sql .= $db->order($sortfield, $sortorder);
297if ($limit) {
298 $sql .= $db->plimit($limit + 1, $offset);
299}
300//print $sql;
301
302$resql = $db->query($sql);
303if (!$resql) {
304 dol_print_error($db);
305 llxFooter();
306 $db->close();
307 exit;
308}
309
310$num = $db->num_rows($resql);
311$i = 0;
312
313$param = '';
314if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
315 $param .= '&contextpage='.urlencode($contextpage);
316}
317if ($limit > 0 && $limit != $conf->liste_limit) {
318 $param .= '&limit='.((int) $limit);
319}
320if ($optioncss != '') {
321 $param .= '&optioncss='.urlencode($optioncss);
322}
323
324if ($search_ref) {
325 $param .= '&search_ref='.urlencode($search_ref);
326}
327if ($search_date_startday) {
328 $param .= '&search_date_startday='.urlencode((string) ($search_date_startday));
329}
330if ($search_date_startmonth) {
331 $param .= '&search_date_startmonth='.urlencode((string) ($search_date_startmonth));
332}
333if ($search_date_startyear) {
334 $param .= '&search_date_startyear='.urlencode((string) ($search_date_startyear));
335}
336if ($search_date_endday) {
337 $param .= '&search_date_endday='.urlencode((string) ($search_date_endday));
338}
339if ($search_date_endmonth) {
340 $param .= '&search_date_endmonth='.urlencode((string) ($search_date_endmonth));
341}
342if ($search_date_endyear) {
343 $param .= '&search_date_endyear='.urlencode((string) ($search_date_endyear));
344}
345if ($search_company) {
346 $param .= '&search_company='.urlencode($search_company);
347}
348if ($search_payment_type) {
349 $param .= '&search_company='.urlencode($search_payment_type);
350}
351if ($search_cheque_num) {
352 $param .= '&search_cheque_num='.urlencode($search_cheque_num);
353}
354if ($search_amount) {
355 $param .= '&search_amount='.urlencode($search_amount);
356}
357
358// Add $param from extra fields
359include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
360
361// List of mass actions available
362$arrayofmassactions = array(
363 //'validate'=>img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("Validate"),
364 //'generate_doc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"),
365 //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
366 //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
367);
368/*if (!empty($permissiontodelete)) {
369 $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
370}*/
371if (GETPOSTINT('nomassaction') || in_array($massaction, array('presend', 'predelete'))) {
372 $arrayofmassactions = array();
373}
374$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
375
376print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
377if ($optioncss != '') {
378 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
379}
380print '<input type="hidden" name="token" value="'.newToken().'">';
381print '<input type="hidden" name="action" value="list">';
382print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
383print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
384print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
385print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
386
387// @phan-suppress-next-line PhanPluginSuspiciousParamOrder
388print_barre_liste($langs->trans('SupplierPayments'), $page, $_SERVER['PHP_SELF'], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'supplier_invoice', 0, '', '', $limit, 0, 0, 1);
389
390if ($search_all) {
391 foreach ($fieldstosearchall as $key => $val) {
392 $fieldstosearchall[$key] = $langs->trans($val);
393 }
394 print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).implode(', ', $fieldstosearchall).'</div>';
395}
396
397$moreforfilter = '';
398
399$parameters = array();
400$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
401if (empty($reshook)) {
402 $moreforfilter .= $hookmanager->resPrint;
403} else {
404 $moreforfilter = $hookmanager->resPrint;
405}
406
407if ($moreforfilter) {
408 print '<div class="liste_titre liste_titre_bydiv centpercent">';
409 print $moreforfilter;
410 print '</div>';
411}
412
413$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
414$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')); // This also change content of $arrayfields
415if (!empty($massactionbutton)) {
416 $selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
417}
418
419print '<div class="div-table-responsive">';
420print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : '').'">';
421
422// Fields title search
423// --------------------------------------------------------------------
424print '<tr class="liste_titre_filter">';
425
426// Action column
427if (getDolGlobalInt('MAIN_CHECKBOX_LEFT_COLUMN')) {
428 print '<td class="liste_titre center maxwidthsearch">';
429 $searchpicto = $form->showFilterButtons('left');
430 print $searchpicto;
431 print '</td>';
432}
433
434// #
435if (getDolGlobalString('MAIN_VIEW_LINE_NUMBER_IN_LIST')) {
436 print '<td class="liste_titre">';
437 print '</td>';
438}
439
440// Filter: Ref
441if (!empty($arrayfields['p.ref']['checked'])) {
442 print '<td class="liste_titre left">';
443 print '<input class="flat" type="text" size="4" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
444 print '</td>';
445}
446
447// Filter: Date
448if (!empty($arrayfields['p.datep']['checked'])) {
449 print '<td class="liste_titre center">';
450 print '<div class="nowrapfordate">';
451 print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
452 print '</div>';
453 print '<div class="nowrapfordate">';
454 print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
455 print '</div>';
456 print '</td>';
457}
458
459// Filter: Thirdparty
460if (!empty($arrayfields['s.nom']['checked'])) {
461 print '<td class="liste_titre">';
462 print '<input class="flat" type="text" size="6" name="search_company" value="'.dol_escape_htmltag($search_company).'">';
463 print '</td>';
464}
465
466// Filter: Payment mode
467if (!empty($arrayfields['c.libelle']['checked'])) {
468 print '<td class="liste_titre">';
469 print $form->select_types_paiements($search_payment_type, 'search_payment_type', '', 2, 1, 1, 0, 1, 'maxwidth100', 1);
470 print '</td>';
471}
472
473// Filter: Cheque number (fund transfer)
474if (!empty($arrayfields['p.num_paiement']['checked'])) {
475 print '<td class="liste_titre">';
476 print '<input class="flat" type="text" size="4" name="search_cheque_num" value="'.dol_escape_htmltag($search_cheque_num).'">';
477 print '</td>';
478}
479
480// Filter: Bank account
481if (!empty($arrayfields['ba.label']['checked'])) {
482 print '<td class="liste_titre">';
483 $form->select_comptes($search_bank_account, 'search_bank_account', 0, '', 1);
484 print '</td>';
485}
486
487// Filter: Amount
488if (!empty($arrayfields['p.amount']['checked'])) {
489 print '<td class="liste_titre right">';
490 print '<input class="flat" type="text" size="4" name="search_amount" value="'.dol_escape_htmltag($search_amount).'">';
491 print '</td>';
492}
493
494// Fields from hook
495$parameters = array('arrayfields' => $arrayfields);
496$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
497print $hookmanager->resPrint;
498
499// Action column
500if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
501 print '<td class="liste_titre center maxwidthsearch">';
502 $searchpicto = $form->showFilterButtons();
503 print $searchpicto;
504 print '</td>';
505}
506
507print '</tr>'."\n";
508
509$totalarray = array();
510$totalarray['nbfield'] = 0;
511
512// Fields title label
513// --------------------------------------------------------------------
514print '<tr class="liste_titre">';
515// Action column
516if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
517 print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
518 $totalarray['nbfield']++;
519}
520if (getDolGlobalString('MAIN_VIEW_LINE_NUMBER_IN_LIST')) {
521 print_liste_field_titre('#', $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder);
522 $totalarray['nbfield']++;
523}
524if (!empty($arrayfields['p.ref']['checked'])) {
525 // @phan-suppress-next-line PhanTypeInvalidDimOffset
526 print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], 'p.rowid', '', $param, '', $sortfield, $sortorder);
527 $totalarray['nbfield']++;
528}
529if (!empty($arrayfields['p.datep']['checked'])) {
530 print_liste_field_titre($arrayfields['p.datep']['label'], $_SERVER["PHP_SELF"], 'p.datep', '', $param, '', $sortfield, $sortorder, 'center ');
531 $totalarray['nbfield']++;
532}
533if (!empty($arrayfields['s.nom']['checked'])) {
534 print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], 's.nom', '', $param, '', $sortfield, $sortorder);
535 $totalarray['nbfield']++;
536}
537if (!empty($arrayfields['c.libelle']['checked'])) {
538 print_liste_field_titre($arrayfields['c.libelle']['label'], $_SERVER["PHP_SELF"], 'c.libelle', '', $param, '', $sortfield, $sortorder);
539 $totalarray['nbfield']++;
540}
541if (!empty($arrayfields['p.num_paiement']['checked'])) {
542 print_liste_field_titre($arrayfields['p.num_paiement']['label'], $_SERVER["PHP_SELF"], "p.num_paiement", '', $param, '', $sortfield, $sortorder, '', $arrayfields['p.num_paiement']['tooltip']);
543 $totalarray['nbfield']++;
544}
545if (!empty($arrayfields['ba.label']['checked'])) {
546 print_liste_field_titre($arrayfields['ba.label']['label'], $_SERVER["PHP_SELF"], 'ba.label', '', $param, '', $sortfield, $sortorder);
547 $totalarray['nbfield']++;
548}
549if (!empty($arrayfields['p.amount']['checked'])) {
550 print_liste_field_titre($arrayfields['p.amount']['label'], $_SERVER["PHP_SELF"], 'p.amount', '', $param, '', $sortfield, $sortorder, 'right ');
551 $totalarray['nbfield']++;
552}
553
554// Hook fields
555$parameters = array('arrayfields' => $arrayfields, 'param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder);
556$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
557print $hookmanager->resPrint;
558
559// Action column
560if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
561 print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
562 $totalarray['nbfield']++;
563}
564print '</tr>';
565
566print '</tr>'."\n";
567
568// Detect if we need a fetch on each output line
569$needToFetchEachLine = 0;
570if (isset($extrafields->attributes[$object->table_element]['computed']) && is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) {
571 foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) {
572 if (!is_null($val) && preg_match('/\$object/', $val)) {
573 $needToFetchEachLine++; // There is at least one compute field that use $object
574 }
575 }
576}
577
578
579// Loop on record
580// --------------------------------------------------------------------
581$i = 0;
582$savnbfield = $totalarray['nbfield'];
583$totalarray = array();
584$totalarray['nbfield'] = 0;
585$imaxinloop = ($limit ? min($num, $limit) : $num);
586while ($i < $imaxinloop) {
587 $objp = $db->fetch_object($resql);
588 if (empty($objp)) {
589 break; // Should not happen
590 }
591
592 $paymentfournstatic->id = $objp->rowid;
593 $paymentfournstatic->ref = $objp->ref;
594 $paymentfournstatic->datepaye = $db->jdate($objp->datep);
595 $paymentfournstatic->amount = $objp->amount;
596
597 $companystatic->id = $objp->socid;
598 $companystatic->name = $objp->name;
599 $companystatic->email = $objp->email;
600
601 if ($mode == 'kanban') {
602 if ($i == 0) {
603 print '<tr class="trkanban"><td colspan="'.$savnbfield.'">';
604 print '<div class="box-flex-container kanban">';
605 }
606 // Output Kanban
607 $selected = -1;
608 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
609 $selected = 0;
610 if (in_array($object->id, $arrayofselected)) {
611 $selected = 1;
612 }
613 }
614 //print $object->getKanbanView('', array('thirdparty'=>$object->thirdparty, 'selected' => $selected));
615 print $object->getKanbanView('', array('selected' => $selected));
616 if ($i == ($imaxinloop - 1)) {
617 print '</div>';
618 print '</td></tr>';
619 }
620 } else {
621 // Show line of result
622 $j = 0;
623 print '<tr data-rowid="'.$object->id.'" class="oddeven">';
624
625 // Action column
626 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
627 print '<td class="nowrap center">';
628 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
629 $selected = 0;
630 if (in_array($object->id, $arrayofselected)) {
631 $selected = 1;
632 }
633 print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
634 }
635 print '</td>';
636 if (!$i) {
637 $totalarray['nbfield']++;
638 }
639 }
640
641 // No
642 if (getDolGlobalString('MAIN_VIEW_LINE_NUMBER_IN_LIST')) {
643 print '<td class="nowraponall">'.(($offset * $limit) + $i).'</td>';
644 if (!$i) {
645 $totalarray['nbfield']++;
646 }
647 }
648
649 // Ref
650 if (!empty($arrayfields['p.ref']['checked'])) {
651 print '<td class="nowraponall">'.$paymentfournstatic->getNomUrl(1).'</td>';
652 if (!$i) {
653 $totalarray['nbfield']++;
654 }
655 }
656
657 // Date
658 if (!empty($arrayfields['p.datep']['checked'])) {
659 $dateformatforpayment = 'dayhour';
660 print '<td class="nowraponall center">'.dol_print_date($db->jdate($objp->datep), $dateformatforpayment).'</td>';
661 if (!$i) {
662 $totalarray['nbfield']++;
663 }
664 }
665
666 // Thirdparty
667 if (!empty($arrayfields['s.nom']['checked'])) {
668 print '<td class="tdoverflowmax125">';
669 if ($objp->socid > 0) {
670 print $companystatic->getNomUrl(1, '', 24);
671 }
672 print '</td>';
673 if (!$i) {
674 $totalarray['nbfield']++;
675 }
676 }
677
678 // Pyament type
679 if (!empty($arrayfields['c.libelle']['checked'])) {
680 $payment_type = $langs->trans("PaymentType".$objp->paiement_type) != "PaymentType".$objp->paiement_type ? $langs->trans("PaymentType".$objp->paiement_type) : $objp->paiement_libelle;
681 print '<td>'.$payment_type.' '.dol_trunc($objp->num_payment, 32).'</td>';
682 if (!$i) {
683 $totalarray['nbfield']++;
684 }
685 }
686
687 // Cheque number (fund transfer)
688 if (!empty($arrayfields['p.num_paiement']['checked'])) {
689 print '<td>'.$objp->num_payment.'</td>';
690 if (!$i) {
691 $totalarray['nbfield']++;
692 }
693 }
694
695 // Bank account
696 if (!empty($arrayfields['ba.label']['checked'])) {
697 print '<td class="tdoverflowmax125">';
698 if ($objp->bid) {
699 $accountstatic->id = $objp->bid;
700 $accountstatic->ref = $objp->bref;
701 $accountstatic->label = $objp->blabel;
702 $accountstatic->number = $objp->number;
703 $accountstatic->iban = $objp->iban_prefix;
704 $accountstatic->bic = $objp->bic;
705 $accountstatic->currency_code = $objp->currency_code;
706 $accountstatic->account_number = $objp->account_number;
707
708 $accountingjournal = new AccountingJournal($db);
709 $accountingjournal->fetch($objp->accountancy_journal);
710 $accountstatic->accountancy_journal = $accountingjournal->code;
711
712 print $accountstatic->getNomUrl(1);
713 }
714 print '</td>';
715 if (!$i) {
716 $totalarray['nbfield']++;
717 }
718 }
719
720 // Amount
721 if (!empty($arrayfields['p.amount']['checked'])) {
722 print '<td class="right">';
723 if ($objp->nbinvoices > 1 || ($objp->totalamount && $objp->amount != $objp->totalamount)) {
724 print $form->textwithpicto('', $langs->trans("PaymentMadeForSeveralInvoices"));
725 }
726 print '<span class="amount">'.price($objp->amount).'</span>';
727 print '</td>';
728 if (!$i) {
729 $totalarray['nbfield']++;
730 $totalarray['pos'][$totalarray['nbfield']] = 'amount';
731 }
732 if (empty($totalarray['val']['amount'])) {
733 $totalarray['val']['amount'] = $objp->amount;
734 } else {
735 $totalarray['val']['amount'] += $objp->amount;
736 }
737 }
738
739 // Fields from hook
740 $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$objp, 'i'=>$i, 'totalarray'=>&$totalarray);
741 $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
742 print $hookmanager->resPrint;
743
744 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
745 print '<td class="nowrap center">';
746 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
747 $selected = 0;
748 if (in_array($object->id, $arrayofselected)) {
749 $selected = 1;
750 }
751 print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
752 }
753 print '</td>';
754 if (!$i) {
755 $totalarray['nbfield']++;
756 }
757 }
758
759 print '</tr>'."\n";
760 }
761
762 $i++;
763}
764
765// Show total line
766include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
767
768// If no record found
769if ($num == 0) {
770 $colspan = 1;
771 foreach ($arrayfields as $key => $val) {
772 if (!empty($val['checked'])) {
773 $colspan++;
774 }
775 }
776 print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
777}
778
779$db->free($resql);
780
781$parameters = array('arrayfields' => $arrayfields, 'sql' => $sql);
782$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
783print $hookmanager->resPrint;
784
785print '</table>'."\n";
786print '</div>'."\n";
787
788print '</form>'."\n";
789
790// End of page
791llxFooter();
792$db->close();
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:67
$totalarray
Definition export.php:1206
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:91
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:73
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...)
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...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
print_liste_field_titre($name, $file="", $field="", $begin="", $param="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $selectlimitsuffix=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
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...
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.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.