dolibarr 21.0.0-beta
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
356print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
357if ($optioncss != '') {
358 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
359}
360print '<input type="hidden" name="token" value="'.newToken().'">';
361print '<input type="hidden" name="action" value="list">';
362print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
363print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
364print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
365print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
366
367// @phan-suppress-next-line PhanPluginSuspiciousParamOrder
368print_barre_liste($langs->trans('SupplierPayments'), $page, $_SERVER['PHP_SELF'], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'supplier_invoice', 0, '', '', $limit, 0, 0, 1);
369
370if ($search_all) {
371 foreach ($fieldstosearchall as $key => $val) {
372 $fieldstosearchall[$key] = $langs->trans($val);
373 }
374 print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).implode(', ', $fieldstosearchall).'</div>';
375}
376
377$moreforfilter = '';
378
379$parameters = array();
380$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
381if (empty($reshook)) {
382 $moreforfilter .= $hookmanager->resPrint;
383} else {
384 $moreforfilter = $hookmanager->resPrint;
385}
386
387if ($moreforfilter) {
388 print '<div class="liste_titre liste_titre_bydiv centpercent">';
389 print $moreforfilter;
390 print '</div>';
391}
392
393$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
394$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')); // This also change content of $arrayfields
395if (!empty($massactionbutton)) {
396 $selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
397}
398
399print '<div class="div-table-responsive">';
400print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : '').'">';
401
402// Fields title search
403// --------------------------------------------------------------------
404print '<tr class="liste_titre_filter">';
405
406// Action column
407if (getDolGlobalInt('MAIN_CHECKBOX_LEFT_COLUMN')) {
408 print '<td class="liste_titre center maxwidthsearch">';
409 $searchpicto = $form->showFilterButtons('left');
410 print $searchpicto;
411 print '</td>';
412}
413
414// #
415if (getDolGlobalString('MAIN_VIEW_LINE_NUMBER_IN_LIST')) {
416 print '<td class="liste_titre">';
417 print '</td>';
418}
419
420// Filter: Ref
421if (!empty($arrayfields['p.ref']['checked'])) {
422 print '<td class="liste_titre left">';
423 print '<input class="flat" type="text" size="4" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
424 print '</td>';
425}
426
427// Filter: Date
428if (!empty($arrayfields['p.datep']['checked'])) {
429 print '<td class="liste_titre center">';
430 print '<div class="nowrapfordate">';
431 print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
432 print '</div>';
433 print '<div class="nowrapfordate">';
434 print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
435 print '</div>';
436 print '</td>';
437}
438
439// Filter: Thirdparty
440if (!empty($arrayfields['s.nom']['checked'])) {
441 print '<td class="liste_titre">';
442 print '<input class="flat" type="text" size="6" name="search_company" value="'.dol_escape_htmltag($search_company).'">';
443 print '</td>';
444}
445
446// Filter: Payment type
447if (!empty($arrayfields['c.libelle']['checked'])) {
448 print '<td class="liste_titre">';
449 $form->select_types_paiements($search_payment_type, 'search_payment_type', '', 2, 1, 1);
450 print '</td>';
451}
452
453// Filter: Cheque number (fund transfer)
454if (!empty($arrayfields['p.num_paiement']['checked'])) {
455 print '<td class="liste_titre">';
456 print '<input class="flat" type="text" size="4" name="search_cheque_num" value="'.dol_escape_htmltag($search_cheque_num).'">';
457 print '</td>';
458}
459
460// Filter: Bank account
461if (!empty($arrayfields['ba.label']['checked'])) {
462 print '<td class="liste_titre">';
463 $form->select_comptes($search_bank_account, 'search_bank_account', 0, '', 1);
464 print '</td>';
465}
466
467// Filter: Amount
468if (!empty($arrayfields['p.amount']['checked'])) {
469 print '<td class="liste_titre right">';
470 print '<input class="flat" type="text" size="4" name="search_amount" value="'.dol_escape_htmltag($search_amount).'">';
471 print '</td>';
472}
473
474// Fields from hook
475$parameters = array('arrayfields' => $arrayfields);
476$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
477print $hookmanager->resPrint;
478
479// Action column
480if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
481 print '<td class="liste_titre center maxwidthsearch">';
482 $searchpicto = $form->showFilterButtons();
483 print $searchpicto;
484 print '</td>';
485}
486
487print '</tr>'."\n";
488
489$totalarray = array();
490$totalarray['nbfield'] = 0;
491
492// Fields title label
493// --------------------------------------------------------------------
494print '<tr class="liste_titre">';
495// Action column
496if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
497 print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
498 $totalarray['nbfield']++;
499}
500if (getDolGlobalString('MAIN_VIEW_LINE_NUMBER_IN_LIST')) {
501 print_liste_field_titre('#', $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder);
502 $totalarray['nbfield']++;
503}
504if (!empty($arrayfields['p.ref']['checked'])) {
505 // @phan-suppress-next-line PhanTypeInvalidDimOffset
506 print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], 'p.rowid', '', $param, '', $sortfield, $sortorder);
507 $totalarray['nbfield']++;
508}
509if (!empty($arrayfields['p.datep']['checked'])) {
510 print_liste_field_titre($arrayfields['p.datep']['label'], $_SERVER["PHP_SELF"], 'p.datep', '', $param, '', $sortfield, $sortorder, 'center ');
511 $totalarray['nbfield']++;
512}
513if (!empty($arrayfields['s.nom']['checked'])) {
514 print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], 's.nom', '', $param, '', $sortfield, $sortorder);
515 $totalarray['nbfield']++;
516}
517if (!empty($arrayfields['c.libelle']['checked'])) {
518 print_liste_field_titre($arrayfields['c.libelle']['label'], $_SERVER["PHP_SELF"], 'c.libelle', '', $param, '', $sortfield, $sortorder);
519 $totalarray['nbfield']++;
520}
521if (!empty($arrayfields['p.num_paiement']['checked'])) {
522 print_liste_field_titre($arrayfields['p.num_paiement']['label'], $_SERVER["PHP_SELF"], "p.num_paiement", '', $param, '', $sortfield, $sortorder, '', $arrayfields['p.num_paiement']['tooltip']);
523 $totalarray['nbfield']++;
524}
525if (!empty($arrayfields['ba.label']['checked'])) {
526 print_liste_field_titre($arrayfields['ba.label']['label'], $_SERVER["PHP_SELF"], 'ba.label', '', $param, '', $sortfield, $sortorder);
527 $totalarray['nbfield']++;
528}
529if (!empty($arrayfields['p.amount']['checked'])) {
530 print_liste_field_titre($arrayfields['p.amount']['label'], $_SERVER["PHP_SELF"], 'p.amount', '', $param, '', $sortfield, $sortorder, 'right ');
531 $totalarray['nbfield']++;
532}
533
534// Hook fields
535$parameters = array('arrayfields' => $arrayfields, 'param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder);
536$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
537print $hookmanager->resPrint;
538
539// Action column
540if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
541 print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
542 $totalarray['nbfield']++;
543}
544print '</tr>';
545
546print '</tr>'."\n";
547
548// Detect if we need a fetch on each output line
549$needToFetchEachLine = 0;
550if (isset($extrafields->attributes[$object->table_element]['computed']) && is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) {
551 foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) {
552 if (!is_null($val) && preg_match('/\$object/', $val)) {
553 $needToFetchEachLine++; // There is at least one compute field that use $object
554 }
555 }
556}
557
558
559// Loop on record
560// --------------------------------------------------------------------
561$i = 0;
562$savnbfield = $totalarray['nbfield'];
563$totalarray = array();
564$totalarray['nbfield'] = 0;
565$imaxinloop = ($limit ? min($num, $limit) : $num);
566while ($i < $imaxinloop) {
567 $objp = $db->fetch_object($resql);
568 if (empty($objp)) {
569 break; // Should not happen
570 }
571
572 $paymentfournstatic->id = $objp->rowid;
573 $paymentfournstatic->ref = $objp->ref;
574 $paymentfournstatic->datepaye = $db->jdate($objp->datep);
575 $paymentfournstatic->amount = $objp->amount;
576
577 $companystatic->id = $objp->socid;
578 $companystatic->name = $objp->name;
579 $companystatic->email = $objp->email;
580
581 if ($mode == 'kanban') {
582 if ($i == 0) {
583 print '<tr class="trkanban"><td colspan="'.$savnbfield.'">';
584 print '<div class="box-flex-container kanban">';
585 }
586 // Output Kanban
587 $selected = -1;
588 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
589 $selected = 0;
590 if (in_array($object->id, $arrayofselected)) {
591 $selected = 1;
592 }
593 }
594 //print $object->getKanbanView('', array('thirdparty'=>$object->thirdparty, 'selected' => $selected));
595 print $object->getKanbanView('', array('selected' => $selected));
596 if ($i == ($imaxinloop - 1)) {
597 print '</div>';
598 print '</td></tr>';
599 }
600 } else {
601 // Show line of result
602 $j = 0;
603 print '<tr data-rowid="'.$object->id.'" class="oddeven">';
604
605 // Action column
606 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
607 print '<td class="nowrap center">';
608 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
609 $selected = 0;
610 if (in_array($object->id, $arrayofselected)) {
611 $selected = 1;
612 }
613 print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
614 }
615 print '</td>';
616 if (!$i) {
617 $totalarray['nbfield']++;
618 }
619 }
620
621 // No
622 if (getDolGlobalString('MAIN_VIEW_LINE_NUMBER_IN_LIST')) {
623 print '<td class="nowraponall">'.(($offset * $limit) + $i).'</td>';
624 if (!$i) {
625 $totalarray['nbfield']++;
626 }
627 }
628
629 // Ref
630 if (!empty($arrayfields['p.ref']['checked'])) {
631 print '<td class="nowraponall">'.$paymentfournstatic->getNomUrl(1).'</td>';
632 if (!$i) {
633 $totalarray['nbfield']++;
634 }
635 }
636
637 // Date
638 if (!empty($arrayfields['p.datep']['checked'])) {
639 $dateformatforpayment = 'dayhour';
640 print '<td class="nowraponall center">'.dol_print_date($db->jdate($objp->datep), $dateformatforpayment).'</td>';
641 if (!$i) {
642 $totalarray['nbfield']++;
643 }
644 }
645
646 // Thirdparty
647 if (!empty($arrayfields['s.nom']['checked'])) {
648 print '<td class="tdoverflowmax125">';
649 if ($objp->socid > 0) {
650 print $companystatic->getNomUrl(1, '', 24);
651 }
652 print '</td>';
653 if (!$i) {
654 $totalarray['nbfield']++;
655 }
656 }
657
658 // Pyament type
659 if (!empty($arrayfields['c.libelle']['checked'])) {
660 $payment_type = $langs->trans("PaymentType".$objp->paiement_type) != "PaymentType".$objp->paiement_type ? $langs->trans("PaymentType".$objp->paiement_type) : $objp->paiement_libelle;
661 print '<td>'.$payment_type.' '.dol_trunc($objp->num_payment, 32).'</td>';
662 if (!$i) {
663 $totalarray['nbfield']++;
664 }
665 }
666
667 // Cheque number (fund transfer)
668 if (!empty($arrayfields['p.num_paiement']['checked'])) {
669 print '<td>'.$objp->num_payment.'</td>';
670 if (!$i) {
671 $totalarray['nbfield']++;
672 }
673 }
674
675 // Bank account
676 if (!empty($arrayfields['ba.label']['checked'])) {
677 print '<td class="tdoverflowmax125">';
678 if ($objp->bid) {
679 $accountstatic->id = $objp->bid;
680 $accountstatic->ref = $objp->bref;
681 $accountstatic->label = $objp->blabel;
682 $accountstatic->number = $objp->number;
683 $accountstatic->iban = $objp->iban_prefix;
684 $accountstatic->bic = $objp->bic;
685 $accountstatic->currency_code = $objp->currency_code;
686 $accountstatic->account_number = $objp->account_number;
687
688 $accountingjournal = new AccountingJournal($db);
689 $accountingjournal->fetch($objp->accountancy_journal);
690 $accountstatic->accountancy_journal = $accountingjournal->code;
691
692 print $accountstatic->getNomUrl(1);
693 }
694 print '</td>';
695 if (!$i) {
696 $totalarray['nbfield']++;
697 }
698 }
699
700 // Amount
701 if (!empty($arrayfields['p.amount']['checked'])) {
702 print '<td class="right">';
703 if ($objp->nbinvoices > 1 || ($objp->totalamount && $objp->amount != $objp->totalamount)) {
704 print $form->textwithpicto('', $langs->trans("PaymentMadeForSeveralInvoices"));
705 }
706 print '<span class="amount">'.price($objp->amount).'</span>';
707 print '</td>';
708 if (!$i) {
709 $totalarray['nbfield']++;
710 $totalarray['pos'][$totalarray['nbfield']] = 'amount';
711 }
712 if (empty($totalarray['val']['amount'])) {
713 $totalarray['val']['amount'] = $objp->amount;
714 } else {
715 $totalarray['val']['amount'] += $objp->amount;
716 }
717 }
718
719 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
720 print '<td class="nowrap center">';
721 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
722 $selected = 0;
723 if (in_array($object->id, $arrayofselected)) {
724 $selected = 1;
725 }
726 print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
727 }
728 print '</td>';
729 if (!$i) {
730 $totalarray['nbfield']++;
731 }
732 }
733
734 print '</tr>'."\n";
735 }
736 $i++;
737}
738
739// Show total line
740include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
741
742// If no record found
743if ($num == 0) {
744 $colspan = 1;
745 foreach ($arrayfields as $key => $val) {
746 if (!empty($val['checked'])) {
747 $colspan++;
748 }
749 }
750 print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
751}
752
753$db->free($resql);
754
755$parameters = array('arrayfields' => $arrayfields, 'sql' => $sql);
756$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
757print $hookmanager->resPrint;
758
759print '</table>'."\n";
760print '</div>'."\n";
761
762print '</form>'."\n";
763
764// End of page
765llxFooter();
766$db->close();
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:66
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...)
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.
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.