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