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