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