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