dolibarr 25.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-2025 MDW <mdeweerd@users.noreply.github.com>
13 * Copyright (C) 2024-2026 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';
45require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
46require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
47require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
48require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
49require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
50require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
51require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php';
52
53// Load translation files required by the page
54$langs->loadLangs(array('bills', 'banks', 'compta', 'companies'));
55
56$action = GETPOST('action', 'alpha');
57$massaction = GETPOST('massaction', 'alpha');
58$confirm = GETPOST('confirm', 'alpha');
59$toselect = GETPOST('toselect', 'array:int');
60$optioncss = GETPOST('optioncss', 'alpha');
61$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'paymentlist';
62$mode = GETPOST('mode', 'alpha');
63
64$facid = GETPOST('facid', 'int');
65$socid = GETPOST('socid', 'int');
66$userid = GETPOST('userid', 'int');
67
68$search_ref = GETPOST("search_ref", "alpha");
69$search_date_startday = GETPOSTINT('search_date_startday');
70$search_date_startmonth = GETPOSTINT('search_date_startmonth');
71$search_date_startyear = GETPOSTINT('search_date_startyear');
72$search_date_endday = GETPOSTINT('search_date_endday');
73$search_date_endmonth = GETPOSTINT('search_date_endmonth');
74$search_date_endyear = GETPOSTINT('search_date_endyear');
75$search_date_start = dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear); // Use tzserver
76$search_date_end = dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear);
77$search_company = GETPOST("search_company", 'alpha');
78$search_paymenttype = GETPOST("search_paymenttype");
79$search_account = GETPOST("search_account", 'alpha');
80$search_payment_num = GETPOST('search_payment_num', 'alpha');
81$search_amount = GETPOST("search_amount", 'alpha'); // alpha because we must be able to search on "< x"
82$search_noteprivate = GETPOST("search_noteprivate");
83$search_status = GETPOST('search_status', 'intcomma');
84$search_sale = GETPOSTINT('search_sale');
85
86
87$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
88$sortfield = GETPOST('sortfield', 'aZ09comma');
89$sortorder = GETPOST('sortorder', 'aZ09comma');
90$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
91
92if (empty($page) || $page == -1) {
93 $page = 0; // If $page is not defined, or '' or -1
94}
95$offset = $limit * $page;
96$pageprev = $page - 1;
97$pagenext = $page + 1;
98
99if (!$sortorder) {
100 $sortorder = "DESC";
101}
102if (!$sortfield) {
103 $sortfield = "p.ref";
104}
105
106$search_all = trim(GETPOST('search_all', 'alphanohtml'));
107
108$arrayofselected = !empty($arrayofselected) && is_array($arrayofselected) ? $arrayofselected : array();
109
110// List of fields to search into when doing a "search in all"
111$fieldstosearchall = array(
112 'p.ref' => "RefPayment",
113 's.nom' => "ThirdParty",
114 'p.num_paiement' => "Numero",
115 'p.amount' => "Amount",
116);
117
118$arrayfields = array(
119 'p.ref' => array('label' => "RefPayment", 'checked' => '1', 'position' => 10),
120 'p.datep' => array('label' => "Date", 'checked' => '1', 'position' => 20),
121 's.nom' => array('label' => "ThirdParty", 'checked' => '1', 'position' => 30),
122 'c.libelle' => array('label' => "Type", 'checked' => '1', 'position' => 40),
123 'transaction' => array('label' => "BankTransactionLine", 'checked' => '1', 'position' => 50, 'enabled' => (string) (int) (isModEnabled("bank"))),
124 'ba.label' => array('label' => "BankAccount", 'checked' => '1', 'position' => 60, 'enabled' => (string) (int) (isModEnabled("bank"))),
125 'p.num_paiement' => array('label' => "Numero", 'checked' => '1', 'position' => 70, 'tooltip' => "ChequeOrTransferNumber"),
126 'p.amount' => array('label' => "Amount", 'checked' => '1', 'position' => 80),
127 'p.note' => array('label' => "Comment", 'checked' => '-1', 'position' => 85),
128 'p.ext_payment_id' => array('label' => "ExtPaymentID", 'checked' => '-1', 'position' => 87),
129 'p.ext_payment_site' => array('label' => "ExtPaymentSite", 'checked' => '-1', 'position' => 88),
130 'p.tms' => array('label' => "DateModification", 'checked' => '-1', 'position' => 150),
131 'p.statut' => array('label' => "Status", 'checked' => '1', 'position' => 200, 'enabled' => (getDolGlobalString('BILL_ADD_PAYMENT_VALIDATION'))),
132);
133$arrayfields = dol_sort_array($arrayfields, 'position');
134
135// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
136$hookmanager->initHooks(array('paymentlist'));
137$object = new Paiement($db);
138
139// Fetch optionals attributes and labels
140$extrafields->fetch_name_optionals_label($object->table_element);
141
142$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
143// Extra fields
144include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
145// Add hook to complete $arrayfield
146$parameters = array('arrayfields' => &$arrayfields);
147$reshook = $hookmanager->executeHooks('completeArrayFields', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
148
149if (!$user->hasRight('societe', 'client', 'voir')) {
150 $search_sale = $user->id;
151}
152
153// Security check
154if ($user->socid) {
155 $socid = $user->socid;
156}
157$result = restrictedArea($user, 'facture', $facid, '');
158
159$permissiontopay = $user->hasRight('facture', 'paiement');
160$permissiontodelete = $user->hasRight('facture', 'delete');
161
162$error = 0;
163
164
165/*
166 * Actions
167 */
168
169if (GETPOST('cancel', 'alpha')) {
170 $action = 'list';
171 $massaction = '';
172}
173if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
174 $massaction = '';
175}
176
177$parameters = array('arrayfields' => &$arrayfields, 'socid' => $socid);
178$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
179if ($reshook < 0) {
180 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
181}
182
183
184if (empty($reshook)) {
185 include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
186
187 // All tests are required to be compatible with all browsers
188 if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
189 $search_ref = '';
190 $search_date_startday = '';
191 $search_date_startmonth = '';
192 $search_date_startyear = '';
193 $search_date_endday = '';
194 $search_date_endmonth = '';
195 $search_date_endyear = '';
196 $search_date_start = '';
197 $search_date_end = '';
198 $search_account = '';
199 $search_amount = '';
200 $search_paymenttype = '';
201 $search_payment_num = '';
202 $search_company = '';
203 $search_noteprivate = '';
204 $search_status = '';
205 $option = '';
206 $toselect = array();
207 $search_array_options = array();
208 }
209 if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')
210 || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) {
211 $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation
212 }
213
214 // Mass actions
215 $objectclass = 'Paiement';
216 $objectlabel = 'Payment';
217 $uploaddir = $conf->invoice->dir_output.'/payments';
218
219 global $error;
220 include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
221
222 if ($action === 'createbankpayment' && $permissiontopay && $confirm == 'yes') {
223 $db->begin();
224
225 foreach ($toselect as $toselectid) {
226 // Create the record into bank for the amount of payment $object
227 if (!$error) {
228 $label = '(CustomerInvoicePayment)';
229 if (GETPOST('type') == Facture::TYPE_CREDIT_NOTE) {
230 $label = '(CustomerInvoicePaymentBack)'; // Refund of a credit note
231 }
232
233 $bankaccountid = GETPOSTINT('accountid');
234 if ($bankaccountid > 0) {
235 $object->fetch($toselectid);
236
237 if (((int) $object->fk_account) != 0) {
238 setEventMessages('Error, at least one payment is already linked to a bank account', null, 'errors');
239 $error++;
240 break;
241 }
242
243 $object->paiementcode = $object->type_code;
244 $object->amounts = $object->getAmountsArray();
245
246 $result = $object->addPaymentToBank($user, 'payment', $label, $bankaccountid, '', '');
247 if ($result < 0) {
248 setEventMessages($object->error, $object->errors, 'errors');
249 $error++;
250 }
251 } else {
252 setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BankAccount")), null, 'errors');
253 $error++;
254 }
255 }
256 }
257
258 if (!$error) {
259 $db->commit();
260 } else {
261 $db->rollback();
262 }
263 }
264}
265
266
267/*
268 * View
269 */
270
271$form = new Form($db);
272$formother = new FormOther($db);
273$accountstatic = new Account($db);
274$companystatic = new Societe($db);
275$bankline = new AccountLine($db);
276
277$title = $langs->trans('ListPayment');
278
279llxHeader('', $title, '', '', 0, 0, '', '', '', 'bodyforlist');
280
281
282$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,";
283$sql .= " p.ext_payment_id, p.ext_payment_site,";
284$sql .= " p.tms,";
285$sql .= " c.code as paiement_code,";
286$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,";
287$sql .= " s.rowid as socid, s.nom as name, s.email,";
288// 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)
289// so SUM(pf.amount) should be equal to p.amount but if we filter on $socid, it may differ
290$sql .= " SUM(pf.amount) as totalamount, COUNT(f.rowid) as nbinvoices";
291// Add fields from extrafields
292if (!empty($extrafields->attributes[$object->table_element]['label'])) {
293 foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
294 $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : '');
295 }
296}
297// Add fields from hooks
298$parameters = array();
299$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
300$sql .= $hookmanager->resPrint;
301$sql = preg_replace('/,\s*$/', '', $sql);
302
303$sqlfields = $sql; // $sql fields to remove for count total
304
305$sql .= " FROM ".MAIN_DB_PREFIX."paiement as p";
306if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
307 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (p.rowid = ef.fk_object)";
308}
309$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_paiement = c.id";
310$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON p.fk_bank = b.rowid";
311$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid";
312
313$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON p.rowid = pf.fk_paiement";
314$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture as f ON pf.fk_facture = f.rowid";
315$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON f.fk_soc = s.rowid";
316
317// Add table from hooks
318$parameters = array();
319$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
320$sql .= $hookmanager->resPrint;
321
322$sql .= " WHERE p.entity IN (".getEntity('invoice').")";
323if ($socid > 0) {
324 $sql .= " AND EXISTS (SELECT f.fk_soc FROM ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."paiement_facture as pf";
325 $sql .= " WHERE p.rowid = pf.fk_paiement AND pf.fk_facture = f.rowid AND f.fk_soc = ".((int) $socid).")";
326}
327if ($userid) {
328 if ($userid == -1) {
329 $sql .= " AND p.fk_user_creat IS NULL";
330 } else {
331 $sql .= " AND p.fk_user_creat = ".((int) $userid);
332 }
333}
334
335// Search criteria
336if ($search_ref) {
337 $sql .= natural_search('p.ref', $search_ref);
338}
339if ($search_date_start) {
340 $sql .= " AND p.datep >= '" . $db->idate($search_date_start) . "'";
341}
342if ($search_date_end) {
343 $sql .= " AND p.datep <= '" . $db->idate($search_date_end) . "'";
344}
345if ($search_account > 0) {
346 $sql .= " AND b.fk_account = ".((int) $search_account);
347} elseif ($search_account == -2) {
348 $sql .= " AND (b.fk_account = 0 OR b.fk_account IS NULL)";
349}
350if ($search_paymenttype != '') {
351 $sql .= " AND c.code = '".$db->escape($search_paymenttype)."'";
352}
353if ($search_payment_num != '') {
354 $sql .= natural_search('p.num_paiement', $search_payment_num);
355}
356if ($search_amount) {
357 $sql .= " AND (".natural_search('p.amount', $search_amount, 1, 1);
358 $sql .= " OR ";
359 $sql .= natural_search('pf.amount', $search_amount, 1, 1);
360 $sql .= ")";
361}
362if ($search_company) {
363 $sql .= natural_search('s.nom', $search_company);
364}
365if ($search_noteprivate) {
366 $sql .= natural_search('p.note', $search_noteprivate);
367}
368// Search on sale representative
369if ($search_sale && $search_sale != -1) {
370 if ($search_sale == -2) {
371 $sql .= " AND ".getSalesRepresentativeSqlFilter('f.fk_soc', 0, 1);
372 } elseif ($search_sale > 0) {
373 $sql .= " AND ".getSalesRepresentativeSqlFilter('f.fk_soc', (int) $search_sale);
374 }
375}
376
377if ($search_all) {
378 $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
379}
380// Add where from extra fields
381include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
382
383// Add where from hooks
384$parameters = array();
385$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook
386$sql .= $hookmanager->resPrint;
387
388$sql .= " GROUP BY p.rowid, p.ref, p.datep, p.fk_bank, p.statut, p.num_paiement, p.amount, p.note, p.ext_payment_id, p.ext_payment_site";
389$sql .= ", c.code";
390$sql .= ", ba.rowid, ba.ref, ba.label, ba.number, ba.account_number, ba.fk_accountancy_journal";
391$sql .= ", s.rowid, s.nom, s.email";
392
393// Overwrite for a debug use case
394if (GETPOST("orphelins", "alpha")) {
395 // Payments not linked to an invoice. Should not happen. For debug only.
396 $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";
397 $sql .= ", c.code as paiement_code";
398
399 $sqlfields = $sql; // $sql fields to remove for count total
400
401 // Add fields from hooks
402 $parameters = array();
403 $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook
404 $sql .= $hookmanager->resPrint;
405 $sql .= " FROM ".MAIN_DB_PREFIX."paiement as p LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_paiement = c.id";
406 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON p.rowid = pf.fk_paiement";
407
408 // Add table from hooks
409 $parameters = array();
410 $reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook
411 $sql .= $hookmanager->resPrint;
412
413 $sql .= " WHERE p.entity IN (".getEntity('invoice').")";
414 $sql .= " AND pf.fk_facture IS NULL";
415
416 // Add where from hooks
417 $parameters = array();
418 $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook
419 $sql .= $hookmanager->resPrint;
420}
421
422
423// Count total nb of records
424$nbtotalofrecords = '';
425if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
426 /* The fast and low memory method to get and count full list converts the sql into a sql count */
427 $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(DISTINCT p.rowid) as nbtotalofrecords', $sql);
428 $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount);
429 $resql = $db->query($sqlforcount);
430 if ($resql) {
431 $objforcount = $db->fetch_object($resql);
432 $nbtotalofrecords = $objforcount->nbtotalofrecords;
433 } else {
435 }
436
437 if (($page * $limit) > (int) $nbtotalofrecords) { // if total resultset is smaller than the paging size (filtering), goto and load page 0
438 $page = 0;
439 $offset = 0;
440 }
441 $db->free($resql);
442}
443
444// Complete request and execute it with limit
445$sql .= $db->order($sortfield, $sortorder);
446if ($limit) {
447 $sql .= $db->plimit($limit + 1, $offset);
448}
449//print $sql;
450
451$resql = $db->query($sql);
452if (!$resql) {
454 llxFooter();
455 $db->close();
456 exit;
457}
458
459$num = $db->num_rows($resql);
460
461
462// Output page
463// --------------------------------------------------------------------
464
465$arrayofselected = is_array($toselect) ? $toselect : array();
466
467$param = '';
468if (!empty($mode)) {
469 $param .= '&mode='.urlencode($mode);
470}
471if (!empty($contextpage) && $contextpage != getDolDefaultContextPage(__FILE__)) {
472 $param .= '&contextpage='.urlencode($contextpage);
473}
474if ($limit > 0 && $limit != $conf->liste_limit) {
475 $param .= '&limit='.((int) $limit);
476}
477if ($optioncss != '') {
478 $param .= '&optioncss='.urlencode($optioncss);
479}
480
481if (GETPOST("orphelins")) {
482 $param .= '&orphelins=1';
483}
484if ($search_ref) {
485 $param .= '&search_ref='.urlencode($search_ref);
486}
487if ($search_date_startday) {
488 $param .= '&search_date_startday='.urlencode((string) ($search_date_startday));
489}
490if ($search_date_startmonth) {
491 $param .= '&search_date_startmonth='.urlencode((string) ($search_date_startmonth));
492}
493if ($search_date_startyear) {
494 $param .= '&search_date_startyear='.urlencode((string) ($search_date_startyear));
495}
496if ($search_date_endday) {
497 $param .= '&search_date_endday='.urlencode((string) ($search_date_endday));
498}
499if ($search_date_endmonth) {
500 $param .= '&search_date_endmonth='.urlencode((string) ($search_date_endmonth));
501}
502if ($search_date_endyear) {
503 $param .= '&search_date_endyear='.urlencode((string) ($search_date_endyear));
504}
505if ($search_company) {
506 $param .= '&search_company='.urlencode($search_company);
507}
508if ($search_amount != '') {
509 $param .= '&search_amount='.urlencode($search_amount);
510}
511if ($search_paymenttype) {
512 $param .= '&search_paymenttype='.urlencode($search_paymenttype);
513}
514if ($search_account) {
515 $param .= '&search_account='.urlencode((string) ($search_account));
516}
517if ($search_payment_num) {
518 $param .= '&search_payment_num='.urlencode($search_payment_num);
519}
520if ($search_noteprivate) {
521 $param .= '&search_noteprivate='.urlencode($search_noteprivate);
522}
523// Add $param from extra fields
524include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
525// Add $param from hooks
526$parameters = array('param' => &$param);
527$reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
528$param .= $hookmanager->resPrint;
529
530// List of mass actions available
531$arrayofmassactions = array(
532 //'validate'=>img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("Validate"),
533 //'generate_doc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"),
534 //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
535 //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
536);
537if (!empty($permissiontopay) && getDolGlobalString('FACTURE_PAYMENT_FIX_LINK_TO_BANK')) {
538 $arrayofmassactions['createbankpayment'] = img_picto('', 'bank', 'class="pictofixedwidth"').$langs->trans("FixLinkToBank");
539}
540if (!empty($permissiontodelete)) {
541 //$arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
542}
543if (GETPOSTINT('nomassaction') || in_array($massaction, array('presend', 'predelete', 'createbankpayment'))) {
544 $arrayofmassactions = array();
545}
546$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
547
548print '<form method="POST" id="searchFormList" action="'.dolBuildUrl($_SERVER["PHP_SELF"]).'">';
549if ($optioncss != '') {
550 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
551}
552print '<input type="hidden" name="token" value="'.newToken().'">';
553print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
554print '<input type="hidden" name="action" value="list">';
555print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
556print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
557print '<input type="hidden" name="page" value="'.$page.'">';
558print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
559print '<input type="hidden" name="page_y" value="">';
560print '<input type="hidden" name="mode" value="'.$mode.'">';
561
562// @phan-suppress-next-line PhanPluginSuspiciousParamOrder
563print_barre_liste($langs->trans("ReceivedCustomersPayments"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'bill', 0, '', '', $limit, 0, 0, 1);
564
565
566if ($massaction == 'createbankpayment') {
567 $formquestion = array();
568
569 $valuefield = '<div style="display: flex; align-items: center; justify-content: flex-end; padding-right: 150px">';
570 $valuefield .= img_picto('', 'bank', 'class="pictofixedwidth"');
571 $valuefield .= $form->select_comptes(0, 'accountid', 0, '', 2, '', 0, '', 1);
572 $valuefield .= '</div>';
573
574 $formquestion[] = array(
575 'type' => 'other',
576 'name' => 'bakaccount',
577 'label' => $langs->trans("BankAccount"),
578 'value' => $valuefield
579 );
580
581 print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ToCreateRelatedRecordIntoBank"), $langs->trans("Confirm"), "createbankpayment", $formquestion, 1, 0, 200, 500, 1);
582}
583
584
585if ($search_all) {
586 $setupstring = '';
587 // @phan-suppress-next-line PhanEmptyForeach
588 foreach ($fieldstosearchall as $key => $val) {
589 $fieldstosearchall[$key] = $langs->trans($val);
590 $setupstring .= $key."=".$val.";";
591 }
592 print '<!-- Search done like if PAYMENT_QUICKSEARCH_ON_FIELDS = '.$setupstring.' -->'."\n";
593 print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).implode(', ', $fieldstosearchall).'</div>'."\n";
594}
595
596$moreforfilter = '';
597
598$parameters = array();
599$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
600if (empty($reshook)) {
601 $moreforfilter .= $hookmanager->resPrint;
602} else {
603 $moreforfilter = $hookmanager->resPrint;
604}
605$parameters = array(
606 'arrayfields' => &$arrayfields,
607);
608
609if (!empty($moreforfilter)) {
610 print '<div class="liste_titre liste_titre_bydiv centpercent">';
611 print $moreforfilter;
612 print '</div>';
613}
614
615$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
616$htmlofselectarray = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, $conf->main_checkbox_left_column); // This also change content of $arrayfields with user setup
617$selectedfields = (($mode != 'kanban' && $mode != 'kanbangroupby') ? $htmlofselectarray : '');
618$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
619
620print '<div class="div-table-responsive">';
621print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : '').'">'."\n";
622
623// Fields title search
624// --------------------------------------------------------------------
625print '<tr class="liste_titre_filter">';
626
627// Action column
628if ($conf->main_checkbox_left_column) {
629 print '<td class="liste_titre center maxwidthsearch">';
630 $searchpicto = $form->showFilterButtons('left');
631 print $searchpicto;
632 print '</td>';
633}
634
635// #
636if (getDolGlobalString('MAIN_VIEW_LINE_NUMBER_IN_LIST')) {
637 print '<td class="liste_titre">';
638 print '</td>';
639}
640
641// Filter: Ref
642if (!empty($arrayfields['p.ref']['checked'])) {
643 print '<td class="liste_titre left">';
644 print '<input class="flat" type="text" size="4" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
645 print '</td>';
646}
647
648// Filter: Date
649if (!empty($arrayfields['p.datep']['checked'])) {
650 print '<td class="liste_titre center">';
651 print '<div class="nowrapfordate">';
652 print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
653 print '</div>';
654 print '<div class="nowrapfordate">';
655 print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
656 print '</div>';
657 print '</td>';
658}
659
660// Filter: Thirdparty
661if (!empty($arrayfields['s.nom']['checked'])) {
662 print '<td class="liste_titre">';
663 print '<input class="flat" type="text" size="6" name="search_company" value="'.dol_escape_htmltag($search_company).'">';
664 print '</td>';
665}
666
667// Filter: Payment type
668if (!empty($arrayfields['c.libelle']['checked'])) {
669 print '<td class="liste_titre">';
670 print $form->select_types_paiements($search_paymenttype, 'search_paymenttype', '', 2, 1, 1, 0, 1, 'maxwidth100', 1);
671 print '</td>';
672}
673
674// Filter: Bank transaction number
675if (!empty($arrayfields['transaction']['checked'])) {
676 print '<td class="liste_titre">';
677 print '<input class="flat" type="text" size="4" name="search_payment_num" value="'.dol_escape_htmltag($search_payment_num).'">';
678 print '</td>';
679}
680
681// Filter: Cheque number (fund transfer)
682if (!empty($arrayfields['p.num_paiement']['checked'])) {
683 print '<td class="liste_titre">';
684 print '</td>';
685}
686
687// Filter: Bank account
688if (!empty($arrayfields['ba.label']['checked'])) {
689 print '<td class="liste_titre">';
690 print $form->select_comptes($search_account, 'search_account', 0, '', 1, '', 0, 'maxwidth125', 1, getDolGlobalString('FACTURE_PAYMENT_FIX_LINK_TO_BANK') ? 1 : 0);
691 print '</td>';
692}
693
694// Filter: Amount
695if (!empty($arrayfields['p.amount']['checked'])) {
696 print '<td class="liste_titre right">';
697 print '<input class="flat" type="text" size="4" name="search_amount" value="'.dol_escape_htmltag($search_amount).'">';
698 print '</td>';
699}
700
701// Filter: Note
702if (!empty($arrayfields['p.note']['checked'])) {
703 print '<td class="liste_titre">';
704 print '<input class="flat maxwidth150" type="text" name="search_noteprivate" value="'.dol_escape_htmltag($search_noteprivate).'">';
705 print '</td>';
706}
707
708// Filter: ext_payment_id
709if (!empty($arrayfields['p.ext_payment_id']['checked'])) {
710 print '<td class="liste_titre">';
711 //print '<input class="flat maxwidth150" type="text" name="search_ext_payment_id" value="'.dol_escape_htmltag($search_ext_payment_id).'">';
712 print '</td>';
713}
714
715// Filter: ext_payment_site
716if (!empty($arrayfields['p.ext_payment_site']['checked'])) {
717 print '<td class="liste_titre">';
718 //print '<input class="flat maxwidth150" type="text" name="search_ext_payment_site" value="'.dol_escape_htmltag($search_payment_site).'">';
719 print '</td>';
720}
721
722// Filter: ext_payment_site
723if (!empty($arrayfields['p.tms']['checked'])) {
724 print '<td class="liste_titre">';
725 //print '<input class="flat maxwidth150" type="text" name="search_ext_payment_site" value="'.dol_escape_htmltag($search_payment_site).'">';
726 print '</td>';
727}
728
729// Filter: Status (only placeholder)
730if (!empty($arrayfields['p.statut']['checked'])) {
731 print '<td class="liste_titre right">';
732 print '</td>';
733}
734
735// Extra fields
736include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
737
738// Fields from hook
739$parameters = array('arrayfields' => $arrayfields);
740$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
741print $hookmanager->resPrint;
742
743// Action column
744if (!$conf->main_checkbox_left_column) {
745 print '<td class="liste_titre center maxwidthsearch">';
746 $searchpicto = $form->showFilterButtons();
747 print $searchpicto;
748 print '</td>';
749}
750
751print '</tr>'."\n";
752
753$totalarray = array();
754$totalarray['nbfield'] = 0;
755
756// Fields title label
757// --------------------------------------------------------------------
758print '<tr class="liste_titre">';
759// Action column
760if ($conf->main_checkbox_left_column) {
761 print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ');
762 $totalarray['nbfield']++;
763}
764if (getDolGlobalString('MAIN_VIEW_LINE_NUMBER_IN_LIST')) {
765 print_liste_field_titre('#', $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder);
766 $totalarray['nbfield']++;
767}
768if (!empty($arrayfields['p.ref']['checked'])) {
769 // False positive @phan-suppress-next-line PhanTypeInvalidDimOffset
770 print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], "p.ref", '', $param, '', $sortfield, $sortorder);
771 $totalarray['nbfield']++;
772}
773if (!empty($arrayfields['p.datep']['checked'])) {
774 print_liste_field_titre($arrayfields['p.datep']['label'], $_SERVER["PHP_SELF"], "p.datep", '', $param, '', $sortfield, $sortorder, 'center ');
775 $totalarray['nbfield']++;
776}
777if (!empty($arrayfields['s.nom']['checked'])) {
778 print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", '', $param, '', $sortfield, $sortorder);
779 $totalarray['nbfield']++;
780}
781if (!empty($arrayfields['c.libelle']['checked'])) {
782 print_liste_field_titre($arrayfields['c.libelle']['label'], $_SERVER["PHP_SELF"], "c.libelle", '', $param, '', $sortfield, $sortorder);
783 $totalarray['nbfield']++;
784}
785if (!empty($arrayfields['p.num_paiement']['checked'])) {
786 print_liste_field_titre($arrayfields['p.num_paiement']['label'], $_SERVER["PHP_SELF"], "p.num_paiement", '', $param, '', $sortfield, $sortorder, '', $arrayfields['p.num_paiement']['tooltip']);
787 $totalarray['nbfield']++;
788}
789if (!empty($arrayfields['transaction']['checked'])) {
790 print_liste_field_titre($arrayfields['transaction']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder);
791 $totalarray['nbfield']++;
792}
793if (!empty($arrayfields['ba.label']['checked'])) {
794 print_liste_field_titre($arrayfields['ba.label']['label'], $_SERVER["PHP_SELF"], "ba.label", '', $param, '', $sortfield, $sortorder);
795 $totalarray['nbfield']++;
796}
797if (!empty($arrayfields['p.amount']['checked'])) {
798 print_liste_field_titre($arrayfields['p.amount']['label'], $_SERVER["PHP_SELF"], "p.amount", '', $param, 'class="right"', $sortfield, $sortorder);
799 $totalarray['nbfield']++;
800}
801if (!empty($arrayfields['p.note']['checked'])) {
802 print_liste_field_titre($arrayfields['p.note']['label'], $_SERVER["PHP_SELF"], "p.note", '', $param, '', $sortfield, $sortorder);
803 $totalarray['nbfield']++;
804}
805if (!empty($arrayfields['p.ext_payment_id']['checked'])) {
806 print_liste_field_titre($arrayfields['p.ext_payment_id']['label'], $_SERVER["PHP_SELF"], "p.ext_payment_id", '', $param, '', $sortfield, $sortorder);
807 $totalarray['nbfield']++;
808}
809if (!empty($arrayfields['p.ext_payment_site']['checked'])) {
810 print_liste_field_titre($arrayfields['p.ext_payment_site']['label'], $_SERVER["PHP_SELF"], "p.ext_payment_site", '', $param, '', $sortfield, $sortorder);
811 $totalarray['nbfield']++;
812}
813if (!empty($arrayfields['p.tms']['checked'])) {
814 print_liste_field_titre($arrayfields['p.tms']['label'], $_SERVER["PHP_SELF"], "p.tms", '', $param, '', $sortfield, $sortorder);
815 $totalarray['nbfield']++;
816}
817if (!empty($arrayfields['p.statut']['checked'])) {
818 print_liste_field_titre($arrayfields['p.statut']['label'], $_SERVER["PHP_SELF"], "p.statut", '', $param, 'class="right"', $sortfield, $sortorder);
819 $totalarray['nbfield']++;
820}
821// Extra fields
822include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
823// Hook fields
824$parameters = array('arrayfields' => $arrayfields, 'param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder);
825$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
826print $hookmanager->resPrint;
827// Action column
828if (!$conf->main_checkbox_left_column) {
829 print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ');
830 $totalarray['nbfield']++;
831}
832
833print '</tr>'."\n";
834
835// Detect if we need a fetch on each output line
836$needToFetchEachLine = 0;
837if (isset($extrafields->attributes[$object->table_element]['computed']) && is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) {
838 foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) {
839 if (!is_null($val) && preg_match('/\$object/', $val)) {
840 $needToFetchEachLine++; // There is at least one compute field that use $object
841 }
842 }
843}
844
845
846// Loop on record
847// --------------------------------------------------------------------
848$i = 0;
849$savnbfield = $totalarray['nbfield'];
850$totalarray = array();
851$totalarray['nbfield'] = 0;
852$imaxinloop = ($limit ? min($num, $limit) : $num);
853while ($i < $imaxinloop) {
854 $obj = $db->fetch_object($resql);
855 if (empty($obj)) {
856 break; // Should not happen
857 }
858
859 $object->id = $obj->rowid;
860 $object->ref = ($obj->ref ? $obj->ref : $obj->rowid);
861 $object->date = $db->jdate($obj->datep);
862 $object->amount = $obj->amount;
863 $object->note_private = $obj->note_private;
864
865 $companystatic->id = $obj->socid;
866 $companystatic->name = $obj->name;
867 $companystatic->email = $obj->email;
868
869 if ($mode == 'kanban' || $mode == 'kanbangroupby') {
870 if ($i == 0) {
871 print '<tr class="trkanban"><td colspan="'.$savnbfield.'">';
872 print '<div class="box-flex-container kanban">';
873 }
874 // Output Kanban
875 $selected = -1;
876 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
877 $selected = 0;
878 if (in_array($object->id, $arrayofselected)) {
879 $selected = 1;
880 }
881 }
882 //print $object->getKanbanView('', array('thirdparty'=>$object->thirdparty, 'selected' => $selected));
883 print $object->getKanbanView('', array('selected' => $selected));
884 if ($i == ($imaxinloop - 1)) {
885 print '</div>';
886 print '</td></tr>';
887 }
888 } else {
889 // Show line of result
890 $j = 0;
891 print '<tr data-rowid="'.$object->id.'" class="oddeven row-with-select">';
892
893 // Action column
894 if ($conf->main_checkbox_left_column) {
895 print '<td class="nowrap center">';
896 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
897 $selected = 0;
898 if (in_array($object->id, $arrayofselected)) {
899 $selected = 1;
900 }
901 print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
902 }
903 print '</td>';
904 if (!$i) {
905 $totalarray['nbfield']++;
906 }
907 }
908
909 // No
910 if (getDolGlobalString('MAIN_VIEW_LINE_NUMBER_IN_LIST')) {
911 print '<td class="nowraponall">'.(($offset * $limit) + $i).'</td>';
912 if (!$i) {
913 $totalarray['nbfield']++;
914 }
915 }
916
917 // Ref
918 if (!empty($arrayfields['p.ref']['checked'])) {
919 print '<td class="nowraponall">'.$object->getNomUrl(1).'</td>';
920 if (!$i) {
921 $totalarray['nbfield']++;
922 }
923 }
924
925 // Date
926 if (!empty($arrayfields['p.datep']['checked'])) {
927 $dateformatforpayment = 'dayhour';
928 print '<td class="nowraponall center">'.dol_print_date($db->jdate($obj->datep), $dateformatforpayment, 'tzuser').'</td>';
929 if (!$i) {
930 $totalarray['nbfield']++;
931 }
932 }
933
934 // Thirdparty
935 if (!empty($arrayfields['s.nom']['checked'])) {
936 print '<td class="tdoverflowmax125">';
937 if ($obj->socid > 0) {
938 print $companystatic->getNomUrl(1, '', 24);
939 }
940 print '</td>';
941 if (!$i) {
942 $totalarray['nbfield']++;
943 }
944 }
945
946 // Payment type
947 if (!empty($arrayfields['c.libelle']['checked'])) {
948 print '<td class="tdoverflowmax100" title="'.dolPrintHTMLForAttribute($langs->trans("PaymentTypeShort".$obj->paiement_code)).'">'.dolPrintHTML($langs->trans("PaymentTypeShort".$obj->paiement_code)).'</td>';
949 if (!$i) {
950 $totalarray['nbfield']++;
951 }
952 }
953
954 // Filter: Cheque number (fund transfer)
955 if (!empty($arrayfields['p.num_paiement']['checked'])) {
956 print '<td>'.$obj->num_payment.'</td>';
957 if (!$i) {
958 $totalarray['nbfield']++;
959 }
960 }
961
962 // Bank transaction
963 if (!empty($arrayfields['transaction']['checked'])) {
964 print '<td class="tdoverflowmax125">';
965 if ($obj->fk_bank > 0) {
966 $bankline->fetch($obj->fk_bank);
967 print $bankline->getNomUrl(1, 0);
968 }
969 print '</td>';
970 if (!$i) {
971 $totalarray['nbfield']++;
972 }
973 }
974
975 // Bank account
976 if (!empty($arrayfields['ba.label']['checked'])) {
977 print '<td>';
978 if ($obj->bid > 0) {
979 $accountstatic->id = $obj->bid;
980 $accountstatic->ref = $obj->bref;
981 $accountstatic->label = $obj->blabel;
982 $accountstatic->number = $obj->number;
983 $accountstatic->account_number = $obj->account_number;
984
985 $accountingjournal = new AccountingJournal($db);
986 $accountingjournal->fetch($obj->accountancy_journal);
987 $accountstatic->accountancy_journal = $accountingjournal->code;
988
989 print $accountstatic->getNomUrl(1);
990 }
991 print '</td>';
992 if (!$i) {
993 $totalarray['nbfield']++;
994 }
995 }
996
997 // Amount
998 if (!empty($arrayfields['p.amount']['checked'])) {
999 print '<td class="right">';
1000 if ($obj->nbinvoices > 1 || ($obj->totalamount && $obj->amount != $obj->totalamount)) {
1001 print $form->textwithpicto('', $langs->trans("PaymentMadeForSeveralInvoices"));
1002 }
1003 print '<span class="amount">'.price($obj->amount).'</span>';
1004 print '</td>';
1005 if (!$i) {
1006 $totalarray['nbfield']++;
1007 $totalarray['pos'][$totalarray['nbfield']] = 'amount';
1008 }
1009 if (empty($totalarray['val']['amount'])) {
1010 $totalarray['val']['amount'] = $obj->amount;
1011 } else {
1012 $totalarray['val']['amount'] += $obj->amount;
1013 }
1014 }
1015
1016 // Note
1017 if (!empty($arrayfields['p.note']['checked'])) {
1018 $firstline = dolGetFirstLineOfText($obj->note_private, 1);
1019 print '<td class="tdoverflowmax200" title="'.dolPrintHTMLForAttribute($firstline).'">';
1020 print dolPrintHTML($firstline).'</span>';
1021 print '</td>';
1022 if (!$i) {
1023 $totalarray['nbfield']++;
1024 }
1025 }
1026
1027 // ext_payment_id
1028 if (!empty($arrayfields['p.ext_payment_id']['checked'])) {
1029 print '<td class="tdoverflowmax200" title="'.dolPrintHTMLForAttribute($obj->ext_payment_id).'">';
1030 print dolPrintHTML($obj->ext_payment_id).'</span>';
1031 print '</td>';
1032 if (!$i) {
1033 $totalarray['nbfield']++;
1034 }
1035 }
1036
1037 // ext_payment_site
1038 if (!empty($arrayfields['p.ext_payment_site']['checked'])) {
1039 print '<td class="tdoverflowmax200" title="'.dolPrintHTMLForAttribute($obj->ext_payment_site).'">';
1040 print dolPrintHTML($obj->ext_payment_site).'</span>';
1041 print '</td>';
1042 if (!$i) {
1043 $totalarray['nbfield']++;
1044 }
1045 }
1046
1047 // Date last change
1048 if (!empty($arrayfields['p.tms']['checked'])) {
1049 print '<td class="tdoverflowmax200">';
1050 print dol_print_date($obj->tms, 'dayhour', 'tzuserrel').'</span>';
1051 print '</td>';
1052 if (!$i) {
1053 $totalarray['nbfield']++;
1054 }
1055 }
1056
1057 // Extra fields
1058 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
1059
1060 // Status
1061 if (!empty($arrayfields['p.statut']['checked'])) {
1062 print '<td class="right">';
1063 if ($obj->statut == 0) {
1064 print '<a href="card.php?id='.$obj->rowid.'&amp;action=valide&amp;token='.newToken().'">';
1065 }
1066 print $object->LibStatut($obj->statut, 5);
1067 if ($obj->statut == 0) {
1068 print '</a>';
1069 }
1070 print '</td>';
1071 if (!$i) {
1072 $totalarray['nbfield']++;
1073 }
1074 }
1075
1076 // Fields from hook
1077 $parameters = array('arrayfields' => $arrayfields, 'obj' => $obj, 'i' => $i, 'totalarray' => &$totalarray);
1078 $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1079 print $hookmanager->resPrint;
1080
1081 // Action column
1082 if (!$conf->main_checkbox_left_column) {
1083 print '<td class="nowrap center">';
1084 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
1085 $selected = 0;
1086 if (in_array($object->id, $arrayofselected)) {
1087 $selected = 1;
1088 }
1089 print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
1090 }
1091 print '</td>';
1092 if (!$i) {
1093 $totalarray['nbfield']++;
1094 }
1095 }
1096
1097 print '</tr>'."\n";
1098 }
1099
1100 $i++;
1101}
1102
1103// Show total line
1104include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
1105
1106// If no record found
1107if ($num == 0) {
1108 $colspan = 1;
1109 foreach ($arrayfields as $key => $val) {
1110 if (!empty($val['checked'])) {
1111 $colspan++;
1112 }
1113 }
1114 print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
1115}
1116
1117$db->free($resql);
1118
1119$parameters = array('arrayfields' => $arrayfields, 'sql' => $sql);
1120$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1121print $hookmanager->resPrint;
1122
1123print '</table>'."\n";
1124print '</div>'."\n";
1125
1126print '</form>'."\n";
1127
1128// End of page
1129llxFooter();
1130$db->close();
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
$totalarray
Definition list.php:501
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:91
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:73
Class to manage bank accounts.
Class to manage bank transaction lines.
Class to manage accounting journals.
const TYPE_CREDIT_NOTE
Credit note invoice.
Class to manage generation of HTML components Only common components must be here.
Class to help generate other html components Only common components are here.
Class to manage payments of customer invoices.
Class to manage third parties objects (customers, suppliers, prospects...)
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
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...
dolGetFirstLineOfText($text, $nboflines=1, $charset='UTF-8')
Return first line of text.
natural_search($fields, $value, $mode=0, $nofirstand=0, $sqltoadd='')
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...
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
getDolDefaultContextPage($s)
Return the default context page string.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
print_liste_field_titre($name, $file="", $field="", $begin="", $param="", $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, $selectlimitsuffix=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
dolPrintHTML($s, $allowiframe=0, $moreallowedtags=array())
Return a string (that can be on several lines) ready to be output on a HTML page.
Definition html.lib.php:73
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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.