dolibarr 22.0.5
list.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2001-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.com>
5 * Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr>
6 * Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
7 * Copyright (C) 2015 Juanjo Menent <jmenent@2byte.es>
8 * Copyright (C) 2017-2024 Alexandre Spangaro <alexandre@inovea-conseil.com>
9 * Copyright (C) 2018-2021 Ferran Marcet <fmarcet@2byte.es>
10 * Copyright (C) 2018 Charlene Benke <charlie@patas-monkey.com>
11 * Copyright (C) 2020 Tobias Sekan <tobias.sekan@startmail.com>
12 * Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
13 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
14 *
15 * This program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 3 of the License, or
18 * (at your option) any later version.
19 *
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * You should have received a copy of the GNU General Public License
26 * along with this program. If not, see <https://www.gnu.org/licenses/>.
27 */
28
35// Load Dolibarr environment
36require '../../main.inc.php';
37require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
38require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
39require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
40require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
41require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php';
42
51// Load translation files required by the page
52$langs->loadLangs(array('bills', 'banks', 'compta', 'companies'));
53
54$action = GETPOST('action', 'alpha');
55$massaction = GETPOST('massaction', 'alpha');
56$confirm = GETPOST('confirm', 'alpha');
57$optioncss = GETPOST('optioncss', 'alpha');
58$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'paymentlist';
59$mode = GETPOST('mode', 'alpha');
60
61$facid = GETPOST('facid', 'int');
62$socid = GETPOST('socid', 'int');
63$userid = GETPOST('userid', 'int');
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_paymenttype = GETPOST("search_paymenttype");
76$search_account = GETPOST("search_account", 'alpha');
77$search_payment_num = GETPOST('search_payment_num', 'alpha');
78$search_amount = GETPOST("search_amount", 'alpha'); // alpha because we must be able to search on "< x"
79$search_noteprivate = GETPOST("search_noteprivate");
80$search_status = GETPOST('search_status', 'intcomma');
81$search_sale = GETPOSTINT('search_sale');
82
83
84$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
85$sortfield = GETPOST('sortfield', 'aZ09comma');
86$sortorder = GETPOST('sortorder', 'aZ09comma');
87$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
88
89if (empty($page) || $page == -1) {
90 $page = 0; // If $page is not defined, or '' or -1
91}
92$offset = $limit * $page;
93$pageprev = $page - 1;
94$pagenext = $page + 1;
95
96if (!$sortorder) {
97 $sortorder = "DESC";
98}
99if (!$sortfield) {
100 $sortfield = "p.ref";
101}
102
103$search_all = trim(GETPOST('search_all', 'alphanohtml'));
104
105$arrayofselected = !empty($arrayofselected) && is_array($arrayofselected) ? $arrayofselected : array();
106
107// List of fields to search into when doing a "search in all"
108$fieldstosearchall = array(
109 'p.ref' => "RefPayment",
110 's.nom' => "ThirdParty",
111 'p.num_paiement' => "Numero",
112 'p.amount' => "Amount",
113);
114
115$arrayfields = array(
116 'p.ref' => array('label' => "RefPayment", 'checked' => '1', 'position' => 10),
117 'p.datep' => array('label' => "Date", 'checked' => '1', 'position' => 20),
118 's.nom' => array('label' => "ThirdParty", 'checked' => '1', 'position' => 30),
119 'c.libelle' => array('label' => "Type", 'checked' => '1', 'position' => 40),
120 'transaction' => array('label' => "BankTransactionLine", 'checked' => '1', 'position' => 50, 'enabled' => (string) (int) (isModEnabled("bank"))),
121 'ba.label' => array('label' => "BankAccount", 'checked' => '1', 'position' => 60, 'enabled' => (string) (int) (isModEnabled("bank"))),
122 'p.num_paiement' => array('label' => "Numero", 'checked' => '1', 'position' => 70, 'tooltip' => "ChequeOrTransferNumber"),
123 'p.amount' => array('label' => "Amount", 'checked' => '1', 'position' => 80),
124 'p.note' => array('label' => "Comment", 'checked' => '-1', 'position' => 85),
125 'p.ext_payment_id' => array('label' => "ExtPaymentID", 'checked' => '-1', 'position' => 87),
126 'p.ext_payment_site' => array('label' => "ExtPaymentSite", 'checked' => '-1', 'position' => 88),
127 'p.statut' => array('label' => "Status", 'checked' => '1', 'position' => 90, 'enabled' => (getDolGlobalString('BILL_ADD_PAYMENT_VALIDATION'))),
128);
129$arrayfields = dol_sort_array($arrayfields, 'position');
130
131// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
132$hookmanager->initHooks(array('paymentlist'));
133$object = new Paiement($db);
134
135if (!$user->hasRight('societe', 'client', 'voir')) {
136 $search_sale = $user->id;
137}
138
139// Security check
140if ($user->socid) {
141 $socid = $user->socid;
142}
143$result = restrictedArea($user, 'facture', $facid, '');
144
145
146/*
147 * Actions
148 */
149
150$parameters = array('socid' => $socid);
151$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
152if ($reshook < 0) {
153 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
154}
155
156
157if (empty($reshook)) {
158 include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
159
160 // All tests are required to be compatible with all browsers
161 if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
162 $search_ref = '';
163 $search_date_startday = '';
164 $search_date_startmonth = '';
165 $search_date_startyear = '';
166 $search_date_endday = '';
167 $search_date_endmonth = '';
168 $search_date_endyear = '';
169 $search_date_start = '';
170 $search_date_end = '';
171 $search_account = '';
172 $search_amount = '';
173 $search_paymenttype = '';
174 $search_payment_num = '';
175 $search_company = '';
176 $search_noteprivate = '';
177 $search_status = '';
178 $option = '';
179 $toselect = array();
180 $search_array_options = array();
181 }
182}
183
184
185/*
186 * View
187 */
188
189$form = new Form($db);
190$formother = new FormOther($db);
191$accountstatic = new Account($db);
192$companystatic = new Societe($db);
193$bankline = new AccountLine($db);
194
195$title = $langs->trans('ListPayment');
196
197llxHeader('', $title, '', '', 0, 0, '', '', '', 'bodyforlist');
198
199if (GETPOST("orphelins", "alpha")) {
200 // Payments not linked to an invoice. Should not happen. For debug only.
201 $sql = "SELECT p.rowid, p.ref, p.datep, p.fk_bank, p.statut, p.num_paiement as num_payment, p.amount, p.note as private_note";
202 $sql .= ", c.code as paiement_code";
203
204 $sqlfields = $sql; // $sql fields to remove for count total
205
206 // Add fields from hooks
207 $parameters = array();
208 $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook
209 $sql .= $hookmanager->resPrint;
210 $sql .= " FROM ".MAIN_DB_PREFIX."paiement as p LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_paiement = c.id";
211 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON p.rowid = pf.fk_paiement";
212 $sql .= " WHERE p.entity IN (".getEntity('invoice').")";
213 $sql .= " AND pf.fk_facture IS NULL";
214
215 // Add where from hooks
216 $parameters = array();
217 $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook
218 $sql .= $hookmanager->resPrint;
219} else {
220 $sql = "SELECT p.rowid, p.ref, p.datep, p.fk_bank, p.statut, p.num_paiement as num_payment, p.amount, p.note as note_private, p.ext_payment_id, p.ext_payment_site";
221 $sql .= ", c.code as paiement_code";
222 $sql .= ", ba.rowid as bid, ba.ref as bref, ba.label as blabel, ba.number, ba.account_number as account_number, ba.fk_accountancy_journal as accountancy_journal";
223 $sql .= ", s.rowid as socid, s.nom as name, s.email";
224 // 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)
225 // so SUM(pf.amount) should be equal to p.amount but if we filter on $socid, it may differ
226 $sql .= ", SUM(pf.amount) as totalamount, COUNT(f.rowid) as nbinvoices";
227
228 // Add fields from hooks
229 $parameters = array();
230 $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook
231 $sql .= $hookmanager->resPrint;
232
233 $sqlfields = $sql; // $sql fields to remove for count total
234
235 $sql .= " FROM ".MAIN_DB_PREFIX."paiement as p";
236 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_paiement = c.id";
237 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON p.fk_bank = b.rowid";
238 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid";
239
240 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON p.rowid = pf.fk_paiement";
241 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture as f ON pf.fk_facture = f.rowid";
242 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON f.fk_soc = s.rowid";
243
244 $sql .= " WHERE p.entity IN (".getEntity('invoice').")";
245 if ($socid > 0) {
246 $sql .= " AND EXISTS (SELECT f.fk_soc FROM ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."paiement_facture as pf";
247 $sql .= " WHERE p.rowid = pf.fk_paiement AND pf.fk_facture = f.rowid AND f.fk_soc = ".((int) $socid).")";
248 }
249 if ($userid) {
250 if ($userid == -1) {
251 $sql .= " AND p.fk_user_creat IS NULL";
252 } else {
253 $sql .= " AND p.fk_user_creat = ".((int) $userid);
254 }
255 }
256
257 // Search criteria
258 if ($search_ref) {
259 $sql .= natural_search('p.ref', $search_ref);
260 }
261 if ($search_date_start) {
262 $sql .= " AND p.datep >= '" . $db->idate($search_date_start) . "'";
263 }
264 if ($search_date_end) {
265 $sql .= " AND p.datep <= '" . $db->idate($search_date_end) . "'";
266 }
267 if ($search_account > 0) {
268 $sql .= " AND b.fk_account=".((int) $search_account);
269 }
270 if ($search_paymenttype != '') {
271 $sql .= " AND c.code='".$db->escape($search_paymenttype)."'";
272 }
273 if ($search_payment_num != '') {
274 $sql .= natural_search('p.num_paiement', $search_payment_num);
275 }
276 if ($search_amount) {
277 $sql .= " AND (".natural_search('p.amount', $search_amount, 1, 1);
278 $sql .= " OR ";
279 $sql .= natural_search('pf.amount', $search_amount, 1, 1);
280 $sql .= ")";
281 }
282 if ($search_company) {
283 $sql .= natural_search('s.nom', $search_company);
284 }
285 if ($search_noteprivate) {
286 $sql .= natural_search('p.note', $search_noteprivate);
287 }
288 // Search on sale representative
289 if ($search_sale && $search_sale != -1) {
290 if ($search_sale == -2) {
291 $sql .= " AND NOT EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc WHERE sc.fk_soc = f.fk_soc)";
292 } elseif ($search_sale > 0) {
293 $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).")";
294 }
295 }
296
297 if ($search_all) {
298 $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
299 }
300
301 // Add where from hooks
302 $parameters = array();
303 $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook
304 $sql .= $hookmanager->resPrint;
305
306 $sql .= " GROUP BY p.rowid, p.ref, p.datep, p.fk_bank, p.statut, p.num_paiement, p.amount, p.note, p.ext_payment_id, p.ext_payment_site";
307 $sql .= ", c.code";
308 $sql .= ", ba.rowid, ba.ref, ba.label, ba.number, ba.account_number, ba.fk_accountancy_journal";
309 $sql .= ", s.rowid, s.nom, s.email";
310}
311
312// Count total nb of records
313$nbtotalofrecords = '';
314if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
315 /* The fast and low memory method to get and count full list converts the sql into a sql count */
316 $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(DISTINCT p.rowid) as nbtotalofrecords', $sql);
317 $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount);
318 $resql = $db->query($sqlforcount);
319 if ($resql) {
320 $objforcount = $db->fetch_object($resql);
321 $nbtotalofrecords = $objforcount->nbtotalofrecords;
322 } else {
323 dol_print_error($db);
324 }
325
326 if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
327 $page = 0;
328 $offset = 0;
329 }
330 $db->free($resql);
331}
332
333// Complete request and execute it with limit
334$sql .= $db->order($sortfield, $sortorder);
335if ($limit) {
336 $sql .= $db->plimit($limit + 1, $offset);
337}
338//print $sql;
339
340$resql = $db->query($sql);
341if (!$resql) {
342 dol_print_error($db);
343 llxFooter();
344 $db->close();
345 exit;
346}
347
348$num = $db->num_rows($resql);
349
350$param = '';
351if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
352 $param .= '&contextpage='.urlencode($contextpage);
353}
354if ($limit > 0 && $limit != $conf->liste_limit) {
355 $param .= '&limit='.((int) $limit);
356}
357if ($optioncss != '') {
358 $param .= '&optioncss='.urlencode($optioncss);
359}
360
361if (GETPOST("orphelins")) {
362 $param .= '&orphelins=1';
363}
364if ($search_ref) {
365 $param .= '&search_ref='.urlencode($search_ref);
366}
367if ($search_date_startday) {
368 $param .= '&search_date_startday='.urlencode((string) ($search_date_startday));
369}
370if ($search_date_startmonth) {
371 $param .= '&search_date_startmonth='.urlencode((string) ($search_date_startmonth));
372}
373if ($search_date_startyear) {
374 $param .= '&search_date_startyear='.urlencode((string) ($search_date_startyear));
375}
376if ($search_date_endday) {
377 $param .= '&search_date_endday='.urlencode((string) ($search_date_endday));
378}
379if ($search_date_endmonth) {
380 $param .= '&search_date_endmonth='.urlencode((string) ($search_date_endmonth));
381}
382if ($search_date_endyear) {
383 $param .= '&search_date_endyear='.urlencode((string) ($search_date_endyear));
384}
385if ($search_company) {
386 $param .= '&search_company='.urlencode($search_company);
387}
388if ($search_amount != '') {
389 $param .= '&search_amount='.urlencode($search_amount);
390}
391if ($search_paymenttype) {
392 $param .= '&search_paymenttype='.urlencode($search_paymenttype);
393}
394if ($search_account) {
395 $param .= '&search_account='.urlencode((string) ($search_account));
396}
397if ($search_payment_num) {
398 $param .= '&search_payment_num='.urlencode($search_payment_num);
399}
400if ($search_noteprivate) {
401 $param .= '&search_noteprivate='.urlencode($search_noteprivate);
402}
403
404print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
405if ($optioncss != '') {
406 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
407}
408print '<input type="hidden" name="token" value="'.newToken().'">';
409print '<input type="hidden" name="action" value="list">';
410print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
411print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
412print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
413print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
414
415// @phan-suppress-next-line PhanPluginSuspiciousParamOrder
416print_barre_liste($langs->trans("ReceivedCustomersPayments"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'bill', 0, '', '', $limit, 0, 0, 1);
417
418if ($search_all) {
419 foreach ($fieldstosearchall as $key => $val) {
420 $fieldstosearchall[$key] = $langs->trans($val);
421 }
422 print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).implode(', ', $fieldstosearchall).'</div>';
423}
424
425$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
426$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')); // This also change content of $arrayfields
427$massactionbutton = '';
428if ($massactionbutton) {
429 $selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
430}
431
432$moreforfilter = '';
433print '<div class="div-table-responsive">';
434print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : '').'">';
435
436// Fields title search
437// --------------------------------------------------------------------
438print '<tr class="liste_titre_filter">';
439
440// Action column
441if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
442 print '<td class="liste_titre center maxwidthsearch">';
443 $searchpicto = $form->showFilterButtons('left');
444 print $searchpicto;
445 print '</td>';
446}
447
448// #
449if (getDolGlobalString('MAIN_VIEW_LINE_NUMBER_IN_LIST')) {
450 print '<td class="liste_titre">';
451 print '</td>';
452}
453
454// Filter: Ref
455if (!empty($arrayfields['p.ref']['checked'])) {
456 print '<td class="liste_titre left">';
457 print '<input class="flat" type="text" size="4" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
458 print '</td>';
459}
460
461// Filter: Date
462if (!empty($arrayfields['p.datep']['checked'])) {
463 print '<td class="liste_titre center">';
464 print '<div class="nowrapfordate">';
465 print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
466 print '</div>';
467 print '<div class="nowrapfordate">';
468 print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
469 print '</div>';
470 print '</td>';
471}
472
473// Filter: Thirdparty
474if (!empty($arrayfields['s.nom']['checked'])) {
475 print '<td class="liste_titre">';
476 print '<input class="flat" type="text" size="6" name="search_company" value="'.dol_escape_htmltag($search_company).'">';
477 print '</td>';
478}
479
480// Filter: Payment type
481if (!empty($arrayfields['c.libelle']['checked'])) {
482 print '<td class="liste_titre">';
483 print $form->select_types_paiements($search_paymenttype, 'search_paymenttype', '', 2, 1, 1, 0, 1, 'maxwidth100', 1);
484 print '</td>';
485}
486
487// Filter: Bank transaction number
488if (!empty($arrayfields['transaction']['checked'])) {
489 print '<td class="liste_titre">';
490 print '<input class="flat" type="text" size="4" name="search_payment_num" value="'.dol_escape_htmltag($search_payment_num).'">';
491 print '</td>';
492}
493
494// Filter: Cheque number (fund transfer)
495if (!empty($arrayfields['p.num_paiement']['checked'])) {
496 print '<td class="liste_titre">';
497 print '</td>';
498}
499
500// Filter: Bank account
501if (!empty($arrayfields['ba.label']['checked'])) {
502 print '<td class="liste_titre">';
503 $form->select_comptes($search_account, 'search_account', 0, '', 1, '', 0, 'maxwidth125');
504 print '</td>';
505}
506
507// Filter: Amount
508if (!empty($arrayfields['p.amount']['checked'])) {
509 print '<td class="liste_titre right">';
510 print '<input class="flat" type="text" size="4" name="search_amount" value="'.dol_escape_htmltag($search_amount).'">';
511 print '</td>';
512}
513
514// Filter: Note
515if (!empty($arrayfields['p.note']['checked'])) {
516 print '<td class="liste_titre">';
517 print '<input class="flat maxwidth150" type="text" name="search_noteprivate" value="'.dol_escape_htmltag($search_noteprivate).'">';
518 print '</td>';
519}
520
521// Filter: ext_payment_id
522if (!empty($arrayfields['p.ext_payment_id']['checked'])) {
523 print '<td class="liste_titre">';
524 //print '<input class="flat maxwidth150" type="text" name="search_ext_payment_id" value="'.dol_escape_htmltag($search_ext_payment_id).'">';
525 print '</td>';
526}
527
528// Filter: ext_payment_site
529if (!empty($arrayfields['p.ext_payment_site']['checked'])) {
530 print '<td class="liste_titre">';
531 //print '<input class="flat maxwidth150" type="text" name="search_ext_payment_site" value="'.dol_escape_htmltag($search_payment_site).'">';
532 print '</td>';
533}
534
535// Filter: Status (only placeholder)
536if (!empty($arrayfields['p.statut']['checked'])) {
537 print '<td class="liste_titre right">';
538 print '</td>';
539}
540
541// Fields from hook
542$parameters = array('arrayfields' => $arrayfields);
543$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
544print $hookmanager->resPrint;
545
546// Action column
547if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
548 print '<td class="liste_titre center maxwidthsearch">';
549 $searchpicto = $form->showFilterButtons();
550 print $searchpicto;
551 print '</td>';
552}
553
554print '</tr>'."\n";
555
556$totalarray = array();
557$totalarray['nbfield'] = 0;
558
559// Fields title label
560// --------------------------------------------------------------------
561print '<tr class="liste_titre">';
562// Action column
563if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
564 print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ');
565 $totalarray['nbfield']++;
566}
567if (getDolGlobalString('MAIN_VIEW_LINE_NUMBER_IN_LIST')) {
568 print_liste_field_titre('#', $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder);
569 $totalarray['nbfield']++;
570}
571if (!empty($arrayfields['p.ref']['checked'])) {
572 // False positive @phan-suppress-next-line PhanTypeInvalidDimOffset
573 print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], "p.ref", '', $param, '', $sortfield, $sortorder);
574 $totalarray['nbfield']++;
575}
576if (!empty($arrayfields['p.datep']['checked'])) {
577 print_liste_field_titre($arrayfields['p.datep']['label'], $_SERVER["PHP_SELF"], "p.datep", '', $param, '', $sortfield, $sortorder, 'center ');
578 $totalarray['nbfield']++;
579}
580if (!empty($arrayfields['s.nom']['checked'])) {
581 print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", '', $param, '', $sortfield, $sortorder);
582 $totalarray['nbfield']++;
583}
584if (!empty($arrayfields['c.libelle']['checked'])) {
585 print_liste_field_titre($arrayfields['c.libelle']['label'], $_SERVER["PHP_SELF"], "c.libelle", '', $param, '', $sortfield, $sortorder);
586 $totalarray['nbfield']++;
587}
588if (!empty($arrayfields['p.num_paiement']['checked'])) {
589 print_liste_field_titre($arrayfields['p.num_paiement']['label'], $_SERVER["PHP_SELF"], "p.num_paiement", '', $param, '', $sortfield, $sortorder, '', $arrayfields['p.num_paiement']['tooltip']);
590 $totalarray['nbfield']++;
591}
592if (!empty($arrayfields['transaction']['checked'])) {
593 print_liste_field_titre($arrayfields['transaction']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder);
594 $totalarray['nbfield']++;
595}
596if (!empty($arrayfields['ba.label']['checked'])) {
597 print_liste_field_titre($arrayfields['ba.label']['label'], $_SERVER["PHP_SELF"], "ba.label", '', $param, '', $sortfield, $sortorder);
598 $totalarray['nbfield']++;
599}
600if (!empty($arrayfields['p.amount']['checked'])) {
601 print_liste_field_titre($arrayfields['p.amount']['label'], $_SERVER["PHP_SELF"], "p.amount", '', $param, 'class="right"', $sortfield, $sortorder);
602 $totalarray['nbfield']++;
603}
604if (!empty($arrayfields['p.note']['checked'])) {
605 print_liste_field_titre($arrayfields['p.note']['label'], $_SERVER["PHP_SELF"], "p.note", '', $param, '', $sortfield, $sortorder);
606 $totalarray['nbfield']++;
607}
608if (!empty($arrayfields['p.ext_payment_id']['checked'])) {
609 print_liste_field_titre($arrayfields['p.ext_payment_id']['label'], $_SERVER["PHP_SELF"], "p.ext_payment_id", '', $param, '', $sortfield, $sortorder);
610 $totalarray['nbfield']++;
611}
612if (!empty($arrayfields['p.ext_payment_site']['checked'])) {
613 print_liste_field_titre($arrayfields['p.ext_payment_site']['label'], $_SERVER["PHP_SELF"], "p.ext_payment_site", '', $param, '', $sortfield, $sortorder);
614 $totalarray['nbfield']++;
615}
616if (!empty($arrayfields['p.statut']['checked'])) {
617 print_liste_field_titre($arrayfields['p.statut']['label'], $_SERVER["PHP_SELF"], "p.statut", '', $param, 'class="right"', $sortfield, $sortorder);
618 $totalarray['nbfield']++;
619}
620// Extra fields
621include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
622// Hook fields
623$parameters = array('arrayfields' => $arrayfields, 'param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder);
624$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
625print $hookmanager->resPrint;
626// Action column
627if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
628 print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ');
629 $totalarray['nbfield']++;
630}
631
632print '</tr>'."\n";
633
634// Detect if we need a fetch on each output line
635$needToFetchEachLine = 0;
636if (isset($extrafields->attributes[$object->table_element]['computed']) && is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) {
637 foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) {
638 if (!is_null($val) && preg_match('/\$object/', $val)) {
639 $needToFetchEachLine++; // There is at least one compute field that use $object
640 }
641 }
642}
643
644
645// Loop on record
646// --------------------------------------------------------------------
647$i = 0;
648$savnbfield = $totalarray['nbfield'];
649$totalarray = array();
650$totalarray['nbfield'] = 0;
651$imaxinloop = ($limit ? min($num, $limit) : $num);
652while ($i < $imaxinloop) {
653 $objp = $db->fetch_object($resql);
654 if (empty($objp)) {
655 break; // Should not happen
656 }
657
658 $object->id = $objp->rowid;
659 $object->ref = ($objp->ref ? $objp->ref : $objp->rowid);
660 $object->date = $db->jdate($objp->datep);
661 $object->amount = $objp->amount;
662 $object->note_private = $objp->note_private;
663
664 $companystatic->id = $objp->socid;
665 $companystatic->name = $objp->name;
666 $companystatic->email = $objp->email;
667
668 if ($mode == 'kanban') {
669 if ($i == 0) {
670 print '<tr class="trkanban"><td colspan="'.$savnbfield.'">';
671 print '<div class="box-flex-container kanban">';
672 }
673 // Output Kanban
674 $selected = -1;
675 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
676 $selected = 0;
677 if (in_array($object->id, $arrayofselected)) {
678 $selected = 1;
679 }
680 }
681 //print $object->getKanbanView('', array('thirdparty'=>$object->thirdparty, 'selected' => $selected));
682 print $object->getKanbanView('', array('selected' => $selected));
683 if ($i == ($imaxinloop - 1)) {
684 print '</div>';
685 print '</td></tr>';
686 }
687 } else {
688 // Show line of result
689 $j = 0;
690 print '<tr data-rowid="'.$object->id.'" class="oddeven">';
691
692 // Action column
693 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
694 print '<td class="nowrap center">';
695 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
696 $selected = 0;
697 if (in_array($object->id, $arrayofselected)) {
698 $selected = 1;
699 }
700 print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
701 }
702 print '</td>';
703 if (!$i) {
704 $totalarray['nbfield']++;
705 }
706 }
707
708 // No
709 if (getDolGlobalString('MAIN_VIEW_LINE_NUMBER_IN_LIST')) {
710 print '<td class="nowraponall">'.(($offset * $limit) + $i).'</td>';
711 if (!$i) {
712 $totalarray['nbfield']++;
713 }
714 }
715
716 // Ref
717 if (!empty($arrayfields['p.ref']['checked'])) {
718 print '<td class="nowraponall">'.$object->getNomUrl(1).'</td>';
719 if (!$i) {
720 $totalarray['nbfield']++;
721 }
722 }
723
724 // Date
725 if (!empty($arrayfields['p.datep']['checked'])) {
726 $dateformatforpayment = 'dayhour';
727 print '<td class="nowraponall center">'.dol_print_date($db->jdate($objp->datep), $dateformatforpayment, 'tzuser').'</td>';
728 if (!$i) {
729 $totalarray['nbfield']++;
730 }
731 }
732
733 // Thirdparty
734 if (!empty($arrayfields['s.nom']['checked'])) {
735 print '<td class="tdoverflowmax125">';
736 if ($objp->socid > 0) {
737 print $companystatic->getNomUrl(1, '', 24);
738 }
739 print '</td>';
740 if (!$i) {
741 $totalarray['nbfield']++;
742 }
743 }
744
745 // Payment type
746 if (!empty($arrayfields['c.libelle']['checked'])) {
747 print '<td class="tdoverflowmax100" title="'.dolPrintHTMLForAttribute($langs->trans("PaymentTypeShort".$objp->paiement_code)).'">'.dolPrintHTML($langs->trans("PaymentTypeShort".$objp->paiement_code)).'</td>';
748 if (!$i) {
749 $totalarray['nbfield']++;
750 }
751 }
752
753 // Filter: Cheque number (fund transfer)
754 if (!empty($arrayfields['p.num_paiement']['checked'])) {
755 print '<td>'.$objp->num_payment.'</td>';
756 if (!$i) {
757 $totalarray['nbfield']++;
758 }
759 }
760
761 // Bank transaction
762 if (!empty($arrayfields['transaction']['checked'])) {
763 print '<td class="tdoverflowmax125">';
764 if ($objp->fk_bank > 0) {
765 $bankline->fetch($objp->fk_bank);
766 print $bankline->getNomUrl(1, 0);
767 }
768 print '</td>';
769 if (!$i) {
770 $totalarray['nbfield']++;
771 }
772 }
773
774 // Bank account
775 if (!empty($arrayfields['ba.label']['checked'])) {
776 print '<td>';
777 if ($objp->bid > 0) {
778 $accountstatic->id = $objp->bid;
779 $accountstatic->ref = $objp->bref;
780 $accountstatic->label = $objp->blabel;
781 $accountstatic->number = $objp->number;
782 $accountstatic->account_number = $objp->account_number;
783
784 $accountingjournal = new AccountingJournal($db);
785 $accountingjournal->fetch($objp->accountancy_journal);
786 $accountstatic->accountancy_journal = $accountingjournal->code;
787
788 print $accountstatic->getNomUrl(1);
789 }
790 print '</td>';
791 if (!$i) {
792 $totalarray['nbfield']++;
793 }
794 }
795
796 // Amount
797 if (!empty($arrayfields['p.amount']['checked'])) {
798 print '<td class="right">';
799 if ($objp->nbinvoices > 1 || ($objp->totalamount && $objp->amount != $objp->totalamount)) {
800 print $form->textwithpicto('', $langs->trans("PaymentMadeForSeveralInvoices"));
801 }
802 print '<span class="amount">'.price($objp->amount).'</span>';
803 print '</td>';
804 if (!$i) {
805 $totalarray['nbfield']++;
806 $totalarray['pos'][$totalarray['nbfield']] = 'amount';
807 }
808 if (empty($totalarray['val']['amount'])) {
809 $totalarray['val']['amount'] = $objp->amount;
810 } else {
811 $totalarray['val']['amount'] += $objp->amount;
812 }
813 }
814
815 // Note
816 if (!empty($arrayfields['p.note']['checked'])) {
817 $firstline = dolGetFirstLineOfText($objp->note_private, 1);
818 print '<td class="tdoverflowmax200" title="'.dolPrintHTMLForAttribute($firstline).'">';
819 print dolPrintHTML($firstline).'</span>';
820 print '</td>';
821 if (!$i) {
822 $totalarray['nbfield']++;
823 }
824 }
825
826 // ext_payment_id
827 if (!empty($arrayfields['p.ext_payment_id']['checked'])) {
828 print '<td class="tdoverflowmax200" title="'.dolPrintHTMLForAttribute($objp->ext_payment_id).'">';
829 print dolPrintHTML($objp->ext_payment_id).'</span>';
830 print '</td>';
831 if (!$i) {
832 $totalarray['nbfield']++;
833 }
834 }
835
836 // ext_payment_site
837 if (!empty($arrayfields['p.ext_payment_site']['checked'])) {
838 print '<td class="tdoverflowmax200" title="'.dolPrintHTMLForAttribute($objp->ext_payment_site).'">';
839 print dolPrintHTML($objp->ext_payment_site).'</span>';
840 print '</td>';
841 if (!$i) {
842 $totalarray['nbfield']++;
843 }
844 }
845
846 // Fields from hook
847 $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$objp, 'i'=>$i, 'totalarray'=>&$totalarray);
848 $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
849 print $hookmanager->resPrint;
850
851 // Status
852 if (!empty($arrayfields['p.statut']['checked'])) {
853 print '<td class="right">';
854 if ($objp->statut == 0) {
855 print '<a href="card.php?id='.$objp->rowid.'&amp;action=valide">';
856 }
857 print $object->LibStatut($objp->statut, 5);
858 if ($objp->statut == 0) {
859 print '</a>';
860 }
861 print '</td>';
862 if (!$i) {
863 $totalarray['nbfield']++;
864 }
865 }
866
867 // Action column
868 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
869 print '<td class="nowrap center">';
870 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
871 $selected = 0;
872 if (in_array($object->id, $arrayofselected)) {
873 $selected = 1;
874 }
875 print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
876 }
877 print '</td>';
878 if (!$i) {
879 $totalarray['nbfield']++;
880 }
881 }
882
883 print '</tr>'."\n";
884 }
885
886 $i++;
887}
888
889// Show total line
890include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
891
892// If no record found
893if ($num == 0) {
894 $colspan = 1;
895 foreach ($arrayfields as $key => $val) {
896 if (!empty($val['checked'])) {
897 $colspan++;
898 }
899 }
900 print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
901}
902
903$db->free($resql);
904
905$parameters = array('arrayfields' => $arrayfields, 'sql' => $sql);
906$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
907print $hookmanager->resPrint;
908
909print '</table>'."\n";
910print '</div>'."\n";
911
912print '</form>'."\n";
913
914// End of page
915llxFooter();
916$db->close();
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:67
$totalarray
Definition export.php:1206
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 bank transaction lines.
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 of customer invoices.
Class to manage third parties objects (customers, suppliers, prospects...)
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.
dolGetFirstLineOfText($text, $nboflines=1, $charset='UTF-8')
Return first line of text.
dolPrintHTML($s, $allowiframe=0)
Return a string (that can be on several lines) ready to be output on a HTML page.
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...
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...
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
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.