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