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