dolibarr 21.0.0-alpha
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';
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 a 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);
233$proj = null;
234if ($arrayfields['account']['checked'] || $arrayfields['subledger']['checked']) {
235 $formaccounting = new FormAccounting($db);
236}
237if ($arrayfields['bank']['checked'] && isModEnabled('accounting')) {
238 $accountingjournal = new AccountingJournal($db);
239}
240if ($arrayfields['ref']['checked']) {
241 $variousstatic = new PaymentVarious($db);
242}
243if ($arrayfields['bank']['checked']) {
244 $accountstatic = new Account($db);
245}
246if ($arrayfields['project']['checked']) {
247 $proj = new Project($db);
248}
249if ($arrayfields['entry']['checked']) {
250 $bankline = new AccountLine($db);
251}
252if ($arrayfields['account']['checked']) {
253 $accountingaccount = new AccountingAccount($db);
254}
255
256$title = $langs->trans("VariousPayments");
257//$help_url = "EN:Module_MyObject|FR:Module_MyObject_FR|ES:Módulo_MyObject";
258$help_url = '';
259
260
261// Build and execute select
262// --------------------------------------------------------------------
263$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,";
264$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,";
265$sql .= " pst.code as payment_code";
266
267$sqlfields = $sql; // $sql fields to remove for count total
268
269$sql .= " FROM ".MAIN_DB_PREFIX."payment_various as v";
270$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pst ON v.fk_typepayment = pst.id";
271$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON v.fk_bank = b.rowid";
272$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid";
273$sql .= " WHERE v.entity IN (".getEntity('payment_various').")";
274
275// Search criteria
276if ($search_ref) {
277 $sql .= " AND v.rowid = ".((int) $search_ref);
278}
279if ($search_label) {
280 $sql .= natural_search(array('v.label'), $search_label);
281}
282if ($search_datep_start) {
283 $sql .= " AND v.datep >= '".$db->idate($search_datep_start)."'";
284}
285if ($search_datep_end) {
286 $sql .= " AND v.datep <= '".$db->idate($search_datep_end)."'";
287}
288if ($search_datev_start) {
289 $sql .= " AND v.datev >= '".$db->idate($search_datev_start)."'";
290}
291if ($search_datev_end) {
292 $sql .= " AND v.datev <= '".$db->idate($search_datev_end)."'";
293}
294if ($search_amount_deb) {
295 $sql .= natural_search("v.amount", $search_amount_deb, 1);
296}
297if ($search_amount_cred) {
298 $sql .= natural_search("v.amount", $search_amount_cred, 1);
299}
300if ($search_bank_account > 0) {
301 $sql .= " AND b.fk_account = ".((int) $search_bank_account);
302}
303if ($search_bank_entry > 0) {
304 $sql .= " AND b.fk_account = ".((int) $search_bank_account);
305}
306if ($search_accountancy_account > 0) {
307 $sql .= " AND v.accountancy_code = ".((int) $search_accountancy_account);
308}
309if ($search_accountancy_subledger > 0) {
310 $sql .= " AND v.subledger_account = ".((int) $search_accountancy_subledger);
311}
312if ($search_type_id > 0) {
313 $sql .= " AND v.fk_typepayment=".((int) $search_type_id);
314}
315if ($search_all) {
316 $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
317}
318//$sql.= dolSqlDateFilter("t.field", $search_xxxday, $search_xxxmonth, $search_xxxyear);
319// Add where from extra fields
320include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
321// Add where from hooks
322$parameters = array();
323$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
324$sql .= $hookmanager->resPrint;
325
326// Count total nb of records
327$nbtotalofrecords = '';
328if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
329 /* The fast and low memory method to get and count full list converts the sql into a sql count */
330 $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql);
331 $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount);
332 $resql = $db->query($sqlforcount);
333 if ($resql) {
334 $objforcount = $db->fetch_object($resql);
335 $nbtotalofrecords = $objforcount->nbtotalofrecords;
336 } else {
337 dol_print_error($db);
338 }
339
340 if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller than the paging size (filtering), goto and load page 0
341 $page = 0;
342 $offset = 0;
343 }
344 $db->free($resql);
345}
346
347// Complete request and execute it with limit
348$sql .= $db->order($sortfield, $sortorder);
349if ($limit) {
350 $sql .= $db->plimit($limit + 1, $offset);
351}
352
353$resql = $db->query($sql);
354if (!$resql) {
355 dol_print_error($db);
356 exit;
357}
358
359$num = $db->num_rows($resql);
360
361// Direct jump if only one record found
362if ($num == 1 && getDolGlobalInt('MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all && !$page) {
363 $obj = $db->fetch_object($resql);
364 $id = $obj->rowid;
365 header("Location: ".DOL_URL_ROOT.'/compta/bank/various_payment/card.php?id='.$id);
366 exit;
367}
368
369// Output page
370// --------------------------------------------------------------------
371
372llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'bodyforlist');
373
374$arrayofselected = is_array($toselect) ? $toselect : array();
375
376$param = '';
377if (!empty($mode)) {
378 $param .= '&mode='.urlencode($mode);
379}
380if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
381 $param .= '&contextpage='.urlencode($contextpage);
382}
383if ($limit > 0 && $limit != $conf->liste_limit) {
384 $param .= '&limit='.((int) $limit);
385}
386if ($optioncss != '') {
387 $param .= '&optioncss='.urlencode($optioncss);
388}
389if ($search_ref) {
390 $param .= '&search_ref='.urlencode($search_ref);
391}
392if ($search_label) {
393 $param .= '&search_label='.urlencode($search_label);
394}
395if ($search_datep_start) {
396 $param .= '&search_datep_start='.urlencode($search_datep_start);
397}
398if ($search_datep_end) {
399 $param .= '&search_datep_end='.urlencode($search_datep_end);
400}
401if ($search_datev_start) {
402 $param .= '&search_datev_start='.urlencode($search_datev_start);
403}
404if ($search_datev_end) {
405 $param .= '&search_datev_end='.urlencode($search_datev_end);
406}
407if ($search_type_id > 0) {
408 $param .= '&search_type_id='.urlencode((string) ($search_type_id));
409}
410if ($search_amount_deb) {
411 $param .= '&search_amount_deb='.urlencode($search_amount_deb);
412}
413if ($search_amount_cred) {
414 $param .= '&search_amount_cred='.urlencode($search_amount_cred);
415}
416if ($search_bank_account > 0) {
417 $param .= '&search_account='.urlencode((string) ($search_bank_account));
418}
419if ($search_accountancy_account > 0) {
420 $param .= '&search_accountancy_account='.urlencode($search_accountancy_account);
421}
422if ($search_accountancy_subledger > 0) {
423 $param .= '&search_accountancy_subledger='.urlencode($search_accountancy_subledger);
424}
425
426$url = DOL_URL_ROOT.'/compta/bank/various_payment/card.php?action=create';
427if (!empty($socid)) {
428 $url .= '&socid='.urlencode((string) ($socid));
429}
430
431// List of mass actions available
432$arrayofmassactions = array();
433$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
434
435print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n";
436if ($optioncss != '') {
437 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
438}
439print '<input type="hidden" name="token" value="'.newToken().'">';
440print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
441print '<input type="hidden" name="action" value="list">';
442print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
443print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
444print '<input type="hidden" name="page" value="'.$page.'">';
445print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
446print '<input type="hidden" name="page_y" value="">';
447print '<input type="hidden" name="mode" value="'.$mode.'">';
448
449$newcardbutton = '';
450$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'));
451$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'));
452$newcardbutton .= dolGetButtonTitleSeparator();
453$newcardbutton .= dolGetButtonTitle($langs->trans('MenuNewVariousPayment'), '', 'fa fa-plus-circle', $url, '', $user->hasRight('banque', 'modifier'));
454
455print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'object_payment', 0, $newcardbutton, '', $limit, 0, 0, 1);
456
457if ($search_all) {
458 $setupstring = '';
459 foreach ($fieldstosearchall as $key => $val) {
460 $fieldstosearchall[$key] = $langs->trans($val);
461 $setupstring .= $key."=".$val.";";
462 }
463 print '<!-- Search done like if VARIOUSPAYMENT_QUICKSEARCH_ON_FIELDS = '.$setupstring.' -->'."\n";
464 print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).implode(', ', $fieldstosearchall).'</div>';
465}
466
467$arrayofmassactions = array();
468
469$moreforfilter = '';
470
471$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
472$htmlofselectarray = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')); // This also change content of $arrayfields with user setup
473$selectedfields = ($mode != 'kanban' ? $htmlofselectarray : '');
474$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
475
476
477print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you don't need reserved height for your table
478print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
479
480// Fields title search
481// --------------------------------------------------------------------
482print '<tr class="liste_titre_filter">';
483// Action column
484if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
485 print '<td class="liste_titre center maxwidthsearch">';
486 $searchpicto = $form->showFilterButtons('left');
487 print $searchpicto;
488 print '</td>';
489}
490
491if (getDolGlobalString('MAIN_VIEW_LINE_NUMBER_IN_LIST')) {
492 print '<td class="liste_titre">';
493 print '</td>';
494}
495
496// Ref
497if ($arrayfields['ref']['checked']) {
498 print '<td class="liste_titre left">';
499 print '<input class="flat" type="text" size="3" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
500 print '</td>';
501}
502
503// Label
504if ($arrayfields['label']['checked']) {
505 print '<td class="liste_titre">';
506 print '<input type="text" class="flat" size="10" name="search_label" value="'.dol_escape_htmltag($search_label).'">';
507 print '</td>';
508}
509
510// Payment date
511if ($arrayfields['datep']['checked']) {
512 print '<td class="liste_titre center">';
513 print '<div class="nowrapfordate">';
514 print $form->selectDate($search_datep_start ? $search_datep_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
515 print '</div>';
516 print '<div class="nowrapfordate">';
517 print $form->selectDate($search_datep_end ? $search_datep_end : -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
518 print '</div>';
519 print '</td>';
520}
521
522// Value date
523if ($arrayfields['datev']['checked']) {
524 print '<td class="liste_titre center">';
525 print '<div class="nowrapfordate">';
526 print $form->selectDate($search_datev_start ? $search_datev_start : -1, 'search_date_value_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
527 print '</div>';
528 print '<div class="nowrapfordate">';
529 print $form->selectDate($search_datev_end ? $search_datev_end : -1, 'search_date_value_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
530 print '</div>';
531 print '</td>';
532}
533
534// Payment type
535if ($arrayfields['type']['checked']) {
536 print '<td class="liste_titre center">';
537 print $form->select_types_paiements($search_type_id, 'search_type_id', '', 0, 1, 1, 16, 1, 'maxwidth100', 1);
538 print '</td>';
539}
540
541// Project
542if ($arrayfields['project']['checked']) {
543 print '<td class="liste_titre">';
544 // TODO
545 print '</td>';
546}
547
548// Bank account
549if ($arrayfields['bank']['checked']) {
550 print '<td class="liste_titre">';
551 $form->select_comptes($search_bank_account, 'search_account', 0, '', 1, '', 0, 'maxwidth100');
552 print '</td>';
553}
554
555// Bank entry
556if ($arrayfields['entry']['checked']) {
557 print '<td class="liste_titre left">';
558 print '<input name="search_bank_entry" class="flat maxwidth50" type="text" value="'.dol_escape_htmltag($search_bank_entry).'">';
559 print '</td>';
560}
561
562// Accounting account
563if (!empty($arrayfields['account']['checked'])) {
564 print '<td class="liste_titre">';
565 print '<div class="nowrap">';
566 print $formaccounting->select_account($search_accountancy_account, 'search_accountancy_account', 1, array(), 1, 1, 'maxwidth200');
567 print '</div>';
568 print '</td>';
569}
570
571// Subledger account
572if (!empty($arrayfields['subledger']['checked'])) {
573 print '<td class="liste_titre">';
574 print '<div class="nowrap">';
575 print $formaccounting->select_auxaccount($search_accountancy_subledger, 'search_accountancy_subledger', 1, 'maxwidth200');
576 print '</div>';
577 print '</td>';
578}
579
580// Debit
581if (!empty($arrayfields['debit']['checked'])) {
582 print '<td class="liste_titre right">';
583 print '<input name="search_amount_deb" class="flat maxwidth50" type="text" value="'.dol_escape_htmltag($search_amount_deb).'">';
584 print '</td>';
585}
586
587// Credit
588if ($arrayfields['credit']['checked']) {
589 print '<td class="liste_titre right">';
590 print '<input name="search_amount_cred" class="flat maxwidth50" type="text" size="8" value="'.dol_escape_htmltag($search_amount_cred).'">';
591 print '</td>';
592}
593
594if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
595 print '<td class="liste_titre center maxwidthsearch">';
596 $searchpicto = $form->showFilterButtons();
597 print $searchpicto;
598 print '</td>';
599}
600
601print '</tr>'."\n";
602
603$totalarray = array();
604$totalarray['nbfield'] = 0;
605
606// Fields title label
607// --------------------------------------------------------------------
608print '<tr class="liste_titre">';
609// Action column
610if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
611 print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
612 $totalarray['nbfield']++;
613}
614if (getDolGlobalString('MAIN_VIEW_LINE_NUMBER_IN_LIST')) {
615 print_liste_field_titre('#', $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder);
616 $totalarray['nbfield']++;
617}
618
619if ($arrayfields['ref']['checked']) {
620 print_liste_field_titre($arrayfields['ref']['label'], $_SERVER["PHP_SELF"], 'v.rowid', '', $param, '', $sortfield, $sortorder);
621 $totalarray['nbfield']++;
622}
623if ($arrayfields['label']['checked']) {
624 print_liste_field_titre($arrayfields['label']['label'], $_SERVER["PHP_SELF"], 'v.label', '', $param, '', $sortfield, $sortorder);
625 $totalarray['nbfield']++;
626}
627if ($arrayfields['datep']['checked']) {
628 print_liste_field_titre($arrayfields['datep']['label'], $_SERVER["PHP_SELF"], 'v.datep,v.rowid', '', $param, '', $sortfield, $sortorder, 'center ');
629 $totalarray['nbfield']++;
630}
631if ($arrayfields['datev']['checked']) {
632 print_liste_field_titre($arrayfields['datev']['label'], $_SERVER["PHP_SELF"], 'v.datev,v.rowid', '', $param, '', $sortfield, $sortorder, 'center ');
633 $totalarray['nbfield']++;
634}
635if ($arrayfields['type']['checked']) {
636 print_liste_field_titre($arrayfields['type']['label'], $_SERVER["PHP_SELF"], 'type', '', $param, '', $sortfield, $sortorder, 'center ');
637 $totalarray['nbfield']++;
638}
639if ($arrayfields['project']['checked']) {
640 print_liste_field_titre($arrayfields['project']['label'], $_SERVER["PHP_SELF"], 'fk_project', '', $param, '', $sortfield, $sortorder);
641 $totalarray['nbfield']++;
642}
643if ($arrayfields['bank']['checked']) {
644 print_liste_field_titre($arrayfields['bank']['label'], $_SERVER["PHP_SELF"], 'ba.label', '', $param, '', $sortfield, $sortorder);
645 $totalarray['nbfield']++;
646}
647if ($arrayfields['entry']['checked']) {
648 print_liste_field_titre($arrayfields['entry']['label'], $_SERVER["PHP_SELF"], 'ba.label', '', $param, '', $sortfield, $sortorder);
649 $totalarray['nbfield']++;
650}
651if (!empty($arrayfields['account']['checked'])) {
652 // False positive @phan-suppress-next-line PhanTypeInvalidDimOffset
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(0, $obj->accountancy_code, 1);
707 $variousstatic->accountancy_code = $accountingaccount->getNomUrl(0, 0, 1, $obj->accountingaccount, 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 ($arrayfields['project']['checked']) {
786 print '<td class="nowraponall">';
787 if ($obj->fk_project > 0 && is_object($proj)) {
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(0, $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();
$id
Definition account.php:39
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($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:70
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.
llxFooter()
Footer empty.
Definition document.php:107
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.
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.
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.
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.