dolibarr 19.0.3
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
30require '../../main.inc.php';
31
32require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php';
33require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
34require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
35require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
36require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
37require_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');
70if (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
78if (!$sortfield) {
79 $sortfield = 't.datev';
80}
81if (!$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
94if (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');
109if ($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
121if ($reshook < 0) {
122 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
123}
124
125
126if (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
187if (!empty($search_ref)) {
188 $sql .= natural_search('t.rowid', $search_ref);
189}
190if (!empty($search_label)) {
191 $sql .= natural_search('t.label', $search_label);
192}
193if (!empty($search_dateend_start)) {
194 $sql .= " AND t.datev >= '".$db->idate($search_dateend_start)."'";
195}
196if (!empty($search_dateend_end)) {
197 $sql .= " AND t.datev <= '".$db->idate($search_dateend_end)."'";
198}
199if (!empty($search_datepayment_start)) {
200 $sql .= " AND t.datep >= '".$db->idate($search_datepayment_start)."'";
201}
202if (!empty($search_datepayment_end)) {
203 $sql .= " AND t.datep <= '".$db->idate($search_datepayment_end)."'";
204}
205if (!empty($search_type) && $search_type > 0) {
206 $sql .= ' AND t.fk_typepayment = '.((int) $search_type);
207}
208if (!empty($search_account) && $search_account > 0) {
209 $sql .= ' AND t.fk_account = '.((int) $search_account);
210}
211if (!empty($search_amount)) {
212 $sql .= natural_search('t.amount', price2num(trim($search_amount)), 1);
213}
214if ($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 = '';
222if (!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);
243if ($limit) {
244 $sql .= $db->plimit($limit + 1, $offset);
245}
246
247$resql = $db->query($sql);
248if (!$resql) {
249 dol_print_error($db);
250 exit;
251}
252
253$num = $db->num_rows($resql);
254
255
256// Output page
257// --------------------------------------------------------------------
258
259llxHeader('', $title, $help_url);
260
261$arrayofselected = is_array($toselect) ? $toselect : array();
262
263$param = '';
264if (!empty($mode)) {
265 $param .= '&mode='.urlencode($mode);
266}
267if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
268 $param .= '&contextpage='.urlencode($contextpage);
269}
270if ($limit > 0 && $limit != $conf->liste_limit) {
271 $param .= '&limit='.((int) $limit);
272}
273if ($optioncss != '') {
274 $param .= '&optioncss='.urlencode($optioncss);
275}
276
277if (!empty($search_ref)) {
278 $param .= '&search_ref="'.$search_ref.'"';
279}
280if (!empty($search_label)) {
281 $param .= '&search_label="'.$search_label.'"';
282}
283if (!empty($search_dateend_start)) {
284 $param .= '&search_dateend_startyear='.GETPOST('search_dateend_startyear', 'int');
285}
286if (!empty($search_dateend_start)) {
287 $param .= '&search_dateend_startmonth='.GETPOST('search_dateend_startmonth', 'int');
288}
289if (!empty($search_dateend_start)) {
290 $param .= '&search_dateend_startday='.GETPOST('search_dateend_startday', 'int');
291}
292if (!empty($search_dateend_end)) {
293 $param .= '&search_dateend_endyear='.GETPOST('search_dateend_endyear', 'int');
294}
295if (!empty($search_dateend_end)) {
296 $param .= '&search_dateend_endmonth='.GETPOST('search_dateend_endmonth', 'int');
297}
298if (!empty($search_dateend_end)) {
299 $param .= '&search_dateend_endday='.GETPOST('search_dateend_endday', 'int');
300}
301if (!empty($search_datepayment_start)) {
302 $param .= '&search_datepayment_startyear='.GETPOST('search_datepayment_startyear', 'int');
303}
304if (!empty($search_datepayment_start)) {
305 $param .= '&search_datepayment_startmonth='.GETPOST('search_datepayment_startmonth', 'int');
306}
307if (!empty($search_datepayment_start)) {
308 $param .= '&search_datepayment_startday='.GETPOST('search_datepayment_startday', 'int');
309}
310if (!empty($search_datepayment_end)) {
311 $param .= '&search_datepayment_endyear='.GETPOST('search_datepayment_endyear', 'int');
312}
313if (!empty($search_datepayment_end)) {
314 $param .= '&search_datepayment_endmonth='.GETPOST('search_datepayment_endmonth', 'int');
315}
316if (!empty($search_datepayment_end)) {
317 $param .= '&search_datepayment_endday='.GETPOST('search_datepayment_endday', 'int');
318}
319if (!empty($search_type) && $search_type > 0) {
320 $param .= '&search_type='.$search_type;
321}
322if (!empty($search_account) && $search_account > 0) {
323 $param .= '&search_account='.$search_account;
324}
325if (!empty($search_amount)) {
326 $param .= '&search_amount="'.$search_amount.'"';
327}
328if ($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);
337if (!empty($permissiontodelete)) {
338 $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
339}
340$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
341
342$moreforfilter = '';
343
344print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
345if ($optioncss != '') {
346 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
347}
348print '<input type="hidden" name="token" value="'.newToken().'">';
349print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
350print '<input type="hidden" name="action" value="list">';
351print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
352print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
353print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
354print '<input type="hidden" name="page" value="'.$page.'">';
355print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
356print '<input type="hidden" name="page_y" value="">';
357print '<input type="hidden" name="mode" value="'.$mode.'">';
358
359$url = DOL_URL_ROOT.'/compta/tva/card.php?action=create';
360if (!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
369print_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;
376include 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
380if ($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
388if (empty($reshook)) {
389 $moreforfilter .= $hookmanager->resPrint;
390} else {
391 $moreforfilter = $hookmanager->resPrint;
392}
393
394if (!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
407print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
408print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
409
410// Fields title search
411// --------------------------------------------------------------------
412print '<tr class="liste_titre_filter">';
413// Action column
414if (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)
422if (getDolGlobalString('MAIN_VIEW_LINE_NUMBER_IN_LIST')) {
423 print '<td class="liste_titre">';
424 print '</td>';
425}
426
427// Filter: Ref
428if (!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
435if (!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
442if (!empty($arrayfields['t.datev']['checked'])) {
443 print '<td class="liste_titre center">';
444 print '<div class="nowrapfordate">';
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="nowrapfordate">';
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="nowrapfordate">';
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="nowrapfordate">';
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
466if (!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
473if (!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
480if (!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
487if (!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
495include 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
500print $hookmanager->resPrint;
501
502// Action column
503if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
504 print '<td class="liste_titre center maxwidthsearch">';
505 $searchpicto = $form->showFilterButtons();
506 print $searchpicto;
507 print '</td>';
508}
509print '</tr>'."\n";
510
511$totalarray = array();
512$totalarray['nbfield'] = 0;
513
514// Fields title label
515// --------------------------------------------------------------------
516print '<tr class="liste_titre">';
517if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
518 print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
519 $totalarray['nbfield']++;
520}
521if (getDolGlobalString('MAIN_VIEW_LINE_NUMBER_IN_LIST')) {
522 print_liste_field_titre('#', $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder);
523 $totalarray['nbfield']++;
524}
525if (!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}
529if (!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}
533if (!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}
537if (!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}
541if (!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}
545if (!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}
549if (!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
554include 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
558print $hookmanager->resPrint;
559
560// Action column
561if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
562 print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
563 $totalarray['nbfield']++;
564}
565print '</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);
574while ($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 $selected = -1;
597 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
598 $selected = 0;
599 if (in_array($object->id, $arrayofselected)) {
600 $selected = 1;
601 }
602 }
603 print $object->getKanbanView('', array('selected' => $selected));
604 if ($i == ($imaxinloop - 1)) {
605 print '</div>';
606 print '</td></tr>';
607 }
608 } else {
609 // Show here line of result
610 $j = 0;
611 print '<tr data-rowid="'.$object->id.'" class="oddeven">';
612 // Action column
613 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
614 print '<td class="nowrap center">';
615 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
616 $selected = 0;
617 if (in_array($object->id, $arrayofselected)) {
618 $selected = 1;
619 }
620 print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
621 }
622 print '</td>';
623 if (!$i) {
624 $totalarray['nbfield']++;
625 }
626 }
627
628 // No
629 if (getDolGlobalString('MAIN_VIEW_LINE_NUMBER_IN_LIST')) {
630 print '<td>'.(($offset * $limit) + $i).'</td>';
631 if (!$i) {
632 $totalarray['nbfield']++;
633 }
634 }
635
636 // Ref
637 if (!empty($arrayfields['t.rowid']['checked'])) {
638 print '<td>';
639 print $tva_static->getNomUrl(1);
640 $filename = dol_sanitizeFileName($tva_static->ref);
641 $filedir = $conf->tax->dir_output.'/vat/'.dol_sanitizeFileName($tva_static->ref);
642 $urlsource = $_SERVER['PHP_SELF'].'?id='.$tva_static->id;
643 print $formfile->getDocumentsLink($tva_static->element, $filename, $filedir, '', 'valignmiddle paddingleft2imp');
644 print '</td>';
645 if (!$i) {
646 $totalarray['nbfield']++;
647 }
648 }
649
650 // Label
651 if (!empty($arrayfields['t.label']['checked'])) {
652 print '<td>'.dol_trunc($obj->label, 40).'</td>';
653 if (!$i) {
654 $totalarray['nbfield']++;
655 }
656 }
657
658 // Date end period
659 if (!empty($arrayfields['t.datev']['checked'])) {
660 print '<td class="center">'.dol_print_date($db->jdate($obj->datev), 'day').'</td>';
661 if (!$i) {
662 $totalarray['nbfield']++;
663 }
664 }
665
666 // Date payment
667 /*if // Buttons
668 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
669 print '<td></td>';
670 }(!empty($arrayfields['t.datep']['checked'])) {
671 print '<td class="center">'.dol_print_date($db->jdate($obj->datep), 'day').'</td>';
672 if (!$i) $totalarray['nbfield']++;
673 }*/
674
675 // Type
676 if (!empty($arrayfields['t.fk_typepayment']['checked'])) {
677 print '<td>';
678 if (!empty($obj->payment_code)) {
679 print $langs->trans("PaymentTypeShort".$obj->payment_code);
680 }
681 print '</td>';
682 if (!$i) {
683 $totalarray['nbfield']++;
684 }
685 }
686
687 // Account
688 if (!empty($arrayfields['t.fk_account']['checked'])) {
689 print '<td>';
690 if ($obj->fk_account > 0) {
691 $bankstatic->id = $obj->fk_account;
692 $bankstatic->ref = $obj->bref;
693 $bankstatic->number = $obj->bnumber;
694 $bankstatic->iban = $obj->iban;
695 $bankstatic->bic = $obj->bic;
696 $bankstatic->currency_code = $langs->trans("Currency".$obj->currency_code);
697 $bankstatic->account_number = $obj->account_number;
698 $bankstatic->clos = $obj->clos;
699
700 //$accountingjournal->fetch($obj->fk_accountancy_journal);
701 //$bankstatic->accountancy_journal = $accountingjournal->getNomUrl(0, 1, 1, '', 1);
702
703 $bankstatic->label = $obj->blabel;
704 print $bankstatic->getNomUrl(1);
705 }
706 print '</td>';
707 if (!$i) {
708 $totalarray['nbfield']++;
709 }
710 }
711
712 // Amount
713 if (!empty($arrayfields['t.amount']['checked'])) {
714 print '<td class="nowrap right"><span class="amount">' . price($obj->amount) . '</span></td>';
715 if (!$i) {
716 $totalarray['nbfield']++;
717 }
718 $totalarray['pos'][$totalarray['nbfield']] = 'amount';
719 if (empty($totalarray['val']['amount'])) {
720 $totalarray['val']['amount'] = $obj->amount;
721 } else {
722 $totalarray['val']['amount'] += $obj->amount;
723 }
724 }
725
726 if (!empty($arrayfields['t.status']['checked'])) {
727 $totalallpayments = $obj->alreadypayed;
728 print '<td class="nowrap right">' . $tva_static->getLibStatut(5, $totalallpayments) . '</td>';
729 if (!$i) {
730 $totalarray['nbfield']++;
731 }
732 if (!empty($arrayfields['t.amount']['checked'])) {
733 $totalarray['pos'][$totalarray['nbfield']] = '';
734 }
735 }
736
737 // Action column
738 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
739 print '<td class="nowrap center">';
740 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
741 $selected = 0;
742 if (in_array($object->id, $arrayofselected)) {
743 $selected = 1;
744 }
745 print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
746 }
747 print '</td>';
748 if (!$i) {
749 $totalarray['nbfield']++;
750 }
751 }
752
753 print '</tr>'."\n";
754 }
755
756 $i++;
757}
758
759// Show total line
760include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
761
762// If no record found
763if ($num == 0) {
764 $colspan = 1;
765 foreach ($arrayfields as $key => $val) {
766 if (!empty($val['checked'])) {
767 $colspan++;
768 }
769 }
770 print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
771}
772
773$db->free($resql);
774
775$parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql);
776$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
777print $hookmanager->resPrint;
778
779print '</table>'."\n";
780print '</div>'."\n";
781
782print '</form>'."\n";
783
784// End of page
785llxFooter();
786$db->close();
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Definition wrapper.php:55
llxFooter()
Empty footer.
Definition wrapper.php:69
Class to manage bank accounts.
Class to manage bank transaction lines.
Class to manage accounting journals.
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
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 a 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.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.