dolibarr  17.0.4
list.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2017-2022 Alexandre Spangaro <aspangaro@open-dsi.fr>
3  * Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
4  * Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
5  * Copyright (C) 2020 Tobias Sekan <tobias.sekan@startmail.com>
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <https://www.gnu.org/licenses/>.
19  */
20 
27 // Load Dolibarr environment
28 require '../../../main.inc.php';
29 require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/paymentvarious.class.php';
30 require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
31 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
32 require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php';
33 require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php';
34 require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
35 
36 // Load translation files required by the page
37 $langs->loadLangs(array("compta", "banks", "bills", "accountancy"));
38 
39 $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'directdebitcredittransferlist'; // To manage different context of search
40 
41 // Security check
42 $socid = GETPOST("socid", "int");
43 if ($user->socid) {
44  $socid = $user->socid;
45 }
46 
47 $optioncss = GETPOST('optioncss', 'alpha');
48 
49 $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
50 $search_ref = GETPOST('search_ref', 'int');
51 $search_user = GETPOST('search_user', 'alpha');
52 $search_label = GETPOST('search_label', 'alpha');
53 $search_datep_start = dol_mktime(0, 0, 0, GETPOST('search_date_startmonth', 'int'), GETPOST('search_date_startday', 'int'), GETPOST('search_date_startyear', 'int'));
54 $search_datep_end = dol_mktime(23, 59, 59, GETPOST('search_date_endmonth', 'int'), GETPOST('search_date_endday', 'int'), GETPOST('search_date_endyear', 'int'));
55 $search_datev_start = dol_mktime(0, 0, 0, GETPOST('search_date_value_startmonth', 'int'), GETPOST('search_date_value_startday', 'int'), GETPOST('search_date_value_startyear', 'int'));
56 $search_datev_end = dol_mktime(23, 59, 59, GETPOST('search_date_value_endmonth', 'int'), GETPOST('search_date_value_endday', 'int'), GETPOST('search_date_value_endyear', 'int'));
57 $search_amount_deb = GETPOST('search_amount_deb', 'alpha');
58 $search_amount_cred = GETPOST('search_amount_cred', 'alpha');
59 $search_bank_account = GETPOST('search_account', 'int');
60 $search_bank_entry = GETPOST('search_bank_entry', 'int');
61 $search_accountancy_account = GETPOST("search_accountancy_account");
62 if ($search_accountancy_account == - 1) {
63  $search_accountancy_account = '';
64 }
65 $search_accountancy_subledger = GETPOST("search_accountancy_subledger");
66 if ($search_accountancy_subledger == - 1) {
67  $search_accountancy_subledger = '';
68 }
69 if (empty($search_datep_start)) {
70  $search_datep_start = GETPOST("search_datep_start", 'int');
71 }
72 if (empty($search_datep_end)) {
73  $search_datep_end = GETPOST("search_datep_end", 'int');
74 }
75 if (empty($search_datev_start)) {
76  $search_datev_start = GETPOST("search_datev_start", 'int');
77 }
78 if (empty($search_datev_end)) {
79  $search_datev_end = GETPOST("search_datev_end", 'int');
80 }
81 $search_type_id = GETPOST('search_type_id', 'int');
82 
83 $sortfield = GETPOST('sortfield', 'aZ09comma');
84 $sortorder = GETPOST('sortorder', 'aZ09comma');
85 $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
86 if (empty($page) || $page == -1) {
87  $page = 0;
88 } // If $page is not defined, or '' or -1
89 $offset = $limit * $page;
90 $pageprev = $page - 1;
91 $pagenext = $page + 1;
92 if (!$sortfield) {
93  $sortfield = "v.datep,v.rowid";
94 }
95 if (!$sortorder) {
96  $sortorder = "DESC,DESC";
97 }
98 
99 $filtre = GETPOST("filtre", 'alpha');
100 
101 if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All test are required to be compatible with all browsers
102  $search_ref = '';
103  $search_label = '';
104  $search_datep_start = '';
105  $search_datep_end = '';
106  $search_datev_start = '';
107  $search_datev_end = '';
108  $search_amount_deb = '';
109  $search_amount_cred = '';
110  $search_bank_account = '';
111  $search_bank_entry = '';
112  $search_accountancy_account = '';
113  $search_accountancy_subledger = '';
114  $search_type_id = '';
115 }
116 
117 $search_all = GETPOSTISSET("search_all") ? trim(GETPOST("search_all", 'alpha')) : trim(GETPOST('sall'));
118 
119 /*
120 * TODO: fill array "$fields" in "/compta/bank/class/paymentvarious.class.php" and use
121 *
122 *
123 * $object = new PaymentVarious($db);
124 *
125 * $search = array();
126 * foreach ($object->fields as $key => $val)
127 * {
128 * if (GETPOST('search_'.$key, 'alpha')) $search[$key] = GETPOST('search_'.$key, 'alpha');
129 * }
130 
131 * $fieldstosearchall = array();
132 * foreach ($object->fields as $key => $val)
133 * {
134 * if ($val['searchall']) $fieldstosearchall['t.'.$key] = $val['label'];
135 * }
136 *
137 */
138 
139 // List of fields to search into when doing a "search in all"
140 $fieldstosearchall = array(
141  'v.rowid'=>"Ref",
142  'v.label'=>"Label",
143  'v.datep'=>"DatePayment",
144  'v.datev'=>"DateValue",
145  'v.amount'=>$langs->trans("Debit").", ".$langs->trans("Credit"),
146 );
147 
148 // Definition of fields for lists
149 $arrayfields = array(
150  'ref' =>array('label'=>"Ref", 'checked'=>1, 'position'=>100),
151  'label' =>array('label'=>"Label", 'checked'=>1, 'position'=>110),
152  'datep' =>array('label'=>"DatePayment", 'checked'=>1, 'position'=>120),
153  'datev' =>array('label'=>"DateValue", 'checked'=>-1, 'position'=>130),
154  'type' =>array('label'=>"PaymentMode", 'checked'=>1, 'position'=>140),
155  'project' =>array('label'=>"Project", 'checked'=>1, 'position'=>200, "enabled"=>isModEnabled('project')),
156  'bank' =>array('label'=>"BankAccount", 'checked'=>1, 'position'=>300, "enabled"=>isModEnabled("banque")),
157  'entry' =>array('label'=>"BankTransactionLine", 'checked'=>1, 'position'=>310, "enabled"=>isModEnabled("banque")),
158  'account' =>array('label'=>"AccountAccountingShort", 'checked'=>1, 'position'=>400, "enabled"=>isModEnabled('accounting')),
159  'subledger' =>array('label'=>"SubledgerAccount", 'checked'=>1, 'position'=>410, "enabled"=>isModEnabled('accounting')),
160  'debit' =>array('label'=>"Debit", 'checked'=>1, 'position'=>500),
161  'credit' =>array('label'=>"Credit", 'checked'=>1, 'position'=>510),
162 );
163 
164 $arrayfields = dol_sort_array($arrayfields, 'position');
165 
166 $object = new PaymentVarious($db);
167 
168 $result = restrictedArea($user, 'banque', '', '', '');
169 
170 
171 /*
172  * Actions
173  */
174 
175 $parameters = array();
176 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
177 if ($reshook < 0) {
178  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
179 }
180 
181 if (empty($reshook)) {
182  // Selection of new fields
183  include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
184 }
185 
186 /*
187  * View
188  */
189 
190 $form = new Form($db);
191 if ($arrayfields['account']['checked'] || $arrayfields['subledger']['checked']) {
192  $formaccounting = new FormAccounting($db);
193 }
194 if ($arrayfields['bank']['checked'] && isModEnabled('accounting')) {
195  $accountingjournal = new AccountingJournal($db);
196 }
197 if ($arrayfields['ref']['checked']) {
198  $variousstatic = new PaymentVarious($db);
199 }
200 if ($arrayfields['bank']['checked']) {
201  $accountstatic = new Account($db);
202 }
203 if ($arrayfields['project']['checked']) {
204  $proj = new Project($db);
205 }
206 if ($arrayfields['entry']['checked']) {
207  $bankline = new AccountLine($db);
208 }
209 if ($arrayfields['account']['checked']) {
210  $accountingaccount = new AccountingAccount($db);
211 }
212 
213 $sql = "SELECT v.rowid, v.sens, v.amount, v.label, v.datep as datep, v.datev as datev, v.fk_typepayment as type, v.num_payment, v.fk_bank, v.accountancy_code, v.subledger_account, v.fk_projet as fk_project,";
214 $sql .= " ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number as bank_account_number, ba.fk_accountancy_journal as accountancy_journal, ba.label as blabel,";
215 $sql .= " pst.code as payment_code";
216 
217 $sqlfields = $sql; // $sql fields to remove for count total
218 
219 $sql .= " FROM ".MAIN_DB_PREFIX."payment_various as v";
220 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pst ON v.fk_typepayment = pst.id";
221 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON v.fk_bank = b.rowid";
222 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid";
223 $sql .= " WHERE v.entity IN (".getEntity('payment_various').")";
224 
225 // Search criteria
226 if ($search_ref) {
227  $sql .= " AND v.rowid = ".((int) $search_ref);
228 }
229 if ($search_label) {
230  $sql .= natural_search(array('v.label'), $search_label);
231 }
232 if ($search_datep_start) {
233  $sql .= " AND v.datep >= '".$db->idate($search_datep_start)."'";
234 }
235 if ($search_datep_end) {
236  $sql .= " AND v.datep <= '".$db->idate($search_datep_end)."'";
237 }
238 if ($search_datev_start) {
239  $sql .= " AND v.datev >= '".$db->idate($search_datev_start)."'";
240 }
241 if ($search_datev_end) {
242  $sql .= " AND v.datev <= '".$db->idate($search_datev_end)."'";
243 }
244 if ($search_amount_deb) {
245  $sql .= natural_search("v.amount", $search_amount_deb, 1);
246 }
247 if ($search_amount_cred) {
248  $sql .= natural_search("v.amount", $search_amount_cred, 1);
249 }
250 if ($search_bank_account > 0) {
251  $sql .= " AND b.fk_account = ".((int) $search_bank_account);
252 }
253 if ($search_bank_entry > 0) {
254  $sql .= " AND b.fk_account = ".((int) $search_bank_account);
255 }
256 if ($search_accountancy_account > 0) {
257  $sql .= " AND v.accountancy_code = ".((int) $search_accountancy_account);
258 }
259 if ($search_accountancy_subledger > 0) {
260  $sql .= " AND v.subledger_account = ".((int) $search_accountancy_subledger);
261 }
262 if ($search_type_id > 0) {
263  $sql .= " AND v.fk_typepayment=".((int) $search_type_id);
264 }
265 if ($search_all) {
266  $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
267 }
268 
269 // Count total nb of records
270 $nbtotalofrecords = '';
271 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
272  /* The fast and low memory method to get and count full list converts the sql into a sql count */
273  $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql);
274  $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount);
275  $resql = $db->query($sqlforcount);
276  if ($resql) {
277  $objforcount = $db->fetch_object($resql);
278  $nbtotalofrecords = $objforcount->nbtotalofrecords;
279  } else {
280  dol_print_error($db);
281  }
282 
283  if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
284  $page = 0;
285  $offset = 0;
286  }
287  $db->free($resql);
288 }
289 
290 // Complete request and execute it with limit
291 $sql .= $db->order($sortfield, $sortorder);
292 if ($limit) {
293  $sql .= $db->plimit($limit + 1, $offset);
294 }
295 
296 $resql = $db->query($sql);
297 if ($resql) {
298  $num = $db->num_rows($resql);
299 
300  // Direct jump if only one record found
301  if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) {
302  $obj = $db->fetch_object($resql);
303  $id = $obj->rowid;
304  header("Location: ".DOL_URL_ROOT.'/compta/bank/various_payment/card.php?id='.$id);
305  exit;
306  }
307 
308  // must be place behind the last "header(...)" call
309  llxHeader('', $langs->trans("VariousPayments"));
310 
311  $i = 0;
312  $total = 0;
313 
314  $param = '';
315  if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
316  $param .= '&contextpage='.urlencode($contextpage);
317  }
318  if ($limit > 0 && $limit != $conf->liste_limit) {
319  $param .= '&limit='.urlencode($limit);
320  }
321  if ($search_ref) {
322  $param .= '&search_ref='.urlencode($search_ref);
323  }
324  if ($search_label) {
325  $param .= '&search_label='.urlencode($search_label);
326  }
327  if ($search_datep_start) {
328  $param .= '&search_datep_start='.urlencode($search_datep_start);
329  }
330  if ($search_datep_end) {
331  $param .= '&search_datep_end='.urlencode($search_datep_end);
332  }
333  if ($search_datev_start) {
334  $param .= '&search_datev_start='.urlencode($search_datev_start);
335  }
336  if ($search_datev_end) {
337  $param .= '&search_datev_end='.urlencode($search_datev_end);
338  }
339  if ($search_type_id > 0) {
340  $param .= '&search_type_id='.urlencode($search_type_id);
341  }
342  if ($search_amount_deb) {
343  $param .= '&search_amount_deb='.urlencode($search_amount_deb);
344  }
345  if ($search_amount_cred) {
346  $param .= '&search_amount_cred='.urlencode($search_amount_cred);
347  }
348  if ($search_bank_account > 0) {
349  $param .= '&search_account='.urlencode($search_bank_account);
350  }
351  if ($search_accountancy_account > 0) {
352  $param .= '&search_accountancy_account='.urlencode($search_accountancy_account);
353  }
354  if ($search_accountancy_subledger > 0) {
355  $param .= '&search_accountancy_subledger='.urlencode($search_accountancy_subledger);
356  }
357  if ($optioncss != '') {
358  $param .= '&optioncss='.urlencode($optioncss);
359  }
360 
361  $url = DOL_URL_ROOT.'/compta/bank/various_payment/card.php?action=create';
362  if (!empty($socid)) {
363  $url .= '&socid='.urlencode($socid);
364  }
365  $newcardbutton = dolGetButtonTitle($langs->trans('MenuNewVariousPayment'), '', 'fa fa-plus-circle', $url, '', $user->rights->banque->modifier);
366 
367  print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
368 
369  if ($optioncss != '') {
370  print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
371  }
372  print '<input type="hidden" name="token" value="'.newToken().'">';
373  print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
374  print '<input type="hidden" name="action" value="list">';
375  print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
376  print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
377  print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
378 
379  print_barre_liste($langs->trans("MenuVariousPayment"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'object_payment', 0, $newcardbutton, '', $limit, 0, 0, 1);
380 
381  if ($search_all) {
382  foreach ($fieldstosearchall as $key => $val) {
383  $fieldstosearchall[$key] = $langs->trans($val);
384  }
385  print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'</div>';
386  }
387 
388  $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
389  $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
390  $moreforfilter= '';
391 
392  print '<div class="div-table-responsive">';
393  print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">';
394 
395  print '<tr class="liste_titre">';
396 
397  if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) {
398  print '<td class="liste_titre">';
399  print '</td>';
400  }
401 
402  // Ref
403  if ($arrayfields['ref']['checked']) {
404  print '<td class="liste_titre left">';
405  print '<input class="flat" type="text" size="3" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
406  print '</td>';
407  }
408 
409  // Label
410  if ($arrayfields['label']['checked']) {
411  print '<td class="liste_titre">';
412  print '<input type="text" class="flat" size="10" name="search_label" value="'.dol_escape_htmltag($search_label).'">';
413  print '</td>';
414  }
415 
416  // Payment date
417  if ($arrayfields['datep']['checked']) {
418  print '<td class="liste_titre center">';
419  print '<div class="nowrap">';
420  print $form->selectDate($search_datep_start ? $search_datep_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
421  print '</div>';
422  print '<div class="nowrap">';
423  print $form->selectDate($search_datep_end ? $search_datep_end : -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
424  print '</div>';
425  print '</td>';
426  }
427 
428  // Value date
429  if ($arrayfields['datev']['checked']) {
430  print '<td class="liste_titre center">';
431  print '<div class="nowrap">';
432  print $form->selectDate($search_datev_start ? $search_datev_start : -1, 'search_date_value_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
433  print '</div>';
434  print '<div class="nowrap">';
435  print $form->selectDate($search_datev_end ? $search_datev_end : -1, 'search_date_value_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
436  print '</div>';
437  print '</td>';
438  }
439 
440  // Payment type
441  if ($arrayfields['type']['checked']) {
442  print '<td class="liste_titre center">';
443  print $form->select_types_paiements($search_type_id, 'search_type_id', '', 0, 1, 1, 16, 1, 'maxwidth100', 1);
444  print '</td>';
445  }
446 
447  // Project
448  if ($arrayfields['project']['checked']) {
449  print '<td class="liste_titre">';
450  // TODO
451  print '</td>';
452  }
453 
454  // Bank account
455  if ($arrayfields['bank']['checked']) {
456  print '<td class="liste_titre">';
457  $form->select_comptes($search_bank_account, 'search_account', 0, '', 1, '', 0, 'maxwidth100');
458  print '</td>';
459  }
460 
461  // Bank entry
462  if ($arrayfields['entry']['checked']) {
463  print '<td class="liste_titre left">';
464  print '<input name="search_bank_entry" class="flat maxwidth50" type="text" value="'.dol_escape_htmltag($search_bank_entry).'">';
465  print '</td>';
466  }
467 
468  // Accounting account
469  if ($arrayfields['account']['checked']) {
470  print '<td class="liste_titre">';
471  print '<div class="nowrap">';
472  print $formaccounting->select_account($search_accountancy_account, 'search_accountancy_account', 1, array(), 1, 1, 'maxwidth200');
473  print '</div>';
474  print '</td>';
475  }
476 
477  // Subledger account
478  if ($arrayfields['subledger']['checked']) {
479  print '<td class="liste_titre">';
480  print '<div class="nowrap">';
481  print $formaccounting->select_auxaccount($search_accountancy_subledger, 'search_accountancy_subledger', 1, 'maxwidth200');
482  print '</div>';
483  print '</td>';
484  }
485 
486  // Debit
487  if ($arrayfields['debit']['checked']) {
488  print '<td class="liste_titre right">';
489  print '<input name="search_amount_deb" class="flat maxwidth50" type="text" value="'.dol_escape_htmltag($search_amount_deb).'">';
490  print '</td>';
491  }
492 
493  // Credit
494  if ($arrayfields['credit']['checked']) {
495  print '<td class="liste_titre right">';
496  print '<input name="search_amount_cred" class="flat maxwidth50" type="text" size="8" value="'.dol_escape_htmltag($search_amount_cred).'">';
497  print '</td>';
498  }
499 
500  print '<td class="liste_titre maxwidthsearch">';
501  $searchpicto = $form->showFilterAndCheckAddButtons(0);
502  print $searchpicto;
503  print '</td>';
504 
505  print '</tr>';
506 
507 
508  print '<tr class="liste_titre">';
509 
510  if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) {
511  print_liste_field_titre('#', $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder);
512  }
513 
514  if ($arrayfields['ref']['checked']) {
515  print_liste_field_titre($arrayfields['ref']['label'], $_SERVER["PHP_SELF"], 'v.rowid', '', $param, '', $sortfield, $sortorder);
516  }
517  if ($arrayfields['label']['checked']) {
518  print_liste_field_titre($arrayfields['label']['label'], $_SERVER["PHP_SELF"], 'v.label', '', $param, '', $sortfield, $sortorder);
519  }
520  if ($arrayfields['datep']['checked']) {
521  print_liste_field_titre($arrayfields['datep']['label'], $_SERVER["PHP_SELF"], 'v.datep,v.rowid', '', $param, '', $sortfield, $sortorder, 'center ');
522  }
523  if ($arrayfields['datev']['checked']) {
524  print_liste_field_titre($arrayfields['datev']['label'], $_SERVER["PHP_SELF"], 'v.datev,v.rowid', '', $param, '', $sortfield, $sortorder, 'center ');
525  }
526  if ($arrayfields['type']['checked']) {
527  print_liste_field_titre($arrayfields['type']['label'], $_SERVER["PHP_SELF"], 'type', '', $param, '', $sortfield, $sortorder, 'center ');
528  }
529  if ($arrayfields['project']['checked']) {
530  print_liste_field_titre($arrayfields['project']['label'], $_SERVER["PHP_SELF"], 'fk_project', '', $param, '', $sortfield, $sortorder);
531  }
532  if ($arrayfields['bank']['checked']) {
533  print_liste_field_titre($arrayfields['bank']['label'], $_SERVER["PHP_SELF"], 'ba.label', '', $param, '', $sortfield, $sortorder);
534  }
535  if ($arrayfields['entry']['checked']) {
536  print_liste_field_titre($arrayfields['entry']['label'], $_SERVER["PHP_SELF"], 'ba.label', '', $param, '', $sortfield, $sortorder);
537  }
538  if ($arrayfields['account']['checked']) {
539  print_liste_field_titre($arrayfields['account']['label'], $_SERVER["PHP_SELF"], 'v.accountancy_code', '', $param, '', $sortfield, $sortorder, 'left ');
540  }
541  if ($arrayfields['subledger']['checked']) {
542  print_liste_field_titre($arrayfields['subledger']['label'], $_SERVER["PHP_SELF"], 'v.subledger_account', '', $param, '', $sortfield, $sortorder, 'left ');
543  }
544  if ($arrayfields['debit']['checked']) {
545  print_liste_field_titre($arrayfields['debit']['label'], $_SERVER["PHP_SELF"], 'v.amount', '', $param, '', $sortfield, $sortorder, 'right ');
546  }
547  if ($arrayfields['credit']['checked']) {
548  print_liste_field_titre($arrayfields['credit']['label'], $_SERVER["PHP_SELF"], 'v.amount', '', $param, '', $sortfield, $sortorder, 'right ');
549  }
550 
551  // Fields from hook
552  $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
553  $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
554  print $hookmanager->resPrint;
555 
556  print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'maxwidthsearch center ');
557  print '</tr>';
558 
559 
560  $totalarray = array();
561  $totalarray['nbfield'] = 0;
562  $totalarray['val']['total_cred'] = 0;
563  $totalarray['val']['total_deb'] = 0;
564 
565  while ($i < min($num, $limit)) {
566  $obj = $db->fetch_object($resql);
567 
568  $variousstatic->id = $obj->rowid;
569  $variousstatic->ref = $obj->rowid;
570  $variousstatic->label = $obj->label;
571 
572  print '<tr class="oddeven">';
573 
574  // No
575  if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) {
576  print '<td>'.(($offset * $limit) + $i).'</td>';
577  }
578 
579  // Ref
580  if ($arrayfields['ref']['checked']) {
581  print '<td>'.$variousstatic->getNomUrl(1)."</td>";
582  if (!$i) {
583  $totalarray['nbfield']++;
584  }
585  }
586 
587  // Label payment
588  if ($arrayfields['label']['checked']) {
589  print '<td class="tdoverflowmax150" title="'.$variousstatic->label.'">'.$variousstatic->label."</td>";
590  if (!$i) {
591  $totalarray['nbfield']++;
592  }
593  }
594 
595  // Date payment
596  if ($arrayfields['datep']['checked']) {
597  print '<td class="center">'.dol_print_date($obj->datep, 'day')."</td>";
598  if (!$i) {
599  $totalarray['nbfield']++;
600  }
601  }
602 
603 
604  // Date value
605  if ($arrayfields['datev']['checked']) {
606  print '<td class="center">'.dol_print_date($obj->datev, 'day')."</td>";
607  if (!$i) {
608  $totalarray['nbfield']++;
609  }
610  }
611 
612  // Type
613  if ($arrayfields['type']['checked']) {
614  print '<td class="center">';
615  if ($obj->payment_code) {
616  print $langs->trans("PaymentTypeShort".$obj->payment_code);
617  print ' ';
618  }
619  print $obj->num_payment;
620  print '</td>';
621  if (!$i) {
622  $totalarray['nbfield']++;
623  }
624  }
625 
626  // Project
627  if ($arrayfields['project']['checked']) {
628  print '<td class="nowraponall">';
629  if ($obj->fk_project > 0) {
630  $proj->fetch($obj->fk_project);
631  print $proj->getNomUrl(1);
632  }
633  print '</td>';
634  if (!$i) {
635  $totalarray['nbfield']++;
636  }
637  }
638 
639  // Bank account
640  if ($arrayfields['bank']['checked']) {
641  print '<td class="nowraponall">';
642  if ($obj->bid > 0) {
643  $accountstatic->id = $obj->bid;
644  $accountstatic->ref = $obj->bref;
645  $accountstatic->number = $obj->bnumber;
646 
647  if (isModEnabled('accounting')) {
648  $accountstatic->account_number = $obj->bank_account_number;
649  $accountingjournal->fetch($obj->accountancy_journal);
650  $accountstatic->accountancy_journal = $accountingjournal->getNomUrl(0, 1, 1, '', 1);
651  }
652 
653  $accountstatic->label = $obj->blabel;
654  print $accountstatic->getNomUrl(1);
655  } else {
656  print '&nbsp;';
657  }
658  print '</td>';
659  if (!$i) {
660  $totalarray['nbfield']++;
661  }
662  }
663 
664  // Bank entry
665  if ($arrayfields['entry']['checked']) {
666  $bankline->fetch($obj->fk_bank);
667  print '<td>'.$bankline->getNomUrl(1).'</td>';
668  if (!$i) {
669  $totalarray['nbfield']++;
670  }
671  }
672 
673  // Accounting account
674  if ($arrayfields['account']['checked']) {
675  require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
676  $result = $accountingaccount->fetch('', $obj->accountancy_code, 1);
677  if ($result > 0) {
678  print '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($obj->accountancy_code.' '.$accountingaccount->label).'">'.$accountingaccount->getNomUrl(0, 1, 1, '', 1).'</td>';
679  } else {
680  print '<td></td>';
681  }
682  if (!$i) {
683  $totalarray['nbfield']++;
684  }
685  }
686 
687  // Accounting subledger account
688  if ($arrayfields['subledger']['checked']) {
689  print '<td class="tdoverflowmax150">'.length_accounta($obj->subledger_account).'</td>';
690  if (!$i) {
691  $totalarray['nbfield']++;
692  }
693  }
694 
695  // Debit
696  if ($arrayfields['debit']['checked']) {
697  print '<td class="nowrap right">';
698  if ($obj->sens == 0) {
699  print '<span class="amount">'.price($obj->amount).'</span>';
700  $totalarray['val']['total_deb'] += $obj->amount;
701  }
702  if (!$i) {
703  $totalarray['nbfield']++;
704  }
705  if (!$i) {
706  $totalarray['pos'][$totalarray['nbfield']] = 'total_deb';
707  }
708  print '</td>';
709  }
710 
711  // Credit
712  if ($arrayfields['credit']['checked']) {
713  print '<td class="nowrap right">';
714  if ($obj->sens == 1) {
715  print '<span class="amount">'.price($obj->amount).'</span>';
716  $totalarray['val']['total_cred'] += $obj->amount;
717  }
718  if (!$i) {
719  $totalarray['nbfield']++;
720  }
721  if (!$i) {
722  $totalarray['pos'][$totalarray['nbfield']] = 'total_cred';
723  }
724  print '</td>';
725  }
726 
727  print '<td></td>';
728 
729  if (!$i) {
730  $totalarray['nbfield']++;
731  }
732 
733  print '</tr>'."\n";
734 
735  $i++;
736  }
737 
738  // Show total line
739  include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
740 
741  // If no record found
742  if ($num == 0) {
743  $colspan = 1;
744  foreach ($arrayfields as $key => $val) {
745  if (!empty($val['checked'])) {
746  $colspan++;
747  }
748  }
749  print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
750  }
751 
752  $db->free($resql);
753 
754  $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql);
755  $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook
756  print $hookmanager->resPrint;
757 
758  print '</table>'."\n";
759  print '</div>'."\n";
760 
761  print '</form>'."\n";
762 } else {
763  dol_print_error($db);
764 }
765 
766 
767 // End of page
768 llxFooter();
769 $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 accounting accounts.
Class to manage generation of HTML components for accounting management.
Class to manage generation of HTML components Only common components must be here.
Class to manage various payments.
Class to manage projects.
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...
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
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.