dolibarr 24.0.0-beta
lines.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2013-2016 Olivier Geffroy <jeff@jeffinfo.com>
3 * Copyright (C) 2013-2024 Alexandre Spangaro <alexandre@inovea-conseil.com>
4 * Copyright (C) 2014-2015 Ari Elbaz (elarifr) <github@accedinfo.com>
5 * Copyright (C) 2013-2016 Florian Henry <florian.henry@open-concept.pro>
6 * Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
7 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 3 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 */
22
29require '../../main.inc.php';
37require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
38require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
39require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
40require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php';
41require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
42require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
43require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
44
45// Load translation files required by the page
46$langs->loadLangs(array("compta", "bills", "other", "accountancy", "trips", "productbatch", "hrm"));
47
48$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
49
50$account_parent = GETPOST('account_parent');
51$changeaccount = GETPOST('changeaccount', 'array');
52// Search Getpost
53$search_lineid = GETPOST('search_lineid', 'alpha'); // Can be '> 100'
54$search_login = GETPOST('search_login', 'alpha');
55$search_expensereport = GETPOST('search_expensereport', 'alpha');
56$search_label = GETPOST('search_label', 'alpha');
57$search_desc = GETPOST('search_desc', 'alpha');
58$search_amount = GETPOST('search_amount', 'alpha');
59$search_account = GETPOST('search_account', 'alpha');
60$search_vat = GETPOST('search_vat', 'alpha');
61$search_date_startday = GETPOSTINT('search_date_startday');
62$search_date_startmonth = GETPOSTINT('search_date_startmonth');
63$search_date_startyear = GETPOSTINT('search_date_startyear');
64$search_date_endday = GETPOSTINT('search_date_endday');
65$search_date_endmonth = GETPOSTINT('search_date_endmonth');
66$search_date_endyear = GETPOSTINT('search_date_endyear');
67$search_date_start = dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear); // Use tzserver
68$search_date_end = dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear);
69
70// Load variable for pagination
71$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : getDolGlobalString('ACCOUNTING_LIMIT_LIST_VENTILATION', $conf->liste_limit);
72$sortfield = GETPOST('sortfield', 'aZ09comma');
73$sortorder = GETPOST('sortorder', 'aZ09comma');
74$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
75if (empty($page) || $page < 0) {
76 $page = 0;
77}
78$offset = $limit * $page;
79$pageprev = $page - 1;
80$pagenext = $page + 1;
81if (!$sortfield) {
82 $sortfield = "erd.date, erd.rowid";
83}
84if (!$sortorder) {
85 if (getDolGlobalInt('ACCOUNTING_LIST_SORT_VENTILATION_DONE') > 0) {
86 $sortorder = "DESC";
87 } else {
88 $sortorder = "ASC";
89 }
90}
91
92// Security check
93if (!isModEnabled('accounting')) {
95}
96if ($user->socid > 0) {
98}
99if (!$user->hasRight('accounting', 'bind', 'write')) {
101}
102
103// Initialize technical objects
104$contextpage = 'accountancyexpensereportlines';
105$hookmanager->initHooks([$contextpage]);
106$formaccounting = new FormAccounting($db);
107
108
109$arrayfields = array(
110 'erd.rowid' => array('label' => "LineId", 'position' => 1, 'checked' => '1', 'enabled' => '1'),
111 'u.login' => array('label' => "Employees", 'position' => 1, 'checked' => '1', 'enabled' => '1'),
112 'er.ref' => array('label' => "ExpenseReport", 'position' => 1, 'checked' => '1', 'enabled' => '1'),
113 'erd.date' => array('label' => "DateOfLine", 'position' => 1, 'checked' => '1', 'enabled' => '1'),
114 'f.label' => array('label' => "TypeFees", 'position' => 1, 'checked' => '1', 'enabled' => '1'),
115 'erd.comments' => array('label' => "Description", 'position' => 1, 'checked' => '1', 'enabled' => '1'),
116 'erd.total_ht' => array('label' => "Amount", 'position' => 1, 'checked' => '1', 'enabled' => '1'),
117 'erd.tva_tx' => array('label' => "VATRate", 'position' => 1, 'checked' => '1', 'enabled' => '1'),
118 'aa.account_number' => array('label' => "AccountAccounting", 'position' => 1, 'checked' => '1', 'enabled' => '1'),
119);
120if (getDolGlobalString('ACCOUNTANCY_USE_EXPENSE_REPORT_VALIDATION_DATE')) {
121 $arrayfields['er.date_valid'] = array('label' => "DateValidation", 'position' => 1, 'checked' => '1', 'enabled' => '1');
122}
123// @phpstan-ignore-next-line
124$arrayfields = dol_sort_array($arrayfields, 'position');
125
126$object = null;
127$action = '';
128
129
130/*
131 * Actions
132 */
133
134$parameters = array('arrayfields' => &$arrayfields);
135$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
136if ($reshook < 0) {
137 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
138}
139
140if (empty($reshook)) {
141 // Selection of new fields
142 include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
143
144 // Purge search criteria
145 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
146 $search_lineid = '';
147 $search_login = '';
148 $search_expensereport = '';
149 $search_label = '';
150 $search_desc = '';
151 $search_amount = '';
152 $search_account = '';
153 $search_vat = '';
154 $search_date_startday = '';
155 $search_date_startmonth = '';
156 $search_date_startyear = '';
157 $search_date_endday = '';
158 $search_date_endmonth = '';
159 $search_date_endyear = '';
160 $search_date_start = '';
161 $search_date_end = '';
162 }
163
164 if (is_array($changeaccount) && count($changeaccount) > 0 && $user->hasRight('accounting', 'bind', 'write')) {
165 $error = 0;
166
167 if (!(GETPOSTINT('account_parent') >= 0)) {
168 $error++;
169 setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Account")), null, 'errors');
170 }
171
172 if (!$error) {
173 $db->begin();
174
175 $sql1 = "UPDATE ".MAIN_DB_PREFIX."expensereport_det as erd";
176 $sql1 .= " SET erd.fk_code_ventilation=".(GETPOSTINT('account_parent') > 0 ? GETPOSTINT('account_parent') : '0');
177 $sql1 .= ' WHERE erd.rowid IN ('.$db->sanitize(implode(',', $changeaccount)).')';
178
179 dol_syslog('accountancy/expensereport/lines.php::changeaccount sql= '.$sql1);
180 $resql1 = $db->query($sql1);
181 if (!$resql1) {
182 $error++;
183 setEventMessages($db->lasterror(), null, 'errors');
184 }
185 if (!$error) {
186 $db->commit();
187 setEventMessages($langs->trans("Save"), null, 'mesgs');
188 } else {
189 $db->rollback();
190 setEventMessages($db->lasterror(), null, 'errors');
191 }
192
193 $account_parent = ''; // Protection to avoid to mass apply it a second time
194 }
195 }
196}
197
198if (GETPOST('sortfield') == 'erd.date, erd.rowid') {
199 $value = (GETPOST('sortorder') == 'asc,asc' ? 0 : 1);
200 require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
201 $res = dolibarr_set_const($db, "ACCOUNTING_LIST_SORT_VENTILATION_DONE", $value, 'yesno', 0, '', $conf->entity);
202}
203
204
205/*
206 * View
207 */
208
209$form = new Form($db);
210$formother = new FormOther($db);
211
212$help_url = 'EN:Module_Double_Entry_Accounting|FR:Module_Comptabilit&eacute;_en_Partie_Double#Liaisons_comptables';
213
214llxHeader('', $langs->trans("ExpenseReportsVentilation").' - '.$langs->trans("Dispatched"), $help_url, '', 0, 0, '', '', '', 'mod-accountancy accountancy-expensereport page-lines');
215
216print '<script type="text/javascript">
217 $(function () {
218 $(\'#select-all\').click(function(event) {
219 // Iterate each checkbox
220 $(\':checkbox\').each(function() {
221 this.checked = true;
222 });
223 });
224 $(\'#unselect-all\').click(function(event) {
225 // Iterate each checkbox
226 $(\':checkbox\').each(function() {
227 this.checked = false;
228 });
229 });
230 });
231 </script>';
232
233/*
234 * Expense reports lines
235 */
236$sql = "SELECT er.ref, er.rowid as erid,";
237$sql .= " erd.rowid, erd.fk_c_type_fees, erd.comments, erd.total_ht, erd.fk_code_ventilation, erd.tva_tx, erd.vat_src_code, erd.date,";
238$sql .= " f.id as type_fees_id, f.code as type_fees_code, f.label as type_fees_label,";
239$sql .= " u.rowid as userid, u.login, u.lastname, u.firstname, u.email, u.gender, u.employee, u.photo, u.statut,";
240$sql .= " aa.label, aa.labelshort, aa.account_number";
241$parameters = array();
242$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
243$sql .= $hookmanager->resPrint;
244$sql .= " FROM ".MAIN_DB_PREFIX."expensereport as er";
245$sql .= " INNER JOIN ".MAIN_DB_PREFIX."expensereport_det as erd ON er.rowid = erd.fk_expensereport";
246$sql .= " INNER JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON aa.rowid = erd.fk_code_ventilation";
247$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_type_fees as f ON f.id = erd.fk_c_type_fees";
248$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid = er.fk_user_author";
249// Add table from hooks
250$parameters = array();
251$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
252$sql .= $hookmanager->resPrint;
253$sql .= " WHERE erd.fk_code_ventilation > 0";
254$sql .= " AND er.entity IN (".getEntity('expensereport', 0).")"; // We don't share object for accountancy
255$sql .= " AND er.fk_statut IN (".ExpenseReport::STATUS_APPROVED.", ".ExpenseReport::STATUS_CLOSED.")";
256// Add search filter like
257if (strlen($search_lineid)) {
258 $sql .= natural_search("erd.rowid", $search_lineid, 1);
259}
260if (strlen(trim($search_login))) {
261 $sql .= natural_search("u.login", $search_login);
262}
263if (strlen(trim($search_expensereport))) {
264 $sql .= natural_search("er.ref", $search_expensereport);
265}
266if (strlen(trim($search_label))) {
267 $sql .= natural_search("f.label", $search_label);
268}
269if (strlen(trim($search_desc))) {
270 $sql .= natural_search("erd.comments", $search_desc);
271}
272if (strlen(trim($search_amount))) {
273 $sql .= natural_search("erd.total_ht", $search_amount, 1);
274}
275if (strlen(trim($search_account))) {
276 $sql .= natural_search("aa.account_number", $search_account);
277}
278if (strlen(trim($search_vat))) {
279 $sql .= natural_search("erd.tva_tx", price2num($search_vat), 1);
280}
281if ($search_date_start) {
282 $sql .= " AND erd.date >= '".$db->idate($search_date_start)."'";
283}
284if ($search_date_end) {
285 $sql .= " AND erd.date <= '".$db->idate($search_date_end)."'";
286}
287$sql .= " AND er.entity IN (".getEntity('expensereport', 0).")"; // We don't share object for accountancy
288// Add where from hooks
289$parameters = array();
290$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook
291$sql .= $hookmanager->resPrint;
292
293$sql .= $db->order($sortfield, $sortorder);
294
295// Count total nb of records
296$nbtotalofrecords = '';
297if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
298 $result = $db->query($sql);
299 $nbtotalofrecords = $db->num_rows($result);
300 if (($page * $limit) > (int) $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
301 $page = 0;
302 $offset = 0;
303 }
304}
305
306$sql .= $db->plimit($limit + 1, $offset);
307
308dol_syslog("accountancy/expensereport/lines.php", LOG_DEBUG);
309$result = $db->query($sql);
310if ($result) {
311 $num_lines = $db->num_rows($result);
312 $i = 0;
313
314 $param = '';
315 if ($contextpage != $_SERVER["PHP_SELF"]) {
316 $param .= '&contextpage='.urlencode($contextpage);
317 }
318 if ($limit > 0 && $limit != $conf->liste_limit) {
319 $param .= '&limit='.((int) $limit);
320 }
321 if ($search_login) {
322 $param .= '&search_login='.urlencode($search_login);
323 }
324 if ($search_expensereport) {
325 $param .= "&search_expensereport=".urlencode($search_expensereport);
326 }
327 if ($search_label) {
328 $param .= "&search_label=".urlencode($search_label);
329 }
330 if ($search_desc) {
331 $param .= "&search_desc=".urlencode($search_desc);
332 }
333 if ($search_account) {
334 $param .= "&search_account=".urlencode($search_account);
335 }
336 if ($search_vat) {
337 $param .= "&search_vat=".urlencode($search_vat);
338 }
339 if ($search_date_startday) {
340 $param .= '&search_date_startday='.urlencode((string) ($search_date_startday));
341 }
342 if ($search_date_startmonth) {
343 $param .= '&search_date_startmonth='.urlencode((string) ($search_date_startmonth));
344 }
345 if ($search_date_startyear) {
346 $param .= '&search_date_startyear='.urlencode((string) ($search_date_startyear));
347 }
348 if ($search_date_endday) {
349 $param .= '&search_date_endday='.urlencode((string) ($search_date_endday));
350 }
351 if ($search_date_endmonth) {
352 $param .= '&search_date_endmonth='.urlencode((string) ($search_date_endmonth));
353 }
354 if ($search_date_endyear) {
355 $param .= '&search_date_endyear='.urlencode((string) ($search_date_endyear));
356 }
357 // Add $param from hooks
358 $parameters = array('param' => &$param);
359 $reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
360 $param .= $hookmanager->resPrint;
361
362 print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">'."\n";
363 print '<input type="hidden" name="action" value="ventil">';
364 if ($optioncss != '') {
365 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
366 }
367 print '<input type="hidden" name="token" value="'.newToken().'">';
368 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
369 print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
370 print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
371 print '<input type="hidden" name="page" value="'.$page.'">';
372
373 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
374 print_barre_liste($langs->trans("ExpenseReportLinesDone").'<br><span class="opacityhigh small">'.$langs->trans("DescVentilDoneExpenseReport").'</span>', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num_lines, $nbtotalofrecords, 'title_accountancy', 0, '', '', $limit, 0, 0, 1);
375
376 print '<br>'.$langs->trans("ChangeAccount").' <div class="inline-block paddingbottom paddingtop">';
377 print $formaccounting->select_account($account_parent, 'account_parent', 2, array(), 0, 0, 'maxwidth300 maxwidthonsmartphone valignmiddle');
378 print '<input type="submit" class="button small smallpaddingimp valignmiddle" value="'.$langs->trans("ChangeBinding").'"/></div>';
379 print '<br><br>';
380
381 $moreforfilter = '';
382
383 $varpage = $contextpage;
384 $htmlofselectarray = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, $conf->main_checkbox_left_column); // This also change content of $arrayfields with user setup
385 $selectedfields = $htmlofselectarray;
386 $selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
387
388 print '<div class="div-table-responsive">';
389 print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
390
391 print '<tr class="liste_titre_filter">';
392 // Action column
393 if ($conf->main_checkbox_left_column) {
394 print '<td class="liste_titre maxwidthsearch center actioncolumn">';
395 $searchpicto = $form->showFilterButtons('left');
396 print $searchpicto;
397 print '</td>';
398 }
399 // Line ID
400 if (!empty($arrayfields['erd.rowid']['checked'])) {
401 print '<td class="liste_titre" data-key="lineid">';
402 print '<input type="text" class="flat maxwidth40" name="search_lineid" value="'.dol_escape_htmltag($search_lineid).'">';
403 print '</td>';
404 }
405 // User
406 if (!empty($arrayfields['u.login']['checked'])) {
407 print '<td class="liste_titre"><input type="text" name="search_login" class="maxwidth50" value="'.$search_login.'"></td>';
408 }
409 // Expensereport
410 if (!empty($arrayfields['er.ref']['checked'])) {
411 print '<td><input type="text" class="flat maxwidth50" name="search_expensereport" value="'.dol_escape_htmltag($search_expensereport).'"></td>';
412 }
413 // date_valid (no search field)
414 if (!empty($arrayfields['er.date_valid']['checked'])) {
415 print '<td class="liste_titre"></td>';
416 }
417 // date
418 if (!empty($arrayfields['erd.date']['checked'])) {
419 print '<td class="liste_titre center">';
420 print '<div class="nowrapfordate">';
421 print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
422 print '</div>';
423 print '<div class="nowrapfordate">';
424 print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
425 print '</div>';
426 print '</td>';
427 }
428 if (!empty($arrayfields['f.label']['checked'])) {
429 print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_label" value="'.dol_escape_htmltag($search_label).'"></td>';
430 }
431 if (!empty($arrayfields['erd.comments']['checked'])) {
432 print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_desc" value="'.dol_escape_htmltag($search_desc).'"></td>';
433 }
434 if (!empty($arrayfields['erd.total_ht']['checked'])) {
435 print '<td class="liste_titre right"><input type="text" class="flat maxwidth50" name="search_amount" value="'.dol_escape_htmltag($search_amount).'"></td>';
436 }
437 if (!empty($arrayfields['erd.tva_tx']['checked'])) {
438 print '<td class="liste_titre center"><input type="text" class="flat maxwidth50" name="search_vat" size="1" placeholder="%" value="'.dol_escape_htmltag($search_vat).'"></td>';
439 }
440 if (!empty($arrayfields['aa.account_number']['checked'])) {
441 print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_account" value="'.dol_escape_htmltag($search_account).'"></td>';
442 }
443 // Fields from hook
444 $parameters = array('arrayfields' => $arrayfields);
445 $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
446 print $hookmanager->resPrint;
447 // Action column
448 if (!$conf->main_checkbox_left_column) {
449 print '<td class="liste_titre center maxwidthsearch actioncolumn">';
450 $searchpicto = $form->showFilterButtons();
451 print $searchpicto;
452 print '</td>';
453 }
454 print "</tr>\n";
455
456 // Fields title label
457 // --------------------------------------------------------------------
458 $totalarray = array();
459 $totalarray['nbfield'] = 0;
460
461 print '<tr class="liste_titre">';
462 // Action column
463 if ($conf->main_checkbox_left_column) {
464 print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
465 $totalarray['nbfield']++;
466 }
467 // Line ID
468 if (!empty($arrayfields['erd.rowid']['checked'])) {
469 print_liste_field_titre($arrayfields['erd.rowid']['label'], $_SERVER["PHP_SELF"], "erd.rowid", "", $param, '', $sortfield, $sortorder);
470 $totalarray['nbfield']++;
471 }
472 // User
473 if (!empty($arrayfields['u.login']['checked'])) {
474 print_liste_field_titre($arrayfields['u.login']['label'], $_SERVER['PHP_SELF'], "u.login", "", $param, '', $sortfield, $sortorder);
475 $totalarray['nbfield']++;
476 }
477 // Expensereport
478 if (!empty($arrayfields['er.ref']['checked'])) {
479 print_liste_field_titre($arrayfields['er.ref']['label'], $_SERVER["PHP_SELF"], "er.ref", "", $param, '', $sortfield, $sortorder);
480 $totalarray['nbfield']++;
481 }
482 // date_valid
483 if (!empty($arrayfields['er.date_valid']['checked'])) {
484 print_liste_field_titre($arrayfields['er.date_valid']['label'], $_SERVER["PHP_SELF"], "er.date_valid", "", $param, '', $sortfield, $sortorder, 'center ');
485 $totalarray['nbfield']++;
486 }
487 // date
488 if (!empty($arrayfields['erd.date']['checked'])) {
489 print_liste_field_titre($arrayfields['erd.date']['label'], $_SERVER["PHP_SELF"], "erd.date, erd.rowid", "", $param, '', $sortfield, $sortorder, 'center ');
490 $totalarray['nbfield']++;
491 }
492 // invoice label
493 if (!empty($arrayfields['f.label']['checked'])) {
494 print_liste_field_titre($arrayfields['f.label']['label'], $_SERVER["PHP_SELF"], "f.label", "", $param, '', $sortfield, $sortorder);
495 $totalarray['nbfield']++;
496 }
497 // expensereport description
498 if (!empty($arrayfields['erd.comments']['checked'])) {
499 print_liste_field_titre($arrayfields['erd.comments']['label'], $_SERVER["PHP_SELF"], "erd.comments", "", $param, '', $sortfield, $sortorder);
500 $totalarray['nbfield']++;
501 }
502 // expensereport total
503 if (!empty($arrayfields['erd.total_ht']['checked'])) {
504 print_liste_field_titre($arrayfields['erd.total_ht']['label'], $_SERVER["PHP_SELF"], "erd.total_ht", "", $param, '', $sortfield, $sortorder, 'right ');
505 $totalarray['nbfield']++;
506 }
507 // VAT
508 if (!empty($arrayfields['erd.tva_tx']['checked'])) {
509 print_liste_field_titre($arrayfields['erd.tva_tx']['label'], $_SERVER["PHP_SELF"], "erd.tva_tx", "", $param, '', $sortfield, $sortorder, 'center ');
510 $totalarray['nbfield']++;
511 }
512 if (!empty($arrayfields['aa.account_number']['checked'])) {
513 print_liste_field_titre($arrayfields['aa.account_number']['label'], $_SERVER["PHP_SELF"], "aa.account_number", "", $param, '', $sortfield, $sortorder);
514 $totalarray['nbfield']++;
515 }
516 // Hook fields
517 $parameters = array('arrayfields' => $arrayfields, 'param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder);
518 $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
519 print $hookmanager->resPrint;
520 // Action column
521 if (!$conf->main_checkbox_left_column) {
522 print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
523 $totalarray['nbfield']++;
524 }
525 print "</tr>\n";
526
527 $expensereportstatic = new ExpenseReport($db);
528 $accountingaccountstatic = new AccountingAccount($db);
529 $userstatic = new User($db);
530
531 if (min($num_lines, $limit)) {
532 $totalarray = array();
533 $totalarray['nbfield'] = 0;
534 }
535
536 $i = 0;
537 while ($i < min($num_lines, $limit)) {
538 $objp = $db->fetch_object($result);
539
540 $expensereportstatic->ref = $objp->ref;
541 $expensereportstatic->id = $objp->erid;
542
543 $userstatic->id = $objp->userid;
544 $userstatic->ref = $objp->label;
545 $userstatic->login = $objp->login;
546 $userstatic->status = $objp->statut;
547 $userstatic->email = $objp->email;
548 $userstatic->gender = $objp->gender;
549 $userstatic->firstname = $objp->firstname;
550 $userstatic->lastname = $objp->lastname;
551 $userstatic->employee = $objp->employee;
552 $userstatic->photo = $objp->photo;
553
554 $accountingaccountstatic->rowid = $objp->fk_compte;
555 $accountingaccountstatic->label = $objp->label;
556 $accountingaccountstatic->labelshort = $objp->labelshort;
557 $accountingaccountstatic->account_number = $objp->account_number;
558
559 print '<tr class="oddeven">';
560
561 // Action column
562 if ($conf->main_checkbox_left_column) {
563 print '<td class="nowrap center actioncolumn">';
564 $selected = in_array($objp->rowid, $changeaccount);
565 print '<input id="cb'.$objp->rowid.'" class="flat checkforselect checkforaction" type="checkbox" name="changeaccount[]" value="'.$objp->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
566 print '</td>';
567 if (!$i) {
568 $totalarray['nbfield']++;
569 }
570 }
571 // Line id
572 if (!empty($arrayfields['erd.rowid']['checked'])) {
573 print '<td>'.$objp->rowid.'</td>';
574 if (!$i) {
575 $totalarray['nbfield']++;
576 }
577 }
578 // Login
579 if (!empty($arrayfields['u.login']['checked'])) {
580 print '<td class="nowraponall">';
581 print $userstatic->getNomUrl(-1, '', 0, 0, 24, 1, 'login', '', 1);
582 print '</td>';
583 if (!$i) {
584 $totalarray['nbfield']++;
585 }
586 }
587 // Ref Expense report
588 if (!empty($arrayfields['er.ref']['checked'])) {
589 print '<td>'.$expensereportstatic->getNomUrl(1).'</td>';
590 if (!$i) {
591 $totalarray['nbfield']++;
592 }
593 }
594 // Date validation
595 if (!empty($arrayfields['er.date_valid']['checked'])) {
596 print '<td class="center">'.dol_print_date($db->jdate($objp->date_valid), 'day').'</td>';
597 if (!$i) {
598 $totalarray['nbfield']++;
599 }
600 }
601 // Date
602 if (!empty($arrayfields['erd.date']['checked'])) {
603 print '<td class="center">'.dol_print_date($db->jdate($objp->date), 'day').'</td>';
604 if (!$i) {
605 $totalarray['nbfield']++;
606 }
607 }
608 // Fees label
609 if (!empty($arrayfields['f.label']['checked'])) {
610 print '<td class="tdoverflow">'.($langs->trans($objp->type_fees_code) == $objp->type_fees_code ? $objp->type_fees_label : $langs->trans(($objp->type_fees_code))).'</td>';
611 if (!$i) {
612 $totalarray['nbfield']++;
613 }
614 }
615 // Fees description -- Can be null
616 if (!empty($arrayfields['erd.comments']['checked'])) {
617 print '<td>';
618 $text = dolGetFirstLineOfText(dol_string_nohtmltag($objp->comments, 1));
619 $trunclength = getDolGlobalInt('ACCOUNTING_LENGTH_DESCRIPTION', 32);
620 print $form->textwithtooltip(dol_trunc($text, $trunclength), $objp->comments);
621 print '</td>';
622 if (!$i) {
623 $totalarray['nbfield']++;
624 }
625 }
626 // Amount without taxes
627 if (!empty($arrayfields['erd.total_ht']['checked'])) {
628 print '<td class="right nowraponall amount">'.price($objp->total_ht).'</td>';
629 if (!$i) {
630 $totalarray['nbfield']++;
631 }
632 }
633 // Vat rate
634 if (!empty($arrayfields['erd.tva_tx']['checked'])) {
635 print '<td class="center">'.vatrate($objp->tva_tx.($objp->vat_src_code ? ' ('.$objp->vat_src_code.')' : '')).'</td>';
636 if (!$i) {
637 $totalarray['nbfield']++;
638 }
639 }
640 // Accounting account affected
641 if (!empty($arrayfields['aa.account_number']['checked'])) {
642 print '<td class="tdoverflowmax200" title="'.dolPrintHTMLForAttribute($accountingaccountstatic->label).'">';
643 print '<a class="editfielda reposition marginleftonly marginrightonly" href="./card.php?id='.$objp->rowid.'&backtopage='.urlencode($_SERVER["PHP_SELF"].($param ? '?'.$param : '')).'">';
644 print img_edit();
645 print '</a> ';
646 print $accountingaccountstatic->getNomUrl(0, 1, 1, '', 1);
647 print '</td>';
648 if (!$i) {
649 $totalarray['nbfield']++;
650 }
651 }
652 // Fields from hook
653 $parameters = array('arrayfields' => $arrayfields, 'obj' => $objp, 'i' => $i, 'totalarray' => &$totalarray);
654 $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
655 print $hookmanager->resPrint;
656 // Action column
657 if (!$conf->main_checkbox_left_column) {
658 print '<td class="nowrap center actioncolumn">';
659 $selected = in_array($objp->rowid, $changeaccount);
660 print '<input id="cb'.$objp->rowid.'" class="flat checkforselect checkforaction" type="checkbox" name="changeaccount[]" value="'.$objp->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
661 print '</td>';
662 if (!$i) {
663 $totalarray['nbfield']++;
664 }
665 }
666
667 print "</tr>";
668 $i++;
669 }
670
671 if ($num_lines == 0) {
672 print '<tr><td colspan="'.$totalarray['nbfield'].'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
673 }
674
675 $parameters = array('arrayfields' => $arrayfields, 'sql' => $sql);
676 $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
677 print $hookmanager->resPrint;
678
679 print "</table>";
680 print "</div>";
681
682 if ($nbtotalofrecords > $limit) {
683 print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num_lines, $nbtotalofrecords, '', 0, '', '', $limit, 1);
684 }
685
686 print '</form>';
687} else {
688 print $db->lasterror();
689}
690
691// End of page
692llxFooter();
693$db->close();
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
$totalarray
Definition list.php:497
dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $note='', $entity=1)
Insert a parameter (key,value) into database (delete old key then insert it again).
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 accounting accounts.
Class to manage Trips and Expenses.
const STATUS_CLOSED
Classified paid.
Class to manage generation of HTML components for accounting management.
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 Dolibarr users.
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_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.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dolGetFirstLineOfText($text, $nboflines=1, $charset='UTF-8')
Return first line of text.
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto='UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
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_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.