dolibarr 19.0.3
list.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2003-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
4 * Copyright (C) 2004-2020 Laurent Destailleur <eldy@users.sourceforge.net>
5 * Copyright (C) 2004 Christophe Combelles <ccomb@free.fr>
6 * Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
7 * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
8 * Copyright (C) 2014 Teddy Andreotti <125155@supinfo.com>
9 * Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
10 * Copyright (C) 2015 Juanjo Menent <jmenent@2byte.es>
11 * Copyright (C) 2017-2023 Alexandre Spangaro <aspangaro@easya.solutions>
12 * Copyright (C) 2018-2021 Frédéric France <frederic.france@netlogic.fr>
13 * Copyright (C) 2020 Tobias Sekan <tobias.sekan@startmail.com>
14 * Copyright (C) 2021 Ferran Marcet <fmarcet@2byte.es>
15 *
16 * This program is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License as published by
18 * the Free Software Foundation; either version 3 of the License, or
19 * (at your option) any later version.
20 *
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
25 *
26 * You should have received a copy of the GNU General Public License
27 * along with this program. If not, see <https://www.gnu.org/licenses/>.
28 */
29
36// Load Dolibarr environment
37require '../../main.inc.php';
38require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php';
39require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
40require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
41require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
42require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php';
43
44// Load translation files required by the page
45$langs->loadLangs(array('companies', 'bills', 'banks', 'compta'));
46
47$action = GETPOST('action', 'alpha');
48$massaction = GETPOST('massaction', 'alpha');
49$optioncss = GETPOST('optioncss', 'alpha');
50$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'vendorpaymentlist';
51$mode = GETPOST('mode', 'aZ');
52$socid = GETPOST('socid', 'int');
53
54$search_ref = GETPOST('search_ref', 'alpha');
55$search_date_startday = GETPOST('search_date_startday', 'int');
56$search_date_startmonth = GETPOST('search_date_startmonth', 'int');
57$search_date_startyear = GETPOST('search_date_startyear', 'int');
58$search_date_endday = GETPOST('search_date_endday', 'int');
59$search_date_endmonth = GETPOST('search_date_endmonth', 'int');
60$search_date_endyear = GETPOST('search_date_endyear', 'int');
61$search_date_start = dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear); // Use tzserver
62$search_date_end = dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear);
63$search_company = GETPOST('search_company', 'alpha');
64$search_payment_type = GETPOST('search_payment_type');
65$search_cheque_num = GETPOST('search_cheque_num', 'alpha');
66$search_bank_account = GETPOST('search_bank_account', 'int');
67$search_amount = GETPOST('search_amount', 'alpha'); // alpha because we must be able to search on '< x'
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
75if (empty($page) || $page == -1) {
76 $page = 0; // If $page is not defined, or '' or -1
77}
78$offset = $limit * $page;
79$pageprev = $page - 1;
80$pagenext = $page + 1;
81
82if (!$sortorder) {
83 $sortorder = "DESC";
84}
85if (!$sortfield) {
86 $sortfield = "p.datep";
87}
88
89$search_all = trim(GETPOSTISSET("search_all") ? GETPOST("search_all", 'alpha') : GETPOST('sall'));
90
91// List of fields to search into when doing a "search in all"
92$fieldstosearchall = array(
93 'p.ref'=>"RefPayment",
94 's.nom'=>"ThirdParty",
95 'p.num_paiement'=>"Numero",
96 'p.amount'=>"Amount",
97);
98
99$arrayfields = array(
100 'p.ref' =>array('label'=>"RefPayment", 'checked'=>1, 'position'=>10),
101 'p.datep' =>array('label'=>"Date", 'checked'=>1, 'position'=>20),
102 's.nom' =>array('label'=>"ThirdParty", 'checked'=>1, 'position'=>30),
103 'c.libelle' =>array('label'=>"Type", 'checked'=>1, 'position'=>40),
104 'p.num_paiement' =>array('label'=>"Numero", 'checked'=>1, 'position'=>50, 'tooltip'=>"ChequeOrTransferNumber"),
105 'ba.label' =>array('label'=>"Account", 'checked'=>1, 'position'=>60, 'enable'=>(isModEnabled("banque"))),
106 'p.amount' =>array('label'=>"Amount", 'checked'=>1, 'position'=>70),
107);
108$arrayfields = dol_sort_array($arrayfields, 'position');
109
110// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
111$hookmanager->initHooks(array('paymentsupplierlist'));
112$object = new PaiementFourn($db);
113
114if (!$user->hasRight('societe', 'client', 'voir')) {
115 $search_sale = $user->id;
116}
117
118// Security check
119if ($user->socid) {
120 $socid = $user->socid;
121}
122
123// doesn't work :-(
124// restrictedArea($user, 'fournisseur');
125// doesn't work :-(
126// require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php';
127// $object = new PaiementFourn($db);
128// restrictedArea($user, $object->element);
129if (!isModEnabled('supplier_invoice')) {
131}
132if ((!$user->hasRight("fournisseur", "facture", "lire") && !getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD'))
133 || (!$user->hasRight("supplier_invoice", "lire") && getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD'))) {
135}
136
137
138/*
139 * Actions
140 */
141
142$parameters = array('socid'=>$socid);
143$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
144if ($reshook < 0) {
145 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
146}
147
148if (empty($reshook)) {
149 include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
150
151 if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
152 $search_ref = '';
153 $search_date_startday = '';
154 $search_date_startmonth = '';
155 $search_date_startyear = '';
156 $search_date_endday = '';
157 $search_date_endmonth = '';
158 $search_date_endyear = '';
159 $search_date_start = '';
160 $search_date_end = '';
161 $search_company = '';
162 $search_payment_type = '';
163 $search_cheque_num = '';
164 $search_bank_account = '';
165 $search_amount = '';
166 $option = '';
167 $toselect = array();
168 $search_array_options = array();
169 }
170}
171
172/*
173 * View
174 */
175
176llxHeader('', $langs->trans('ListPayment'));
177
178$form = new Form($db);
179$formother = new FormOther($db);
180$accountstatic = new Account($db);
181$companystatic = new Societe($db);
182$paymentfournstatic = new PaiementFourn($db);
183
184$sql = 'SELECT p.rowid, p.ref, p.datep, p.fk_bank, p.statut, p.num_paiement as num_payment, p.amount';
185$sql .= ', c.code as paiement_type, c.libelle as paiement_libelle';
186$sql .= ', ba.rowid as bid, ba.ref as bref, ba.label as blabel, ba.number, ba.account_number as account_number, ba.iban_prefix, ba.bic, ba.currency_code, ba.fk_accountancy_journal as accountancy_journal';
187$sql .= ', s.rowid as socid, s.nom as name, s.email';
188// 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)
189// so SUM(pf.amount) should be equal to p.amount but if we filter on $socid, it may differ
190$sql .= ", SUM(pf.amount) as totalamount, COUNT(f.rowid) as nbinvoices";
191
192$sqlfields = $sql; // $sql fields to remove for count total
193
194$sql .= ' FROM '.MAIN_DB_PREFIX.'paiementfourn AS p';
195$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement AS c ON p.fk_paiement = c.id';
196$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON p.fk_bank = b.rowid';
197$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank_account as ba ON b.fk_account = ba.rowid';
198
199$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn_facturefourn AS pf ON p.rowid = pf.fk_paiementfourn';
200$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'facture_fourn AS f ON f.rowid = pf.fk_facturefourn';
201$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe AS s ON s.rowid = f.fk_soc';
202
203$sql .= ' WHERE f.entity IN ('.getEntity('supplier_invoice').')'; // TODO We should use p.entity that does not exists yet in this table
204if ($socid > 0) {
205 $sql .= " AND EXISTS (SELECT f.fk_soc FROM ".MAIN_DB_PREFIX."facture_fourn as f, ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf";
206 $sql .= " WHERE p.rowid = pf.fk_paiementfourn AND pf.fk_facturefourn = f.rowid AND f.fk_soc = ".((int) $socid).")";
207}
208
209// Search criteria
210if ($search_ref) {
211 $sql .= natural_search('p.ref', $search_ref);
212}
213if ($search_date_start) {
214 $sql .= " AND p.datep >= '" . $db->idate($search_date_start) . "'";
215}
216if ($search_date_end) {
217 $sql .=" AND p.datep <= '" . $db->idate($search_date_end) . "'";
218}
219
220if ($search_company) {
221 $sql .= natural_search('s.nom', $search_company);
222}
223if ($search_payment_type != '') {
224 $sql .= " AND c.code = '".$db->escape($search_payment_type)."'";
225}
226if ($search_cheque_num != '') {
227 $sql .= natural_search('p.num_paiement', $search_cheque_num);
228}
229if ($search_amount) {
230 $sql .= " AND (".natural_search('p.amount', $search_amount, 1, 1);
231 $sql .= " OR ";
232 $sql .= natural_search('pf.amount', $search_amount, 1, 1);
233 $sql .= ")";
234}
235if ($search_bank_account > 0) {
236 $sql .= ' AND b.fk_account = '.((int) $search_bank_account);
237}
238if ($search_all) {
239 $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
240}
241// Search on sale representative
242if ($search_sale && $search_sale != '-1') {
243 if ($search_sale == -2) {
244 $sql .= " AND NOT EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc WHERE sc.fk_soc = f.fk_soc)";
245 } elseif ($search_sale > 0) {
246 $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).")";
247 }
248}
249
250// Add where from extra fields
251include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
252
253$sql .= ' GROUP BY p.rowid, p.ref, p.datep, p.fk_bank, p.statut, p.num_paiement, p.amount, s.rowid, s.nom, s.email, c.code, c.libelle,';
254$sql .= ' ba.rowid, ba.ref, ba.label, ba.number, ba.account_number, ba.iban_prefix, ba.bic, ba.currency_code, ba.fk_accountancy_journal';
255
256// Count total nb of records
257$nbtotalofrecords = '';
258if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
259 /* The fast and low memory method to get and count full list converts the sql into a sql count */
260 $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(DISTINCT p.rowid) as nbtotalofrecords', $sql);
261 $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount);
262 $resql = $db->query($sqlforcount);
263 if ($resql) {
264 $objforcount = $db->fetch_object($resql);
265 $nbtotalofrecords = $objforcount->nbtotalofrecords;
266 } else {
267 dol_print_error($db);
268 }
269
270 if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
271 $page = 0;
272 $offset = 0;
273 }
274 $db->free($resql);
275}
276
277// Complete request and execute it with limit
278$sql .= $db->order($sortfield, $sortorder);
279if ($limit) {
280 $sql .= $db->plimit($limit + 1, $offset);
281}
282//print $sql;
283
284$resql = $db->query($sql);
285if (!$resql) {
286 dol_print_error($db);
287 llxFooter();
288 $db->close();
289 exit;
290}
291
292$num = $db->num_rows($resql);
293$i = 0;
294
295$param = '';
296if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
297 $param .= '&contextpage='.urlencode($contextpage);
298}
299if ($limit > 0 && $limit != $conf->liste_limit) {
300 $param .= '&limit='.((int) $limit);
301}
302if ($optioncss != '') {
303 $param .= '&optioncss='.urlencode($optioncss);
304}
305
306if ($search_ref) {
307 $param .= '&search_ref='.urlencode($search_ref);
308}
309if ($search_date_startday) {
310 $param .= '&search_date_startday='.urlencode($search_date_startday);
311}
312if ($search_date_startmonth) {
313 $param .= '&search_date_startmonth='.urlencode($search_date_startmonth);
314}
315if ($search_date_startyear) {
316 $param .= '&search_date_startyear='.urlencode($search_date_startyear);
317}
318if ($search_date_endday) {
319 $param .= '&search_date_endday='.urlencode($search_date_endday);
320}
321if ($search_date_endmonth) {
322 $param .= '&search_date_endmonth='.urlencode($search_date_endmonth);
323}
324if ($search_date_endyear) {
325 $param .= '&search_date_endyear='.urlencode($search_date_endyear);
326}
327if ($search_company) {
328 $param .= '&search_company='.urlencode($search_company);
329}
330if ($search_payment_type) {
331 $param .= '&search_company='.urlencode($search_payment_type);
332}
333if ($search_cheque_num) {
334 $param .= '&search_cheque_num='.urlencode($search_cheque_num);
335}
336if ($search_amount) {
337 $param .= '&search_amount='.urlencode($search_amount);
338}
339
340// Add $param from extra fields
341include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
342
343print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
344if ($optioncss != '') {
345 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
346}
347print '<input type="hidden" name="token" value="'.newToken().'">';
348print '<input type="hidden" name="action" value="list">';
349print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
350print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
351print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
352print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
353
354print_barre_liste($langs->trans('SupplierPayments'), $page, $_SERVER['PHP_SELF'], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'supplier_invoice', 0, '', '', $limit, 0, 0, 1);
355
356if ($search_all) {
357 foreach ($fieldstosearchall as $key => $val) {
358 $fieldstosearchall[$key] = $langs->trans($val);
359 }
360 print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'</div>';
361}
362
363$moreforfilter = '';
364
365$parameters = array();
366$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook
367if (empty($reshook)) {
368 $moreforfilter .= $hookmanager->resPrint;
369} else {
370 $moreforfilter = $hookmanager->resPrint;
371}
372
373if ($moreforfilter) {
374 print '<div class="liste_titre liste_titre_bydiv centpercent">';
375 print $moreforfilter;
376 print '</div>';
377}
378
379$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
380$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN', '')); // This also change content of $arrayfields
381if (!empty($massactionbutton)) {
382 $selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
383}
384
385print '<div class="div-table-responsive">';
386print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : '').'">';
387
388// Fields title search
389// --------------------------------------------------------------------
390print '<tr class="liste_titre_filter">';
391
392// Action column
393if (getDolGlobalInt('MAIN_CHECKBOX_LEFT_COLUMN')) {
394 print '<td class="liste_titre center maxwidthsearch">';
395 $searchpicto = $form->showFilterButtons('left');
396 print $searchpicto;
397 print '</td>';
398}
399
400// #
401if (getDolGlobalString('MAIN_VIEW_LINE_NUMBER_IN_LIST')) {
402 print '<td class="liste_titre">';
403 print '</td>';
404}
405
406// Filter: Ref
407if (!empty($arrayfields['p.ref']['checked'])) {
408 print '<td class="liste_titre left">';
409 print '<input class="flat" type="text" size="4" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
410 print '</td>';
411}
412
413// Filter: Date
414if (!empty($arrayfields['p.datep']['checked'])) {
415 print '<td class="liste_titre center">';
416 print '<div class="nowrapfordate">';
417 print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
418 print '</div>';
419 print '<div class="nowrapfordate">';
420 print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
421 print '</div>';
422 print '</td>';
423}
424
425// Filter: Thirdparty
426if (!empty($arrayfields['s.nom']['checked'])) {
427 print '<td class="liste_titre">';
428 print '<input class="flat" type="text" size="6" name="search_company" value="'.dol_escape_htmltag($search_company).'">';
429 print '</td>';
430}
431
432// Filter: Payment type
433if (!empty($arrayfields['c.libelle']['checked'])) {
434 print '<td class="liste_titre">';
435 $form->select_types_paiements($search_payment_type, 'search_payment_type', '', 2, 1, 1);
436 print '</td>';
437}
438
439// Filter: Cheque number (fund transfer)
440if (!empty($arrayfields['p.num_paiement']['checked'])) {
441 print '<td class="liste_titre">';
442 print '<input class="flat" type="text" size="4" name="search_cheque_num" value="'.dol_escape_htmltag($search_cheque_num).'">';
443 print '</td>';
444}
445
446// Filter: Bank account
447if (!empty($arrayfields['ba.label']['checked'])) {
448 print '<td class="liste_titre">';
449 $form->select_comptes($search_bank_account, 'search_bank_account', 0, '', 1);
450 print '</td>';
451}
452
453// Filter: Amount
454if (!empty($arrayfields['p.amount']['checked'])) {
455 print '<td class="liste_titre right">';
456 print '<input class="flat" type="text" size="4" name="search_amount" value="'.dol_escape_htmltag($search_amount).'">';
457 print '</td>';
458}
459
460// Fields from hook
461$parameters = array('arrayfields'=>$arrayfields);
462$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
463print $hookmanager->resPrint;
464
465// Action column
466if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
467 print '<td class="liste_titre center maxwidthsearch">';
468 $searchpicto = $form->showFilterButtons();
469 print $searchpicto;
470 print '</td>';
471}
472
473print '</tr>'."\n";
474
475$totalarray = array();
476$totalarray['nbfield'] = 0;
477
478// Fields title label
479// --------------------------------------------------------------------
480print '<tr class="liste_titre">';
481// Action column
482if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
483 print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
484 $totalarray['nbfield']++;
485}
486if (getDolGlobalString('MAIN_VIEW_LINE_NUMBER_IN_LIST')) {
487 print_liste_field_titre('#', $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder);
488 $totalarray['nbfield']++;
489}
490if (!empty($arrayfields['p.ref']['checked'])) {
491 print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], 'p.rowid', '', $param, '', $sortfield, $sortorder);
492 $totalarray['nbfield']++;
493}
494if (!empty($arrayfields['p.datep']['checked'])) {
495 print_liste_field_titre($arrayfields['p.datep']['label'], $_SERVER["PHP_SELF"], 'p.datep', '', $param, '', $sortfield, $sortorder, 'center ');
496 $totalarray['nbfield']++;
497}
498if (!empty($arrayfields['s.nom']['checked'])) {
499 print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], 's.nom', '', $param, '', $sortfield, $sortorder);
500 $totalarray['nbfield']++;
501}
502if (!empty($arrayfields['c.libelle']['checked'])) {
503 print_liste_field_titre($arrayfields['c.libelle']['label'], $_SERVER["PHP_SELF"], 'c.libelle', '', $param, '', $sortfield, $sortorder);
504 $totalarray['nbfield']++;
505}
506if (!empty($arrayfields['p.num_paiement']['checked'])) {
507 print_liste_field_titre($arrayfields['p.num_paiement']['label'], $_SERVER["PHP_SELF"], "p.num_paiement", '', $param, '', $sortfield, $sortorder, '', $arrayfields['p.num_paiement']['tooltip']);
508 $totalarray['nbfield']++;
509}
510if (!empty($arrayfields['ba.label']['checked'])) {
511 print_liste_field_titre($arrayfields['ba.label']['label'], $_SERVER["PHP_SELF"], 'ba.label', '', $param, '', $sortfield, $sortorder);
512 $totalarray['nbfield']++;
513}
514if (!empty($arrayfields['p.amount']['checked'])) {
515 print_liste_field_titre($arrayfields['p.amount']['label'], $_SERVER["PHP_SELF"], 'p.amount', '', $param, '', $sortfield, $sortorder, 'right ');
516 $totalarray['nbfield']++;
517}
518
519// Hook fields
520$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
521$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
522print $hookmanager->resPrint;
523
524// Action column
525if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
526 print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
527 $totalarray['nbfield']++;
528}
529print '</tr>';
530
531print '</tr>'."\n";
532
533// Detect if we need a fetch on each output line
534$needToFetchEachLine = 0;
535if (isset($extrafields->attributes[$object->table_element]['computed']) && is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) {
536 foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) {
537 if (!is_null($val) && preg_match('/\$object/', $val)) {
538 $needToFetchEachLine++; // There is at least one compute field that use $object
539 }
540 }
541}
542
543
544// Loop on record
545// --------------------------------------------------------------------
546$i = 0;
547$savnbfield = $totalarray['nbfield'];
548$totalarray = array();
549$totalarray['nbfield'] = 0;
550$imaxinloop = ($limit ? min($num, $limit) : $num);
551while ($i < $imaxinloop) {
552 $objp = $db->fetch_object($resql);
553 if (empty($objp)) {
554 break; // Should not happen
555 }
556
557 $paymentfournstatic->id = $objp->rowid;
558 $paymentfournstatic->ref = $objp->ref;
559 $paymentfournstatic->datepaye = $db->jdate($objp->datep);
560 $paymentfournstatic->amount = $objp->amount;
561
562 $companystatic->id = $objp->socid;
563 $companystatic->name = $objp->name;
564 $companystatic->email = $objp->email;
565
566 if ($mode == 'kanban') {
567 if ($i == 0) {
568 print '<tr class="trkanban"><td colspan="'.$savnbfield.'">';
569 print '<div class="box-flex-container kanban">';
570 }
571 // Output Kanban
572 $selected = -1;
573 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
574 $selected = 0;
575 if (in_array($object->id, $arrayofselected)) {
576 $selected = 1;
577 }
578 }
579 //print $object->getKanbanView('', array('thirdparty'=>$object->thirdparty, 'selected' => $selected));
580 print $object->getKanbanView('', array('selected' => $selected));
581 if ($i == ($imaxinloop - 1)) {
582 print '</div>';
583 print '</td></tr>';
584 }
585 } else {
586 // Show line of result
587 $j = 0;
588 print '<tr data-rowid="'.$object->id.'" class="oddeven">';
589
590 // Action column
591 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
592 print '<td class="nowrap center">';
593 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
594 $selected = 0;
595 if (in_array($object->id, $arrayofselected)) {
596 $selected = 1;
597 }
598 print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
599 }
600 print '</td>';
601 if (!$i) {
602 $totalarray['nbfield']++;
603 }
604 }
605
606 // No
607 if (getDolGlobalString('MAIN_VIEW_LINE_NUMBER_IN_LIST')) {
608 print '<td class="nowraponall">'.(($offset * $limit) + $i).'</td>';
609 if (!$i) {
610 $totalarray['nbfield']++;
611 }
612 }
613
614 // Ref
615 if (!empty($arrayfields['p.ref']['checked'])) {
616 print '<td class="nowraponall">'.$paymentfournstatic->getNomUrl(1).'</td>';
617 if (!$i) {
618 $totalarray['nbfield']++;
619 }
620 }
621
622 // Date
623 if (!empty($arrayfields['p.datep']['checked'])) {
624 $dateformatforpayment = 'dayhour';
625 print '<td class="nowraponall center">'.dol_print_date($db->jdate($objp->datep), $dateformatforpayment).'</td>';
626 if (!$i) {
627 $totalarray['nbfield']++;
628 }
629 }
630
631 // Thirdparty
632 if (!empty($arrayfields['s.nom']['checked'])) {
633 print '<td class="tdoverflowmax125">';
634 if ($objp->socid > 0) {
635 print $companystatic->getNomUrl(1, '', 24);
636 }
637 print '</td>';
638 if (!$i) {
639 $totalarray['nbfield']++;
640 }
641 }
642
643 // Pyament type
644 if (!empty($arrayfields['c.libelle']['checked'])) {
645 $payment_type = $langs->trans("PaymentType".$objp->paiement_type) != "PaymentType".$objp->paiement_type ? $langs->trans("PaymentType".$objp->paiement_type) : $objp->paiement_libelle;
646 print '<td>'.$payment_type.' '.dol_trunc($objp->num_payment, 32).'</td>';
647 if (!$i) {
648 $totalarray['nbfield']++;
649 }
650 }
651
652 // Cheque number (fund transfer)
653 if (!empty($arrayfields['p.num_paiement']['checked'])) {
654 print '<td>'.$objp->num_payment.'</td>';
655 if (!$i) {
656 $totalarray['nbfield']++;
657 }
658 }
659
660 // Bank account
661 if (!empty($arrayfields['ba.label']['checked'])) {
662 print '<td class="tdoverflowmax125">';
663 if ($objp->bid) {
664 $accountstatic->id = $objp->bid;
665 $accountstatic->ref = $objp->bref;
666 $accountstatic->label = $objp->blabel;
667 $accountstatic->number = $objp->number;
668 $accountstatic->iban = $objp->iban_prefix;
669 $accountstatic->bic = $objp->bic;
670 $accountstatic->currency_code = $objp->currency_code;
671 $accountstatic->account_number = $objp->account_number;
672
673 $accountingjournal = new AccountingJournal($db);
674 $accountingjournal->fetch($objp->accountancy_journal);
675 $accountstatic->accountancy_journal = $accountingjournal->code;
676
677 print $accountstatic->getNomUrl(1);
678 }
679 print '</td>';
680 if (!$i) {
681 $totalarray['nbfield']++;
682 }
683 }
684
685 // Amount
686 if (!empty($arrayfields['p.amount']['checked'])) {
687 print '<td class="right">';
688 if ($objp->nbinvoices > 1 || ($objp->totalamount && $objp->amount != $objp->totalamount)) {
689 print $form->textwithpicto('', $langs->trans("PaymentMadeForSeveralInvoices"));
690 }
691 print '<span class="amount">'.price($objp->amount).'</span>';
692 print '</td>';
693 if (!$i) {
694 $totalarray['nbfield']++;
695 $totalarray['pos'][$totalarray['nbfield']] = 'amount';
696 }
697 if (empty($totalarray['val']['amount'])) {
698 $totalarray['val']['amount'] = $objp->amount;
699 } else {
700 $totalarray['val']['amount'] += $objp->amount;
701 }
702 }
703
704 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
705 print '<td class="nowrap center">';
706 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
707 $selected = 0;
708 if (in_array($object->id, $arrayofselected)) {
709 $selected = 1;
710 }
711 print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
712 }
713 print '</td>';
714 if (!$i) {
715 $totalarray['nbfield']++;
716 }
717 }
718
719 print '</tr>'."\n";
720 }
721 $i++;
722}
723
724// Show total line
725include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
726
727// If no record found
728if ($num == 0) {
729 $colspan = 1;
730 foreach ($arrayfields as $key => $val) {
731 if (!empty($val['checked'])) {
732 $colspan++;
733 }
734 }
735 print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
736}
737
738$db->free($resql);
739
740$parameters = array('arrayfields' => $arrayfields, 'sql' => $sql);
741$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
742print $hookmanager->resPrint;
743
744print '</table>'."\n";
745print '</div>'."\n";
746
747print '</form>'."\n";
748
749// End of page
750llxFooter();
751$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 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 for supplier 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.
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip='', $forcenowrapcolumntitle=0)
Get 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.
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.