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') ? (GETPOSTINT('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, $object, $action); // 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 // @phan-suppress-next-line PhanTypeInvalidDimOffset
498 print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], 'p.rowid', '', $param, '', $sortfield, $sortorder);
499 $totalarray['nbfield']++;
500}
501if (!empty($arrayfields['p.datep']['checked'])) {
502 print_liste_field_titre($arrayfields['p.datep']['label'], $_SERVER["PHP_SELF"], 'p.datep', '', $param, '', $sortfield, $sortorder, 'center ');
503 $totalarray['nbfield']++;
504}
505if (!empty($arrayfields['s.nom']['checked'])) {
506 print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], 's.nom', '', $param, '', $sortfield, $sortorder);
507 $totalarray['nbfield']++;
508}
509if (!empty($arrayfields['c.libelle']['checked'])) {
510 print_liste_field_titre($arrayfields['c.libelle']['label'], $_SERVER["PHP_SELF"], 'c.libelle', '', $param, '', $sortfield, $sortorder);
511 $totalarray['nbfield']++;
512}
513if (!empty($arrayfields['p.num_paiement']['checked'])) {
514 print_liste_field_titre($arrayfields['p.num_paiement']['label'], $_SERVER["PHP_SELF"], "p.num_paiement", '', $param, '', $sortfield, $sortorder, '', $arrayfields['p.num_paiement']['tooltip']);
515 $totalarray['nbfield']++;
516}
517if (!empty($arrayfields['ba.label']['checked'])) {
518 print_liste_field_titre($arrayfields['ba.label']['label'], $_SERVER["PHP_SELF"], 'ba.label', '', $param, '', $sortfield, $sortorder);
519 $totalarray['nbfield']++;
520}
521if (!empty($arrayfields['p.amount']['checked'])) {
522 print_liste_field_titre($arrayfields['p.amount']['label'], $_SERVER["PHP_SELF"], 'p.amount', '', $param, '', $sortfield, $sortorder, 'right ');
523 $totalarray['nbfield']++;
524}
525
526// Hook fields
527$parameters = array('arrayfields' => $arrayfields, 'param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder);
528$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
529print $hookmanager->resPrint;
530
531// Action column
532if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
533 print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
534 $totalarray['nbfield']++;
535}
536print '</tr>';
537
538print '</tr>'."\n";
539
540// Detect if we need a fetch on each output line
541$needToFetchEachLine = 0;
542if (isset($extrafields->attributes[$object->table_element]['computed']) && is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) {
543 foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) {
544 if (!is_null($val) && preg_match('/\$object/', $val)) {
545 $needToFetchEachLine++; // There is at least one compute field that use $object
546 }
547 }
548}
549
550
551// Loop on record
552// --------------------------------------------------------------------
553$i = 0;
554$savnbfield = $totalarray['nbfield'];
555$totalarray = array();
556$totalarray['nbfield'] = 0;
557$imaxinloop = ($limit ? min($num, $limit) : $num);
558while ($i < $imaxinloop) {
559 $objp = $db->fetch_object($resql);
560 if (empty($objp)) {
561 break; // Should not happen
562 }
563
564 $paymentfournstatic->id = $objp->rowid;
565 $paymentfournstatic->ref = $objp->ref;
566 $paymentfournstatic->datepaye = $db->jdate($objp->datep);
567 $paymentfournstatic->amount = $objp->amount;
568
569 $companystatic->id = $objp->socid;
570 $companystatic->name = $objp->name;
571 $companystatic->email = $objp->email;
572
573 if ($mode == 'kanban') {
574 if ($i == 0) {
575 print '<tr class="trkanban"><td colspan="'.$savnbfield.'">';
576 print '<div class="box-flex-container kanban">';
577 }
578 // Output Kanban
579 $selected = -1;
580 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
581 $selected = 0;
582 if (in_array($object->id, $arrayofselected)) {
583 $selected = 1;
584 }
585 }
586 //print $object->getKanbanView('', array('thirdparty'=>$object->thirdparty, 'selected' => $selected));
587 print $object->getKanbanView('', array('selected' => $selected));
588 if ($i == ($imaxinloop - 1)) {
589 print '</div>';
590 print '</td></tr>';
591 }
592 } else {
593 // Show line of result
594 $j = 0;
595 print '<tr data-rowid="'.$object->id.'" class="oddeven">';
596
597 // Action column
598 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
599 print '<td class="nowrap center">';
600 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
601 $selected = 0;
602 if (in_array($object->id, $arrayofselected)) {
603 $selected = 1;
604 }
605 print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
606 }
607 print '</td>';
608 if (!$i) {
609 $totalarray['nbfield']++;
610 }
611 }
612
613 // No
614 if (getDolGlobalString('MAIN_VIEW_LINE_NUMBER_IN_LIST')) {
615 print '<td class="nowraponall">'.(($offset * $limit) + $i).'</td>';
616 if (!$i) {
617 $totalarray['nbfield']++;
618 }
619 }
620
621 // Ref
622 if (!empty($arrayfields['p.ref']['checked'])) {
623 print '<td class="nowraponall">'.$paymentfournstatic->getNomUrl(1).'</td>';
624 if (!$i) {
625 $totalarray['nbfield']++;
626 }
627 }
628
629 // Date
630 if (!empty($arrayfields['p.datep']['checked'])) {
631 $dateformatforpayment = 'dayhour';
632 print '<td class="nowraponall center">'.dol_print_date($db->jdate($objp->datep), $dateformatforpayment).'</td>';
633 if (!$i) {
634 $totalarray['nbfield']++;
635 }
636 }
637
638 // Thirdparty
639 if (!empty($arrayfields['s.nom']['checked'])) {
640 print '<td class="tdoverflowmax125">';
641 if ($objp->socid > 0) {
642 print $companystatic->getNomUrl(1, '', 24);
643 }
644 print '</td>';
645 if (!$i) {
646 $totalarray['nbfield']++;
647 }
648 }
649
650 // Pyament type
651 if (!empty($arrayfields['c.libelle']['checked'])) {
652 $payment_type = $langs->trans("PaymentType".$objp->paiement_type) != "PaymentType".$objp->paiement_type ? $langs->trans("PaymentType".$objp->paiement_type) : $objp->paiement_libelle;
653 print '<td>'.$payment_type.' '.dol_trunc($objp->num_payment, 32).'</td>';
654 if (!$i) {
655 $totalarray['nbfield']++;
656 }
657 }
658
659 // Cheque number (fund transfer)
660 if (!empty($arrayfields['p.num_paiement']['checked'])) {
661 print '<td>'.$objp->num_payment.'</td>';
662 if (!$i) {
663 $totalarray['nbfield']++;
664 }
665 }
666
667 // Bank account
668 if (!empty($arrayfields['ba.label']['checked'])) {
669 print '<td class="tdoverflowmax125">';
670 if ($objp->bid) {
671 $accountstatic->id = $objp->bid;
672 $accountstatic->ref = $objp->bref;
673 $accountstatic->label = $objp->blabel;
674 $accountstatic->number = $objp->number;
675 $accountstatic->iban = $objp->iban_prefix;
676 $accountstatic->bic = $objp->bic;
677 $accountstatic->currency_code = $objp->currency_code;
678 $accountstatic->account_number = $objp->account_number;
679
680 $accountingjournal = new AccountingJournal($db);
681 $accountingjournal->fetch($objp->accountancy_journal);
682 $accountstatic->accountancy_journal = $accountingjournal->code;
683
684 print $accountstatic->getNomUrl(1);
685 }
686 print '</td>';
687 if (!$i) {
688 $totalarray['nbfield']++;
689 }
690 }
691
692 // Amount
693 if (!empty($arrayfields['p.amount']['checked'])) {
694 print '<td class="right">';
695 if ($objp->nbinvoices > 1 || ($objp->totalamount && $objp->amount != $objp->totalamount)) {
696 print $form->textwithpicto('', $langs->trans("PaymentMadeForSeveralInvoices"));
697 }
698 print '<span class="amount">'.price($objp->amount).'</span>';
699 print '</td>';
700 if (!$i) {
701 $totalarray['nbfield']++;
702 $totalarray['pos'][$totalarray['nbfield']] = 'amount';
703 }
704 if (empty($totalarray['val']['amount'])) {
705 $totalarray['val']['amount'] = $objp->amount;
706 } else {
707 $totalarray['val']['amount'] += $objp->amount;
708 }
709 }
710
711 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
712 print '<td class="nowrap center">';
713 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
714 $selected = 0;
715 if (in_array($object->id, $arrayofselected)) {
716 $selected = 1;
717 }
718 print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
719 }
720 print '</td>';
721 if (!$i) {
722 $totalarray['nbfield']++;
723 }
724 }
725
726 print '</tr>'."\n";
727 }
728 $i++;
729}
730
731// Show total line
732include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
733
734// If no record found
735if ($num == 0) {
736 $colspan = 1;
737 foreach ($arrayfields as $key => $val) {
738 if (!empty($val['checked'])) {
739 $colspan++;
740 }
741 }
742 print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
743}
744
745$db->free($resql);
746
747$parameters = array('arrayfields' => $arrayfields, 'sql' => $sql);
748$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
749print $hookmanager->resPrint;
750
751print '</table>'."\n";
752print '</div>'."\n";
753
754print '</form>'."\n";
755
756// End of page
757llxFooter();
758$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...
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.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.