dolibarr  18.0.6
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-2021 Alexandre Spangaro <aspangaro@open-dsi.fr>
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
34 require '../../main.inc.php';
35 require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
36 require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
37 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
38 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
39 require_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 
50 $facid = GETPOST('facid', 'int');
51 $socid = GETPOST('socid', 'int');
52 $userid = GETPOST('userid', 'int');
53 
54 // Security check
55 if ($user->socid) $socid = $user->socid;
56 $result = restrictedArea($user, 'facture', $facid, '');
57 
58 $search_ref = GETPOST("search_ref", "alpha");
59 $search_date_startday = GETPOST('search_date_startday', 'int');
60 $search_date_startmonth = GETPOST('search_date_startmonth', 'int');
61 $search_date_startyear = GETPOST('search_date_startyear', 'int');
62 $search_date_endday = GETPOST('search_date_endday', 'int');
63 $search_date_endmonth = GETPOST('search_date_endmonth', 'int');
64 $search_date_endyear = GETPOST('search_date_endyear', 'int');
65 $search_date_start = dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear); // Use tzserver
66 $search_date_end = dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear);
67 $search_company = GETPOST("search_company", 'alpha');
68 $search_paymenttype = GETPOST("search_paymenttype");
69 $search_account = GETPOST("search_account", "int");
70 $search_payment_num = GETPOST('search_payment_num', 'alpha');
71 $search_amount = GETPOST("search_amount", 'alpha'); // alpha because we must be able to search on "< x"
72 $search_status = GETPOST('search_status', 'intcomma');
73 $search_sale = GETPOST('search_sale', 'int');
74 
75 $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
76 $sortfield = GETPOST('sortfield', 'aZ09comma');
77 $sortorder = GETPOST('sortorder', 'aZ09comma');
78 $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
79 
80 if (empty($page) || $page == -1) {
81  $page = 0; // If $page is not defined, or '' or -1
82 }
83 $offset = $limit * $page;
84 $pageprev = $page - 1;
85 $pagenext = $page + 1;
86 
87 if (!$sortorder) {
88  $sortorder = "DESC";
89 }
90 if (!$sortfield) {
91  $sortfield = "p.ref";
92 }
93 
94 $search_all = trim(GETPOSTISSET("search_all") ? GETPOST("search_all", 'alpha') : GETPOST('sall'));
95 
96 // List of fields to search into when doing a "search in all"
97 $fieldstosearchall = array(
98  'p.ref'=>"RefPayment",
99  's.nom'=>"ThirdParty",
100  'p.num_paiement'=>"Numero",
101  'p.amount'=>"Amount",
102 );
103 
104 $arrayfields = array(
105  'p.ref' => array('label'=>"RefPayment", 'checked'=>1, 'position'=>10),
106  'p.datep' => array('label'=>"Date", 'checked'=>1, 'position'=>20),
107  's.nom' => array('label'=>"ThirdParty", 'checked'=>1, 'position'=>30),
108  'c.libelle' => array('label'=>"Type", 'checked'=>1, 'position'=>40),
109  'transaction' => array('label'=>"BankTransactionLine", 'checked'=>1, 'position'=>50, 'enabled'=>(isModEnabled("banque"))),
110  'ba.label' => array('label'=>"Account", 'checked'=>1, 'position'=>60, 'enabled'=>(isModEnabled("banque"))),
111  'p.num_paiement' => array('label'=>"Numero", 'checked'=>1, 'position'=>70, 'tooltip'=>"ChequeOrTransferNumber"),
112  'p.amount' => array('label'=>"Amount", 'checked'=>1, 'position'=>80),
113  'p.statut' => array('label'=>"Status", 'checked'=>1, 'position'=>90, 'enabled'=>(!empty($conf->global->BILL_ADD_PAYMENT_VALIDATION))),
114 );
115 $arrayfields = dol_sort_array($arrayfields, 'position');
116 
117 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
118 $hookmanager->initHooks(array('paymentlist'));
119 $object = new Paiement($db);
120 
121 if (!$user->hasRight('societe', 'client', 'voir')) {
122  $search_sale = $user->id;
123 }
124 
125 // Security check
126 if ($user->socid) {
127  $socid = $user->socid;
128 }
129 $result = restrictedArea($user, 'facture', $facid, '');
130 
131 
132 /*
133  * Actions
134  */
135 
136 $parameters = array('socid'=>$socid);
137 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
138 if ($reshook < 0) {
139  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
140 }
141 
142 
143 if (empty($reshook)) {
144  include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
145 
146  // All tests are required to be compatible with all browsers
147  if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
148  $search_ref = '';
149  $search_date_startday = '';
150  $search_date_startmonth = '';
151  $search_date_startyear = '';
152  $search_date_endday = '';
153  $search_date_endmonth = '';
154  $search_date_endyear = '';
155  $search_date_start = '';
156  $search_date_end = '';
157  $search_account = '';
158  $search_amount = '';
159  $search_paymenttype = '';
160  $search_payment_num = '';
161  $search_company = '';
162  $search_status = '';
163  $option = '';
164  $toselect = array();
165  $search_array_options = array();
166  }
167 }
168 
169 /*
170  * View
171  */
172 
173 $form = new Form($db);
174 $formother = new FormOther($db);
175 $accountstatic = new Account($db);
176 $companystatic = new Societe($db);
177 $bankline = new AccountLine($db);
178 
179 llxHeader('', $langs->trans('ListPayment'));
180 
181 if (GETPOST("orphelins", "alpha")) {
182  // Payments not linked to an invoice. Should not happend. For debug only.
183  $sql = "SELECT p.rowid, p.ref, p.datep, p.amount, p.statut, p.num_paiement";
184  $sql .= ", c.code as paiement_code";
185 
186  $sqlfields = $sql; // $sql fields to remove for count total
187 
188  // Add fields from hooks
189  $parameters = array();
190  $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook
191  $sql .= $hookmanager->resPrint;
192  $sql .= " FROM ".MAIN_DB_PREFIX."paiement as p LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_paiement = c.id";
193  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON p.rowid = pf.fk_paiement";
194  $sql .= " WHERE p.entity IN (".getEntity('invoice').")";
195  $sql .= " AND pf.fk_facture IS NULL";
196 
197  // Add where from hooks
198  $parameters = array();
199  $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook
200  $sql .= $hookmanager->resPrint;
201 } else {
202  $sql = "SELECT p.rowid, p.ref, p.datep, p.fk_bank, p.statut, p.num_paiement, p.amount";
203  $sql .= ", c.code as paiement_code";
204  $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";
205  $sql .= ", s.rowid as socid, s.nom as name, s.email";
206  // 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)
207  // so SUM(pf.amount) should be equal to p.amount but if we filter on $socid, it may differ
208  $sql .= ", SUM(pf.amount) as totalamount, COUNT(f.rowid) as nbinvoices";
209 
210  // Add fields from hooks
211  $parameters = array();
212  $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook
213  $sql .= $hookmanager->resPrint;
214 
215  $sqlfields = $sql; // $sql fields to remove for count total
216 
217  $sql .= " FROM ".MAIN_DB_PREFIX."paiement as p";
218  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_paiement = c.id";
219  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON p.fk_bank = b.rowid";
220  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid";
221 
222  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON p.rowid = pf.fk_paiement";
223  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture as f ON pf.fk_facture = f.rowid";
224  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON f.fk_soc = s.rowid";
225 
226  $sql .= " WHERE p.entity IN (".getEntity('invoice').")";
227  if ($socid > 0) {
228  $sql .= " AND EXISTS (SELECT f.fk_soc FROM ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."paiement_facture as pf";
229  $sql .= " WHERE p.rowid = pf.fk_paiement AND pf.fk_facture = f.rowid AND f.fk_soc = ".((int) $socid).")";
230  }
231  if ($userid) {
232  if ($userid == -1) {
233  $sql .= " AND p.fk_user_creat IS NULL";
234  } else {
235  $sql .= " AND p.fk_user_creat = ".((int) $userid);
236  }
237  }
238 
239  // Search criteria
240  if ($search_ref) {
241  $sql .= natural_search('p.ref', $search_ref);
242  }
243  if ($search_date_start) {
244  $sql .= " AND p.datep >= '" . $db->idate($search_date_start) . "'";
245  }
246  if ($search_date_end) {
247  $sql .= " AND p.datep <= '" . $db->idate($search_date_end) . "'";
248  }
249  if ($search_account > 0) {
250  $sql .= " AND b.fk_account=".((int) $search_account);
251  }
252  if ($search_paymenttype != '') {
253  $sql .= " AND c.code='".$db->escape($search_paymenttype)."'";
254  }
255  if ($search_payment_num != '') {
256  $sql .= natural_search('p.num_paiement', $search_payment_num);
257  }
258  if ($search_amount) {
259  $sql .= " AND (".natural_search('p.amount', $search_amount, 1, 1);
260  $sql .= " OR ";
261  $sql .= natural_search('pf.amount', $search_amount, 1, 1);
262  $sql .= ")";
263  }
264  if ($search_company) {
265  $sql .= natural_search('s.nom', $search_company);
266  }
267  // Search on sale representative
268  if ($search_sale && $search_sale != '-1') {
269  if ($search_sale == -2) {
270  $sql .= " AND NOT EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc WHERE sc.fk_soc = f.fk_soc)";
271  } elseif ($search_sale > 0) {
272  $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).")";
273  }
274  }
275 
276  if ($search_all) {
277  $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
278  }
279 
280  // Add where from hooks
281  $parameters = array();
282  $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook
283  $sql .= $hookmanager->resPrint;
284 
285  $sql .= " GROUP BY p.rowid, p.ref, p.datep, p.fk_bank, p.statut, p.num_paiement, p.amount";
286  $sql .= ", c.code";
287  $sql .= ", ba.rowid, ba.ref, ba.label, ba.number, ba.account_number, ba.fk_accountancy_journal";
288  $sql .= ", s.rowid, s.nom, s.email";
289 }
290 
291 // Count total nb of records
292 $nbtotalofrecords = '';
293 if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
294  /* The fast and low memory method to get and count full list converts the sql into a sql count */
295  $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(DISTINCT p.rowid) as nbtotalofrecords', $sql);
296  $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount);
297  $resql = $db->query($sqlforcount);
298  if ($resql) {
299  $objforcount = $db->fetch_object($resql);
300  $nbtotalofrecords = $objforcount->nbtotalofrecords;
301  } else {
302  dol_print_error($db);
303  }
304 
305  if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
306  $page = 0;
307  $offset = 0;
308  }
309  $db->free($resql);
310 }
311 
312 // Complete request and execute it with limit
313 $sql .= $db->order($sortfield, $sortorder);
314 if ($limit) {
315  $sql .= $db->plimit($limit + 1, $offset);
316 }
317 //print $sql;
318 
319 $resql = $db->query($sql);
320 if (!$resql) {
321  dol_print_error($db);
322  llxFooter();
323  $db->close();
324  exit;
325 }
326 
327 $num = $db->num_rows($resql);
328 
329 $param = '';
330 if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
331  $param .= '&contextpage='.urlencode($contextpage);
332 }
333 if ($limit > 0 && $limit != $conf->liste_limit) {
334  $param .= '&limit='.((int) $limit);
335 }
336 
337 if (GETPOST("orphelins")) {
338  $param .= '&orphelins=1';
339 }
340 if ($search_ref) {
341  $param .= '&search_ref='.urlencode($search_ref);
342 }
343 if ($search_date_startday) {
344  $param .= '&search_date_startday='.urlencode($search_date_startday);
345 }
346 if ($search_date_startmonth) {
347  $param .= '&search_date_startmonth='.urlencode($search_date_startmonth);
348 }
349 if ($search_date_startyear) {
350  $param .= '&search_date_startyear='.urlencode($search_date_startyear);
351 }
352 if ($search_date_endday) {
353  $param .= '&search_date_endday='.urlencode($search_date_endday);
354 }
355 if ($search_date_endmonth) {
356  $param .= '&search_date_endmonth='.urlencode($search_date_endmonth);
357 }
358 if ($search_date_endyear) {
359  $param .= '&search_date_endyear='.urlencode($search_date_endyear);
360 }
361 if ($search_company) {
362  $param .= '&search_company='.urlencode($search_company);
363 }
364 if ($search_amount != '') {
365  $param .= '&search_amount='.urlencode($search_amount);
366 }
367 if ($search_paymenttype) {
368  $param .= '&search_paymenttype='.urlencode($search_paymenttype);
369 }
370 if ($search_account) {
371  $param .= '&search_account='.urlencode($search_account);
372 }
373 if ($search_payment_num) {
374  $param .= '&search_payment_num='.urlencode($search_payment_num);
375 }
376 if ($optioncss != '') {
377  $param .= '&optioncss='.urlencode($optioncss);
378 }
379 
380 print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
381 if ($optioncss != '') {
382  print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
383 }
384 print '<input type="hidden" name="token" value="'.newToken().'">';
385 print '<input type="hidden" name="action" value="list">';
386 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
387 print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
388 print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
389 print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
390 
391 print_barre_liste($langs->trans("ReceivedCustomersPayments"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'bill', 0, '', '', $limit, 0, 0, 1);
392 
393 if ($search_all) {
394  foreach ($fieldstosearchall as $key => $val) {
395  $fieldstosearchall[$key] = $langs->trans($val);
396  }
397  print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'</div>';
398 }
399 
400 $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
401 $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
402 $massactionbutton = '';
403 if ($massactionbutton) {
404  $selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
405 }
406 
407 $moreforfilter = '';
408 print '<div class="div-table-responsive">';
409 print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : '').'">';
410 
411 print '<tr class="liste_titre_filter">';
412 
413 // Filters: Lines (placeholder)
414 print '<tr class="liste_titre_filter">';
415 if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) {
416  print '<td class="liste_titre">';
417  print '</td>';
418 }
419 
420 // Filter: Ref
421 if (!empty($arrayfields['p.ref']['checked'])) {
422  print '<td class="liste_titre left">';
423  print '<input class="flat" type="text" size="4" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
424  print '</td>';
425 }
426 
427 // Filter: Date
428 if (!empty($arrayfields['p.datep']['checked'])) {
429  print '<td class="liste_titre center">';
430  print '<div class="nowrap">';
431  print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
432  print '</div>';
433  print '<div class="nowrap">';
434  print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
435  print '</div>';
436  print '</td>';
437 }
438 
439 // Filter: Thirdparty
440 if (!empty($arrayfields['s.nom']['checked'])) {
441  print '<td class="liste_titre">';
442  print '<input class="flat" type="text" size="6" name="search_company" value="'.dol_escape_htmltag($search_company).'">';
443  print '</td>';
444 }
445 
446 // Filter: Payment type
447 if (!empty($arrayfields['c.libelle']['checked'])) {
448  print '<td class="liste_titre">';
449  print $form->select_types_paiements($search_paymenttype, 'search_paymenttype', '', 2, 1, 1, 0, 1, 'maxwidth100', 1);
450  print '</td>';
451 }
452 
453 // Filter: Bank transaction number
454 if (!empty($arrayfields['transaction']['checked'])) {
455  print '<td class="liste_titre">';
456  print '<input class="flat" type="text" size="4" name="search_payment_num" value="'.dol_escape_htmltag($search_payment_num).'">';
457  print '</td>';
458 }
459 
460 // Filter: Cheque number (fund transfer)
461 if (!empty($arrayfields['p.num_paiement']['checked'])) {
462  print '<td class="liste_titre">';
463  print '</td>';
464 }
465 
466 // Filter: Bank account
467 if (!empty($arrayfields['ba.label']['checked'])) {
468  print '<td class="liste_titre">';
469  $form->select_comptes($search_account, 'search_account', 0, '', 1);
470  print '</td>';
471 }
472 
473 // Filter: Amount
474 if (!empty($arrayfields['p.amount']['checked'])) {
475  print '<td class="liste_titre right">';
476  print '<input class="flat" type="text" size="4" name="search_amount" value="'.dol_escape_htmltag($search_amount).'">';
477  print '</td>';
478 }
479 
480 // Filter: Status (only placeholder)
481 if (!empty($arrayfields['p.statut']['checked'])) {
482  print '<td class="liste_titre right">';
483  print '</td>';
484 }
485 
486 // Fields from hook
487 $parameters = array('arrayfields'=>$arrayfields);
488 $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
489 print $hookmanager->resPrint;
490 
491 print '<td class="liste_titre maxwidthsearch">';
492 print $form->showFilterAndCheckAddButtons(0);
493 print '</td>';
494 
495 print "</tr>";
496 
497 print '<tr class="liste_titre">';
498 if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) {
499  print_liste_field_titre('#', $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder);
500 }
501 if (!empty($arrayfields['p.ref']['checked'])) {
502  print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], "p.ref", '', $param, '', $sortfield, $sortorder);
503 }
504 if (!empty($arrayfields['p.datep']['checked'])) {
505  print_liste_field_titre($arrayfields['p.datep']['label'], $_SERVER["PHP_SELF"], "p.datep", '', $param, '', $sortfield, $sortorder, 'center ');
506 }
507 if (!empty($arrayfields['s.nom']['checked'])) {
508  print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", '', $param, '', $sortfield, $sortorder);
509 }
510 if (!empty($arrayfields['c.libelle']['checked'])) {
511  print_liste_field_titre($arrayfields['c.libelle']['label'], $_SERVER["PHP_SELF"], "c.libelle", '', $param, '', $sortfield, $sortorder);
512 }
513 if (!empty($arrayfields['p.num_paiement']['checked'])) {
514  print_liste_field_titre($arrayfields['p.num_paiement']['label'], $_SERVER["PHP_SELF"], "p.num_paiement", '', $param, '', $sortfield, $sortorder, '', $arrayfields['p.num_paiement']['tooltip']);
515 }
516 if (!empty($arrayfields['transaction']['checked'])) {
517  print_liste_field_titre($arrayfields['transaction']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder);
518 }
519 if (!empty($arrayfields['ba.label']['checked'])) {
520  print_liste_field_titre($arrayfields['ba.label']['label'], $_SERVER["PHP_SELF"], "ba.label", '', $param, '', $sortfield, $sortorder);
521 }
522 if (!empty($arrayfields['p.amount']['checked'])) {
523  print_liste_field_titre($arrayfields['p.amount']['label'], $_SERVER["PHP_SELF"], "p.amount", '', $param, 'class="right"', $sortfield, $sortorder);
524 }
525 if (!empty($arrayfields['p.statut']['checked'])) {
526  print_liste_field_titre($arrayfields['p.statut']['label'], $_SERVER["PHP_SELF"], "p.statut", '', $param, 'class="right"', $sortfield, $sortorder);
527 }
528 
529 // Hook fields
530 $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
531 $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
532 print $hookmanager->resPrint;
533 
534 print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], '', '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ');
535 print "</tr>";
536 
537 $checkedCount = 0;
538 foreach ($arrayfields as $column) {
539  if ($column['checked']) {
540  $checkedCount++;
541  }
542 }
543 
544 $i = 0;
545 $totalarray = array();
546 $totalarray['nbfield'] = 0;
547 while ($i < min($num, $limit)) {
548  $objp = $db->fetch_object($resql);
549 
550  $object->id = $objp->rowid;
551  $object->ref = ($objp->ref ? $objp->ref : $objp->rowid);
552  $object->date = $db->jdate($objp->datep);
553  $object->amount = $objp->amount;
554 
555  $companystatic->id = $objp->socid;
556  $companystatic->name = $objp->name;
557  $companystatic->email = $objp->email;
558 
559  print '<tr class="oddeven">';
560 
561  // No
562  if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) {
563  print '<td>'.(($offset * $limit) + $i).'</td>';
564  if (!$i) {
565  $totalarray['nbfield']++;
566  }
567  }
568 
569  // Ref
570  if (!empty($arrayfields['p.ref']['checked'])) {
571  print '<td>'.$object->getNomUrl(1).'</td>';
572  if (!$i) {
573  $totalarray['nbfield']++;
574  }
575  }
576 
577  // Date
578  if (!empty($arrayfields['p.datep']['checked'])) {
579  $dateformatforpayment = 'dayhour';
580  print '<td class="center">'.dol_print_date($db->jdate($objp->datep), $dateformatforpayment, 'tzuser').'</td>';
581  if (!$i) {
582  $totalarray['nbfield']++;
583  }
584  }
585 
586  // Thirdparty
587  if (!empty($arrayfields['s.nom']['checked'])) {
588  print '<td>';
589  if ($objp->socid > 0) {
590  print $companystatic->getNomUrl(1, '', 24);
591  }
592  print '</td>';
593  if (!$i) {
594  $totalarray['nbfield']++;
595  }
596  }
597 
598  // Payment type
599  if (!empty($arrayfields['c.libelle']['checked'])) {
600  print '<td>'.$langs->trans("PaymentTypeShort".$objp->paiement_code).'</td>';
601  if (!$i) {
602  $totalarray['nbfield']++;
603  }
604  }
605 
606  // Filter: Cheque number (fund transfer)
607  if (!empty($arrayfields['p.num_paiement']['checked'])) {
608  print '<td>'.$objp->num_paiement.'</td>';
609  if (!$i) {
610  $totalarray['nbfield']++;
611  }
612  }
613 
614  // Bank transaction
615  if (!empty($arrayfields['transaction']['checked'])) {
616  print '<td>';
617  if ($objp->fk_bank > 0) {
618  $bankline->fetch($objp->fk_bank);
619  print $bankline->getNomUrl(1, 0);
620  }
621  print '</td>';
622  if (!$i) {
623  $totalarray['nbfield']++;
624  }
625  }
626 
627  // Bank account
628  if (!empty($arrayfields['ba.label']['checked'])) {
629  print '<td>';
630  if ($objp->bid > 0) {
631  $accountstatic->id = $objp->bid;
632  $accountstatic->ref = $objp->bref;
633  $accountstatic->label = $objp->blabel;
634  $accountstatic->number = $objp->number;
635  $accountstatic->account_number = $objp->account_number;
636 
637  $accountingjournal = new AccountingJournal($db);
638  $accountingjournal->fetch($objp->accountancy_journal);
639  $accountstatic->accountancy_journal = $accountingjournal->code;
640 
641  print $accountstatic->getNomUrl(1);
642  }
643  print '</td>';
644  if (!$i) {
645  $totalarray['nbfield']++;
646  }
647  }
648 
649  // Amount
650  if (!empty($arrayfields['p.amount']['checked'])) {
651  print '<td class="right">';
652  if ($objp->nbinvoices > 1 || ($objp->totalamount && $objp->amount != $objp->totalamount)) {
653  print $form->textwithpicto('', $langs->trans("PaymentMadeForSeveralInvoices"));
654  }
655  print '<span class="amount">'.price($objp->amount).'</span>';
656  print '</td>';
657  if (!$i) {
658  $totalarray['nbfield']++;
659  }
660  $totalarray['pos'][$checkedCount] = 'amount';
661  if (empty($totalarray['val']['amount'])) {
662  $totalarray['val']['amount'] = $objp->amount;
663  } else {
664  $totalarray['val']['amount'] += $objp->amount;
665  }
666  }
667 
668  // Status
669  if (!empty($arrayfields['p.statut']['checked'])) {
670  print '<td class="right">';
671  if ($objp->statut == 0) {
672  print '<a href="card.php?id='.$objp->rowid.'&amp;action=valide">';
673  }
674  print $object->LibStatut($objp->statut, 5);
675  if ($objp->statut == 0) {
676  print '</a>';
677  }
678  print '</td>';
679  if (!$i) {
680  $totalarray['nbfield']++;
681  }
682  }
683 
684  // Buttons
685  print '<td></td>';
686  if (!$i) {
687  $totalarray['nbfield']++;
688  }
689 
690  print '</tr>';
691 
692  $i++;
693 }
694 
695 // Show total line
696 include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
697 
698 // If no record found
699 if ($num == 0) {
700  $colspan = 1;
701  foreach ($arrayfields as $key => $val) {
702  if (!empty($val['checked'])) {
703  $colspan++;
704  }
705  }
706  print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>';
707 }
708 
709 print "</table>";
710 print "</div>";
711 print "</form>";
712 
713 // End of page
714 llxFooter();
715 $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:56
llxFooter()
Empty footer.
Definition: wrapper.php:70
Class to manage bank accounts.
Class to manage bank transaction lines.
Class to manage accounting accounts.
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...)
if(isModEnabled('facture') && $user->hasRight('facture', 'lire')) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') && $user->hasRight('don', 'lire')) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $sql
Social contributions to pay.
Definition: index.php:746
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:143
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 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.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
isModEnabled($module)
Is Dolibarr module enabled.
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.