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