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