33 require
'../main.inc.php';
34 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
35 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
36 require_once DOL_DOCUMENT_ROOT.
'/expensereport/class/expensereport.class.php';
37 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
38 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
39 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formexpensereport.class.php';
40 require_once DOL_DOCUMENT_ROOT.
'/core/lib/usergroups.lib.php';
41 require_once DOL_DOCUMENT_ROOT.
'/expensereport/class/expensereport_ik.class.php';
44 $langs->loadLangs(array(
'companies',
'users',
'trips'));
46 $action =
GETPOST(
'action',
'aZ09');
47 $massaction =
GETPOST(
'massaction',
'alpha');
48 $show_files =
GETPOST(
'show_files',
'int');
49 $confirm =
GETPOST(
'confirm',
'alpha');
50 $cancel =
GETPOST(
'cancel',
'alpha');
51 $toselect =
GETPOST(
'toselect',
'array');
52 $contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'expensereportlist';
54 $childids = $user->getAllChildIds(1);
57 $socid =
GETPOST(
'socid',
'int');
59 $socid = $user->socid;
66 if ($id == $user->id) {
69 if (!empty($user->rights->expensereport->readall)) {
72 if (!empty($user->rights->expensereport->lire) && in_array($id, $childids)) {
80 $diroutputmassaction = $conf->expensereport->dir_output.
'/temp/massgeneration/'.$user->id;
84 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
85 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
86 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
88 if (empty($page) || $page == -1) {
91 $offset = $limit * $page;
92 $pageprev = $page - 1;
93 $pagenext = $page + 1;
98 $sortfield =
"d.date_debut";
102 $sall = trim((
GETPOST(
'search_all',
'alphanohtml') !=
'') ?
GETPOST(
'search_all',
'alphanohtml') :
GETPOST(
'sall',
'alphanohtml'));
104 $search_ref =
GETPOST(
'search_ref',
'alpha');
105 $search_user =
GETPOST(
'search_user',
'int');
106 $search_amount_ht =
GETPOST(
'search_amount_ht',
'alpha');
107 $search_amount_vat =
GETPOST(
'search_amount_vat',
'alpha');
108 $search_amount_ttc =
GETPOST(
'search_amount_ttc',
'alpha');
109 $search_status = (
GETPOST(
'search_status',
'intcomma') !=
'' ?
GETPOST(
'search_status',
'intcomma') :
GETPOST(
'statut',
'intcomma'));
111 $search_date_startday =
GETPOST(
'search_date_startday',
'int');
112 $search_date_startmonth =
GETPOST(
'search_date_startmonth',
'int');
113 $search_date_startyear =
GETPOST(
'search_date_startyear',
'int');
114 $search_date_startendday =
GETPOST(
'search_date_startendday',
'int');
115 $search_date_startendmonth =
GETPOST(
'search_date_startendmonth',
'int');
116 $search_date_startendyear =
GETPOST(
'search_date_startendyear',
'int');
117 $search_date_start =
dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear);
118 $search_date_startend =
dol_mktime(23, 59, 59, $search_date_startendmonth, $search_date_startendday, $search_date_startendyear);
120 $search_date_endday =
GETPOST(
'search_date_endday',
'int');
121 $search_date_endmonth =
GETPOST(
'search_date_endmonth',
'int');
122 $search_date_endyear =
GETPOST(
'search_date_endyear',
'int');
123 $search_date_endendday =
GETPOST(
'search_date_endendday',
'int');
124 $search_date_endendmonth =
GETPOST(
'search_date_endendmonth',
'int');
125 $search_date_endendyear =
GETPOST(
'search_date_endendyear',
'int');
126 $search_date_end =
dol_mktime(0, 0, 0, $search_date_endmonth, $search_date_endday, $search_date_endyear);
127 $search_date_endend =
dol_mktime(23, 59, 59, $search_date_endendmonth, $search_date_endendday, $search_date_endendyear);
129 $optioncss =
GETPOST(
'optioncss',
'alpha');
131 if ($search_status ==
'') {
134 if ($search_user ==
'') {
140 $hookmanager->initHooks(array(
'expensereportlist'));
144 $extrafields->fetch_name_optionals_label($object->table_element);
146 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element,
'',
'search_');
150 $fieldstosearchall = array(
152 'd.note_public'=>
"NotePublic",
153 'u.lastname'=>
'EmployeeLastname',
154 'u.firstname'=>
"EmployeeFirstname",
157 if (empty($user->socid)) {
158 $fieldstosearchall[
"d.note_private"] =
"NotePrivate";
161 $arrayfields = array(
162 'd.ref'=>array(
'label'=>$langs->trans(
"Ref"),
'checked'=>1),
163 'user'=>array(
'label'=>$langs->trans(
"User"),
'checked'=>1),
164 'd.date_debut'=>array(
'label'=>$langs->trans(
"DateStart"),
'checked'=>1),
165 'd.date_fin'=>array(
'label'=>$langs->trans(
"DateEnd"),
'checked'=>1),
166 'd.date_valid'=>array(
'label'=>$langs->trans(
"DateValidation"),
'checked'=>1),
167 'd.date_approve'=>array(
'label'=>$langs->trans(
"DateApprove"),
'checked'=>1),
168 'd.total_ht'=>array(
'label'=>$langs->trans(
"AmountHT"),
'checked'=>1),
169 'd.total_vat'=>array(
'label'=>$langs->trans(
"AmountVAT"),
'checked'=>1),
170 'd.total_ttc'=>array(
'label'=>$langs->trans(
"AmountTTC"),
'checked'=>1),
171 'd.date_create'=>array(
'label'=>$langs->trans(
"DateCreation"),
'checked'=>0,
'position'=>500),
172 'd.tms'=>array(
'label'=>$langs->trans(
"DateModificationShort"),
'checked'=>0,
'position'=>500),
173 'd.fk_statut'=>array(
'label'=>$langs->trans(
"Status"),
'checked'=>1,
'position'=>1000),
176 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_array_fields.tpl.php';
178 $canedituser = (!empty($user->admin) || $user->rights->user->user->creer);
180 $objectuser =
new User($db);
187 if (
GETPOST(
'cancel',
'alpha')) {
188 $action =
'list'; $massaction =
'';
190 if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
194 $parameters = array(
'socid'=>$socid);
195 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
200 if (empty($reshook)) {
202 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
205 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
208 $search_amount_ht =
"";
209 $search_amount_vat =
"";
210 $search_amount_ttc =
"";
212 $search_date_startday =
'';
213 $search_date_startmonth =
'';
214 $search_date_startyear =
'';
215 $search_date_startendday =
'';
216 $search_date_startendmonth =
'';
217 $search_date_startendyear =
'';
218 $search_date_start =
'';
219 $search_date_startend =
'';
220 $search_date_endday =
'';
221 $search_date_endmonth =
'';
222 $search_date_endyear =
'';
223 $search_date_endendday =
'';
224 $search_date_endendmonth =
'';
225 $search_date_endendyear =
'';
226 $search_date_end =
'';
227 $search_date_endend =
'';
229 $search_array_options = array();
231 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')
232 ||
GETPOST(
'button_search_x',
'alpha') ||
GETPOST(
'button_search.x',
'alpha') ||
GETPOST(
'button_search',
'alpha')) {
237 $objectclass =
'ExpenseReport';
238 $objectlabel =
'ExpenseReport';
239 $permissiontoread = $user->rights->expensereport->lire;
240 $permissiontodelete = $user->rights->expensereport->supprimer;
241 $uploaddir = $conf->expensereport->dir_output;
242 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
255 $fuser =
new User($db);
257 $title = $langs->trans(
"TripsAndExpenses");
264 $user_id = $user->id;
268 $fuser->fetch($id,
'',
'', 1);
270 $user_id = $fuser->id;
272 $search_user = $user_id;
275 $sql =
"SELECT d.rowid, d.ref, d.fk_user_author, d.total_ht, d.total_tva, d.total_ttc, d.fk_statut as status,";
276 $sql .=
" d.date_debut, d.date_fin, d.date_create, d.tms as date_modif, d.date_valid, d.date_approve, d.note_private, d.note_public,";
277 $sql .=
" u.rowid as id_user, u.firstname, u.lastname, u.login, u.email, u.statut, u.photo";
279 if (!empty($extrafields->attributes[$object->table_element][
'label'])) {
280 foreach ($extrafields->attributes[$object->table_element][
'label'] as $key => $val) {
281 $sql .= ($extrafields->attributes[$object->table_element][
'type'][$key] !=
'separate' ?
", ef.".$key.
" as options_".$key :
'');
285 $parameters = array();
286 $reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters);
287 $sql .= $hookmanager->resPrint;
291 $sql .=
" FROM ".MAIN_DB_PREFIX.
"expensereport as d";
292 if (isset($extrafields->attributes[$object->table_element][
'label']) && is_array($extrafields->attributes[$object->table_element][
'label']) && count($extrafields->attributes[$object->table_element][
'label'])) {
293 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element.
"_extrafields as ef on (d.rowid = ef.fk_object)";
295 $sql .=
", ".MAIN_DB_PREFIX.
"user as u";
296 $sql .=
" WHERE d.fk_user_author = u.rowid AND d.entity IN (".getEntity(
'expensereport').
")";
302 if (!empty($search_ref)) {
306 if ($search_date_start) {
307 $sql .=
" AND d.date_debut >= '".$db->idate($search_date_start).
"'";
309 if ($search_date_startend) {
310 $sql .=
" AND d.date_debut <= '".$db->idate($search_date_startend).
"'";
313 if ($search_date_end) {
314 $sql .=
" AND d.date_fin >= '".$db->idate($search_date_end).
"'";
316 if ($search_date_endend) {
317 $sql .=
" AND d.date_fin <= '".$db->idate($search_date_endend).
"'";
320 if ($search_amount_ht !=
'') {
323 if ($search_amount_ttc !=
'') {
327 if ($search_user !=
'' && $search_user >= 0) {
328 $sql .=
" AND u.rowid = '".$db->escape($search_user).
"'";
331 if ($search_status !=
'' && $search_status >= 0) {
332 $sql .=
" AND d.fk_statut IN (".$db->sanitize($search_status).
")";
335 if (empty($user->rights->expensereport->readall) && empty($user->rights->expensereport->lire_tous)
336 && (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || empty($user->rights->expensereport->writeall_advance))) {
337 $sql .=
" AND d.fk_user_author IN (".$db->sanitize(join(
',', $childids)).
")\n";
340 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
342 $parameters = array();
343 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters);
344 $sql .= $hookmanager->resPrint;
348 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
350 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords', $sql);
351 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
352 $resql = $db->query($sqlforcount);
354 $objforcount = $db->fetch_object(
$resql);
368 $sql .= $db->order($sortfield, $sortorder);
370 $sql .= $db->plimit($limit + 1, $offset);
374 $resql = $db->query($sql);
376 $num = $db->num_rows(
$resql);
378 $arrayofselected = is_array($toselect) ? $toselect : array();
381 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
382 $param .=
'&contextpage='.urlencode($contextpage);
384 if ($limit > 0 && $limit != $conf->liste_limit) {
385 $param .=
'&limit='.urlencode($limit);
388 $param .=
"&sall=".urlencode($sall);
391 $param .=
"&search_ref=".urlencode($search_ref);
394 if ($search_date_startday) {
395 $param .=
'&search_date_startday='.urlencode($search_date_startday);
397 if ($search_date_startmonth) {
398 $param .=
'&search_date_startmonth='.urlencode($search_date_startmonth);
400 if ($search_date_startyear) {
401 $param .=
'&search_date_startyear='.urlencode($search_date_startyear);
403 if ($search_date_startendday) {
404 $param .=
'&search_date_startendday='.urlencode($search_date_startendday);
406 if ($search_date_startendmonth) {
407 $param .=
'&search_date_startendmonth='.urlencode($search_date_startendmonth);
409 if ($search_date_startendyear) {
410 $param .=
'&search_date_startendyear='.urlencode($search_date_startendyear);
413 if ($search_date_endday) {
414 $param .=
'&search_date_endday='.urlencode($search_date_endday);
416 if ($search_date_endmonth) {
417 $param .=
'&search_date_endmonth='.urlencode($search_date_endmonth);
419 if ($search_date_endyear) {
420 $param .=
'&search_date_endyear='.urlencode($search_date_endyear);
422 if ($search_date_endendday) {
423 $param .=
'&search_date_endendday='.urlencode($search_date_endendday);
425 if ($search_date_endendmonth) {
426 $param .=
'&search_date_endendmonth='.urlencode($search_date_endendmonth);
428 if ($search_date_endendyear) {
429 $param .=
'&search_date_endendyear='.urlencode($search_date_endendyear);
432 $param .=
"&search_user=".urlencode($search_user);
434 if ($search_amount_ht) {
435 $param .=
"&search_amount_ht=".urlencode($search_amount_ht);
437 if ($search_amount_ttc) {
438 $param .=
"&search_amount_ttc=".urlencode($search_amount_ttc);
440 if ($search_status >= 0) {
441 $param .=
"&search_status=".urlencode($search_status);
443 if ($optioncss !=
'') {
444 $param .=
'&optioncss='.urlencode($optioncss);
447 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
450 $arrayofmassactions = array(
451 'generate_doc'=>
img_picto(
'',
'pdf',
'class="pictofixedwidth"').$langs->trans(
"ReGeneratePDF"),
452 'builddoc'=>
img_picto(
'',
'pdf',
'class="pictofixedwidth"').$langs->trans(
"PDFMerge"),
453 'presend'=>
img_picto(
'',
'email',
'class="pictofixedwidth"').$langs->trans(
"SendByMail"),
455 if ($user->rights->expensereport->supprimer) {
456 $arrayofmassactions[
'predelete'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
458 if (in_array($massaction, array(
'presend',
'predelete'))) {
459 $arrayofmassactions = array();
461 $massactionbutton =
$form->selectMassAction(
'', $arrayofmassactions);
464 print
'<form id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">'.
"\n";
465 if ($optioncss !=
'') {
466 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
468 print
'<input type="hidden" name="token" value="'.newToken().
'">';
469 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
470 print
'<input type="hidden" name="action" value="'.($action ==
'edit' ?
'update' :
'list').
'">';
471 print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
472 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
473 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
475 print
'<input type="hidden" name="id" value="'.$id.
'">';
479 $title = $langs->trans(
"User");
480 $linkback =
'<a href="'.DOL_URL_ROOT.
'/user/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
485 dol_banner_tab($fuser,
'id', $linkback, $user->rights->user->user->lire || $user->admin);
489 if ($action !=
'edit') {
490 print
'<div class="tabsAction">';
492 $childids = $user->getAllChildIds(1);
494 $canedit = ((in_array($user_id, $childids) && $user->rights->expensereport->creer)
495 || ($conf->global->MAIN_USE_ADVANCED_PERMS && $user->rights->expensereport->writeall_advance));
499 print
'<a href="'.DOL_URL_ROOT.
'/expensereport/card.php?action=create&fk_user_author='.$fuser->id.
'" class="butAction">'.$langs->trans(
"AddTrip").
'</a>';
501 print
'<a href="#" class="butActionRefused" title="'.$langs->trans(
"NotEnoughPermissions").
'">'.$langs->trans(
"AddTrip").
'</a>';
506 print
$form->buttonsSaveCancel(
"Save",
'');
509 $title = $langs->trans(
"ListTripsAndExpenses");
511 $url = DOL_URL_ROOT.
'/expensereport/card.php?action=create';
512 if (!empty($socid)) {
513 $url .=
'&socid='.$socid;
515 $newcardbutton =
dolGetButtonTitle($langs->trans(
'NewTrip'),
'',
'fa fa-plus-circle', $url,
'', $user->rights->expensereport->creer);
517 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num,
$nbtotalofrecords,
'trip', 0, $newcardbutton,
'', $limit, 0, 0, 1);
520 $topicmail =
"SendExpenseReport";
521 $modelmail =
"expensereport";
523 $trackid =
'exp'.$object->id;
524 include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
527 foreach ($fieldstosearchall as $key => $val) {
528 $fieldstosearchall[$key] = $langs->trans($val);
530 print
'<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $sall).join(
', ', $fieldstosearchall).
'</div>';
535 $parameters = array();
536 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters);
537 if (empty($reshook)) {
538 $moreforfilter .= $hookmanager->resPrint;
540 $moreforfilter = $hookmanager->resPrint;
543 if (!empty($moreforfilter)) {
544 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
545 print $moreforfilter;
549 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
550 $selectedfields =
$form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN'));
551 $selectedfields .= (count($arrayofmassactions) ?
$form->showCheckAddButtons(
'checkforselect', 1) :
'');
553 print
'<div class="div-table-responsive">';
554 print
'<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
557 print
'<tr class="liste_titre_filter">';
560 print
'<td class="liste_titre maxwidthsearch">';
561 $searchpicto =
$form->showFilterButtons(
'left');
565 if (!empty($arrayfields[
'd.ref'][
'checked'])) {
566 print
'<td class="liste_titre" align="left">';
567 print
'<input class="flat" size="15" type="text" name="search_ref" value="'.$search_ref.
'">';
571 if (!empty($arrayfields[
'user'][
'checked'])) {
572 if ($user->rights->expensereport->readall || $user->rights->expensereport->lire_tous) {
573 print
'<td class="liste_titre maxwidthonspartphone" align="left">';
574 print
$form->select_dolusers($search_user,
'search_user', 1,
'', 0,
'',
'', 0, 0, 0,
'', 0,
'',
'maxwidth200');
577 print
'<td class="liste_titre"> </td>';
581 if (!empty($arrayfields[
'd.date_debut'][
'checked'])) {
582 print
'<td class="liste_titre" align="center">';
583 print
'<div class="nowrap">';
584 print
$form->selectDate($search_date_start ? $search_date_start : -1,
'search_date_start', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
586 print
'<div class="nowrap">';
587 print
$form->selectDate($search_date_startend ? $search_date_startend : -1,
'search_date_startend', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
592 if (!empty($arrayfields[
'd.date_fin'][
'checked'])) {
593 print
'<td class="liste_titre" align="center">';
594 print
'<div class="nowrap">';
595 print
$form->selectDate($search_date_end ? $search_date_end : -1,
'search_date_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
597 print
'<div class="nowrap">';
598 print
$form->selectDate($search_date_endend ? $search_date_endend : -1,
'search_date_endend', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
603 if (!empty($arrayfields[
'd.date_valid'][
'checked'])) {
604 print
'<td class="liste_titre" align="center">';
610 if (!empty($arrayfields[
'd.date_approve'][
'checked'])) {
611 print
'<td class="liste_titre" align="center">';
617 if (!empty($arrayfields[
'd.total_ht'][
'checked'])) {
618 print
'<td class="liste_titre right"><input class="flat" type="text" size="5" name="search_amount_ht" value="'.$search_amount_ht.
'"></td>';
620 if (!empty($arrayfields[
'd.total_vat'][
'checked'])) {
621 print
'<td class="liste_titre right"><input class="flat" type="text" size="5" name="search_amount_vat" value="'.$search_amount_vat.
'"></td>';
624 if (!empty($arrayfields[
'd.total_ttc'][
'checked'])) {
625 print
'<td class="liste_titre right"><input class="flat" type="text" size="5" name="search_amount_ttc" value="'.$search_amount_ttc.
'"></td>';
628 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
631 $parameters = array(
'arrayfields'=>$arrayfields);
632 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters);
633 print $hookmanager->resPrint;
635 if (!empty($arrayfields[
'd.date_create'][
'checked'])) {
636 print
'<td class="liste_titre">';
640 if (!empty($arrayfields[
'd.tms'][
'checked'])) {
641 print
'<td class="liste_titre">';
645 if (!empty($arrayfields[
'd.fk_statut'][
'checked'])) {
646 print
'<td class="liste_titre right">';
647 $formexpensereport->selectExpensereportStatus($search_status,
'search_status', 1, 1);
652 print
'<td class="liste_titre maxwidthsearch">';
653 $searchpicto =
$form->showFilterButtons();
660 print
'<tr class="liste_titre">';
662 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'align="center"', $sortfield, $sortorder,
'maxwidthsearch ');
664 if (!empty($arrayfields[
'd.ref'][
'checked'])) {
665 print_liste_field_titre($arrayfields[
'd.ref'][
'label'], $_SERVER[
"PHP_SELF"],
"d.ref",
"", $param,
'', $sortfield, $sortorder);
667 if (!empty($arrayfields[
'user'][
'checked'])) {
668 print_liste_field_titre($arrayfields[
'user'][
'label'], $_SERVER[
"PHP_SELF"],
"u.lastname",
"", $param,
'', $sortfield, $sortorder);
670 if (!empty($arrayfields[
'd.date_debut'][
'checked'])) {
671 print_liste_field_titre($arrayfields[
'd.date_debut'][
'label'], $_SERVER[
"PHP_SELF"],
"d.date_debut",
"", $param,
'align="center"', $sortfield, $sortorder);
673 if (!empty($arrayfields[
'd.date_fin'][
'checked'])) {
674 print_liste_field_titre($arrayfields[
'd.date_fin'][
'label'], $_SERVER[
"PHP_SELF"],
"d.date_fin",
"", $param,
'align="center"', $sortfield, $sortorder);
676 if (!empty($arrayfields[
'd.date_valid'][
'checked'])) {
677 print_liste_field_titre($arrayfields[
'd.date_valid'][
'label'], $_SERVER[
"PHP_SELF"],
"d.date_valid",
"", $param,
'align="center"', $sortfield, $sortorder);
679 if (!empty($arrayfields[
'd.date_approve'][
'checked'])) {
680 print_liste_field_titre($arrayfields[
'd.date_approve'][
'label'], $_SERVER[
"PHP_SELF"],
"d.date_approve",
"", $param,
'align="center"', $sortfield, $sortorder);
682 if (!empty($arrayfields[
'd.total_ht'][
'checked'])) {
683 print_liste_field_titre($arrayfields[
'd.total_ht'][
'label'], $_SERVER[
"PHP_SELF"],
"d.total_ht",
"", $param,
'align="right"', $sortfield, $sortorder);
685 if (!empty($arrayfields[
'd.total_vat'][
'checked'])) {
686 print_liste_field_titre($arrayfields[
'd.total_vat'][
'label'], $_SERVER[
"PHP_SELF"],
"d.total_tva",
"", $param,
'align="right"', $sortfield, $sortorder);
688 if (!empty($arrayfields[
'd.total_ttc'][
'checked'])) {
689 print_liste_field_titre($arrayfields[
'd.total_ttc'][
'label'], $_SERVER[
"PHP_SELF"],
"d.total_ttc",
"", $param,
'align="right"', $sortfield, $sortorder);
692 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
694 $parameters = array(
'arrayfields'=>$arrayfields,
'param'=>$param,
'sortfield'=>$sortfield,
'sortorder'=>$sortorder);
695 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters);
696 print $hookmanager->resPrint;
697 if (!empty($arrayfields[
'd.date_create'][
'checked'])) {
698 print_liste_field_titre($arrayfields[
'd.date_create'][
'label'], $_SERVER[
"PHP_SELF"],
"d.date_create",
"", $param,
'align="center" class="nowrap"', $sortfield, $sortorder);
700 if (!empty($arrayfields[
'd.tms'][
'checked'])) {
701 print_liste_field_titre($arrayfields[
'd.tms'][
'label'], $_SERVER[
"PHP_SELF"],
"d.tms",
"", $param,
'align="center" class="nowrap"', $sortfield, $sortorder);
703 if (!empty($arrayfields[
'd.fk_statut'][
'checked'])) {
704 print_liste_field_titre($arrayfields[
'd.fk_statut'][
'label'], $_SERVER[
"PHP_SELF"],
"d.fk_statut",
"", $param,
'align="right"', $sortfield, $sortorder);
707 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'align="center"', $sortfield, $sortorder,
'maxwidthsearch ');
712 $total_total_ttc = 0;
713 $total_total_tva = 0;
716 $usertmp =
new User($db);
720 $totalarray = array();
721 $totalarray[
'nbfield'] = 0;
722 $totalarray[
'val'] = array();
723 $totalarray[
'val'][
'd.total_ht'] = 0;
724 $totalarray[
'val'][
'd.total_tva'] = 0;
725 $totalarray[
'val'][
'd.total_ttc'] = 0;
726 $totalarray[
'totalizable'] = array();
727 while ($i < min($num, $limit)) {
728 $obj = $db->fetch_object(
$resql);
730 $expensereportstatic->id = $obj->rowid;
731 $expensereportstatic->ref = $obj->ref;
732 $expensereportstatic->status = $obj->status;
733 $expensereportstatic->date_debut = $db->jdate($obj->date_debut);
734 $expensereportstatic->date_fin = $db->jdate($obj->date_fin);
735 $expensereportstatic->date_create = $db->jdate($obj->date_create);
736 $expensereportstatic->date_modif = $db->jdate($obj->date_modif);
737 $expensereportstatic->date_valid = $db->jdate($obj->date_valid);
738 $expensereportstatic->date_approve = $db->jdate($obj->date_approve);
739 $expensereportstatic->note_private = $obj->note_private;
740 $expensereportstatic->note_public = $obj->note_public;
743 print
'<tr class="oddeven">';
746 print
'<td class="nowrap center">';
747 if ($massactionbutton || $massaction) {
749 if (in_array($obj->rowid, $arrayofselected)) {
752 print
'<input id="cb'.$obj->rowid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
757 if (!empty($arrayfields[
'd.ref'][
'checked'])) {
759 print
'<table class="nobordernopadding"><tr class="nocellnopadd">';
760 print
'<td class="nobordernopadding nowrap">';
761 print $expensereportstatic->getNomUrl(1);
764 print
'<td class="nobordernopadding nowrap">';
765 if ($expensereportstatic->status == 2 && $expensereportstatic->hasDelay(
'toappove')) {
768 if ($expensereportstatic->status == 5 && $expensereportstatic->hasDelay(
'topay')) {
771 if (!empty($obj->note_private) || !empty($obj->note_public)) {
772 print
' <span class="note">';
773 print
'<a href="'.DOL_URL_ROOT.
'/expensereport/note.php?id='.$obj->rowid.
'">'.
img_picto($langs->trans(
"ViewPrivateNote"),
'object_generic').
'</a>';
777 print
'<td width="16" class="nobordernopadding hideonsmartphone right">';
780 $urlsource = $_SERVER[
'PHP_SELF'].
'?id='.$obj->rowid;
781 print $formfile->getDocumentsLink($expensereportstatic->element, $filename, $filedir);
783 print
'</tr></table>';
786 $totalarray[
'nbfield']++;
790 if (!empty($arrayfields[
'user'][
'checked'])) {
791 print
'<td class="left">';
792 $usertmp->id = $obj->id_user;
793 $usertmp->lastname = $obj->lastname;
794 $usertmp->firstname = $obj->firstname;
795 $usertmp->login = $obj->login;
796 $usertmp->statut = $obj->statut;
797 $usertmp->photo = $obj->photo;
798 $usertmp->email = $obj->email;
799 print $usertmp->getNomUrl(-1);
802 $totalarray[
'nbfield']++;
806 if (!empty($arrayfields[
'd.date_debut'][
'checked'])) {
807 print
'<td class="center">'.($obj->date_debut > 0 ?
dol_print_date($db->jdate($obj->date_debut),
'day') :
'').
'</td>';
809 $totalarray[
'nbfield']++;
813 if (!empty($arrayfields[
'd.date_fin'][
'checked'])) {
814 print
'<td class="center">'.($obj->date_fin > 0 ?
dol_print_date($db->jdate($obj->date_fin),
'day') :
'').
'</td>';
816 $totalarray[
'nbfield']++;
820 if (!empty($arrayfields[
'd.date_valid'][
'checked'])) {
821 print
'<td class="center">'.($obj->date_valid > 0 ?
dol_print_date($db->jdate($obj->date_valid),
'day') :
'').
'</td>';
823 $totalarray[
'nbfield']++;
827 if (!empty($arrayfields[
'd.date_approve'][
'checked'])) {
828 print
'<td class="center">'.($obj->date_approve > 0 ?
dol_print_date($db->jdate($obj->date_approve),
'day') :
'').
'</td>';
830 $totalarray[
'nbfield']++;
834 if (!empty($arrayfields[
'd.total_ht'][
'checked'])) {
835 print
'<td class="right">'.price($obj->total_ht).
"</td>\n";
837 $totalarray[
'nbfield']++;
840 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'd.total_ht';
842 $totalarray[
'val'][
'd.total_ht'] += $obj->total_ht;
845 if (!empty($arrayfields[
'd.total_vat'][
'checked'])) {
846 print
'<td class="right">'.price($obj->total_tva).
"</td>\n";
848 $totalarray[
'nbfield']++;
851 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'd.total_tva';
853 $totalarray[
'val'][
'd.total_tva'] += $obj->total_tva;
856 if (!empty($arrayfields[
'd.total_ttc'][
'checked'])) {
857 print
'<td class="right">'.price($obj->total_ttc).
"</td>\n";
859 $totalarray[
'nbfield']++;
862 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'd.total_ttc';
864 $totalarray[
'val'][
'd.total_ttc'] += $obj->total_ttc;
868 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
870 $parameters = array(
'arrayfields'=>$arrayfields,
'obj'=>$obj,
'i'=>$i,
'totalarray'=>&$totalarray);
871 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters);
872 print $hookmanager->resPrint;
875 if (!empty($arrayfields[
'd.date_create'][
'checked'])) {
876 print
'<td class="nowrap center">';
880 $totalarray[
'nbfield']++;
884 if (!empty($arrayfields[
'd.tms'][
'checked'])) {
885 print
'<td class="nowrap center">';
889 $totalarray[
'nbfield']++;
893 if (!empty($arrayfields[
'd.fk_statut'][
'checked'])) {
894 print
'<td class="nowrap right">'.$expensereportstatic->getLibStatut(5).
'</td>';
896 $totalarray[
'nbfield']++;
901 print
'<td class="nowrap center">';
902 if ($massactionbutton || $massaction) {
904 if (in_array($obj->rowid, $arrayofselected)) {
907 print
'<input id="cb'.$obj->rowid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
912 $totalarray[
'nbfield']++;
917 $total_total_ht = $total_total_ht + $obj->total_ht;
918 $total_total_tva = $total_total_tva + $obj->total_tva;
919 $total_total_ttc = $total_total_ttc + $obj->total_ttc;
925 foreach ($arrayfields as $key => $val) {
926 if (!empty($val[
'checked'])) {
930 print
'<tr><td colspan="'.$colspan.
'" class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</td></tr>';
934 include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
938 $parameters = array(
'arrayfields'=>$arrayfields,
'sql'=>$sql);
939 $reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters);
940 print $hookmanager->resPrint;
942 print
'</table>'.
"\n";
945 print
'</form>'.
"\n";
948 $hidegeneratedfilelistifempty = 1;
949 if ($massaction ==
'builddoc' || $action ==
'remove_file' || $show_files) {
950 $hidegeneratedfilelistifempty = 0;
954 $urlsource = $_SERVER[
'PHP_SELF'].
'?sortfield='.$sortfield.
'&sortorder='.$sortorder;
955 $urlsource .= str_replace(
'&',
'&', $param);
957 $filedir = $diroutputmassaction;
958 $genallowed = $user->rights->expensereport->lire;
959 $delallowed = $user->rights->expensereport->creer;
961 print $formfile->showdocuments(
'massfilesarea_expensereport',
'', $filedir, $urlsource, 0, $delallowed,
'', 1, 1, 0, 48, 1, $param, $title,
'',
'',
'',
null, $hidegeneratedfilelistifempty);
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage Trips and Expenses.
Class to manage Dolibarr users.
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='rowid', $fieldref='ref', $morehtmlref='', $moreparam='', $nodbprefix=0, $morehtmlleft='', $morehtmlstatus='', $onlybanner=0, $morehtmlright='')
Show tab footer of a card.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
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...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show 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.
print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
if(!function_exists('utf8_encode')) if(!function_exists('utf8_decode')) getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
$nbtotalofrecords
Count total nb of records.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.
user_prepare_head(User $object)
Prepare array with list of tabs.