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