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