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