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