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