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