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