dolibarr 23.0.4
list.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2003-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
4 * Copyright (C) 2004-2020 Laurent Destailleur <eldy@users.sourceforge.net>
5 * Copyright (C) 2004 Christophe Combelles <ccomb@free.fr>
6 * Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
7 * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
8 * Copyright (C) 2014 Teddy Andreotti <125155@supinfo.com>
9 * Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
10 * Copyright (C) 2015 Juanjo Menent <jmenent@2byte.es>
11 * Copyright (C) 2017-2023 Alexandre Spangaro <aspangaro@easya.solutions>
12 * Copyright (C) 2018-2025 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 $sortfield = "p.datep";
97}
98
99$search_all = trim(GETPOST('search_all', 'alphanohtml'));
100
101// List of fields to search into when doing a "search in all"
102$fieldstosearchall = array(
103 'p.ref' => "RefPayment",
104 's.nom' => "ThirdParty",
105 'p.num_paiement' => "Numero",
106 'p.amount' => "Amount",
107);
108
109$arrayfields = array(
110 'p.ref' => array('label' => "RefPayment", 'checked' => '1', 'position' => 10),
111 'p.datep' => array('label' => "Date", 'checked' => '1', 'position' => 20),
112 's.nom' => array('label' => "ThirdParty", 'checked' => '1', 'position' => 30),
113 'c.libelle' => array('label' => "Type", 'checked' => '1', 'position' => 40),
114 'p.num_paiement' => array('label' => "Numero", 'checked' => '1', 'position' => 50, 'tooltip' => "ChequeOrTransferNumber"),
115 'ba.label' => array('label' => "BankAccount", 'checked' => '1', 'position' => 60, 'enabled' => (string) (int) (isModEnabled("bank"))),
116 'p.amount' => array('label' => "Amount", 'checked' => '1', 'position' => 70),
117);
118$arrayfields = dol_sort_array($arrayfields, 'position');
119
120// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
121$hookmanager->initHooks(array('paymentsupplierlist'));
122$object = new PaiementFourn($db);
123
124if (!$user->hasRight('societe', 'client', 'voir')) {
125 $search_sale = $user->id;
126}
127
128// Security check
129if ($user->socid) {
130 $socid = $user->socid;
131}
132
133// doesn't work :-(
134// restrictedArea($user, 'fournisseur');
135// doesn't work :-(
136// require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php';
137// $object = new PaiementFourn($db);
138// restrictedArea($user, $object->element);
139if (!isModEnabled('supplier_invoice')) {
141}
142if ((!$user->hasRight("fournisseur", "facture", "lire") && !getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD'))
143 || (!$user->hasRight("supplier_invoice", "lire") && getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD'))) {
145}
146
147$arrayofselected = !empty($arrayofselected) && is_array($arrayofselected) ? $arrayofselected : array();
148
149
150/*
151 * Actions
152 */
153
154$parameters = array('socid' => $socid);
155$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
156if ($reshook < 0) {
157 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
158}
159
160if (empty($reshook)) {
161 include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
162
163 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
164 $search_ref = '';
165 $search_date_startday = '';
166 $search_date_startmonth = '';
167 $search_date_startyear = '';
168 $search_date_endday = '';
169 $search_date_endmonth = '';
170 $search_date_endyear = '';
171 $search_date_start = '';
172 $search_date_end = '';
173 $search_company = '';
174 $search_payment_type = '';
175 $search_cheque_num = '';
176 $search_bank_account = '';
177 $search_amount = '';
178 $option = '';
179 $toselect = array();
180 $search_array_options = array();
181 }
182}
183
184
185/*
186 * View
187 */
188
189$title = $langs->trans('ListPayment');
190$help_url = '';
191
192llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'bodyforlist');
193
194$form = new Form($db);
195$formother = new FormOther($db);
196$accountstatic = new Account($db);
197$companystatic = new Societe($db);
198$paymentfournstatic = new PaiementFourn($db);
199
200$sql = 'SELECT p.rowid, p.ref, p.datep, p.fk_bank, p.statut, p.num_paiement as num_payment, p.amount';
201$sql .= ', c.code as paiement_type, c.libelle as paiement_libelle';
202$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';
203$sql .= ', s.rowid as socid, s.nom as name, s.email';
204// 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)
205// so SUM(pf.amount) should be equal to p.amount but if we filter on $socid, it may differ
206$sql .= ", SUM(pf.amount) as totalamount, COUNT(f.rowid) as nbinvoices";
207
208$sqlfields = $sql; // $sql fields to remove for count total
209
210$sql .= ' FROM '.MAIN_DB_PREFIX.'paiementfourn AS p';
211$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement AS c ON p.fk_paiement = c.id';
212$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON p.fk_bank = b.rowid';
213$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank_account as ba ON b.fk_account = ba.rowid';
214
215$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn_facturefourn AS pf ON p.rowid = pf.fk_paiementfourn';
216$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'facture_fourn AS f ON f.rowid = pf.fk_facturefourn';
217$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe AS s ON s.rowid = f.fk_soc';
218
219$sql .= ' WHERE f.entity IN ('.getEntity('supplier_invoice').')'; // TODO We should use p.entity that does not exists yet in this table
220if ($socid > 0) {
221 $sql .= " AND EXISTS (SELECT f.fk_soc FROM ".MAIN_DB_PREFIX."facture_fourn as f, ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf";
222 $sql .= " WHERE p.rowid = pf.fk_paiementfourn AND pf.fk_facturefourn = f.rowid AND f.fk_soc = ".((int) $socid).")";
223}
224
225// Search criteria
226if ($search_ref) {
227 $sql .= natural_search('p.ref', $search_ref);
228}
229if ($search_date_start) {
230 $sql .= " AND p.datep >= '" . $db->idate($search_date_start) . "'";
231}
232if ($search_date_end) {
233 $sql .= " AND p.datep <= '" . $db->idate($search_date_end) . "'";
234}
235
236if ($search_company) {
237 $sql .= natural_search('s.nom', $search_company);
238}
239if ($search_payment_type != '') {
240 $sql .= " AND c.code = '".$db->escape($search_payment_type)."'";
241}
242if ($search_cheque_num != '') {
243 $sql .= natural_search('p.num_paiement', $search_cheque_num);
244}
245if ($search_amount) {
246 $sql .= " AND (".natural_search('p.amount', $search_amount, 1, 1);
247 $sql .= " OR ";
248 $sql .= natural_search('pf.amount', $search_amount, 1, 1);
249 $sql .= ")";
250}
251if ($search_bank_account > 0) {
252 $sql .= ' AND b.fk_account = '.((int) $search_bank_account);
253}
254if ($search_all) {
255 $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
256}
257// Search on sale representative
258if ($search_sale && $search_sale != '-1') {
259 if ($search_sale == -2) {
260 $sql .= " AND NOT EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc WHERE sc.fk_soc = f.fk_soc)";
261 } elseif ($search_sale > 0) {
262 $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).")";
263 }
264}
265
266// Add where from extra fields
267include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
268
269$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,';
270$sql .= ' ba.rowid, ba.ref, ba.label, ba.number, ba.account_number, ba.iban_prefix, ba.bic, ba.currency_code, ba.fk_accountancy_journal';
271
272// Count total nb of records
273$nbtotalofrecords = '';
274if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
275 /* The fast and low memory method to get and count full list converts the sql into a sql count */
276 $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(DISTINCT p.rowid) as nbtotalofrecords', $sql);
277 $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount);
278 $resql = $db->query($sqlforcount);
279 if ($resql) {
280 $objforcount = $db->fetch_object($resql);
281 $nbtotalofrecords = $objforcount->nbtotalofrecords;
282 } else {
283 dol_print_error($db);
284 }
285
286 if (($page * $limit) > (int) $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
287 $page = 0;
288 $offset = 0;
289 }
290 $db->free($resql);
291}
292
293// Complete request and execute it with limit
294$sql .= $db->order($sortfield, $sortorder);
295if ($limit) {
296 $sql .= $db->plimit($limit + 1, $offset);
297}
298//print $sql;
299
300$resql = $db->query($sql);
301if (!$resql) {
302 dol_print_error($db);
303 llxFooter();
304 $db->close();
305 exit;
306}
307
308$num = $db->num_rows($resql);
309$i = 0;
310
311$param = '';
312if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
313 $param .= '&contextpage='.urlencode($contextpage);
314}
315if ($limit > 0 && $limit != $conf->liste_limit) {
316 $param .= '&limit='.((int) $limit);
317}
318if ($optioncss != '') {
319 $param .= '&optioncss='.urlencode($optioncss);
320}
321
322if ($search_ref) {
323 $param .= '&search_ref='.urlencode($search_ref);
324}
325if ($search_date_startday) {
326 $param .= '&search_date_startday='.urlencode((string) ($search_date_startday));
327}
328if ($search_date_startmonth) {
329 $param .= '&search_date_startmonth='.urlencode((string) ($search_date_startmonth));
330}
331if ($search_date_startyear) {
332 $param .= '&search_date_startyear='.urlencode((string) ($search_date_startyear));
333}
334if ($search_date_endday) {
335 $param .= '&search_date_endday='.urlencode((string) ($search_date_endday));
336}
337if ($search_date_endmonth) {
338 $param .= '&search_date_endmonth='.urlencode((string) ($search_date_endmonth));
339}
340if ($search_date_endyear) {
341 $param .= '&search_date_endyear='.urlencode((string) ($search_date_endyear));
342}
343if ($search_company) {
344 $param .= '&search_company='.urlencode($search_company);
345}
346if ($search_payment_type) {
347 $param .= '&search_company='.urlencode($search_payment_type);
348}
349if ($search_cheque_num) {
350 $param .= '&search_cheque_num='.urlencode($search_cheque_num);
351}
352if ($search_amount) {
353 $param .= '&search_amount='.urlencode($search_amount);
354}
355
356// Add $param from extra fields
357include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
358
359// List of mass actions available
360$arrayofmassactions = array(
361 //'validate'=>img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("Validate"),
362 //'generate_doc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"),
363 //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
364 //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
365);
366/*if (!empty($permissiontodelete)) {
367 $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
368}*/
369if (GETPOSTINT('nomassaction') || in_array($massaction, array('presend', 'predelete'))) {
370 $arrayofmassactions = array();
371}
372$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
373
374print '<form method="POST" action="'.dolBuildUrl($_SERVER["PHP_SELF"]).'">';
375if ($optioncss != '') {
376 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
377}
378print '<input type="hidden" name="token" value="'.newToken().'">';
379print '<input type="hidden" name="action" value="list">';
380print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
381print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
382print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
383print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
384
385// @phan-suppress-next-line PhanPluginSuspiciousParamOrder
386print_barre_liste($langs->trans('SupplierPayments'), $page, $_SERVER['PHP_SELF'], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'supplier_invoice', 0, '', '', $limit, 0, 0, 1);
387
388if ($search_all) {
389 foreach ($fieldstosearchall as $key => $val) {
390 $fieldstosearchall[$key] = $langs->trans($val);
391 }
392 print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).implode(', ', $fieldstosearchall).'</div>';
393}
394
395$moreforfilter = '';
396
397$parameters = array();
398$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
399if (empty($reshook)) {
400 $moreforfilter .= $hookmanager->resPrint;
401} else {
402 $moreforfilter = $hookmanager->resPrint;
403}
404
405if ($moreforfilter) {
406 print '<div class="liste_titre liste_titre_bydiv centpercent">';
407 print $moreforfilter;
408 print '</div>';
409}
410
411$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
412$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')); // This also change content of $arrayfields
413if (!empty($massactionbutton)) {
414 $selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
415}
416
417print '<div class="div-table-responsive">';
418print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : '').'">';
419
420// Fields title search
421// --------------------------------------------------------------------
422print '<tr class="liste_titre_filter">';
423
424// Action column
425if (getDolGlobalInt('MAIN_CHECKBOX_LEFT_COLUMN')) {
426 print '<td class="liste_titre center maxwidthsearch">';
427 $searchpicto = $form->showFilterButtons('left');
428 print $searchpicto;
429 print '</td>';
430}
431
432// #
433if (getDolGlobalString('MAIN_VIEW_LINE_NUMBER_IN_LIST')) {
434 print '<td class="liste_titre">';
435 print '</td>';
436}
437
438// Filter: Ref
439if (!empty($arrayfields['p.ref']['checked'])) {
440 print '<td class="liste_titre left">';
441 print '<input class="flat" type="text" size="4" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
442 print '</td>';
443}
444
445// Filter: Date
446if (!empty($arrayfields['p.datep']['checked'])) {
447 print '<td class="liste_titre center">';
448 print '<div class="nowrapfordate">';
449 print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
450 print '</div>';
451 print '<div class="nowrapfordate">';
452 print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
453 print '</div>';
454 print '</td>';
455}
456
457// Filter: Thirdparty
458if (!empty($arrayfields['s.nom']['checked'])) {
459 print '<td class="liste_titre">';
460 print '<input class="flat" type="text" size="6" name="search_company" value="'.dol_escape_htmltag($search_company).'">';
461 print '</td>';
462}
463
464// Filter: Payment mode
465if (!empty($arrayfields['c.libelle']['checked'])) {
466 print '<td class="liste_titre">';
467 print $form->select_types_paiements($search_payment_type, 'search_payment_type', '', 2, 1, 1, 0, 1, 'maxwidth100', 1);
468 print '</td>';
469}
470
471// Filter: Cheque number (fund transfer)
472if (!empty($arrayfields['p.num_paiement']['checked'])) {
473 print '<td class="liste_titre">';
474 print '<input class="flat" type="text" size="4" name="search_cheque_num" value="'.dol_escape_htmltag($search_cheque_num).'">';
475 print '</td>';
476}
477
478// Filter: Bank account
479if (!empty($arrayfields['ba.label']['checked'])) {
480 print '<td class="liste_titre">';
481 $form->select_comptes($search_bank_account, 'search_bank_account', 0, '', 1);
482 print '</td>';
483}
484
485// Filter: Amount
486if (!empty($arrayfields['p.amount']['checked'])) {
487 print '<td class="liste_titre right">';
488 print '<input class="flat" type="text" size="4" name="search_amount" value="'.dol_escape_htmltag($search_amount).'">';
489 print '</td>';
490}
491
492// Fields from hook
493$parameters = array('arrayfields' => $arrayfields);
494$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
495print $hookmanager->resPrint;
496
497// Action column
498if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
499 print '<td class="liste_titre center maxwidthsearch">';
500 $searchpicto = $form->showFilterButtons();
501 print $searchpicto;
502 print '</td>';
503}
504
505print '</tr>'."\n";
506
507$totalarray = array();
508$totalarray['nbfield'] = 0;
509
510// Fields title label
511// --------------------------------------------------------------------
512print '<tr class="liste_titre">';
513// Action column
514if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
515 print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
516 $totalarray['nbfield']++;
517}
518if (getDolGlobalString('MAIN_VIEW_LINE_NUMBER_IN_LIST')) {
519 print_liste_field_titre('#', $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder);
520 $totalarray['nbfield']++;
521}
522if (!empty($arrayfields['p.ref']['checked'])) {
523 // @phan-suppress-next-line PhanTypeInvalidDimOffset
524 print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], 'p.rowid', '', $param, '', $sortfield, $sortorder);
525 $totalarray['nbfield']++;
526}
527if (!empty($arrayfields['p.datep']['checked'])) {
528 print_liste_field_titre($arrayfields['p.datep']['label'], $_SERVER["PHP_SELF"], 'p.datep', '', $param, '', $sortfield, $sortorder, 'center ');
529 $totalarray['nbfield']++;
530}
531if (!empty($arrayfields['s.nom']['checked'])) {
532 print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], 's.nom', '', $param, '', $sortfield, $sortorder);
533 $totalarray['nbfield']++;
534}
535if (!empty($arrayfields['c.libelle']['checked'])) {
536 print_liste_field_titre($arrayfields['c.libelle']['label'], $_SERVER["PHP_SELF"], 'c.libelle', '', $param, '', $sortfield, $sortorder);
537 $totalarray['nbfield']++;
538}
539if (!empty($arrayfields['p.num_paiement']['checked'])) {
540 print_liste_field_titre($arrayfields['p.num_paiement']['label'], $_SERVER["PHP_SELF"], "p.num_paiement", '', $param, '', $sortfield, $sortorder, '', $arrayfields['p.num_paiement']['tooltip']);
541 $totalarray['nbfield']++;
542}
543if (!empty($arrayfields['ba.label']['checked'])) {
544 print_liste_field_titre($arrayfields['ba.label']['label'], $_SERVER["PHP_SELF"], 'ba.label', '', $param, '', $sortfield, $sortorder);
545 $totalarray['nbfield']++;
546}
547if (!empty($arrayfields['p.amount']['checked'])) {
548 print_liste_field_titre($arrayfields['p.amount']['label'], $_SERVER["PHP_SELF"], 'p.amount', '', $param, '', $sortfield, $sortorder, 'right ');
549 $totalarray['nbfield']++;
550}
551
552// Hook fields
553$parameters = array('arrayfields' => $arrayfields, 'param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder);
554$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
555print $hookmanager->resPrint;
556
557// Action column
558if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
559 print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
560 $totalarray['nbfield']++;
561}
562print '</tr>';
563
564print '</tr>'."\n";
565
566// Detect if we need a fetch on each output line
567$needToFetchEachLine = 0;
568if (isset($extrafields->attributes[$object->table_element]['computed']) && is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) {
569 foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) {
570 if (!is_null($val) && preg_match('/\$object/', $val)) {
571 $needToFetchEachLine++; // There is at least one compute field that use $object
572 }
573 }
574}
575
576
577// Loop on record
578// --------------------------------------------------------------------
579$i = 0;
580$savnbfield = $totalarray['nbfield'];
581$totalarray = array();
582$totalarray['nbfield'] = 0;
583$imaxinloop = ($limit ? min($num, $limit) : $num);
584while ($i < $imaxinloop) {
585 $objp = $db->fetch_object($resql);
586 if (empty($objp)) {
587 break; // Should not happen
588 }
589
590 $paymentfournstatic->id = $objp->rowid;
591 $paymentfournstatic->ref = $objp->ref;
592 $paymentfournstatic->datepaye = $db->jdate($objp->datep);
593 $paymentfournstatic->amount = $objp->amount;
594
595 $companystatic->id = $objp->socid;
596 $companystatic->name = $objp->name;
597 $companystatic->email = $objp->email;
598
599 if ($mode == 'kanban') {
600 if ($i == 0) {
601 print '<tr class="trkanban"><td colspan="'.$savnbfield.'">';
602 print '<div class="box-flex-container kanban">';
603 }
604 // Output Kanban
605 $selected = -1;
606 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
607 $selected = 0;
608 if (in_array($object->id, $arrayofselected)) {
609 $selected = 1;
610 }
611 }
612 //print $object->getKanbanView('', array('thirdparty'=>$object->thirdparty, 'selected' => $selected));
613 print $object->getKanbanView('', array('selected' => $selected));
614 if ($i == ($imaxinloop - 1)) {
615 print '</div>';
616 print '</td></tr>';
617 }
618 } else {
619 // Show line of result
620 $j = 0;
621 print '<tr data-rowid="'.$object->id.'" class="oddeven row-with-select">';
622
623 // Action column
624 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
625 print '<td class="nowrap center">';
626 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
627 $selected = 0;
628 if (in_array($object->id, $arrayofselected)) {
629 $selected = 1;
630 }
631 print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
632 }
633 print '</td>';
634 if (!$i) {
635 $totalarray['nbfield']++;
636 }
637 }
638
639 // No
640 if (getDolGlobalString('MAIN_VIEW_LINE_NUMBER_IN_LIST')) {
641 print '<td class="nowraponall">'.(($offset * $limit) + $i).'</td>';
642 if (!$i) {
643 $totalarray['nbfield']++;
644 }
645 }
646
647 // Ref
648 if (!empty($arrayfields['p.ref']['checked'])) {
649 print '<td class="nowraponall">'.$paymentfournstatic->getNomUrl(1).'</td>';
650 if (!$i) {
651 $totalarray['nbfield']++;
652 }
653 }
654
655 // Date
656 if (!empty($arrayfields['p.datep']['checked'])) {
657 $dateformatforpayment = 'dayhour';
658 print '<td class="nowraponall center">'.dol_print_date($db->jdate($objp->datep), $dateformatforpayment).'</td>';
659 if (!$i) {
660 $totalarray['nbfield']++;
661 }
662 }
663
664 // Thirdparty
665 if (!empty($arrayfields['s.nom']['checked'])) {
666 print '<td class="tdoverflowmax125">';
667 if ($objp->socid > 0) {
668 print $companystatic->getNomUrl(1, '', 24);
669 }
670 print '</td>';
671 if (!$i) {
672 $totalarray['nbfield']++;
673 }
674 }
675
676 // Pyament type
677 if (!empty($arrayfields['c.libelle']['checked'])) {
678 $payment_type = $langs->trans("PaymentType".$objp->paiement_type) != "PaymentType".$objp->paiement_type ? $langs->trans("PaymentType".$objp->paiement_type) : $objp->paiement_libelle;
679 print '<td>'.$payment_type.' '.dol_trunc($objp->num_payment, 32).'</td>';
680 if (!$i) {
681 $totalarray['nbfield']++;
682 }
683 }
684
685 // Cheque number (fund transfer)
686 if (!empty($arrayfields['p.num_paiement']['checked'])) {
687 print '<td>'.$objp->num_payment.'</td>';
688 if (!$i) {
689 $totalarray['nbfield']++;
690 }
691 }
692
693 // Bank account
694 if (!empty($arrayfields['ba.label']['checked'])) {
695 print '<td class="tdoverflowmax125">';
696 if ($objp->bid) {
697 $accountstatic->id = $objp->bid;
698 $accountstatic->ref = $objp->bref;
699 $accountstatic->label = $objp->blabel;
700 $accountstatic->number = $objp->number;
701 $accountstatic->iban = $objp->iban_prefix;
702 $accountstatic->bic = $objp->bic;
703 $accountstatic->currency_code = $objp->currency_code;
704 $accountstatic->account_number = $objp->account_number;
705
706 $accountingjournal = new AccountingJournal($db);
707 $accountingjournal->fetch($objp->accountancy_journal);
708 $accountstatic->accountancy_journal = $accountingjournal->code;
709
710 print $accountstatic->getNomUrl(1);
711 }
712 print '</td>';
713 if (!$i) {
714 $totalarray['nbfield']++;
715 }
716 }
717
718 // Amount
719 if (!empty($arrayfields['p.amount']['checked'])) {
720 print '<td class="right">';
721 if ($objp->nbinvoices > 1 || ($objp->totalamount && $objp->amount != $objp->totalamount)) {
722 print $form->textwithpicto('', $langs->trans("PaymentMadeForSeveralInvoices"));
723 }
724 print '<span class="amount">'.price($objp->amount).'</span>';
725 print '</td>';
726 if (!$i) {
727 $totalarray['nbfield']++;
728 $totalarray['pos'][$totalarray['nbfield']] = 'amount';
729 }
730 if (empty($totalarray['val']['amount'])) {
731 $totalarray['val']['amount'] = $objp->amount;
732 } else {
733 $totalarray['val']['amount'] += $objp->amount;
734 }
735 }
736
737 // Fields from hook
738 $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$objp, 'i'=>$i, 'totalarray'=>&$totalarray);
739 $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
740 print $hookmanager->resPrint;
741
742 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
743 print '<td class="nowrap center">';
744 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
745 $selected = 0;
746 if (in_array($object->id, $arrayofselected)) {
747 $selected = 1;
748 }
749 print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
750 }
751 print '</td>';
752 if (!$i) {
753 $totalarray['nbfield']++;
754 }
755 }
756
757 print '</tr>'."\n";
758 }
759
760 $i++;
761}
762
763// Show total line
764include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
765
766// If no record found
767if ($num == 0) {
768 $colspan = 1;
769 foreach ($arrayfields as $key => $val) {
770 if (!empty($val['checked'])) {
771 $colspan++;
772 }
773 }
774 print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
775}
776
777$db->free($resql);
778
779$parameters = array('arrayfields' => $arrayfields, 'sql' => $sql);
780$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
781print $hookmanager->resPrint;
782
783print '</table>'."\n";
784print '</div>'."\n";
785
786print '</form>'."\n";
787
788// End of page
789llxFooter();
790$db->close();
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
$totalarray
Definition export.php:1216
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, $sqltoadd='')
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.
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.