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