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