dolibarr 22.0.5
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';
30require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
31require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
32require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
33require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php';
34require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
35require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
36require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
37
46// Load translation files required by the page
47$langs->loadLangs(array("compta", "bills", "other", "accountancy", "trips", "productbatch", "hrm"));
48
49$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
50
51$account_parent = GETPOST('account_parent');
52$changeaccount = GETPOST('changeaccount', 'array');
53// Search Getpost
54$search_lineid = GETPOST('search_lineid', 'alpha'); // Can be '> 100'
55$search_login = GETPOST('search_login', 'alpha');
56$search_expensereport = GETPOST('search_expensereport', 'alpha');
57$search_label = GETPOST('search_label', 'alpha');
58$search_desc = GETPOST('search_desc', 'alpha');
59$search_amount = GETPOST('search_amount', 'alpha');
60$search_account = GETPOST('search_account', 'alpha');
61$search_vat = GETPOST('search_vat', 'alpha');
62$search_date_startday = GETPOSTINT('search_date_startday');
63$search_date_startmonth = GETPOSTINT('search_date_startmonth');
64$search_date_startyear = GETPOSTINT('search_date_startyear');
65$search_date_endday = GETPOSTINT('search_date_endday');
66$search_date_endmonth = GETPOSTINT('search_date_endmonth');
67$search_date_endyear = GETPOSTINT('search_date_endyear');
68$search_date_start = dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear); // Use tzserver
69$search_date_end = dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear);
70
71// Load variable for pagination
72$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : getDolGlobalString('ACCOUNTING_LIMIT_LIST_VENTILATION', $conf->liste_limit);
73$sortfield = GETPOST('sortfield', 'aZ09comma');
74$sortorder = GETPOST('sortorder', 'aZ09comma');
75$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
76if (empty($page) || $page < 0) {
77 $page = 0;
78}
79$offset = $limit * $page;
80$pageprev = $page - 1;
81$pagenext = $page + 1;
82if (!$sortfield) {
83 $sortfield = "erd.date, erd.rowid";
84}
85if (!$sortorder) {
86 if (getDolGlobalInt('ACCOUNTING_LIST_SORT_VENTILATION_DONE') > 0) {
87 $sortorder = "DESC";
88 } else {
89 $sortorder = "ASC";
90 }
91}
92
93// Security check
94if (!isModEnabled('accounting')) {
96}
97if ($user->socid > 0) {
99}
100if (!$user->hasRight('accounting', 'bind', 'write')) {
102}
103
104// Initialize technical objects
105$contextpage = 'accountancyexpensereportlines';
106$hookmanager->initHooks([$contextpage]);
107$formaccounting = new FormAccounting($db);
108
109
110$arrayfields = array(
111 'erd.rowid' => array('label' => "LineId", 'position' => 1, 'checked' => '1', 'enabled' => '1'),
112 'u.login' => array('label' => "Employees", 'position' => 1, 'checked' => '1', 'enabled' => '1'),
113 'er.ref' => array('label' => "ExpenseReport", 'position' => 1, 'checked' => '1', 'enabled' => '1'),
114 'erd.date' => array('label' => "DateOfLine", 'position' => 1, 'checked' => '1', 'enabled' => '1'),
115 'f.label' => array('label' => "TypeFees", 'position' => 1, 'checked' => '1', 'enabled' => '1'),
116 'erd.comments' => array('label' => "Description", 'position' => 1, 'checked' => '1', 'enabled' => '1'),
117 'erd.total_ht' => array('label' => "Amount", 'position' => 1, 'checked' => '1', 'enabled' => '1'),
118 'erd.tva_tx' => array('label' => "VATRate", 'position' => 1, 'checked' => '1', 'enabled' => '1'),
119 'aa.account_number' => array('label' => "AccountAccounting", 'position' => 1, 'checked' => '1', 'enabled' => '1'),
120);
121if (getDolGlobalString('ACCOUNTANCY_USE_EXPENSE_REPORT_VALIDATION_DATE')) {
122 $arrayfields['er.date_valid'] = array('label' => "DateValidation", 'position' => 1, 'checked' => '1', 'enabled' => '1');
123}
124// @phpstan-ignore-next-line
125$arrayfields = dol_sort_array($arrayfields, 'position');
126
127$object = null;
128$action = '';
129
130
131/*
132 * Actions
133 */
134
135$parameters = array('arrayfields' => &$arrayfields);
136$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
137if ($reshook < 0) {
138 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
139}
140
141if (empty($reshook)) {
142 // Selection of new fields
143 include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
144
145 // Purge search criteria
146 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
147 $search_lineid = '';
148 $search_login = '';
149 $search_expensereport = '';
150 $search_label = '';
151 $search_desc = '';
152 $search_amount = '';
153 $search_account = '';
154 $search_vat = '';
155 $search_date_startday = '';
156 $search_date_startmonth = '';
157 $search_date_startyear = '';
158 $search_date_endday = '';
159 $search_date_endmonth = '';
160 $search_date_endyear = '';
161 $search_date_start = '';
162 $search_date_end = '';
163 }
164
165 if (is_array($changeaccount) && count($changeaccount) > 0 && $user->hasRight('accounting', 'bind', 'write')) {
166 $error = 0;
167
168 if (!(GETPOSTINT('account_parent') >= 0)) {
169 $error++;
170 setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Account")), null, 'errors');
171 }
172
173 if (!$error) {
174 $db->begin();
175
176 $sql1 = "UPDATE ".MAIN_DB_PREFIX."expensereport_det as erd";
177 $sql1 .= " SET erd.fk_code_ventilation=".(GETPOSTINT('account_parent') > 0 ? GETPOSTINT('account_parent') : '0');
178 $sql1 .= ' WHERE erd.rowid IN ('.$db->sanitize(implode(',', $changeaccount)).')';
179
180 dol_syslog('accountancy/expensereport/lines.php::changeaccount sql= '.$sql1);
181 $resql1 = $db->query($sql1);
182 if (!$resql1) {
183 $error++;
184 setEventMessages($db->lasterror(), null, 'errors');
185 }
186 if (!$error) {
187 $db->commit();
188 setEventMessages($langs->trans("Save"), null, 'mesgs');
189 } else {
190 $db->rollback();
191 setEventMessages($db->lasterror(), null, 'errors');
192 }
193
194 $account_parent = ''; // Protection to avoid to mass apply it a second time
195 }
196 }
197}
198
199if (GETPOST('sortfield') == 'erd.date, erd.rowid') {
200 $value = (GETPOST('sortorder') == 'asc,asc' ? 0 : 1);
201 require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
202 $res = dolibarr_set_const($db, "ACCOUNTING_LIST_SORT_VENTILATION_DONE", $value, 'yesno', 0, '', $conf->entity);
203}
204
205
206/*
207 * View
208 */
209
210$form = new Form($db);
211$formother = new FormOther($db);
212
213$help_url = 'EN:Module_Double_Entry_Accounting|FR:Module_Comptabilit&eacute;_en_Partie_Double#Liaisons_comptables';
214
215llxHeader('', $langs->trans("ExpenseReportsVentilation").' - '.$langs->trans("Dispatched"), $help_url, '', 0, 0, '', '', '', 'mod-accountancy accountancy-expensereport page-lines');
216
217print '<script type="text/javascript">
218 $(function () {
219 $(\'#select-all\').click(function(event) {
220 // Iterate each checkbox
221 $(\':checkbox\').each(function() {
222 this.checked = true;
223 });
224 });
225 $(\'#unselect-all\').click(function(event) {
226 // Iterate each checkbox
227 $(\':checkbox\').each(function() {
228 this.checked = false;
229 });
230 });
231 });
232 </script>';
233
234/*
235 * Expense reports lines
236 */
237$sql = "SELECT er.ref, er.rowid as erid,";
238$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,";
239$sql .= " f.id as type_fees_id, f.code as type_fees_code, f.label as type_fees_label,";
240$sql .= " u.rowid as userid, u.login, u.lastname, u.firstname, u.email, u.gender, u.employee, u.photo, u.statut,";
241$sql .= " aa.label, aa.labelshort, aa.account_number";
242$parameters = array();
243$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
244$sql .= $hookmanager->resPrint;
245$sql .= " FROM ".MAIN_DB_PREFIX."expensereport as er";
246$sql .= " INNER JOIN ".MAIN_DB_PREFIX."expensereport_det as erd ON er.rowid = erd.fk_expensereport";
247$sql .= " INNER JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON aa.rowid = erd.fk_code_ventilation";
248$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_type_fees as f ON f.id = erd.fk_c_type_fees";
249$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid = er.fk_user_author";
250// Add table from hooks
251$parameters = array();
252$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
253$sql .= $hookmanager->resPrint;
254$sql .= " WHERE erd.fk_code_ventilation > 0";
255$sql .= " AND er.entity IN (".getEntity('expensereport', 0).")"; // We don't share object for accountancy
256$sql .= " AND er.fk_statut IN (".ExpenseReport::STATUS_APPROVED.", ".ExpenseReport::STATUS_CLOSED.")";
257// Add search filter like
258if (strlen($search_lineid)) {
259 $sql .= natural_search("erd.rowid", $search_lineid, 1);
260}
261if (strlen(trim($search_login))) {
262 $sql .= natural_search("u.login", $search_login);
263}
264if (strlen(trim($search_expensereport))) {
265 $sql .= natural_search("er.ref", $search_expensereport);
266}
267if (strlen(trim($search_label))) {
268 $sql .= natural_search("f.label", $search_label);
269}
270if (strlen(trim($search_desc))) {
271 $sql .= natural_search("erd.comments", $search_desc);
272}
273if (strlen(trim($search_amount))) {
274 $sql .= natural_search("erd.total_ht", $search_amount, 1);
275}
276if (strlen(trim($search_account))) {
277 $sql .= natural_search("aa.account_number", $search_account);
278}
279if (strlen(trim($search_vat))) {
280 $sql .= natural_search("erd.tva_tx", price2num($search_vat), 1);
281}
282if ($search_date_start) {
283 $sql .= " AND erd.date >= '".$db->idate($search_date_start)."'";
284}
285if ($search_date_end) {
286 $sql .= " AND erd.date <= '".$db->idate($search_date_end)."'";
287}
288$sql .= " AND er.entity IN (".getEntity('expensereport', 0).")"; // We don't share object for accountancy
289// Add where from hooks
290$parameters = array();
291$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook
292$sql .= $hookmanager->resPrint;
293
294$sql .= $db->order($sortfield, $sortorder);
295
296// Count total nb of records
297$nbtotalofrecords = '';
298if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
299 $result = $db->query($sql);
300 $nbtotalofrecords = $db->num_rows($result);
301 if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
302 $page = 0;
303 $offset = 0;
304 }
305}
306
307$sql .= $db->plimit($limit + 1, $offset);
308
309dol_syslog("accountancy/expensereport/lines.php", LOG_DEBUG);
310$result = $db->query($sql);
311if ($result) {
312 $num_lines = $db->num_rows($result);
313 $i = 0;
314
315 $param = '';
316 if ($contextpage != $_SERVER["PHP_SELF"]) {
317 $param .= '&contextpage='.urlencode($contextpage);
318 }
319 if ($limit > 0 && $limit != $conf->liste_limit) {
320 $param .= '&limit='.((int) $limit);
321 }
322 if ($search_login) {
323 $param .= '&search_login='.urlencode($search_login);
324 }
325 if ($search_expensereport) {
326 $param .= "&search_expensereport=".urlencode($search_expensereport);
327 }
328 if ($search_label) {
329 $param .= "&search_label=".urlencode($search_label);
330 }
331 if ($search_desc) {
332 $param .= "&search_desc=".urlencode($search_desc);
333 }
334 if ($search_account) {
335 $param .= "&search_account=".urlencode($search_account);
336 }
337 if ($search_vat) {
338 $param .= "&search_vat=".urlencode($search_vat);
339 }
340 if ($search_date_startday) {
341 $param .= '&search_date_startday='.urlencode((string) ($search_date_startday));
342 }
343 if ($search_date_startmonth) {
344 $param .= '&search_date_startmonth='.urlencode((string) ($search_date_startmonth));
345 }
346 if ($search_date_startyear) {
347 $param .= '&search_date_startyear='.urlencode((string) ($search_date_startyear));
348 }
349 if ($search_date_endday) {
350 $param .= '&search_date_endday='.urlencode((string) ($search_date_endday));
351 }
352 if ($search_date_endmonth) {
353 $param .= '&search_date_endmonth='.urlencode((string) ($search_date_endmonth));
354 }
355 if ($search_date_endyear) {
356 $param .= '&search_date_endyear='.urlencode((string) ($search_date_endyear));
357 }
358 // Add $param from hooks
359 $parameters = array('param' => &$param);
360 $reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
361 $param .= $hookmanager->resPrint;
362
363 print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">'."\n";
364 print '<input type="hidden" name="action" value="ventil">';
365 if ($optioncss != '') {
366 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
367 }
368 print '<input type="hidden" name="token" value="'.newToken().'">';
369 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
370 print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
371 print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
372 print '<input type="hidden" name="page" value="'.$page.'">';
373
374 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
375 print_barre_liste($langs->trans("ExpenseReportLinesDone").'<br><span class="opacitymedium small">'.$langs->trans("DescVentilDoneExpenseReport").'</span>', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num_lines, $nbtotalofrecords, 'title_accountancy', 0, '', '', $limit, 0, 0, 1);
376
377 print '<br>'.$langs->trans("ChangeAccount").' <div class="inline-block paddingbottom marginbottomonly">';
378 print $formaccounting->select_account($account_parent, 'account_parent', 2, array(), 0, 0, 'maxwidth300 maxwidthonsmartphone valignmiddle');
379 print '<input type="submit" class="button small smallpaddingimp valignmiddle" value="'.$langs->trans("ChangeBinding").'"/></div>';
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="'.dol_escape_htmltag($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( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:67
$totalarray
Definition export.php:1206
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 permettant la generation de composants html autre Only common components are here.
Class to manage Dolibarr users.
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)
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.
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.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.