32 require
'../main.inc.php';
33 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
34 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
35 require_once DOL_DOCUMENT_ROOT.
'/expensereport/class/expensereport.class.php';
36 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
37 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
38 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formexpensereport.class.php';
39 require_once DOL_DOCUMENT_ROOT.
'/core/lib/usergroups.lib.php';
40 require_once DOL_DOCUMENT_ROOT.
'/expensereport/class/expensereport_ik.class.php';
43 $langs->loadLangs(array(
'companies',
'users',
'trips'));
45 $action =
GETPOST(
'action',
'aZ09');
46 $massaction =
GETPOST(
'massaction',
'alpha');
47 $show_files =
GETPOST(
'show_files',
'int');
48 $confirm =
GETPOST(
'confirm',
'alpha');
49 $cancel =
GETPOST(
'cancel',
'alpha');
50 $toselect =
GETPOST(
'toselect',
'array');
51 $contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'expensereportlist';
53 $childids = $user->getAllChildIds(1);
56 $socid =
GETPOST(
'socid',
'int');
58 $socid = $user->socid;
65 if ($id == $user->id) {
68 if (!empty($user->rights->expensereport->readall)) {
71 if (!empty($user->rights->expensereport->lire) && in_array($id, $childids)) {
79 $diroutputmassaction = $conf->expensereport->dir_output.
'/temp/massgeneration/'.$user->id;
83 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
84 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
85 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
87 if (empty($page) || $page == -1) {
90 $offset = $limit * $page;
91 $pageprev = $page - 1;
92 $pagenext = $page + 1;
97 $sortfield =
"d.date_debut";
101 $sall = trim((
GETPOST(
'search_all',
'alphanohtml') !=
'') ?
GETPOST(
'search_all',
'alphanohtml') :
GETPOST(
'sall',
'alphanohtml'));
103 $search_ref =
GETPOST(
'search_ref',
'alpha');
104 $search_user =
GETPOST(
'search_user',
'int');
105 $search_amount_ht =
GETPOST(
'search_amount_ht',
'alpha');
106 $search_amount_vat =
GETPOST(
'search_amount_vat',
'alpha');
107 $search_amount_ttc =
GETPOST(
'search_amount_ttc',
'alpha');
108 $search_status = (
GETPOST(
'search_status',
'intcomma') !=
'' ?
GETPOST(
'search_status',
'intcomma') :
GETPOST(
'statut',
'intcomma'));
110 $search_date_startday =
GETPOST(
'search_date_startday',
'int');
111 $search_date_startmonth =
GETPOST(
'search_date_startmonth',
'int');
112 $search_date_startyear =
GETPOST(
'search_date_startyear',
'int');
113 $search_date_startendday =
GETPOST(
'search_date_startendday',
'int');
114 $search_date_startendmonth =
GETPOST(
'search_date_startendmonth',
'int');
115 $search_date_startendyear =
GETPOST(
'search_date_startendyear',
'int');
116 $search_date_start =
dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear);
117 $search_date_startend =
dol_mktime(23, 59, 59, $search_date_startendmonth, $search_date_startendday, $search_date_startendyear);
119 $search_date_endday =
GETPOST(
'search_date_endday',
'int');
120 $search_date_endmonth =
GETPOST(
'search_date_endmonth',
'int');
121 $search_date_endyear =
GETPOST(
'search_date_endyear',
'int');
122 $search_date_endendday =
GETPOST(
'search_date_endendday',
'int');
123 $search_date_endendmonth =
GETPOST(
'search_date_endendmonth',
'int');
124 $search_date_endendyear =
GETPOST(
'search_date_endendyear',
'int');
125 $search_date_end =
dol_mktime(0, 0, 0, $search_date_endmonth, $search_date_endday, $search_date_endyear);
126 $search_date_endend =
dol_mktime(23, 59, 59, $search_date_endendmonth, $search_date_endendday, $search_date_endendyear);
128 $optioncss =
GETPOST(
'optioncss',
'alpha');
130 if ($search_status ==
'') {
133 if ($search_user ==
'') {
139 $hookmanager->initHooks(array(
'expensereportlist'));
143 $extrafields->fetch_name_optionals_label($object->table_element);
145 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element,
'',
'search_');
149 $fieldstosearchall = array(
151 'd.note_public'=>
"NotePublic",
152 'u.lastname'=>
'EmployeeLastname',
153 'u.firstname'=>
"EmployeeFirstname",
156 if (empty($user->socid)) {
157 $fieldstosearchall[
"d.note_private"] =
"NotePrivate";
160 $arrayfields = array(
161 'd.ref'=>array(
'label'=>$langs->trans(
"Ref"),
'checked'=>1),
162 'user'=>array(
'label'=>$langs->trans(
"User"),
'checked'=>1),
163 'd.date_debut'=>array(
'label'=>$langs->trans(
"DateStart"),
'checked'=>1),
164 'd.date_fin'=>array(
'label'=>$langs->trans(
"DateEnd"),
'checked'=>1),
165 'd.date_valid'=>array(
'label'=>$langs->trans(
"DateValidation"),
'checked'=>1),
166 'd.date_approve'=>array(
'label'=>$langs->trans(
"DateApprove"),
'checked'=>1),
167 'd.total_ht'=>array(
'label'=>$langs->trans(
"AmountHT"),
'checked'=>1),
168 'd.total_vat'=>array(
'label'=>$langs->trans(
"AmountVAT"),
'checked'=>1),
169 'd.total_ttc'=>array(
'label'=>$langs->trans(
"AmountTTC"),
'checked'=>1),
170 'd.date_create'=>array(
'label'=>$langs->trans(
"DateCreation"),
'checked'=>0,
'position'=>500),
171 'd.tms'=>array(
'label'=>$langs->trans(
"DateModificationShort"),
'checked'=>0,
'position'=>500),
172 'd.fk_statut'=>array(
'label'=>$langs->trans(
"Status"),
'checked'=>1,
'position'=>1000),
175 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_array_fields.tpl.php';
177 $canedituser = (!empty($user->admin) || $user->rights->user->user->creer);
179 $objectuser =
new User($db);
186 if (
GETPOST(
'cancel',
'alpha')) {
187 $action =
'list'; $massaction =
'';
189 if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
193 $parameters = array(
'socid'=>$socid);
194 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
199 if (empty($reshook)) {
201 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
204 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
207 $search_amount_ht =
"";
208 $search_amount_vat =
"";
209 $search_amount_ttc =
"";
211 $search_date_startday =
'';
212 $search_date_startmonth =
'';
213 $search_date_startyear =
'';
214 $search_date_startendday =
'';
215 $search_date_startendmonth =
'';
216 $search_date_startendyear =
'';
217 $search_date_start =
'';
218 $search_date_startend =
'';
219 $search_date_endday =
'';
220 $search_date_endmonth =
'';
221 $search_date_endyear =
'';
222 $search_date_endendday =
'';
223 $search_date_endendmonth =
'';
224 $search_date_endendyear =
'';
225 $search_date_end =
'';
226 $search_date_endend =
'';
228 $search_array_options = array();
230 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')
231 ||
GETPOST(
'button_search_x',
'alpha') ||
GETPOST(
'button_search.x',
'alpha') ||
GETPOST(
'button_search',
'alpha')) {
236 $objectclass =
'ExpenseReport';
237 $objectlabel =
'ExpenseReport';
238 $permissiontoread = $user->rights->expensereport->lire;
239 $permissiontodelete = $user->rights->expensereport->supprimer;
240 $uploaddir = $conf->expensereport->dir_output;
241 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
254 $fuser =
new User($db);
256 $title = $langs->trans(
"ListOfTrips");
263 $user_id = $user->id;
267 $fuser->fetch($id,
'',
'', 1);
269 $user_id = $fuser->id;
271 $search_user = $user_id;
274 $sql =
"SELECT d.rowid, d.ref, d.fk_user_author, d.total_ht, d.total_tva, d.total_ttc, d.fk_statut as status,";
275 $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,";
276 $sql .=
" u.rowid as id_user, u.firstname, u.lastname, u.login, u.email, u.statut, u.photo";
278 if (!empty($extrafields->attributes[$object->table_element][
'label'])) {
279 foreach ($extrafields->attributes[$object->table_element][
'label'] as $key => $val) {
280 $sql .= ($extrafields->attributes[$object->table_element][
'type'][$key] !=
'separate' ?
", ef.".$key.
" as options_".$key :
'');
284 $parameters = array();
285 $reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters);
286 $sql .= $hookmanager->resPrint;
287 $sql .=
" FROM ".MAIN_DB_PREFIX.
"expensereport as d";
288 if (isset($extrafields->attributes[$object->table_element][
'label']) && is_array($extrafields->attributes[$object->table_element][
'label']) && count($extrafields->attributes[$object->table_element][
'label'])) {
289 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element.
"_extrafields as ef on (d.rowid = ef.fk_object)";
291 $sql .=
", ".MAIN_DB_PREFIX.
"user as u";
292 $sql .=
" WHERE d.fk_user_author = u.rowid AND d.entity IN (".getEntity(
'expensereport').
")";
298 if (!empty($search_ref)) {
302 if ($search_date_start) {
303 $sql .=
" AND d.date_debut >= '".$db->idate($search_date_start).
"'";
305 if ($search_date_startend) {
306 $sql .=
" AND d.date_debut <= '".$db->idate($search_date_startend).
"'";
309 if ($search_date_end) {
310 $sql .=
" AND d.date_fin >= '".$db->idate($search_date_end).
"'";
312 if ($search_date_endend) {
313 $sql .=
" AND d.date_fin <= '".$db->idate($search_date_endend).
"'";
316 if ($search_amount_ht !=
'') {
319 if ($search_amount_ttc !=
'') {
323 if ($search_user !=
'' && $search_user >= 0) {
324 $sql .=
" AND u.rowid = '".$db->escape($search_user).
"'";
327 if ($search_status !=
'' && $search_status >= 0) {
328 $sql .=
" AND d.fk_statut IN (".$db->sanitize($search_status).
")";
331 if (empty($user->rights->expensereport->readall) && empty($user->rights->expensereport->lire_tous)
332 && (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || empty($user->rights->expensereport->writeall_advance))) {
333 $sql .=
" AND d.fk_user_author IN (".$db->sanitize(join(
',', $childids)).
")\n";
336 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
338 $parameters = array();
339 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters);
340 $sql .= $hookmanager->resPrint;
342 $sql .= $db->order($sortfield, $sortorder);
345 $nbtotalofrecords =
'';
346 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
347 $result = $db->query($sql);
348 $nbtotalofrecords = $db->num_rows($result);
349 if (($page * $limit) > $nbtotalofrecords) {
355 $sql .= $db->plimit($limit + 1, $offset);
358 $resql = $db->query($sql);
360 $num = $db->num_rows(
$resql);
362 $arrayofselected = is_array($toselect) ? $toselect : array();
365 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
366 $param .=
'&contextpage='.urlencode($contextpage);
368 if ($limit > 0 && $limit != $conf->liste_limit) {
369 $param .=
'&limit='.urlencode($limit);
372 $param .=
"&sall=".urlencode($sall);
375 $param .=
"&search_ref=".urlencode($search_ref);
378 if ($search_date_startday) {
379 $param .=
'&search_date_startday='.urlencode($search_date_startday);
381 if ($search_date_startmonth) {
382 $param .=
'&search_date_startmonth='.urlencode($search_date_startmonth);
384 if ($search_date_startyear) {
385 $param .=
'&search_date_startyear='.urlencode($search_date_startyear);
387 if ($search_date_startendday) {
388 $param .=
'&search_date_startendday='.urlencode($search_date_startendday);
390 if ($search_date_startendmonth) {
391 $param .=
'&search_date_startendmonth='.urlencode($search_date_startendmonth);
393 if ($search_date_startendyear) {
394 $param .=
'&search_date_startendyear='.urlencode($search_date_startendyear);
397 if ($search_date_endday) {
398 $param .=
'&search_date_endday='.urlencode($search_date_endday);
400 if ($search_date_endmonth) {
401 $param .=
'&search_date_endmonth='.urlencode($search_date_endmonth);
403 if ($search_date_endyear) {
404 $param .=
'&search_date_endyear='.urlencode($search_date_endyear);
406 if ($search_date_endendday) {
407 $param .=
'&search_date_endendday='.urlencode($search_date_endendday);
409 if ($search_date_endendmonth) {
410 $param .=
'&search_date_endendmonth='.urlencode($search_date_endendmonth);
412 if ($search_date_endendyear) {
413 $param .=
'&search_date_endendyear='.urlencode($search_date_endendyear);
416 $param .=
"&search_user=".urlencode($search_user);
418 if ($search_amount_ht) {
419 $param .=
"&search_amount_ht=".urlencode($search_amount_ht);
421 if ($search_amount_ttc) {
422 $param .=
"&search_amount_ttc=".urlencode($search_amount_ttc);
424 if ($search_status >= 0) {
425 $param .=
"&search_status=".urlencode($search_status);
427 if ($optioncss !=
'') {
428 $param .=
'&optioncss='.urlencode($optioncss);
431 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
434 $arrayofmassactions = array(
435 'generate_doc'=>
img_picto(
'',
'pdf',
'class="pictofixedwidth"').$langs->trans(
"ReGeneratePDF"),
436 'builddoc'=>
img_picto(
'',
'pdf',
'class="pictofixedwidth"').$langs->trans(
"PDFMerge"),
437 'presend'=>
img_picto(
'',
'email',
'class="pictofixedwidth"').$langs->trans(
"SendByMail"),
439 if ($user->rights->expensereport->supprimer) {
440 $arrayofmassactions[
'predelete'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
442 if (in_array($massaction, array(
'presend',
'predelete'))) {
443 $arrayofmassactions = array();
445 $massactionbutton =
$form->selectMassAction(
'', $arrayofmassactions);
448 print
'<form id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">'.
"\n";
449 if ($optioncss !=
'') {
450 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
452 print
'<input type="hidden" name="token" value="'.newToken().
'">';
453 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
454 print
'<input type="hidden" name="action" value="'.($action ==
'edit' ?
'update' :
'list').
'">';
455 print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
456 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
457 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
459 print
'<input type="hidden" name="id" value="'.$id.
'">';
463 $title = $langs->trans(
"User");
464 $linkback =
'<a href="'.DOL_URL_ROOT.
'/user/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
469 dol_banner_tab($fuser,
'id', $linkback, $user->rights->user->user->lire || $user->admin);
473 if ($action !=
'edit') {
474 print
'<div class="tabsAction">';
476 $childids = $user->getAllChildIds(1);
478 $canedit = ((in_array($user_id, $childids) && $user->rights->expensereport->creer)
479 || ($conf->global->MAIN_USE_ADVANCED_PERMS && $user->rights->expensereport->writeall_advance));
483 print
'<a href="'.DOL_URL_ROOT.
'/expensereport/card.php?action=create&fk_user_author='.$fuser->id.
'" class="butAction">'.$langs->trans(
"AddTrip").
'</a>';
485 print
'<a href="#" class="butActionRefused" title="'.$langs->trans(
"NotEnoughPermissions").
'">'.$langs->trans(
"AddTrip").
'</a>';
490 print
$form->buttonsSaveCancel(
"Save",
'');
493 $title = $langs->trans(
"ListTripsAndExpenses");
495 $url = DOL_URL_ROOT.
'/expensereport/card.php?action=create';
496 if (!empty($socid)) {
497 $url .=
'&socid='.$socid;
499 $newcardbutton =
dolGetButtonTitle($langs->trans(
'NewTrip'),
'',
'fa fa-plus-circle', $url,
'', $user->rights->expensereport->creer);
501 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'trip', 0, $newcardbutton,
'', $limit, 0, 0, 1);
504 $topicmail =
"SendExpenseReport";
505 $modelmail =
"expensereport";
507 $trackid =
'exp'.$object->id;
508 include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
511 foreach ($fieldstosearchall as $key => $val) {
512 $fieldstosearchall[$key] = $langs->trans($val);
514 print
'<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $sall).join(
', ', $fieldstosearchall).
'</div>';
519 $parameters = array();
520 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters);
521 if (empty($reshook)) {
522 $moreforfilter .= $hookmanager->resPrint;
524 $moreforfilter = $hookmanager->resPrint;
527 if (!empty($moreforfilter)) {
528 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
529 print $moreforfilter;
533 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
534 $selectedfields =
$form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage);
535 $selectedfields .= (count($arrayofmassactions) ?
$form->showCheckAddButtons(
'checkforselect', 1) :
'');
537 print
'<div class="div-table-responsive">';
538 print
'<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
541 print
'<tr class="liste_titre_filter">';
542 if (!empty($arrayfields[
'd.ref'][
'checked'])) {
543 print
'<td class="liste_titre" align="left">';
544 print
'<input class="flat" size="15" type="text" name="search_ref" value="'.$search_ref.
'">';
548 if (!empty($arrayfields[
'user'][
'checked'])) {
549 if ($user->rights->expensereport->readall || $user->rights->expensereport->lire_tous) {
550 print
'<td class="liste_titre maxwidthonspartphone" align="left">';
551 print
$form->select_dolusers($search_user,
'search_user', 1,
'', 0,
'',
'', 0, 0, 0,
'', 0,
'',
'maxwidth200');
554 print
'<td class="liste_titre"> </td>';
558 if (!empty($arrayfields[
'd.date_debut'][
'checked'])) {
559 print
'<td class="liste_titre" align="center">';
560 print
'<div class="nowrap">';
561 print
$form->selectDate($search_date_start ? $search_date_start : -1,
'search_date_start', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
563 print
'<div class="nowrap">';
564 print
$form->selectDate($search_date_startend ? $search_date_startend : -1,
'search_date_startend', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
569 if (!empty($arrayfields[
'd.date_fin'][
'checked'])) {
570 print
'<td class="liste_titre" align="center">';
571 print
'<div class="nowrap">';
572 print
$form->selectDate($search_date_end ? $search_date_end : -1,
'search_date_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
574 print
'<div class="nowrap">';
575 print
$form->selectDate($search_date_endend ? $search_date_endend : -1,
'search_date_endend', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
580 if (!empty($arrayfields[
'd.date_valid'][
'checked'])) {
581 print
'<td class="liste_titre" align="center">';
587 if (!empty($arrayfields[
'd.date_approve'][
'checked'])) {
588 print
'<td class="liste_titre" align="center">';
594 if (!empty($arrayfields[
'd.total_ht'][
'checked'])) {
595 print
'<td class="liste_titre right"><input class="flat" type="text" size="5" name="search_amount_ht" value="'.$search_amount_ht.
'"></td>';
597 if (!empty($arrayfields[
'd.total_vat'][
'checked'])) {
598 print
'<td class="liste_titre right"><input class="flat" type="text" size="5" name="search_amount_vat" value="'.$search_amount_vat.
'"></td>';
601 if (!empty($arrayfields[
'd.total_ttc'][
'checked'])) {
602 print
'<td class="liste_titre right"><input class="flat" type="text" size="5" name="search_amount_ttc" value="'.$search_amount_ttc.
'"></td>';
605 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
608 $parameters = array(
'arrayfields'=>$arrayfields);
609 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters);
610 print $hookmanager->resPrint;
612 if (!empty($arrayfields[
'd.date_create'][
'checked'])) {
613 print
'<td class="liste_titre">';
617 if (!empty($arrayfields[
'd.tms'][
'checked'])) {
618 print
'<td class="liste_titre">';
622 if (!empty($arrayfields[
'd.fk_statut'][
'checked'])) {
623 print
'<td class="liste_titre right">';
624 $formexpensereport->selectExpensereportStatus($search_status,
'search_status', 1, 1);
628 print
'<td class="liste_titre maxwidthsearch">';
629 $searchpicto =
$form->showFilterButtons();
635 print
'<tr class="liste_titre">';
636 if (!empty($arrayfields[
'd.ref'][
'checked'])) {
637 print_liste_field_titre($arrayfields[
'd.ref'][
'label'], $_SERVER[
"PHP_SELF"],
"d.ref",
"", $param,
'', $sortfield, $sortorder);
639 if (!empty($arrayfields[
'user'][
'checked'])) {
640 print_liste_field_titre($arrayfields[
'user'][
'label'], $_SERVER[
"PHP_SELF"],
"u.lastname",
"", $param,
'', $sortfield, $sortorder);
642 if (!empty($arrayfields[
'd.date_debut'][
'checked'])) {
643 print_liste_field_titre($arrayfields[
'd.date_debut'][
'label'], $_SERVER[
"PHP_SELF"],
"d.date_debut",
"", $param,
'align="center"', $sortfield, $sortorder);
645 if (!empty($arrayfields[
'd.date_fin'][
'checked'])) {
646 print_liste_field_titre($arrayfields[
'd.date_fin'][
'label'], $_SERVER[
"PHP_SELF"],
"d.date_fin",
"", $param,
'align="center"', $sortfield, $sortorder);
648 if (!empty($arrayfields[
'd.date_valid'][
'checked'])) {
649 print_liste_field_titre($arrayfields[
'd.date_valid'][
'label'], $_SERVER[
"PHP_SELF"],
"d.date_valid",
"", $param,
'align="center"', $sortfield, $sortorder);
651 if (!empty($arrayfields[
'd.date_approve'][
'checked'])) {
652 print_liste_field_titre($arrayfields[
'd.date_approve'][
'label'], $_SERVER[
"PHP_SELF"],
"d.date_approve",
"", $param,
'align="center"', $sortfield, $sortorder);
654 if (!empty($arrayfields[
'd.total_ht'][
'checked'])) {
655 print_liste_field_titre($arrayfields[
'd.total_ht'][
'label'], $_SERVER[
"PHP_SELF"],
"d.total_ht",
"", $param,
'align="right"', $sortfield, $sortorder);
657 if (!empty($arrayfields[
'd.total_vat'][
'checked'])) {
658 print_liste_field_titre($arrayfields[
'd.total_vat'][
'label'], $_SERVER[
"PHP_SELF"],
"d.total_tva",
"", $param,
'align="right"', $sortfield, $sortorder);
660 if (!empty($arrayfields[
'd.total_ttc'][
'checked'])) {
661 print_liste_field_titre($arrayfields[
'd.total_ttc'][
'label'], $_SERVER[
"PHP_SELF"],
"d.total_ttc",
"", $param,
'align="right"', $sortfield, $sortorder);
664 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
666 $parameters = array(
'arrayfields'=>$arrayfields,
'param'=>$param,
'sortfield'=>$sortfield,
'sortorder'=>$sortorder);
667 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters);
668 print $hookmanager->resPrint;
669 if (!empty($arrayfields[
'd.date_create'][
'checked'])) {
670 print_liste_field_titre($arrayfields[
'd.date_create'][
'label'], $_SERVER[
"PHP_SELF"],
"d.date_create",
"", $param,
'align="center" class="nowrap"', $sortfield, $sortorder);
672 if (!empty($arrayfields[
'd.tms'][
'checked'])) {
673 print_liste_field_titre($arrayfields[
'd.tms'][
'label'], $_SERVER[
"PHP_SELF"],
"d.tms",
"", $param,
'align="center" class="nowrap"', $sortfield, $sortorder);
675 if (!empty($arrayfields[
'd.fk_statut'][
'checked'])) {
676 print_liste_field_titre($arrayfields[
'd.fk_statut'][
'label'], $_SERVER[
"PHP_SELF"],
"d.fk_statut",
"", $param,
'align="right"', $sortfield, $sortorder);
678 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'align="center"', $sortfield, $sortorder,
'maxwidthsearch ');
682 $total_total_ttc = 0;
683 $total_total_tva = 0;
686 $usertmp =
new User($db);
690 $totalarray = array();
691 $totalarray[
'nbfield'] = 0;
692 $totalarray[
'val'] = array();
693 $totalarray[
'val'][
'd.total_ht'] = 0;
694 $totalarray[
'val'][
'd.total_tva'] = 0;
695 $totalarray[
'val'][
'd.total_ttc'] = 0;
696 $totalarray[
'totalizable'] = array();
697 while ($i < min($num, $limit)) {
698 $obj = $db->fetch_object(
$resql);
700 $expensereportstatic->id = $obj->rowid;
701 $expensereportstatic->ref = $obj->ref;
702 $expensereportstatic->status = $obj->status;
703 $expensereportstatic->date_debut = $db->jdate($obj->date_debut);
704 $expensereportstatic->date_fin = $db->jdate($obj->date_fin);
705 $expensereportstatic->date_create = $db->jdate($obj->date_create);
706 $expensereportstatic->date_modif = $db->jdate($obj->date_modif);
707 $expensereportstatic->date_valid = $db->jdate($obj->date_valid);
708 $expensereportstatic->date_approve = $db->jdate($obj->date_approve);
709 $expensereportstatic->note_private = $obj->note_private;
710 $expensereportstatic->note_public = $obj->note_public;
713 print
'<tr class="oddeven">';
715 if (!empty($arrayfields[
'd.ref'][
'checked'])) {
717 print
'<table class="nobordernopadding"><tr class="nocellnopadd">';
718 print
'<td class="nobordernopadding nowrap">';
719 print $expensereportstatic->getNomUrl(1);
722 print
'<td class="nobordernopadding nowrap">';
723 if ($expensereportstatic->status == 2 && $expensereportstatic->hasDelay(
'toappove')) {
726 if ($expensereportstatic->status == 5 && $expensereportstatic->hasDelay(
'topay')) {
729 if (!empty($obj->note_private) || !empty($obj->note_public)) {
730 print
' <span class="note">';
731 print
'<a href="'.DOL_URL_ROOT.
'/expensereport/note.php?id='.$obj->rowid.
'">'.
img_picto($langs->trans(
"ViewPrivateNote"),
'object_generic').
'</a>';
735 print
'<td width="16" class="nobordernopadding hideonsmartphone right">';
738 $urlsource = $_SERVER[
'PHP_SELF'].
'?id='.$obj->rowid;
739 print $formfile->getDocumentsLink($expensereportstatic->element, $filename, $filedir);
741 print
'</tr></table>';
744 $totalarray[
'nbfield']++;
748 if (!empty($arrayfields[
'user'][
'checked'])) {
749 print
'<td class="left">';
750 $usertmp->id = $obj->id_user;
751 $usertmp->lastname = $obj->lastname;
752 $usertmp->firstname = $obj->firstname;
753 $usertmp->login = $obj->login;
754 $usertmp->statut = $obj->statut;
755 $usertmp->photo = $obj->photo;
756 $usertmp->email = $obj->email;
757 print $usertmp->getNomUrl(-1);
760 $totalarray[
'nbfield']++;
764 if (!empty($arrayfields[
'd.date_debut'][
'checked'])) {
765 print
'<td class="center">'.($obj->date_debut > 0 ?
dol_print_date($db->jdate($obj->date_debut),
'day') :
'').
'</td>';
767 $totalarray[
'nbfield']++;
771 if (!empty($arrayfields[
'd.date_fin'][
'checked'])) {
772 print
'<td class="center">'.($obj->date_fin > 0 ?
dol_print_date($db->jdate($obj->date_fin),
'day') :
'').
'</td>';
774 $totalarray[
'nbfield']++;
778 if (!empty($arrayfields[
'd.date_valid'][
'checked'])) {
779 print
'<td class="center">'.($obj->date_valid > 0 ?
dol_print_date($db->jdate($obj->date_valid),
'day') :
'').
'</td>';
781 $totalarray[
'nbfield']++;
785 if (!empty($arrayfields[
'd.date_approve'][
'checked'])) {
786 print
'<td class="center">'.($obj->date_approve > 0 ?
dol_print_date($db->jdate($obj->date_approve),
'day') :
'').
'</td>';
788 $totalarray[
'nbfield']++;
792 if (!empty($arrayfields[
'd.total_ht'][
'checked'])) {
793 print
'<td class="right">'.price($obj->total_ht).
"</td>\n";
795 $totalarray[
'nbfield']++;
798 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'd.total_ht';
800 $totalarray[
'val'][
'd.total_ht'] += $obj->total_ht;
803 if (!empty($arrayfields[
'd.total_vat'][
'checked'])) {
804 print
'<td class="right">'.price($obj->total_tva).
"</td>\n";
806 $totalarray[
'nbfield']++;
809 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'd.total_tva';
811 $totalarray[
'val'][
'd.total_tva'] += $obj->total_tva;
814 if (!empty($arrayfields[
'd.total_ttc'][
'checked'])) {
815 print
'<td class="right">'.price($obj->total_ttc).
"</td>\n";
817 $totalarray[
'nbfield']++;
820 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'd.total_ttc';
822 $totalarray[
'val'][
'd.total_ttc'] += $obj->total_ttc;
826 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
828 $parameters = array(
'arrayfields'=>$arrayfields,
'obj'=>$obj,
'i'=>$i,
'totalarray'=>&$totalarray);
829 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters);
830 print $hookmanager->resPrint;
833 if (!empty($arrayfields[
'd.date_create'][
'checked'])) {
834 print
'<td class="nowrap center">';
838 $totalarray[
'nbfield']++;
842 if (!empty($arrayfields[
'd.tms'][
'checked'])) {
843 print
'<td class="nowrap center">';
847 $totalarray[
'nbfield']++;
851 if (!empty($arrayfields[
'd.fk_statut'][
'checked'])) {
852 print
'<td class="nowrap right">'.$expensereportstatic->getLibStatut(5).
'</td>';
854 $totalarray[
'nbfield']++;
858 print
'<td class="nowrap center">';
859 if ($massactionbutton || $massaction) {
861 if (in_array($obj->rowid, $arrayofselected)) {
864 print
'<input id="cb'.$obj->rowid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
868 $totalarray[
'nbfield']++;
873 $total_total_ht = $total_total_ht + $obj->total_ht;
874 $total_total_tva = $total_total_tva + $obj->total_tva;
875 $total_total_ttc = $total_total_ttc + $obj->total_ttc;
881 foreach ($arrayfields as $key => $val) {
882 if (!empty($val[
'checked'])) {
886 print
'<tr><td colspan="'.$colspan.
'" class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</td></tr>';
890 include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
894 $parameters = array(
'arrayfields'=>$arrayfields,
'sql'=>$sql);
895 $reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters);
896 print $hookmanager->resPrint;
898 print
'</table>'.
"\n";
901 print
'</form>'.
"\n";
904 $hidegeneratedfilelistifempty = 1;
905 if ($massaction ==
'builddoc' || $action ==
'remove_file' || $show_files) {
906 $hidegeneratedfilelistifempty = 0;
910 $urlsource = $_SERVER[
'PHP_SELF'].
'?sortfield='.$sortfield.
'&sortorder='.$sortorder;
911 $urlsource .= str_replace(
'&',
'&', $param);
913 $filedir = $diroutputmassaction;
914 $genallowed = $user->rights->expensereport->lire;
915 $delallowed = $user->rights->expensereport->creer;
917 print $formfile->showdocuments(
'massfilesarea_expensereport',
'', $filedir, $urlsource, 0, $delallowed,
'', 1, 1, 0, 48, 1, $param, $title,
'',
'',
'',
null, $hidegeneratedfilelistifempty);