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