dolibarr  20.0.0-beta
list.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2004-2020 Laurent Destailleur <eldy@users.sourceforge.net>
4  * Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.com>
5  * Copyright (C) 2011-2019 Alexandre Spangaro <aspangaro@open-dsi.fr>
6  * Copyright (C) 2020 Tobias Sekan <tobias.sekan@startmail.com>
7  * Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
8  * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 3 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program. If not, see <https://www.gnu.org/licenses/>.
22  */
23 
30 // Load Dolibarr environment
31 require '../../main.inc.php';
32 
33 require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php';
34 require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
35 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
36 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
37 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
38 require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php';
39 
40 // Load translation files required by the page
41 $langs->loadLangs(array('compta', 'bills'));
42 
43 $action = GETPOST('action', 'aZ09') ? GETPOST('action', 'aZ09') : 'view'; // The action 'create'/'add', 'edit'/'update', 'view', ...
44 $massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists)
45 $show_files = GETPOSTINT('show_files'); // Show files area generated by bulk actions ?
46 $confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation
47 $cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button
48 $toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list
49 $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'salestaxeslist';
50 $backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page
51 $optioncss = GETPOST('optioncss', 'alpha');
52 $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
53 $mode = GETPOST('mode', 'aZ'); // The output mode ('list', 'kanban', 'hierarchy', 'calendar', ...)
54 
55 $search_ref = GETPOST('search_ref', 'alpha');
56 $search_label = GETPOST('search_label', 'alpha');
57 $search_dateend_start = dol_mktime(0, 0, 0, GETPOSTINT('search_dateend_startmonth'), GETPOSTINT('search_dateend_startday'), GETPOSTINT('search_dateend_startyear'));
58 $search_dateend_end = dol_mktime(23, 59, 59, GETPOSTINT('search_dateend_endmonth'), GETPOSTINT('search_dateend_endday'), GETPOSTINT('search_dateend_endyear'));
59 $search_datepayment_start = dol_mktime(0, 0, 0, GETPOSTINT('search_datepayment_startmonth'), GETPOSTINT('search_datepayment_startday'), GETPOSTINT('search_datepayment_startyear'));
60 $search_datepayment_end = dol_mktime(23, 59, 59, GETPOSTINT('search_datepayment_endmonth'), GETPOSTINT('search_datepayment_endday'), GETPOSTINT('search_datepayment_endyear'));
61 $search_type = GETPOST('search_type', 'intcomma');
62 $search_account = GETPOST('search_account', 'alpha');
63 $search_amount = GETPOST('search_amount', 'alpha');
64 $search_status = GETPOST('search_status', 'intcomma');
65 
66 $limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
67 $sortfield = GETPOST('sortfield', 'aZ09comma');
68 $sortorder = GETPOST('sortorder', 'aZ09comma');
69 $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOSTINT('page');
70 if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
71  // If $page is not defined, or '' or -1 or if we click on clear filters
72  $page = 0;
73 }
74 $offset = $limit * $page;
75 $pageprev = $page - 1;
76 $pagenext = $page + 1;
77 
78 if (!$sortfield) {
79  $sortfield = 't.datev';
80 }
81 if (!$sortorder) {
82  $sortorder = 'DESC';
83 }
84 
85 $arrayfields = array(
86  't.rowid' => array('checked' => 1, 'position' => 10, 'label' => "Ref",),
87  't.label' => array('checked' => 1, 'position' => 20, 'label' => "Label"),
88  't.datev' => array('checked' => 1, 'position' => 30, 'label' => "PeriodEndDate"),
89  't.fk_typepayment' => array('checked' => 1, 'position' => 50, 'label' => "DefaultPaymentMode"),
90  't.amount' => array('checked' => 1, 'position' => 90, 'label' => "Amount"),
91  't.datec' => array('checked' => 1, 'position' => 91, 'label' => "DateCreation"),
92  't.status' => array('checked' => 1, 'position' => 92, 'label' => "Status"),
93 );
94 
95 if (isModEnabled("bank")) {
96  $arrayfields['t.fk_account'] = array('checked' => 1, 'position' => 60, 'label' => "DefaultBankAccount");
97 }
98 
99 $arrayfields = dol_sort_array($arrayfields, 'position');
100 '@phan-var-force array<string,array{label:string,checked?:int<0,1>,position?:int,help?:string}> $arrayfields'; // dol_sort_array looses type for Phan
101 
102 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
103 $hookmanager->initHooks(array('salestaxeslist'));
104 $object = new Tva($db);
105 
106 $permissiontoadd = $user->hasRight('tax', 'charges', 'creer');
107 $permissiontodelete = $user->hasRight('tax', 'charges', 'supprimer');
108 
109 // Security check
110 $socid = GETPOSTINT('socid');
111 if ($user->socid) {
112  $socid = $user->socid;
113 }
114 $result = restrictedArea($user, 'tax', '', 'tva', 'charges');
115 
116 
117 /*
118  * Actions
119  */
120 
121 $parameters = array('socid' => $socid);
122 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
123 if ($reshook < 0) {
124  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
125 }
126 
127 
128 if (empty($reshook)) {
129  // Selection of new fields
130  include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
131 
132  if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // Both test are required to be compatible with all browsers
133  $search_ref = '';
134  $search_label = '';
135  $search_dateend_start = '';
136  $search_dateend_end = '';
137  $search_datepayment_start = '';
138  $search_datepayment_end = '';
139  $search_type = '';
140  $search_account = '';
141  $search_amount = '';
142  $search_status = '';
143  $toselect = array();
144  $search_array_options = array();
145  }
146 
147  // Mass actions
148  $objectclass = 'Tva';
149  $objectlabel = 'Tva';
150  $uploaddir = $conf->tax->dir_output;
151  include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
152 }
153 
154 
155 /*
156  * View
157  */
158 
159 $form = new Form($db);
160 $formother = new FormOther($db);
161 $formfile = new FormFile($db);
162 $tva_static = new Tva($db);
163 $bankstatic = new Account($db);
164 $accountingjournal = new AccountingJournal($db);
165 $bankline = new AccountLine($db);
166 
167 $now = dol_now();
168 
169 $title = $langs->trans("VATDeclarations");
170 //$help_url = "EN:Module_MyObject|FR:Module_MyObject_FR|ES:Módulo_MyObject";
171 $help_url = '';
172 
173 
174 // Build and execute select
175 // --------------------------------------------------------------------
176 $sql = 'SELECT t.rowid, t.amount, t.label, t.datec, t.datev, t.paye as status, t.fk_typepayment as type, t.fk_account,';
177 $sql .= ' ba.label as blabel, ba.ref as bref, ba.number as bnumber, ba.account_number, ba.iban_prefix as iban, ba.bic, ba.currency_code, ba.clos,';
178 $sql .= ' t.num_payment, pst.code as payment_code,';
179 $sql .= ' SUM(ptva.amount) as alreadypayed';
180 
181 $sqlfields = $sql; // $sql fields to remove for count total
182 
183 $sql .= ' FROM '.MAIN_DB_PREFIX.'tva as t';
184 $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as pst ON (t.fk_typepayment = pst.id)';
185 $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank_account as ba ON (t.fk_account = ba.rowid)';
186 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."payment_vat as ptva ON (ptva.fk_tva = t.rowid)";
187 $sql .= ' WHERE t.entity IN ('.getEntity($object->element).')';
188 
189 if (!empty($search_ref)) {
190  $sql .= natural_search('t.rowid', $search_ref);
191 }
192 if (!empty($search_label)) {
193  $sql .= natural_search('t.label', $search_label);
194 }
195 if (!empty($search_dateend_start)) {
196  $sql .= " AND t.datev >= '".$db->idate($search_dateend_start)."'";
197 }
198 if (!empty($search_dateend_end)) {
199  $sql .= " AND t.datev <= '".$db->idate($search_dateend_end)."'";
200 }
201 if (!empty($search_datepayment_start)) {
202  $sql .= " AND t.datep >= '".$db->idate($search_datepayment_start)."'";
203 }
204 if (!empty($search_datepayment_end)) {
205  $sql .= " AND t.datep <= '".$db->idate($search_datepayment_end)."'";
206 }
207 if (!empty($search_type) && $search_type > 0) {
208  $sql .= ' AND t.fk_typepayment = '.((int) $search_type);
209 }
210 if (!empty($search_account) && $search_account > 0) {
211  $sql .= ' AND t.fk_account = '.((int) $search_account);
212 }
213 if (!empty($search_amount)) {
214  $sql .= natural_search('t.amount', price2num(trim($search_amount)), 1);
215 }
216 if ($search_status != '' && $search_status >= 0) {
217  $sql .= " AND t.paye = ".((int) $search_status);
218 }
219 
220 $sql .= " GROUP BY t.rowid, t.amount, t.label, t.datec, t.datev, t.paye, t.fk_typepayment, t.fk_account,";
221 $sql .= " ba.label, ba.ref, ba.number, ba.account_number, ba.iban_prefix, ba.bic, ba.currency_code, ba.clos, t.num_payment, pst.code";
222 
223 // Count total nb of records
224 $nbtotalofrecords = '';
225 if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
226  /* The fast and low memory method to get and count full list converts the sql into a sql count */
227  $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql);
228  $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount);
229  $resql = $db->query($sqlforcount);
230  if ($resql) {
231  $objforcount = $db->fetch_object($resql);
232  $nbtotalofrecords = $objforcount->nbtotalofrecords;
233  } else {
234  dol_print_error($db);
235  }
236 
237  if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller than the paging size (filtering), goto and load page 0
238  $page = 0;
239  $offset = 0;
240  }
241  $db->free($resql);
242 }
243 
244 // Complete request and execute it with limit
245 $sql .= $db->order($sortfield, $sortorder);
246 if ($limit) {
247  $sql .= $db->plimit($limit + 1, $offset);
248 }
249 
250 $resql = $db->query($sql);
251 if (!$resql) {
252  dol_print_error($db);
253  exit;
254 }
255 
256 $num = $db->num_rows($resql);
257 
258 
259 // Output page
260 // --------------------------------------------------------------------
261 
262 llxHeader('', $title, $help_url);
263 
264 $arrayofselected = is_array($toselect) ? $toselect : array();
265 
266 $param = '';
267 if (!empty($mode)) {
268  $param .= '&mode='.urlencode($mode);
269 }
270 if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
271  $param .= '&contextpage='.urlencode($contextpage);
272 }
273 if ($limit > 0 && $limit != $conf->liste_limit) {
274  $param .= '&limit='.((int) $limit);
275 }
276 if ($optioncss != '') {
277  $param .= '&optioncss='.urlencode($optioncss);
278 }
279 
280 if (!empty($search_ref)) {
281  $param .= '&search_ref="'.$search_ref.'"';
282 }
283 if (!empty($search_label)) {
284  $param .= '&search_label="'.$search_label.'"';
285 }
286 if (!empty($search_dateend_start)) {
287  $param .= '&search_dateend_startyear='.GETPOSTINT('search_dateend_startyear');
288 }
289 if (!empty($search_dateend_start)) {
290  $param .= '&search_dateend_startmonth='.GETPOSTINT('search_dateend_startmonth');
291 }
292 if (!empty($search_dateend_start)) {
293  $param .= '&search_dateend_startday='.GETPOSTINT('search_dateend_startday');
294 }
295 if (!empty($search_dateend_end)) {
296  $param .= '&search_dateend_endyear='.GETPOSTINT('search_dateend_endyear');
297 }
298 if (!empty($search_dateend_end)) {
299  $param .= '&search_dateend_endmonth='.GETPOSTINT('search_dateend_endmonth');
300 }
301 if (!empty($search_dateend_end)) {
302  $param .= '&search_dateend_endday='.GETPOSTINT('search_dateend_endday');
303 }
304 if (!empty($search_datepayment_start)) {
305  $param .= '&search_datepayment_startyear='.GETPOSTINT('search_datepayment_startyear');
306 }
307 if (!empty($search_datepayment_start)) {
308  $param .= '&search_datepayment_startmonth='.GETPOSTINT('search_datepayment_startmonth');
309 }
310 if (!empty($search_datepayment_start)) {
311  $param .= '&search_datepayment_startday='.GETPOSTINT('search_datepayment_startday');
312 }
313 if (!empty($search_datepayment_end)) {
314  $param .= '&search_datepayment_endyear='.GETPOSTINT('search_datepayment_endyear');
315 }
316 if (!empty($search_datepayment_end)) {
317  $param .= '&search_datepayment_endmonth='.GETPOSTINT('search_datepayment_endmonth');
318 }
319 if (!empty($search_datepayment_end)) {
320  $param .= '&search_datepayment_endday='.GETPOSTINT('search_datepayment_endday');
321 }
322 if (!empty($search_type) && $search_type > 0) {
323  $param .= '&search_type='.$search_type;
324 }
325 if (!empty($search_account) && $search_account > 0) {
326  $param .= '&search_account='.$search_account;
327 }
328 if (!empty($search_amount)) {
329  $param .= '&search_amount="'.$search_amount.'"';
330 }
331 if ($search_status != '' && $search_status != '-1') {
332  $param .= '&search_status='.urlencode($search_status);
333 }
334 
335 // List of mass actions available
336 $arrayofmassactions = array(
337  //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
338  //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
339 );
340 if (!empty($permissiontodelete)) {
341  $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
342 }
343 $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
344 
345 $moreforfilter = '';
346 
347 print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
348 if ($optioncss != '') {
349  print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
350 }
351 print '<input type="hidden" name="token" value="'.newToken().'">';
352 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
353 print '<input type="hidden" name="action" value="list">';
354 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
355 print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
356 print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
357 print '<input type="hidden" name="page" value="'.$page.'">';
358 print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
359 print '<input type="hidden" name="page_y" value="">';
360 print '<input type="hidden" name="mode" value="'.$mode.'">';
361 
362 $url = DOL_URL_ROOT.'/compta/tva/card.php?action=create';
363 if (!empty($socid)) {
364  $url .= '&socid='.$socid;
365 }
366 $newcardbutton = '';
367 $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'));
368 $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'));
369 $newcardbutton .= dolGetButtonTitleSeparator();
370 $newcardbutton .= dolGetButtonTitle($langs->trans('NewVATPayment'), '', 'fa fa-plus-circle', $url, '', $permissiontoadd);
371 
372 print_barre_liste($title, $page, $_SERVER['PHP_SELF'], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_accountancy', 0, $newcardbutton, '', $limit, 0, 0, 1);
373 
374 // Add code for pre mass action (confirmation or email presend form)
375 $topicmail = "SendVAT";
376 $modelmail = "vat";
377 $objecttmp = new Tva($db);
378 $trackid = 'vat'.$object->id;
379 include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
380 
381 $varpage = empty($contextpage) ? $_SERVER['PHP_SELF'] : $contextpage;
382 $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')); // This also change content of $arrayfields
383 if ($massactionbutton) {
384  $selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
385 }
386 
387 $moreforfilter = '';
388 
389 $parameters = array();
390 $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
391 if (empty($reshook)) {
392  $moreforfilter .= $hookmanager->resPrint;
393 } else {
394  $moreforfilter = $hookmanager->resPrint;
395 }
396 
397 if (!empty($moreforfilter)) {
398  print '<div class="liste_titre liste_titre_bydiv centpercent">';
399  print $moreforfilter;
400  $parameters = array();
401  $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
402  print $hookmanager->resPrint;
403  print '</div>';
404 }
405 
406 $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
407 $htmlofselectarray = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')); // This also change content of $arrayfields with user setup
408 $selectedfields = ($mode != 'kanban' ? $htmlofselectarray : '');
409 $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
410 
411 print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you don't need reserved height for your table
412 print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
413 
414 // Fields title search
415 // --------------------------------------------------------------------
416 print '<tr class="liste_titre_filter">';
417 // Action column
418 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
419  print '<td class="liste_titre center maxwidthsearch">';
420  $searchpicto = $form->showFilterButtons('left');
421  print $searchpicto;
422  print '</td>';
423 }
424 
425 // Filters: Lines (placeholder)
426 if (getDolGlobalString('MAIN_VIEW_LINE_NUMBER_IN_LIST')) {
427  print '<td class="liste_titre">';
428  print '</td>';
429 }
430 
431 // Filter: Ref
432 if (!empty($arrayfields['t.rowid']['checked'])) {
433  print '<td class="liste_titre">';
434  print '<input type="text" class="flat" size="4" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
435  print '</td>';
436 }
437 
438 // Filter: Label
439 if (!empty($arrayfields['t.label']['checked'])) {
440  print '<td class="liste_titre">';
441  print '<input type="text" class="flat" size="10" name="search_label" value="'.dol_escape_htmltag($search_label).'">';
442  print '</td>';
443 }
444 
445 // Filter: Date end period
446 if (!empty($arrayfields['t.datev']['checked'])) {
447  print '<td class="liste_titre center">';
448  print '<div class="nowrapfordate">';
449  print $form->selectDate($search_dateend_start ? $search_dateend_start : -1, 'search_dateend_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"));
450  print '</div>';
451  print '<div class="nowrapfordate">';
452  print $form->selectDate($search_dateend_end ? $search_dateend_end : -1, 'search_dateend_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to"));
453  print '</div>';
454  print '</td>';
455 }
456 
457 // Filter: Date payment
458 /*if (!empty($arrayfields['t.datep']['checked'])) {
459  print '<td class="liste_titre center">';
460  print '<div class="nowrapfordate">';
461  print $form->selectDate($search_datepayment_start ? $search_datepayment_start : -1, 'search_datepayment_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"));
462  print '</div>';
463  print '<div class="nowrapfordate">';
464  print $form->selectDate($search_datepayment_end ? $search_datepayment_end : -1, 'search_datepayment_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to"));
465  print '</div>';
466  print '</td>';
467 }*/
468 
469 // Filter: Type
470 if (!empty($arrayfields['t.fk_typepayment']['checked'])) {
471  print '<td class="liste_titre left">';
472  print $form->select_types_paiements($search_type, 'search_type', '', 0, 1, 1, 16, 1, '', 1);
473  print '</td>';
474 }
475 
476 // Filter: Bank Account
477 if (!empty($arrayfields['t.fk_account']['checked'])) {
478  print '<td class="liste_titre left">';
479  $form->select_comptes($search_account, 'search_account', 0, '', 1);
480  print '</td>';
481 }
482 
483 // Filter: Amount
484 if (!empty($arrayfields['t.amount']['checked'])) {
485  print '<td class="liste_titre right">';
486  print '<input name="search_amount" class="flat" type="text" size="8" value="'.$search_amount.'">';
487  print '</td>';
488 }
489 
490 // Filter: Date creation
491 if (!empty($arrayfields['t.datec']['checked'])) {
492  print '<td class="liste_titre right">';
493  //print '<input name="search_amount" class="flat" type="text" size="8" value="'.$search_amount.'">';
494  print '</td>';
495 }
496 
497 // Status
498 if (!empty($arrayfields['t.status']['checked'])) {
499  print '<td class="liste_titre right parentonrightofpage">';
500  $liststatus = array('0' => $langs->trans("Unpaid"), '1' => $langs->trans("Paid"));
501  // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
502  print $form->selectarray('search_status', $liststatus, $search_status, 1, 0, 0, '', 0, 0, 0, '', 'search_status width100 onrightofpage');
503  print '</td>';
504 }
505 
506 // Extra fields
507 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
508 
509 // Fields from hook
510 $parameters = array('arrayfields' => $arrayfields);
511 $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
512 print $hookmanager->resPrint;
513 
514 // Action column
515 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
516  print '<td class="liste_titre center maxwidthsearch">';
517  $searchpicto = $form->showFilterButtons();
518  print $searchpicto;
519  print '</td>';
520 }
521 print '</tr>'."\n";
522 
523 $totalarray = array();
524 $totalarray['nbfield'] = 0;
525 
526 // Fields title label
527 // --------------------------------------------------------------------
528 print '<tr class="liste_titre">';
529 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
530  print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
531  $totalarray['nbfield']++;
532 }
533 if (getDolGlobalString('MAIN_VIEW_LINE_NUMBER_IN_LIST')) {
534  print_liste_field_titre('#', $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder);
535  $totalarray['nbfield']++;
536 }
537 if (!empty($arrayfields['t.rowid']['checked'])) {
538  print_liste_field_titre($arrayfields['t.rowid']['label'], $_SERVER['PHP_SELF'], 't.rowid', '', $param, '', $sortfield, $sortorder);
539  $totalarray['nbfield']++;
540 }
541 if (!empty($arrayfields['t.label']['checked'])) {
542  print_liste_field_titre($arrayfields['t.label']['label'], $_SERVER['PHP_SELF'], 't.label', '', $param, '', $sortfield, $sortorder);
543  $totalarray['nbfield']++;
544 }
545 if (!empty($arrayfields['t.datev']['checked'])) {
546  print_liste_field_titre($arrayfields['t.datev']['label'], $_SERVER['PHP_SELF'], 't.datev', '', $param, '', $sortfield, $sortorder, 'center ');
547  $totalarray['nbfield']++;
548 }
549 if (!empty($arrayfields['t.fk_typepayment']['checked'])) {
550  print_liste_field_titre($arrayfields['t.fk_typepayment']['label'], $_SERVER['PHP_SELF'], 't.fk_typepayment', '', $param, '', $sortfield, $sortorder, 'left ');
551  $totalarray['nbfield']++;
552 }
553 if (!empty($arrayfields['t.fk_account']['checked'])) {
554  print_liste_field_titre($arrayfields['t.fk_account']['label'], $_SERVER['PHP_SELF'], 't.fk_account', '', $param, '', $sortfield, $sortorder, 'left ');
555  $totalarray['nbfield']++;
556 }
557 if (!empty($arrayfields['t.amount']['checked'])) {
558  print_liste_field_titre($arrayfields['t.amount']['label'], $_SERVER['PHP_SELF'], 't.amount', '', $param, '', $sortfield, $sortorder, 'right ');
559  $totalarray['nbfield']++;
560 }
561 if (!empty($arrayfields['t.datec']['checked'])) {
562  print_liste_field_titre($arrayfields['t.datec']['label'], $_SERVER['PHP_SELF'], 't.datec', '', $param, '', $sortfield, $sortorder, 'center ');
563  $totalarray['nbfield']++;
564 }
565 if (!empty($arrayfields['t.status']['checked'])) {
566  print_liste_field_titre($arrayfields['t.status']['label'], $_SERVER["PHP_SELF"], "t.paye", "", $param, 'class="right"', $sortfield, $sortorder);
567  $totalarray['nbfield']++;
568 }
569 // Extra fields
570 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
571 // Hook fields
572 $parameters = array('arrayfields' => $arrayfields, 'param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder);
573 $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
574 print $hookmanager->resPrint;
575 
576 // Action column
577 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
578  print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
579  $totalarray['nbfield']++;
580 }
581 print '</tr>'."\n";
582 
583 // Loop on record
584 // --------------------------------------------------------------------
585 $i = 0;
586 $savnbfield = $totalarray['nbfield'];
587 $totalarray = array();
588 $totalarray['nbfield'] = 0;
589 $imaxinloop = ($limit ? min($num, $limit) : $num);
590 while ($i < $imaxinloop) {
591  $obj = $db->fetch_object($resql);
592  if (empty($obj)) {
593  break; // Should not happen
594  }
595 
596  $tva_static->id = $obj->rowid;
597  $tva_static->ref = $obj->rowid;
598  $tva_static->label = $obj->label;
599  $tva_static->type_payment = $obj->payment_code;
600  $tva_static->datev = $obj->datev;
601  $tva_static->date_creation = $obj->datec;
602  $tva_static->amount = $obj->amount;
603  $tva_static->paye = $obj->status;
604  $tva_static->status = $obj->status;
605  $object = $tva_static;
606 
607  if ($mode == 'kanban') {
608  if ($i == 0) {
609  print '<tr class="trkanban"><td colspan="'.$savnbfield.'">';
610  print '<div class="box-flex-container kanban">';
611  }
612  // Output Kanban
613  $selected = -1;
614  if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
615  $selected = 0;
616  if (in_array($object->id, $arrayofselected)) {
617  $selected = 1;
618  }
619  }
620  print $object->getKanbanView('', array('selected' => $selected));
621  if ($i == ($imaxinloop - 1)) {
622  print '</div>';
623  print '</td></tr>';
624  }
625  } else {
626  // Show here line of result
627  $j = 0;
628  print '<tr data-rowid="'.$object->id.'" class="oddeven">';
629  // Action column
630  if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
631  print '<td class="nowrap center">';
632  if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
633  $selected = 0;
634  if (in_array($object->id, $arrayofselected)) {
635  $selected = 1;
636  }
637  print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
638  }
639  print '</td>';
640  if (!$i) {
641  $totalarray['nbfield']++;
642  }
643  }
644 
645  // No
646  if (getDolGlobalString('MAIN_VIEW_LINE_NUMBER_IN_LIST')) {
647  print '<td>'.(($offset * $limit) + $i).'</td>';
648  if (!$i) {
649  $totalarray['nbfield']++;
650  }
651  }
652 
653  // Ref
654  if (!empty($arrayfields['t.rowid']['checked'])) {
655  print '<td>';
656  print $tva_static->getNomUrl(1);
657  $filename = dol_sanitizeFileName($tva_static->ref);
658  $filedir = $conf->tax->dir_output.'/vat/'.dol_sanitizeFileName($tva_static->ref);
659  $urlsource = $_SERVER['PHP_SELF'].'?id='.$tva_static->id;
660  print $formfile->getDocumentsLink($tva_static->element, $filename, $filedir, '', 'valignmiddle paddingleft2imp');
661  print '</td>';
662  if (!$i) {
663  $totalarray['nbfield']++;
664  }
665  }
666 
667  // Label
668  if (!empty($arrayfields['t.label']['checked'])) {
669  print '<td>'.dol_trunc($obj->label, 40).'</td>';
670  if (!$i) {
671  $totalarray['nbfield']++;
672  }
673  }
674 
675  // Date end period
676  if (!empty($arrayfields['t.datev']['checked'])) {
677  print '<td class="center">'.dol_print_date($db->jdate($obj->datev), 'day').'</td>';
678  if (!$i) {
679  $totalarray['nbfield']++;
680  }
681  }
682 
683  // Date payment
684  /*if // Buttons
685  if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
686  print '<td></td>';
687  }(!empty($arrayfields['t.datep']['checked'])) {
688  print '<td class="center">'.dol_print_date($db->jdate($obj->datep), 'day').'</td>';
689  if (!$i) $totalarray['nbfield']++;
690  }*/
691 
692  // Type
693  if (!empty($arrayfields['t.fk_typepayment']['checked'])) {
694  print '<td>';
695  if (!empty($obj->payment_code)) {
696  print $langs->trans("PaymentTypeShort".$obj->payment_code);
697  }
698  print '</td>';
699  if (!$i) {
700  $totalarray['nbfield']++;
701  }
702  }
703 
704  // Account
705  if (!empty($arrayfields['t.fk_account']['checked'])) {
706  print '<td>';
707  if ($obj->fk_account > 0) {
708  $bankstatic->id = $obj->fk_account;
709  $bankstatic->ref = $obj->bref;
710  $bankstatic->number = $obj->bnumber;
711  $bankstatic->iban = $obj->iban;
712  $bankstatic->bic = $obj->bic;
713  $bankstatic->currency_code = $langs->trans("Currency".$obj->currency_code);
714  $bankstatic->account_number = $obj->account_number;
715  $bankstatic->clos = $obj->clos;
716 
717  //$accountingjournal->fetch($obj->fk_accountancy_journal);
718  //$bankstatic->accountancy_journal = $accountingjournal->getNomUrl(0, 1, 1, '', 1);
719 
720  $bankstatic->label = $obj->blabel;
721  print $bankstatic->getNomUrl(1);
722  }
723  print '</td>';
724  if (!$i) {
725  $totalarray['nbfield']++;
726  }
727  }
728 
729  // Amount
730  if (!empty($arrayfields['t.amount']['checked'])) {
731  print '<td class="nowrap right"><span class="amount">' . price($obj->amount) . '</span></td>';
732  if (!$i) {
733  $totalarray['nbfield']++;
734  }
735  $totalarray['pos'][$totalarray['nbfield']] = 'amount';
736  if (empty($totalarray['val']['amount'])) {
737  $totalarray['val']['amount'] = $obj->amount;
738  } else {
739  $totalarray['val']['amount'] += $obj->amount;
740  }
741  }
742 
743  if (!empty($arrayfields['t.datec']['checked'])) {
744  print '<td class="center">'.dol_print_date($db->jdate($obj->datec), 'day').'</td>';
745  if (!$i) {
746  $totalarray['nbfield']++;
747  }
748  }
749 
750  if (!empty($arrayfields['t.status']['checked'])) {
751  print '<td class="nowrap right">' . $tva_static->getLibStatut(5, $obj->alreadypayed) . '</td>';
752  if (!$i) {
753  $totalarray['nbfield']++;
754  }
755  if (!empty($arrayfields['t.amount']['checked'])) {
756  $totalarray['pos'][$totalarray['nbfield']] = '';
757  }
758  }
759 
760  // Action column
761  if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
762  print '<td class="nowrap center">';
763  if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
764  $selected = 0;
765  if (in_array($object->id, $arrayofselected)) {
766  $selected = 1;
767  }
768  print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
769  }
770  print '</td>';
771  if (!$i) {
772  $totalarray['nbfield']++;
773  }
774  }
775 
776  print '</tr>'."\n";
777  }
778 
779  $i++;
780 }
781 
782 // Show total line
783 include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
784 
785 // If no record found
786 if ($num == 0) {
787  $colspan = 1;
788  foreach ($arrayfields as $key => $val) {
789  if (!empty($val['checked'])) {
790  $colspan++;
791  }
792  }
793  print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
794 }
795 
796 $db->free($resql);
797 
798 $parameters = array('arrayfields' => $arrayfields, 'sql' => $sql);
799 $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
800 print $hookmanager->resPrint;
801 
802 print '</table>'."\n";
803 print '</div>'."\n";
804 
805 print '</form>'."\n";
806 
807 // End of page
808 llxFooter();
809 $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 journals.
Class to offer components to list and upload files.
Class to manage generation of HTML components Only common components must be here.
Class permettant la generation de composants html autre Only common components are here.
Put here description of your class.
Definition: tva.class.php:37
if(isModEnabled('invoice') && $user->hasRight('facture', 'lire')) if((isModEnabled('fournisseur') &&!getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD') && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') && $user->hasRight('don', 'lire')) if(isModEnabled('tax') && $user->hasRight('tax', 'charges', 'lire')) if(isModEnabled('invoice') &&isModEnabled('order') && $user->hasRight("commande", "lire") &&!getDolGlobalString('WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER')) $sql
Social contributions to pay.
Definition: index.php:745
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...
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
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...
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
dol_now($mode='auto')
Return date for now.
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_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
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.