dolibarr 20.0.0
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 *
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 3 of the License, or
17 * (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program. If not, see <https://www.gnu.org/licenses/>.
26 */
27
34// Load Dolibarr environment
35require '../../main.inc.php';
36require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
37require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
38require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
39require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
40require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php';
41
42// Load translation files required by the page
43$langs->loadLangs(array('bills', 'banks', 'compta', 'companies'));
44
45$action = GETPOST('action', 'alpha');
46$massaction = GETPOST('massaction', 'alpha');
47$confirm = GETPOST('confirm', 'alpha');
48$optioncss = GETPOST('optioncss', 'alpha');
49$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'paymentlist';
50$mode = GETPOST('mode', 'alpha');
51
52$facid = GETPOST('facid', 'int');
53$socid = GETPOST('socid', 'int');
54$userid = GETPOST('userid', 'int');
55
56$search_ref = GETPOST("search_ref", "alpha");
57$search_date_startday = GETPOSTINT('search_date_startday');
58$search_date_startmonth = GETPOSTINT('search_date_startmonth');
59$search_date_startyear = GETPOSTINT('search_date_startyear');
60$search_date_endday = GETPOSTINT('search_date_endday');
61$search_date_endmonth = GETPOSTINT('search_date_endmonth');
62$search_date_endyear = GETPOSTINT('search_date_endyear');
63$search_date_start = dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear); // Use tzserver
64$search_date_end = dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear);
65$search_company = GETPOST("search_company", 'alpha');
66$search_paymenttype = GETPOST("search_paymenttype");
67$search_account = GETPOST("search_account", 'alpha');
68$search_payment_num = GETPOST('search_payment_num', 'alpha');
69$search_amount = GETPOST("search_amount", 'alpha'); // alpha because we must be able to search on "< x"
70$search_status = GETPOST('search_status', 'intcomma');
71$search_sale = GETPOSTINT('search_sale');
72
73
74$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
75$sortfield = GETPOST('sortfield', 'aZ09comma');
76$sortorder = GETPOST('sortorder', 'aZ09comma');
77$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
78
79if (empty($page) || $page == -1) {
80 $page = 0; // If $page is not defined, or '' or -1
81}
82$offset = $limit * $page;
83$pageprev = $page - 1;
84$pagenext = $page + 1;
85
86if (!$sortorder) {
87 $sortorder = "DESC";
88}
89if (!$sortfield) {
90 $sortfield = "p.ref";
91}
92
93$search_all = trim(GETPOSTISSET("search_all") ? GETPOST("search_all", 'alpha') : GETPOST('sall'));
94
95// List of fields to search into when doing a "search in all"
96$fieldstosearchall = array(
97 'p.ref' => "RefPayment",
98 's.nom' => "ThirdParty",
99 'p.num_paiement' => "Numero",
100 'p.amount' => "Amount",
101);
102
103$arrayfields = array(
104 'p.ref' => array('label' => "RefPayment", 'checked' => 1, 'position' => 10),
105 'p.datep' => array('label' => "Date", 'checked' => 1, 'position' => 20),
106 's.nom' => array('label' => "ThirdParty", 'checked' => 1, 'position' => 30),
107 'c.libelle' => array('label' => "Type", 'checked' => 1, 'position' => 40),
108 'transaction' => array('label' => "BankTransactionLine", 'checked' => 1, 'position' => 50, 'enabled' => (isModEnabled("bank"))),
109 'ba.label' => array('label' => "BankAccount", 'checked' => 1, 'position' => 60, 'enabled' => (isModEnabled("bank"))),
110 'p.num_paiement' => array('label' => "Numero", 'checked' => 1, 'position' => 70, 'tooltip' => "ChequeOrTransferNumber"),
111 'p.amount' => array('label' => "Amount", 'checked' => 1, 'position' => 80),
112 'p.statut' => array('label' => "Status", 'checked' => 1, 'position' => 90, 'enabled' => (getDolGlobalString('BILL_ADD_PAYMENT_VALIDATION'))),
113);
114$arrayfields = dol_sort_array($arrayfields, 'position');
115'@phan-var-force array<string,array{label:string,checked?:int<0,1>,position?:int,help?:string}> $arrayfields'; // dol_sort_array looses type for Phan
116
117// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
118$hookmanager->initHooks(array('paymentlist'));
119$object = new Paiement($db);
120
121if (!$user->hasRight('societe', 'client', 'voir')) {
122 $search_sale = $user->id;
123}
124
125// Security check
126if ($user->socid) {
127 $socid = $user->socid;
128}
129$result = restrictedArea($user, 'facture', $facid, '');
130
131
132/*
133 * Actions
134 */
135
136$parameters = array('socid' => $socid);
137$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
138if ($reshook < 0) {
139 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
140}
141
142
143if (empty($reshook)) {
144 include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
145
146 // All tests are required to be compatible with all browsers
147 if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
148 $search_ref = '';
149 $search_date_startday = '';
150 $search_date_startmonth = '';
151 $search_date_startyear = '';
152 $search_date_endday = '';
153 $search_date_endmonth = '';
154 $search_date_endyear = '';
155 $search_date_start = '';
156 $search_date_end = '';
157 $search_account = '';
158 $search_amount = '';
159 $search_paymenttype = '';
160 $search_payment_num = '';
161 $search_company = '';
162 $search_status = '';
163 $option = '';
164 $toselect = array();
165 $search_array_options = array();
166 }
167}
168
169
170/*
171 * View
172 */
173
174$form = new Form($db);
175$formother = new FormOther($db);
176$accountstatic = new Account($db);
177$companystatic = new Societe($db);
178$bankline = new AccountLine($db);
179
180llxHeader('', $langs->trans('ListPayment'), '', 0, 0, '', '', '', 'bodyforlist');
181
182if (GETPOST("orphelins", "alpha")) {
183 // Payments not linked to an invoice. Should not happen. For debug only.
184 $sql = "SELECT p.rowid, p.ref, p.datep, p.amount, p.statut, p.num_paiement as num_payment,";
185 $sql .= " c.code as paiement_code";
186
187 $sqlfields = $sql; // $sql fields to remove for count total
188
189 // Add fields from hooks
190 $parameters = array();
191 $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook
192 $sql .= $hookmanager->resPrint;
193 $sql .= " FROM ".MAIN_DB_PREFIX."paiement as p LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_paiement = c.id";
194 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON p.rowid = pf.fk_paiement";
195 $sql .= " WHERE p.entity IN (".getEntity('invoice').")";
196 $sql .= " AND pf.fk_facture IS NULL";
197
198 // Add where from hooks
199 $parameters = array();
200 $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook
201 $sql .= $hookmanager->resPrint;
202} else {
203 $sql = "SELECT p.rowid, p.ref, p.datep, p.fk_bank, p.statut, p.num_paiement as num_payment, p.amount";
204 $sql .= ", c.code as paiement_code";
205 $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";
206 $sql .= ", s.rowid as socid, s.nom as name, s.email";
207 // 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)
208 // so SUM(pf.amount) should be equal to p.amount but if we filter on $socid, it may differ
209 $sql .= ", SUM(pf.amount) as totalamount, COUNT(f.rowid) as nbinvoices";
210
211 // Add fields from hooks
212 $parameters = array();
213 $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook
214 $sql .= $hookmanager->resPrint;
215
216 $sqlfields = $sql; // $sql fields to remove for count total
217
218 $sql .= " FROM ".MAIN_DB_PREFIX."paiement as p";
219 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_paiement = c.id";
220 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON p.fk_bank = b.rowid";
221 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid";
222
223 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON p.rowid = pf.fk_paiement";
224 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture as f ON pf.fk_facture = f.rowid";
225 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON f.fk_soc = s.rowid";
226
227 $sql .= " WHERE p.entity IN (".getEntity('invoice').")";
228 if ($socid > 0) {
229 $sql .= " AND EXISTS (SELECT f.fk_soc FROM ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."paiement_facture as pf";
230 $sql .= " WHERE p.rowid = pf.fk_paiement AND pf.fk_facture = f.rowid AND f.fk_soc = ".((int) $socid).")";
231 }
232 if ($userid) {
233 if ($userid == -1) {
234 $sql .= " AND p.fk_user_creat IS NULL";
235 } else {
236 $sql .= " AND p.fk_user_creat = ".((int) $userid);
237 }
238 }
239
240 // Search criteria
241 if ($search_ref) {
242 $sql .= natural_search('p.ref', $search_ref);
243 }
244 if ($search_date_start) {
245 $sql .= " AND p.datep >= '" . $db->idate($search_date_start) . "'";
246 }
247 if ($search_date_end) {
248 $sql .= " AND p.datep <= '" . $db->idate($search_date_end) . "'";
249 }
250 if ($search_account > 0) {
251 $sql .= " AND b.fk_account=".((int) $search_account);
252 }
253 if ($search_paymenttype != '') {
254 $sql .= " AND c.code='".$db->escape($search_paymenttype)."'";
255 }
256 if ($search_payment_num != '') {
257 $sql .= natural_search('p.num_paiement', $search_payment_num);
258 }
259 if ($search_amount) {
260 $sql .= " AND (".natural_search('p.amount', $search_amount, 1, 1);
261 $sql .= " OR ";
262 $sql .= natural_search('pf.amount', $search_amount, 1, 1);
263 $sql .= ")";
264 }
265 if ($search_company) {
266 $sql .= natural_search('s.nom', $search_company);
267 }
268 // Search on sale representative
269 if ($search_sale && $search_sale != -1) {
270 if ($search_sale == -2) {
271 $sql .= " AND NOT EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc WHERE sc.fk_soc = f.fk_soc)";
272 } elseif ($search_sale > 0) {
273 $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).")";
274 }
275 }
276
277 if ($search_all) {
278 $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
279 }
280
281 // Add where from hooks
282 $parameters = array();
283 $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook
284 $sql .= $hookmanager->resPrint;
285
286 $sql .= " GROUP BY p.rowid, p.ref, p.datep, p.fk_bank, p.statut, p.num_paiement, p.amount";
287 $sql .= ", c.code";
288 $sql .= ", ba.rowid, ba.ref, ba.label, ba.number, ba.account_number, ba.fk_accountancy_journal";
289 $sql .= ", s.rowid, s.nom, s.email";
290}
291
292// Count total nb of records
293$nbtotalofrecords = '';
294if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
295 /* The fast and low memory method to get and count full list converts the sql into a sql count */
296 $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(DISTINCT p.rowid) as nbtotalofrecords', $sql);
297 $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount);
298 $resql = $db->query($sqlforcount);
299 if ($resql) {
300 $objforcount = $db->fetch_object($resql);
301 $nbtotalofrecords = $objforcount->nbtotalofrecords;
302 } else {
303 dol_print_error($db);
304 }
305
306 if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
307 $page = 0;
308 $offset = 0;
309 }
310 $db->free($resql);
311}
312
313// Complete request and execute it with limit
314$sql .= $db->order($sortfield, $sortorder);
315if ($limit) {
316 $sql .= $db->plimit($limit + 1, $offset);
317}
318//print $sql;
319
320$resql = $db->query($sql);
321if (!$resql) {
322 dol_print_error($db);
323 llxFooter();
324 $db->close();
325 exit;
326}
327
328$num = $db->num_rows($resql);
329
330$param = '';
331if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
332 $param .= '&contextpage='.urlencode($contextpage);
333}
334if ($limit > 0 && $limit != $conf->liste_limit) {
335 $param .= '&limit='.((int) $limit);
336}
337
338if (GETPOST("orphelins")) {
339 $param .= '&orphelins=1';
340}
341if ($search_ref) {
342 $param .= '&search_ref='.urlencode($search_ref);
343}
344if ($search_date_startday) {
345 $param .= '&search_date_startday='.urlencode((string) ($search_date_startday));
346}
347if ($search_date_startmonth) {
348 $param .= '&search_date_startmonth='.urlencode((string) ($search_date_startmonth));
349}
350if ($search_date_startyear) {
351 $param .= '&search_date_startyear='.urlencode((string) ($search_date_startyear));
352}
353if ($search_date_endday) {
354 $param .= '&search_date_endday='.urlencode((string) ($search_date_endday));
355}
356if ($search_date_endmonth) {
357 $param .= '&search_date_endmonth='.urlencode((string) ($search_date_endmonth));
358}
359if ($search_date_endyear) {
360 $param .= '&search_date_endyear='.urlencode((string) ($search_date_endyear));
361}
362if ($search_company) {
363 $param .= '&search_company='.urlencode($search_company);
364}
365if ($search_amount != '') {
366 $param .= '&search_amount='.urlencode($search_amount);
367}
368if ($search_paymenttype) {
369 $param .= '&search_paymenttype='.urlencode($search_paymenttype);
370}
371if ($search_account) {
372 $param .= '&search_account='.urlencode((string) ($search_account));
373}
374if ($search_payment_num) {
375 $param .= '&search_payment_num='.urlencode($search_payment_num);
376}
377if ($optioncss != '') {
378 $param .= '&optioncss='.urlencode($optioncss);
379}
380
381print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
382if ($optioncss != '') {
383 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
384}
385print '<input type="hidden" name="token" value="'.newToken().'">';
386print '<input type="hidden" name="action" value="list">';
387print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
388print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
389print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
390print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
391
392// @phan-suppress-next-line PhanPluginSuspiciousParamOrder
393print_barre_liste($langs->trans("ReceivedCustomersPayments"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'bill', 0, '', '', $limit, 0, 0, 1);
394
395if ($search_all) {
396 foreach ($fieldstosearchall as $key => $val) {
397 $fieldstosearchall[$key] = $langs->trans($val);
398 }
399 print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).implode(', ', $fieldstosearchall).'</div>';
400}
401
402$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
403$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')); // This also change content of $arrayfields
404$massactionbutton = '';
405if ($massactionbutton) {
406 $selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
407}
408
409$moreforfilter = '';
410print '<div class="div-table-responsive">';
411print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : '').'">';
412
413// Fields title search
414// --------------------------------------------------------------------
415print '<tr class="liste_titre_filter">';
416
417// Action column
418if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
419 print '<td class="liste_titre center maxwidthsearch">';
420 $searchpicto = $form->showFilterButtons('left');
421 print $searchpicto;
422 print '</td>';
423}
424
425// #
426if (getDolGlobalString('MAIN_VIEW_LINE_NUMBER_IN_LIST')) {
427 print '<td class="liste_titre">';
428 print '</td>';
429}
430
431// Filter: Ref
432if (!empty($arrayfields['p.ref']['checked'])) {
433 print '<td class="liste_titre left">';
434 print '<input class="flat" type="text" size="4" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
435 print '</td>';
436}
437
438// Filter: Date
439if (!empty($arrayfields['p.datep']['checked'])) {
440 print '<td class="liste_titre center">';
441 print '<div class="nowrapfordate">';
442 print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
443 print '</div>';
444 print '<div class="nowrapfordate">';
445 print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
446 print '</div>';
447 print '</td>';
448}
449
450// Filter: Thirdparty
451if (!empty($arrayfields['s.nom']['checked'])) {
452 print '<td class="liste_titre">';
453 print '<input class="flat" type="text" size="6" name="search_company" value="'.dol_escape_htmltag($search_company).'">';
454 print '</td>';
455}
456
457// Filter: Payment type
458if (!empty($arrayfields['c.libelle']['checked'])) {
459 print '<td class="liste_titre">';
460 print $form->select_types_paiements($search_paymenttype, 'search_paymenttype', '', 2, 1, 1, 0, 1, 'maxwidth100', 1);
461 print '</td>';
462}
463
464// Filter: Bank transaction number
465if (!empty($arrayfields['transaction']['checked'])) {
466 print '<td class="liste_titre">';
467 print '<input class="flat" type="text" size="4" name="search_payment_num" value="'.dol_escape_htmltag($search_payment_num).'">';
468 print '</td>';
469}
470
471// Filter: Cheque number (fund transfer)
472if (!empty($arrayfields['p.num_paiement']['checked'])) {
473 print '<td class="liste_titre">';
474 print '</td>';
475}
476
477// Filter: Bank account
478if (!empty($arrayfields['ba.label']['checked'])) {
479 print '<td class="liste_titre">';
480 $form->select_comptes($search_account, 'search_account', 0, '', 1);
481 print '</td>';
482}
483
484// Filter: Amount
485if (!empty($arrayfields['p.amount']['checked'])) {
486 print '<td class="liste_titre right">';
487 print '<input class="flat" type="text" size="4" name="search_amount" value="'.dol_escape_htmltag($search_amount).'">';
488 print '</td>';
489}
490
491// Filter: Status (only placeholder)
492if (!empty($arrayfields['p.statut']['checked'])) {
493 print '<td class="liste_titre right">';
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 (!getDolGlobalString('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 (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
520 print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ');
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 print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], "p.ref", '', $param, '', $sortfield, $sortorder);
529 $totalarray['nbfield']++;
530}
531if (!empty($arrayfields['p.datep']['checked'])) {
532 print_liste_field_titre($arrayfields['p.datep']['label'], $_SERVER["PHP_SELF"], "p.datep", '', $param, '', $sortfield, $sortorder, 'center ');
533 $totalarray['nbfield']++;
534}
535if (!empty($arrayfields['s.nom']['checked'])) {
536 print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", '', $param, '', $sortfield, $sortorder);
537 $totalarray['nbfield']++;
538}
539if (!empty($arrayfields['c.libelle']['checked'])) {
540 print_liste_field_titre($arrayfields['c.libelle']['label'], $_SERVER["PHP_SELF"], "c.libelle", '', $param, '', $sortfield, $sortorder);
541 $totalarray['nbfield']++;
542}
543if (!empty($arrayfields['p.num_paiement']['checked'])) {
544 print_liste_field_titre($arrayfields['p.num_paiement']['label'], $_SERVER["PHP_SELF"], "p.num_paiement", '', $param, '', $sortfield, $sortorder, '', $arrayfields['p.num_paiement']['tooltip']);
545 $totalarray['nbfield']++;
546}
547if (!empty($arrayfields['transaction']['checked'])) {
548 print_liste_field_titre($arrayfields['transaction']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder);
549 $totalarray['nbfield']++;
550}
551if (!empty($arrayfields['ba.label']['checked'])) {
552 print_liste_field_titre($arrayfields['ba.label']['label'], $_SERVER["PHP_SELF"], "ba.label", '', $param, '', $sortfield, $sortorder);
553 $totalarray['nbfield']++;
554}
555if (!empty($arrayfields['p.amount']['checked'])) {
556 print_liste_field_titre($arrayfields['p.amount']['label'], $_SERVER["PHP_SELF"], "p.amount", '', $param, 'class="right"', $sortfield, $sortorder);
557 $totalarray['nbfield']++;
558}
559if (!empty($arrayfields['p.statut']['checked'])) {
560 print_liste_field_titre($arrayfields['p.statut']['label'], $_SERVER["PHP_SELF"], "p.statut", '', $param, 'class="right"', $sortfield, $sortorder);
561 $totalarray['nbfield']++;
562}
563// Extra fields
564include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
565// Hook fields
566$parameters = array('arrayfields' => $arrayfields, 'param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder);
567$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
568print $hookmanager->resPrint;
569// Action column
570if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
571 print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ');
572 $totalarray['nbfield']++;
573}
574
575print '</tr>'."\n";
576
577// Detect if we need a fetch on each output line
578$needToFetchEachLine = 0;
579if (isset($extrafields->attributes[$object->table_element]['computed']) && is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) {
580 foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) {
581 if (!is_null($val) && preg_match('/\$object/', $val)) {
582 $needToFetchEachLine++; // There is at least one compute field that use $object
583 }
584 }
585}
586
587
588// Loop on record
589// --------------------------------------------------------------------
590$i = 0;
591$savnbfield = $totalarray['nbfield'];
592$totalarray = array();
593$totalarray['nbfield'] = 0;
594$imaxinloop = ($limit ? min($num, $limit) : $num);
595while ($i < $imaxinloop) {
596 $objp = $db->fetch_object($resql);
597 if (empty($objp)) {
598 break; // Should not happen
599 }
600
601 $object->id = $objp->rowid;
602 $object->ref = ($objp->ref ? $objp->ref : $objp->rowid);
603 $object->date = $db->jdate($objp->datep);
604 $object->amount = $objp->amount;
605
606 $companystatic->id = $objp->socid;
607 $companystatic->name = $objp->name;
608 $companystatic->email = $objp->email;
609
610 if ($mode == 'kanban') {
611 if ($i == 0) {
612 print '<tr class="trkanban"><td colspan="'.$savnbfield.'">';
613 print '<div class="box-flex-container kanban">';
614 }
615 // Output Kanban
616 $selected = -1;
617 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
618 $selected = 0;
619 if (in_array($object->id, $arrayofselected)) {
620 $selected = 1;
621 }
622 }
623 //print $object->getKanbanView('', array('thirdparty'=>$object->thirdparty, 'selected' => $selected));
624 print $object->getKanbanView('', array('selected' => $selected));
625 if ($i == ($imaxinloop - 1)) {
626 print '</div>';
627 print '</td></tr>';
628 }
629 } else {
630 // Show line of result
631 $j = 0;
632 print '<tr data-rowid="'.$object->id.'" class="oddeven">';
633
634 // Action column
635 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
636 print '<td class="nowrap center">';
637 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
638 $selected = 0;
639 if (in_array($object->id, $arrayofselected)) {
640 $selected = 1;
641 }
642 print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
643 }
644 print '</td>';
645 if (!$i) {
646 $totalarray['nbfield']++;
647 }
648 }
649
650 // No
651 if (getDolGlobalString('MAIN_VIEW_LINE_NUMBER_IN_LIST')) {
652 print '<td class="nowraponall">'.(($offset * $limit) + $i).'</td>';
653 if (!$i) {
654 $totalarray['nbfield']++;
655 }
656 }
657
658 // Ref
659 if (!empty($arrayfields['p.ref']['checked'])) {
660 print '<td class="nowraponall">'.$object->getNomUrl(1).'</td>';
661 if (!$i) {
662 $totalarray['nbfield']++;
663 }
664 }
665
666 // Date
667 if (!empty($arrayfields['p.datep']['checked'])) {
668 $dateformatforpayment = 'dayhour';
669 print '<td class="nowraponall center">'.dol_print_date($db->jdate($objp->datep), $dateformatforpayment, 'tzuser').'</td>';
670 if (!$i) {
671 $totalarray['nbfield']++;
672 }
673 }
674
675 // Thirdparty
676 if (!empty($arrayfields['s.nom']['checked'])) {
677 print '<td class="tdoverflowmax125">';
678 if ($objp->socid > 0) {
679 print $companystatic->getNomUrl(1, '', 24);
680 }
681 print '</td>';
682 if (!$i) {
683 $totalarray['nbfield']++;
684 }
685 }
686
687 // Payment type
688 if (!empty($arrayfields['c.libelle']['checked'])) {
689 print '<td>'.$langs->trans("PaymentTypeShort".$objp->paiement_code).'</td>';
690 if (!$i) {
691 $totalarray['nbfield']++;
692 }
693 }
694
695 // Filter: Cheque number (fund transfer)
696 if (!empty($arrayfields['p.num_paiement']['checked'])) {
697 print '<td>'.$objp->num_payment.'</td>';
698 if (!$i) {
699 $totalarray['nbfield']++;
700 }
701 }
702
703 // Bank transaction
704 if (!empty($arrayfields['transaction']['checked'])) {
705 print '<td class="tdoverflowmax125">';
706 if ($objp->fk_bank > 0) {
707 $bankline->fetch($objp->fk_bank);
708 print $bankline->getNomUrl(1, 0);
709 }
710 print '</td>';
711 if (!$i) {
712 $totalarray['nbfield']++;
713 }
714 }
715
716 // Bank account
717 if (!empty($arrayfields['ba.label']['checked'])) {
718 print '<td>';
719 if ($objp->bid > 0) {
720 $accountstatic->id = $objp->bid;
721 $accountstatic->ref = $objp->bref;
722 $accountstatic->label = $objp->blabel;
723 $accountstatic->number = $objp->number;
724 $accountstatic->account_number = $objp->account_number;
725
726 $accountingjournal = new AccountingJournal($db);
727 $accountingjournal->fetch($objp->accountancy_journal);
728 $accountstatic->accountancy_journal = $accountingjournal->code;
729
730 print $accountstatic->getNomUrl(1);
731 }
732 print '</td>';
733 if (!$i) {
734 $totalarray['nbfield']++;
735 }
736 }
737
738 // Amount
739 if (!empty($arrayfields['p.amount']['checked'])) {
740 print '<td class="right">';
741 if ($objp->nbinvoices > 1 || ($objp->totalamount && $objp->amount != $objp->totalamount)) {
742 print $form->textwithpicto('', $langs->trans("PaymentMadeForSeveralInvoices"));
743 }
744 print '<span class="amount">'.price($objp->amount).'</span>';
745 print '</td>';
746 if (!$i) {
747 $totalarray['nbfield']++;
748 $totalarray['pos'][$totalarray['nbfield']] = 'amount';
749 }
750 if (empty($totalarray['val']['amount'])) {
751 $totalarray['val']['amount'] = $objp->amount;
752 } else {
753 $totalarray['val']['amount'] += $objp->amount;
754 }
755 }
756
757 // Status
758 if (!empty($arrayfields['p.statut']['checked'])) {
759 print '<td class="right">';
760 if ($objp->statut == 0) {
761 print '<a href="card.php?id='.$objp->rowid.'&amp;action=valide">';
762 }
763 print $object->LibStatut($objp->statut, 5);
764 if ($objp->statut == 0) {
765 print '</a>';
766 }
767 print '</td>';
768 if (!$i) {
769 $totalarray['nbfield']++;
770 }
771 }
772
773 // Action column
774 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
775 print '<td class="nowrap center">';
776 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
777 $selected = 0;
778 if (in_array($object->id, $arrayofselected)) {
779 $selected = 1;
780 }
781 print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
782 }
783 print '</td>';
784 if (!$i) {
785 $totalarray['nbfield']++;
786 }
787 }
788
789 print '</tr>'."\n";
790 }
791
792 $i++;
793}
794
795// Show total line
796include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
797
798// If no record found
799if ($num == 0) {
800 $colspan = 1;
801 foreach ($arrayfields as $key => $val) {
802 if (!empty($val['checked'])) {
803 $colspan++;
804 }
805 }
806 print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
807}
808
809$db->free($resql);
810
811$parameters = array('arrayfields' => $arrayfields, 'sql' => $sql);
812$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
813print $hookmanager->resPrint;
814
815print '</table>'."\n";
816print '</div>'."\n";
817
818print '</form>'."\n";
819
820// End of page
821llxFooter();
822$db->close();
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:58
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Definition wrapper.php:55
llxFooter()
Empty footer.
Definition wrapper.php:69
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...
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
natural_search($fields, $value, $mode=0, $nofirstand=0)
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by the value of a given key, which produces ascending (default) or descending out...
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
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 dolibarr global constant string value.
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.