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