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