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