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