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