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