dolibarr  18.0.0
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 (!getDolGlobalInt('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='.((int) $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 $totalarray['nbfield'] = 0;
517 while ($i < min($num, $limit)) {
518  $objp = $db->fetch_object($resql);
519 
520  $object->id = $objp->rowid;
521  $object->ref = ($objp->ref ? $objp->ref : $objp->rowid);
522 
523  $companystatic->id = $objp->socid;
524  $companystatic->name = $objp->name;
525  $companystatic->email = $objp->email;
526 
527  print '<tr class="oddeven">';
528 
529  // No
530  if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) {
531  print '<td>'.(($offset * $limit) + $i).'</td>';
532  if (!$i) {
533  $totalarray['nbfield']++;
534  }
535  }
536 
537  // Ref
538  if (!empty($arrayfields['p.ref']['checked'])) {
539  print '<td>'.$object->getNomUrl(1).'</td>';
540  if (!$i) {
541  $totalarray['nbfield']++;
542  }
543  }
544 
545  // Date
546  if (!empty($arrayfields['p.datep']['checked'])) {
547  $dateformatforpayment = 'dayhour';
548  print '<td class="center">'.dol_print_date($db->jdate($objp->datep), $dateformatforpayment, 'tzuser').'</td>';
549  if (!$i) {
550  $totalarray['nbfield']++;
551  }
552  }
553 
554  // Thirdparty
555  if (!empty($arrayfields['s.nom']['checked'])) {
556  print '<td>';
557  if ($objp->socid > 0) {
558  print $companystatic->getNomUrl(1, '', 24);
559  }
560  print '</td>';
561  if (!$i) {
562  $totalarray['nbfield']++;
563  }
564  }
565 
566  // Payment type
567  if (!empty($arrayfields['c.libelle']['checked'])) {
568  print '<td>'.$langs->trans("PaymentTypeShort".$objp->paiement_code).'</td>';
569  if (!$i) {
570  $totalarray['nbfield']++;
571  }
572  }
573 
574  // Filter: Cheque number (fund transfer)
575  if (!empty($arrayfields['p.num_paiement']['checked'])) {
576  print '<td>'.$objp->num_paiement.'</td>';
577  if (!$i) {
578  $totalarray['nbfield']++;
579  }
580  }
581 
582  // Bank transaction
583  if (!empty($arrayfields['transaction']['checked'])) {
584  print '<td>';
585  if ($objp->fk_bank > 0) {
586  $bankline->fetch($objp->fk_bank);
587  print $bankline->getNomUrl(1, 0);
588  }
589  print '</td>';
590  if (!$i) {
591  $totalarray['nbfield']++;
592  }
593  }
594 
595  // Bank account
596  if (!empty($arrayfields['ba.label']['checked'])) {
597  print '<td>';
598  if ($objp->bid > 0) {
599  $accountstatic->id = $objp->bid;
600  $accountstatic->ref = $objp->bref;
601  $accountstatic->label = $objp->blabel;
602  $accountstatic->number = $objp->number;
603  $accountstatic->account_number = $objp->account_number;
604 
605  $accountingjournal = new AccountingJournal($db);
606  $accountingjournal->fetch($objp->accountancy_journal);
607  $accountstatic->accountancy_journal = $accountingjournal->code;
608 
609  print $accountstatic->getNomUrl(1);
610  }
611  print '</td>';
612  if (!$i) {
613  $totalarray['nbfield']++;
614  }
615  }
616 
617  // Amount
618  if (!empty($arrayfields['p.amount']['checked'])) {
619  print '<td class="right"><span class="amount">'.price($objp->amount).'</span></td>';
620  if (!$i) {
621  $totalarray['nbfield']++;
622  }
623  $totalarray['pos'][$checkedCount] = 'amount';
624  if (empty($totalarray['val']['amount'])) {
625  $totalarray['val']['amount'] = $objp->amount;
626  } else {
627  $totalarray['val']['amount'] += $objp->amount;
628  }
629  }
630 
631  // Status
632  if (!empty($arrayfields['p.statut']['checked'])) {
633  print '<td class="right">';
634  if ($objp->statut == 0) {
635  print '<a href="card.php?id='.$objp->rowid.'&amp;action=valide">';
636  }
637  print $object->LibStatut($objp->statut, 5);
638  if ($objp->statut == 0) {
639  print '</a>';
640  }
641  print '</td>';
642  if (!$i) {
643  $totalarray['nbfield']++;
644  }
645  }
646 
647  // Buttons
648  print '<td></td>';
649  if (!$i) {
650  $totalarray['nbfield']++;
651  }
652 
653  print '</tr>';
654 
655  $i++;
656 }
657 
658 // Show total line
659 include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
660 
661 // If no record found
662 if ($num == 0) {
663  $colspan = 1;
664  foreach ($arrayfields as $key => $val) {
665  if (!empty($val['checked'])) {
666  $colspan++;
667  }
668  }
669  print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>';
670 }
671 
672 print "</table>";
673 print "</div>";
674 print "</form>";
675 
676 // End of page
677 llxFooter();
678 $db->close();
Societe
Class to manage third parties objects (customers, suppliers, prospects...)
Definition: societe.class.php:51
llxFooter
llxFooter()
Empty footer.
Definition: wrapper.php:70
GETPOST
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Definition: functions.lib.php:609
dol_print_error
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
Definition: functions.lib.php:5107
dol_sort_array
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...
Definition: functions.lib.php:8922
$form
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:143
FormOther
Classe permettant la generation de composants html autre Only common components are here.
Definition: html.formother.class.php:39
llxHeader
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
AccountingJournal
Class to manage accounting accounts.
Definition: accountingjournal.class.php:27
print_barre_liste
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.
Definition: functions.lib.php:5530
setEventMessages
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
Definition: functions.lib.php:8673
$sql
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
restrictedArea
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.
Definition: security.lib.php:353
isModEnabled
isModEnabled($module)
Is Dolibarr module enabled.
Definition: functions.lib.php:207
Paiement
Class to manage payments of customer invoices.
Definition: paiement.class.php:43
GETPOSTISSET
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
Definition: functions.lib.php:509
print_liste_field_titre
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
Definition: functions.lib.php:5295
natural_search
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...
Definition: functions.lib.php:10024
Form
Class to manage generation of HTML components Only common components must be here.
Definition: html.form.class.php:53
AccountLine
Class to manage bank transaction lines.
Definition: account.class.php:1880
dol_mktime
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...
Definition: functions.lib.php:2968
getDolGlobalInt
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
Definition: functions.lib.php:156
Account
Class to manage bank accounts.
Definition: account.class.php:40