dolibarr  17.0.4
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  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 3 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program. If not, see <https://www.gnu.org/licenses/>.
21  */
22 
29 // Load Dolibarr environment
30 require '../../main.inc.php';
31 
32 require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php';
33 require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
34 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
35 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
36 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
37 require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php';
38 
39 // Load translation files required by the page
40 $langs->loadLangs(array('compta', 'bills'));
41 
42 $action = GETPOST('action', 'alpha');
43 $massaction = GETPOST('massaction', 'alpha');
44 $confirm = GETPOST('confirm', 'alpha');
45 $optioncss = GETPOST('optioncss', 'alpha');
46 $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'salestaxeslist';
47 
48 $search_ref = GETPOST('search_ref', 'alpha');
49 $search_label = GETPOST('search_label', 'alpha');
50 $search_dateend_start = dol_mktime(0, 0, 0, GETPOST('search_dateend_startmonth', 'int'), GETPOST('search_dateend_startday', 'int'), GETPOST('search_dateend_startyear', 'int'));
51 $search_dateend_end = dol_mktime(23, 59, 59, GETPOST('search_dateend_endmonth', 'int'), GETPOST('search_dateend_endday', 'int'), GETPOST('search_dateend_endyear', 'int'));
52 $search_datepayment_start = dol_mktime(0, 0, 0, GETPOST('search_datepayment_startmonth', 'int'), GETPOST('search_datepayment_startday', 'int'), GETPOST('search_datepayment_startyear', 'int'));
53 $search_datepayment_end = dol_mktime(23, 59, 59, GETPOST('search_datepayment_endmonth', 'int'), GETPOST('search_datepayment_endday', 'int'), GETPOST('search_datepayment_endyear', 'int'));
54 $search_type = GETPOST('search_type', 'int');
55 $search_account = GETPOST('search_account', 'int');
56 $search_amount = GETPOST('search_amount', 'alpha');
57 $search_status = GETPOST('search_status', 'int');
58 $ltt = GETPOST("ltt", "int");
59 
60 $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
61 $sortfield = GETPOST('sortfield', 'aZ09comma');
62 $sortorder = GETPOST('sortorder', 'aZ09comma');
63 $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST('page', 'int');
64 
65 if (empty($page) || $page == -1) {
66  $page = 0; // If $page is not defined, or '' or -1
67 }
68 $offset = $limit * $page;
69 $pageprev = $page - 1;
70 $pagenext = $page + 1;
71 
72 if (!$sortfield) {
73  $sortfield = 't.datev';
74 }
75 if (!$sortorder) {
76  $sortorder = 'DESC';
77 }
78 
79 $arrayfields = array(
80  't.rowid' =>array('checked'=>1, 'position'=>10, 'label'=>"Ref",),
81  't.label' =>array('checked'=>1, 'position'=>20, 'label'=>"Label"),
82  't.datev' =>array('checked'=>1, 'position'=>30, 'label'=>"PeriodEndDate"),
83  't.fk_typepayment' =>array('checked'=>1, 'position'=>50, 'label'=>"DefaultPaymentMode"),
84  't.amount' =>array('checked'=>1, 'position'=>90, 'label'=>"Amount"),
85  't.status' =>array('checked'=>1, 'position'=>90, 'label'=>"Status"),
86 );
87 
88 if (isModEnabled("banque")) {
89  $arrayfields['t.fk_account'] = array('checked'=>1, 'position'=>60, 'label'=>"DefaultBankAccount");
90 }
91 
92 $arrayfields = dol_sort_array($arrayfields, 'position');
93 
94 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
95 $hookmanager->initHooks(array('salestaxeslist'));
96 $object = new Tva($db);
97 
98 // Security check
99 $socid = GETPOST('socid', 'int');
100 if ($user->socid) {
101  $socid = $user->socid;
102 }
103 $result = restrictedArea($user, 'tax', '', 'tva', 'charges');
104 
105 
106 /*
107  * Actions
108  */
109 
110 $parameters = array('socid'=>$socid);
111 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
112 if ($reshook < 0) {
113  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
114 }
115 
116 
117 if (empty($reshook)) {
118  include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
119 
120  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
121  $search_ref = '';
122  $search_label = '';
123  $search_dateend_start = '';
124  $search_dateend_end = '';
125  $search_datepayment_start = '';
126  $search_datepayment_end = '';
127  $search_type = '';
128  $search_account = '';
129  $search_amount = '';
130  $search_status = '';
131  }
132 }
133 
134 
135 /*
136  * View
137  */
138 
139 $form = new Form($db);
140 $formother = new FormOther($db);
141 $formfile = new FormFile($db);
142 $tva_static = new Tva($db);
143 $bankstatic = new Account($db);
144 $accountingjournal = new AccountingJournal($db);
145 $bankline = new AccountLine($db);
146 
147 llxHeader('', $langs->trans("VATDeclarations"));
148 
149 $sql = 'SELECT t.rowid, t.amount, t.label, t.datev, t.datep, t.paye, t.fk_typepayment as type, t.fk_account,';
150 $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,';
151 $sql.= ' t.num_payment, pst.code as payment_code,';
152 $sql .= ' SUM(ptva.amount) as alreadypayed';
153 
154 $sqlfields = $sql; // $sql fields to remove for count total
155 
156 $sql .= ' FROM '.MAIN_DB_PREFIX.'tva as t';
157 $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as pst ON (t.fk_typepayment = pst.id)';
158 $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank_account as ba ON (t.fk_account = ba.rowid)';
159 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."payment_vat as ptva ON (ptva.fk_tva = t.rowid)";
160 $sql .= ' WHERE t.entity IN ('.getEntity($object->element).')';
161 
162 if (!empty($search_ref)) {
163  $sql .= natural_search('t.rowid', $search_ref);
164 }
165 if (!empty($search_label)) {
166  $sql .= natural_search('t.label', $search_label);
167 }
168 if (!empty($search_dateend_start)) {
169  $sql .= " AND t.datev >= '".$db->idate($search_dateend_start)."'";
170 }
171 if (!empty($search_dateend_end)) {
172  $sql .= " AND t.datev <= '".$db->idate($search_dateend_end)."'";
173 }
174 if (!empty($search_datepayment_start)) {
175  $sql .= " AND t.datep >= '".$db->idate($search_datepayment_start)."'";
176 }
177 if (!empty($search_datepayment_end)) {
178  $sql .= " AND t.datep <= '".$db->idate($search_datepayment_end)."'";
179 }
180 if (!empty($search_type) && $search_type > 0) {
181  $sql .= ' AND t.fk_typepayment = '.((int) $search_type);
182 }
183 if (!empty($search_account) && $search_account > 0) {
184  $sql .= ' AND t.fk_account = '.((int) $search_account);
185 }
186 if (!empty($search_amount)) {
187  $sql .= natural_search('t.amount', price2num(trim($search_amount)), 1);
188 }
189 if ($search_status != '' && $search_status >= 0) {
190  $sql .= " AND t.paye = ".((int) $search_status);
191 }
192 
193 $sql .= " GROUP BY t.rowid, t.amount, t.label, t.datev, t.datep, t.paye, t.fk_typepayment, t.fk_account, ba.label, ba.ref, ba.number, ba.account_number, ba.iban_prefix, ba.bic, ba.currency_code, ba.clos, t.num_payment, pst.code";
194 
195 // Count total nb of records
196 $nbtotalofrecords = '';
197 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
198  /* The fast and low memory method to get and count full list converts the sql into a sql count */
199  $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql);
200  $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount);
201  $resql = $db->query($sqlforcount);
202  if ($resql) {
203  $objforcount = $db->fetch_object($resql);
204  $nbtotalofrecords = $objforcount->nbtotalofrecords;
205  } else {
206  dol_print_error($db);
207  }
208 
209  if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
210  $page = 0;
211  $offset = 0;
212  }
213  $db->free($resql);
214 }
215 
216 // Complete request and execute it with limit
217 $sql .= $db->order($sortfield, $sortorder);
218 if ($limit) {
219  $sql .= $db->plimit($limit + 1, $offset);
220 }
221 
222 $resql = $db->query($sql);
223 if (!$resql) {
224  dol_print_error($db);
225  llxFooter();
226  $db->close();
227  exit;
228 }
229 
230 $num = $db->num_rows($resql);
231 
232 $param = '';
233 if (!empty($contextpage) && $contextpage != $_SERVER['PHP_SELF']) {
234  $param .= '&contextpage='.$contextpage;
235 }
236 if ($limit > 0 && $limit != $conf->liste_limit) {
237  $param .= '&limit='.$limit;
238 }
239 if ($optioncss != '') {
240  $param .= '&optioncss='.urlencode($optioncss);
241 }
242 
243 if (!empty($search_ref)) {
244  $param .= '&search_ref="'.$search_ref.'"';
245 }
246 if (!empty($search_label)) {
247  $param .= '&search_label="'.$search_label.'"';
248 }
249 if (!empty($search_dateend_start)) {
250  $param .= '&search_dateend_startyear='.GETPOST('search_dateend_startyear', 'int');
251 }
252 if (!empty($search_dateend_start)) {
253  $param .= '&search_dateend_startmonth='.GETPOST('search_dateend_startmonth', 'int');
254 }
255 if (!empty($search_dateend_start)) {
256  $param .= '&search_dateend_startday='.GETPOST('search_dateend_startday', 'int');
257 }
258 if (!empty($search_dateend_end)) {
259  $param .= '&search_dateend_endyear='.GETPOST('search_dateend_endyear', 'int');
260 }
261 if (!empty($search_dateend_end)) {
262  $param .= '&search_dateend_endmonth='.GETPOST('search_dateend_endmonth', 'int');
263 }
264 if (!empty($search_dateend_end)) {
265  $param .= '&search_dateend_endday='.GETPOST('search_dateend_endday', 'int');
266 }
267 if (!empty($search_datepayment_start)) {
268  $param .= '&search_datepayment_startyear='.GETPOST('search_datepayment_startyear', 'int');
269 }
270 if (!empty($search_datepayment_start)) {
271  $param .= '&search_datepayment_startmonth='.GETPOST('search_datepayment_startmonth', 'int');
272 }
273 if (!empty($search_datepayment_start)) {
274  $param .= '&search_datepayment_startday='.GETPOST('search_datepayment_startday', 'int');
275 }
276 if (!empty($search_datepayment_end)) {
277  $param .= '&search_datepayment_endyear='.GETPOST('search_datepayment_endyear', 'int');
278 }
279 if (!empty($search_datepayment_end)) {
280  $param .= '&search_datepayment_endmonth='.GETPOST('search_datepayment_endmonth', 'int');
281 }
282 if (!empty($search_datepayment_end)) {
283  $param .= '&search_datepayment_endday='.GETPOST('search_datepayment_endday', 'int');
284 }
285 if (!empty($search_type) && $search_type > 0) {
286  $param .= '&search_type='.$search_type;
287 }
288 if (!empty($search_account) && $search_account > 0) {
289  $param .= '&search_account='.$search_account;
290 }
291 if (!empty($search_amount)) {
292  $param .= '&search_amount="'.$search_amount.'"';
293 }
294 if ($search_status != '' && $search_status != '-1') {
295  $param .= '&search_status='.urlencode($search_status);
296 }
297 $arrayofmassactions = array(
298  //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
299  //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
300 );
301 $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
302 
303 $moreforfilter = '';
304 
305 print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
306 if ($optioncss != '') {
307  print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
308 }
309 print '<input type="hidden" name="token" value="'.newToken().'">';
310 print '<input type="hidden" name="action" value="list">';
311 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
312 print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
313 print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
314 print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
315 
316 $url = DOL_URL_ROOT.'/compta/tva/card.php?action=create';
317 if (!empty($socid)) {
318  $url .= '&socid='.$socid;
319 }
320 $newcardbutton = dolGetButtonTitle($langs->trans('NewVATPayment'), '', 'fa fa-plus-circle', $url, '', $user->rights->tax->charges->creer);
321 print_barre_liste($langs->trans("VATDeclarations"), $page, $_SERVER['PHP_SELF'], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_accountancy', 0, $newcardbutton, '', $limit, 0, 0, 1);
322 
323 $varpage = empty($contextpage) ? $_SERVER['PHP_SELF'] : $contextpage;
324 $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
325 if ($massactionbutton) {
326  $selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
327 }
328 
329 print '<div class="div-table-responsive">';
330 print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : '').'">';
331 
332 print '<tr class="liste_titre_filter">';
333 
334 // Filters: Lines (placeholder)
335 if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) {
336  print '<td class="liste_titre">';
337  print '</td>';
338 }
339 
340 // Filter: Ref
341 if (!empty($arrayfields['t.rowid']['checked'])) {
342  print '<td class="liste_titre">';
343  print '<input type="text" class="flat" size="4" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
344  print '</td>';
345 }
346 
347 // Filter: Label
348 if (!empty($arrayfields['t.label']['checked'])) {
349  print '<td class="liste_titre">';
350  print '<input type="text" class="flat" size="10" name="search_label" value="'.dol_escape_htmltag($search_label).'">';
351  print '</td>';
352 }
353 
354 // Filter: Date end period
355 if (!empty($arrayfields['t.datev']['checked'])) {
356  print '<td class="liste_titre center">';
357  print '<div class="nowrap">';
358  print $form->selectDate($search_dateend_start ? $search_dateend_start : -1, 'search_dateend_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"));
359  print '</div>';
360  print '<div class="nowrap">';
361  print $form->selectDate($search_dateend_end ? $search_dateend_end : -1, 'search_dateend_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to"));
362  print '</div>';
363  print '</td>';
364 }
365 
366 // Filter: Date payment
367 /*if (!empty($arrayfields['t.datep']['checked'])) {
368  print '<td class="liste_titre center">';
369  print '<div class="nowrap">';
370  print $form->selectDate($search_datepayment_start ? $search_datepayment_start : -1, 'search_datepayment_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"));
371  print '</div>';
372  print '<div class="nowrap">';
373  print $form->selectDate($search_datepayment_end ? $search_datepayment_end : -1, 'search_datepayment_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to"));
374  print '</div>';
375  print '</td>';
376 }*/
377 
378 // Filter: Type
379 if (!empty($arrayfields['t.fk_typepayment']['checked'])) {
380  print '<td class="liste_titre left">';
381  print $form->select_types_paiements($search_type, 'search_type', '', 0, 1, 1, 16, 1, '', 1);
382  print '</td>';
383 }
384 
385 // Filter: Bank Account
386 if (!empty($arrayfields['t.fk_account']['checked'])) {
387  print '<td class="liste_titre left">';
388  $form->select_comptes($search_account, 'search_account', 0, '', 1);
389  print '</td>';
390 }
391 
392 // Filter: Amount
393 if (!empty($arrayfields['t.amount']['checked'])) {
394  print '<td class="liste_titre right">';
395  print '<input name="search_amount" class="flat" type="text" size="8" value="'.$search_amount.'">';
396  print '</td>';
397 }
398 
399 // Status
400 if (!empty($arrayfields['t.status']['checked'])) {
401  print '<td class="liste_titre maxwidthonsmartphone right">';
402  $liststatus = array('0' => $langs->trans("Unpaid"), '1' => $langs->trans("Paid"));
403  print $form->selectarray('search_status', $liststatus, $search_status, 1, 0, 0, '', 0, 0, 0, '', 'onrightofpage');
404  print '</td>';
405 }
406 
407 // Fields from hook
408 $parameters = array('arrayfields'=>$arrayfields);
409 $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
410 print $hookmanager->resPrint;
411 
412 // Filter: Buttons
413 print '<td class="liste_titre maxwidthsearch">';
414 print $form->showFilterAndCheckAddButtons(0);
415 print '</td>';
416 
417 print '</tr>';
418 
419 print '<tr class="liste_titre">';
420 if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) {
421  print_liste_field_titre('#', $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder);
422 }
423 if (!empty($arrayfields['t.rowid']['checked'])) {
424  print_liste_field_titre($arrayfields['t.rowid']['label'], $_SERVER['PHP_SELF'], 't.rowid', '', $param, '', $sortfield, $sortorder);
425 }
426 if (!empty($arrayfields['t.label']['checked'])) {
427  print_liste_field_titre($arrayfields['t.label']['label'], $_SERVER['PHP_SELF'], 't.label', '', $param, 'align="left"', $sortfield, $sortorder);
428 }
429 if (!empty($arrayfields['t.datev']['checked'])) {
430  print_liste_field_titre($arrayfields['t.datev']['label'], $_SERVER['PHP_SELF'], 't.datev', '', $param, 'align="center"', $sortfield, $sortorder);
431 }
432 if (!empty($arrayfields['t.fk_typepayment']['checked'])) {
433  print_liste_field_titre($arrayfields['t.fk_typepayment']['label'], $_SERVER['PHP_SELF'], 't.fk_typepayment', '', $param, '', $sortfield, $sortorder, 'left ');
434 }
435 if (!empty($arrayfields['t.fk_account']['checked'])) {
436  print_liste_field_titre($arrayfields['t.fk_account']['label'], $_SERVER['PHP_SELF'], 't.fk_account', '', $param, '', $sortfield, $sortorder, 'left ');
437 }
438 if (!empty($arrayfields['t.amount']['checked'])) {
439  print_liste_field_titre($arrayfields['t.amount']['label'], $_SERVER['PHP_SELF'], 't.amount', '', $param, '', $sortfield, $sortorder, 'right ');
440 }
441 if (!empty($arrayfields['t.status']['checked'])) {
442  print_liste_field_titre($arrayfields['t.status']['label'], $_SERVER["PHP_SELF"], "t.paye", "", $param, 'class="right"', $sortfield, $sortorder);
443 }
444 
445 // Hook fields
446 $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
447 $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
448 print $hookmanager->resPrint;
449 
450 print_liste_field_titre($selectedfields, $_SERVER['PHP_SELF'], '', '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ');
451 print '</tr>';
452 
453 $i = 0;
454 $totalarray = array();
455 $totalarray['nbfield'] = 0;
456 $total = 0;
457 
458 while ($i < min($num, $limit)) {
459  $obj = $db->fetch_object($resql);
460 
461  $tva_static->id = $obj->rowid;
462  $tva_static->ref = $obj->rowid;
463  $tva_static->label = $obj->label;
464 
465  print '<tr class="oddeven">';
466 
467  // No
468  if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) {
469  print '<td>'.(($offset * $limit) + $i).'</td>';
470  if (!$i) {
471  $totalarray['nbfield']++;
472  }
473  }
474 
475  // Ref
476  if (!empty($arrayfields['t.rowid']['checked'])) {
477  print '<td>';
478  print $tva_static->getNomUrl(1);
479  $filename = dol_sanitizeFileName($tva_static->ref);
480  $filedir = $conf->tax->dir_output.'/vat/'.dol_sanitizeFileName($tva_static->ref);
481  $urlsource = $_SERVER['PHP_SELF'].'?id='.$tva_static->id;
482  print $formfile->getDocumentsLink($tva_static->element, $filename, $filedir, '', 'valignmiddle paddingleft2imp');
483  print '</td>';
484  if (!$i) {
485  $totalarray['nbfield']++;
486  }
487  }
488 
489  // Label
490  if (!empty($arrayfields['t.label']['checked'])) {
491  print '<td>'.dol_trunc($obj->label, 40).'</td>';
492  if (!$i) {
493  $totalarray['nbfield']++;
494  }
495  }
496 
497  // Date end period
498  if (!empty($arrayfields['t.datev']['checked'])) {
499  print '<td class="center">'.dol_print_date($db->jdate($obj->datev), 'day').'</td>';
500  if (!$i) {
501  $totalarray['nbfield']++;
502  }
503  }
504 
505  // Date payment
506  /*if (!empty($arrayfields['t.datep']['checked'])) {
507  print '<td class="center">'.dol_print_date($db->jdate($obj->datep), 'day').'</td>';
508  if (!$i) $totalarray['nbfield']++;
509  }*/
510 
511  // Type
512  if (!empty($arrayfields['t.fk_typepayment']['checked'])) {
513  print '<td>';
514  if (!empty($obj->payment_code)) print $langs->trans("PaymentTypeShort".$obj->payment_code);
515  print '</td>';
516  if (!$i) {
517  $totalarray['nbfield']++;
518  }
519  }
520 
521  // Account
522  if (!empty($arrayfields['t.fk_account']['checked'])) {
523  print '<td>';
524  if ($obj->fk_account > 0) {
525  $bankstatic->id = $obj->fk_account;
526  $bankstatic->ref = $obj->bref;
527  $bankstatic->number = $obj->bnumber;
528  $bankstatic->iban = $obj->iban;
529  $bankstatic->bic = $obj->bic;
530  $bankstatic->currency_code = $langs->trans("Currency".$obj->currency_code);
531  $bankstatic->account_number = $obj->account_number;
532  $bankstatic->clos = $obj->clos;
533 
534  //$accountingjournal->fetch($obj->fk_accountancy_journal);
535  //$bankstatic->accountancy_journal = $accountingjournal->getNomUrl(0, 1, 1, '', 1);
536 
537  $bankstatic->label = $obj->blabel;
538  print $bankstatic->getNomUrl(1);
539  }
540  print '</td>';
541  if (!$i) $totalarray['nbfield']++;
542  }
543 
544  // Amount
545  if (!empty($arrayfields['t.amount']['checked'])) {
546  $total = $total + $obj->amount;
547  print '<td class="nowrap right"><span class="amount">' . price($obj->amount) . '</span></td>';
548  if (!$i) {
549  $totalarray['nbfield']++;
550  }
551  $totalarray['pos'][$totalarray['nbfield']] = 'amount';
552  if (empty($totalarray['val']['amount'])) {
553  $totalarray['val']['amount'] = $obj->amount;
554  } else {
555  $totalarray['val']['amount'] += $obj->amount;
556  }
557  }
558 
559  if (!empty($arrayfields['t.status']['checked'])) {
560  print '<td class="nowrap right">' . $tva_static->LibStatut($obj->paye, 5, $obj->alreadypayed) . '</td>';
561  if (!$i) {
562  $totalarray['nbfield']++;
563  }
564  if (!empty($arrayfields['t.amount']['checked'])) {
565  $totalarray['pos'][$totalarray['nbfield']] = '';
566  }
567  }
568 
569  // Buttons
570  print '<td></td>';
571 
572  print '</tr>';
573 
574  $i++;
575 }
576 
577 // Add a buttons placeholder for the total line
578 $totalarray['nbfield']++;
579 
580 // Show total line
581 include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
582 
583 // If no record found
584 if ($num == 0) {
585  $colspan = 1;
586  foreach ($arrayfields as $key => $val) {
587  if (!empty($val['checked'])) {
588  $colspan++;
589  }
590  }
591  print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
592 }
593 
594 $db->free($resql);
595 
596 $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql);
597 $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook
598 print $hookmanager->resPrint;
599 
600 print '</table>'."\n";
601 print '</div>'."\n";
602 
603 print '</form>'."\n";
604 
605 // End of page
606 llxFooter();
607 $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:56
llxFooter()
Empty footer.
Definition: wrapper.php:70
Class to manage bank accounts.
Class to manage bank transaction lines.
Class to manage accounting accounts.
Class to offer components to list and upload files.
Class to manage generation of HTML components Only common components must be here.
Classe permettant la generation de composants html autre Only common components are here.
Put here description of your class.
Definition: tva.class.php:36
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
Definition: index.php:745
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:143
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...
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
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...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
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_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.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
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.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
isModEnabled($module)
Is Dolibarr module enabled.
$nbtotalofrecords
Count total nb of records.
Definition: list.php:329
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.