33require
'../main.inc.php';
34require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
35require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
36require_once DOL_DOCUMENT_ROOT.
'/expensereport/class/expensereport.class.php';
37require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
38require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
39require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formexpensereport.class.php';
40require_once DOL_DOCUMENT_ROOT.
'/core/lib/usergroups.lib.php';
41require_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';
53$mode =
GETPOST(
'mode',
'alpha');
55$childids = $user->getAllChildIds(1);
58$socid =
GETPOST(
'socid',
'int');
60 $socid = $user->socid;
67 if ($id == $user->id) {
70 if (!empty($user->rights->expensereport->readall)) {
73 if (!empty($user->rights->expensereport->lire) && in_array($id, $childids)) {
81$diroutputmassaction = $conf->expensereport->dir_output.
'/temp/massgeneration/'.$user->id;
85$limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
86$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
87$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
88$page = GETPOSTISSET(
'pageplusone') ? (
GETPOST(
'pageplusone') - 1) :
GETPOST(
"page",
'int');
89if (empty($page) || $page == -1) {
92$offset = $limit * $page;
99 $sortfield =
"d.date_debut";
103$sall = trim((
GETPOST(
'search_all',
'alphanohtml') !=
'') ?
GETPOST(
'search_all',
'alphanohtml') :
GETPOST(
'sall',
'alphanohtml'));
105$search_ref =
GETPOST(
'search_ref',
'alpha');
106$search_user =
GETPOST(
'search_user',
'int');
107$search_amount_ht =
GETPOST(
'search_amount_ht',
'alpha');
108$search_amount_vat =
GETPOST(
'search_amount_vat',
'alpha');
109$search_amount_ttc =
GETPOST(
'search_amount_ttc',
'alpha');
110$search_status = (
GETPOST(
'search_status',
'intcomma') !=
'' ?
GETPOST(
'search_status',
'intcomma') :
GETPOST(
'statut',
'intcomma'));
112$search_date_startday =
GETPOST(
'search_date_startday',
'int');
113$search_date_startmonth =
GETPOST(
'search_date_startmonth',
'int');
114$search_date_startyear =
GETPOST(
'search_date_startyear',
'int');
115$search_date_startendday =
GETPOST(
'search_date_startendday',
'int');
116$search_date_startendmonth =
GETPOST(
'search_date_startendmonth',
'int');
117$search_date_startendyear =
GETPOST(
'search_date_startendyear',
'int');
118$search_date_start =
dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear);
119$search_date_startend =
dol_mktime(23, 59, 59, $search_date_startendmonth, $search_date_startendday, $search_date_startendyear);
121$search_date_endday =
GETPOST(
'search_date_endday',
'int');
122$search_date_endmonth =
GETPOST(
'search_date_endmonth',
'int');
123$search_date_endyear =
GETPOST(
'search_date_endyear',
'int');
124$search_date_endendday =
GETPOST(
'search_date_endendday',
'int');
125$search_date_endendmonth =
GETPOST(
'search_date_endendmonth',
'int');
126$search_date_endendyear =
GETPOST(
'search_date_endendyear',
'int');
127$search_date_end =
dol_mktime(0, 0, 0, $search_date_endmonth, $search_date_endday, $search_date_endyear);
128$search_date_endend =
dol_mktime(23, 59, 59, $search_date_endendmonth, $search_date_endendday, $search_date_endendyear);
130$optioncss =
GETPOST(
'optioncss',
'alpha');
132if ($search_status ==
'') {
135if ($search_user ==
'') {
141$hookmanager->initHooks(array(
'expensereportlist'));
145$extrafields->fetch_name_optionals_label($object->table_element);
147$search_array_options = $extrafields->getOptionalsFromPost($object->table_element,
'',
'search_');
151$fieldstosearchall = array(
153 'd.note_public'=>
"NotePublic",
154 'u.lastname'=>
'EmployeeLastname',
155 'u.firstname'=>
"EmployeeFirstname",
158if (empty($user->socid)) {
159 $fieldstosearchall[
"d.note_private"] =
"NotePrivate";
163 'd.ref'=>array(
'label'=>$langs->trans(
"Ref"),
'checked'=>1),
164 'user'=>array(
'label'=>$langs->trans(
"User"),
'checked'=>1),
165 'd.date_debut'=>array(
'label'=>$langs->trans(
"DateStart"),
'checked'=>1),
166 'd.date_fin'=>array(
'label'=>$langs->trans(
"DateEnd"),
'checked'=>1),
167 'd.date_valid'=>array(
'label'=>$langs->trans(
"DateValidation"),
'checked'=>1),
168 'd.date_approve'=>array(
'label'=>$langs->trans(
"DateApprove"),
'checked'=>1),
169 'd.total_ht'=>array(
'label'=>$langs->trans(
"AmountHT"),
'checked'=>1),
170 'd.total_vat'=>array(
'label'=>$langs->trans(
"AmountVAT"),
'checked'=>1),
171 'd.total_ttc'=>array(
'label'=>$langs->trans(
"AmountTTC"),
'checked'=>1),
172 'd.date_create'=>array(
'label'=>$langs->trans(
"DateCreation"),
'checked'=>0,
'position'=>500),
173 'd.tms'=>array(
'label'=>$langs->trans(
"DateModificationShort"),
'checked'=>0,
'position'=>500),
174 'd.fk_statut'=>array(
'label'=>$langs->trans(
"Status"),
'checked'=>1,
'position'=>1000),
177include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_array_fields.tpl.php';
179$canedituser = (!empty($user->admin) || $user->hasRight(
'user',
'user',
'creer'));
181$objectuser =
new User($db);
188if (
GETPOST(
'cancel',
'alpha')) {
189 $action =
'list'; $massaction =
'';
191if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
195$parameters = array(
'socid'=>$socid);
196$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
201if (empty($reshook)) {
203 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
206 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
209 $search_amount_ht =
"";
210 $search_amount_vat =
"";
211 $search_amount_ttc =
"";
213 $search_date_startday =
'';
214 $search_date_startmonth =
'';
215 $search_date_startyear =
'';
216 $search_date_startendday =
'';
217 $search_date_startendmonth =
'';
218 $search_date_startendyear =
'';
219 $search_date_start =
'';
220 $search_date_startend =
'';
221 $search_date_endday =
'';
222 $search_date_endmonth =
'';
223 $search_date_endyear =
'';
224 $search_date_endendday =
'';
225 $search_date_endendmonth =
'';
226 $search_date_endendyear =
'';
227 $search_date_end =
'';
228 $search_date_endend =
'';
230 $search_array_options = array();
232 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')
233 ||
GETPOST(
'button_search_x',
'alpha') ||
GETPOST(
'button_search.x',
'alpha') ||
GETPOST(
'button_search',
'alpha')) {
238 $objectclass =
'ExpenseReport';
239 $objectlabel =
'ExpenseReport';
240 $permissiontoread = $user->rights->expensereport->lire;
241 $permissiontodelete = $user->rights->expensereport->supprimer;
242 $uploaddir = $conf->expensereport->dir_output;
243 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
251$form =
new Form($db);
256$fuser =
new User($db);
258$title = $langs->trans(
"TripsAndExpenses");
269 $fuser->fetch($id,
'',
'', 1);
271 $user_id = $fuser->id;
273 $search_user = $user_id;
276$sql =
"SELECT d.rowid, d.ref, d.fk_user_author, d.total_ht, d.total_tva, d.total_ttc, d.fk_statut as status,";
277$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,";
278$sql .=
" u.rowid as id_user, u.firstname, u.lastname, u.login, u.email, u.statut, u.photo";
280if (!empty($extrafields->attributes[$object->table_element][
'label'])) {
281 foreach ($extrafields->attributes[$object->table_element][
'label'] as $key => $val) {
282 $sql .= ($extrafields->attributes[$object->table_element][
'type'][$key] !=
'separate' ?
", ef.".$key.
" as options_".$key :
'');
286$parameters = array();
287$reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters);
288$sql .= $hookmanager->resPrint;
292$sql .=
" FROM ".MAIN_DB_PREFIX.
"expensereport as d";
293if (isset($extrafields->attributes[$object->table_element][
'label']) && is_array($extrafields->attributes[$object->table_element][
'label']) && count($extrafields->attributes[$object->table_element][
'label'])) {
294 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element.
"_extrafields as ef on (d.rowid = ef.fk_object)";
296$sql .=
", ".MAIN_DB_PREFIX.
"user as u";
297$sql .=
" WHERE d.fk_user_author = u.rowid AND d.entity IN (".getEntity(
'expensereport').
")";
303if (!empty($search_ref)) {
307if ($search_date_start) {
308 $sql .=
" AND d.date_debut >= '".$db->idate($search_date_start).
"'";
310if ($search_date_startend) {
311 $sql .=
" AND d.date_debut <= '".$db->idate($search_date_startend).
"'";
314if ($search_date_end) {
315 $sql .=
" AND d.date_fin >= '".$db->idate($search_date_end).
"'";
317if ($search_date_endend) {
318 $sql .=
" AND d.date_fin <= '".$db->idate($search_date_endend).
"'";
321if ($search_amount_ht !=
'') {
324if ($search_amount_ttc !=
'') {
328if ($search_user !=
'' && $search_user >= 0) {
329 $sql .=
" AND u.rowid = '".$db->escape($search_user).
"'";
332if ($search_status !=
'' && $search_status >= 0) {
333 $sql .=
" AND d.fk_statut IN (".$db->sanitize($search_status).
")";
336if (empty($user->rights->expensereport->readall) && empty($user->rights->expensereport->lire_tous)
337 && (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || empty($user->rights->expensereport->writeall_advance))) {
338 $sql .=
" AND d.fk_user_author IN (".$db->sanitize(join(
',', $childids)).
")\n";
341include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
343$parameters = array();
344$reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters);
345$sql .= $hookmanager->resPrint;
348$nbtotalofrecords =
'';
351 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords', $sql);
352 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
353 $resql = $db->query($sqlforcount);
355 $objforcount = $db->fetch_object($resql);
356 $nbtotalofrecords = $objforcount->nbtotalofrecords;
361 if (($page * $limit) > $nbtotalofrecords) {
369$sql .= $db->order($sortfield, $sortorder);
371 $sql .= $db->plimit($limit + 1, $offset);
375$resql = $db->query($sql);
377 $num = $db->num_rows($resql);
379 $arrayofselected = is_array($toselect) ? $toselect : array();
383 $param .=
'&mode='.urlencode($mode);
385 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
386 $param .=
'&contextpage='.urlencode($contextpage);
388 if ($limit > 0 && $limit != $conf->liste_limit) {
389 $param .=
'&limit='.((int) $limit);
392 $param .=
"&sall=".urlencode($sall);
395 $param .=
"&search_ref=".urlencode($search_ref);
398 if ($search_date_startday) {
399 $param .=
'&search_date_startday='.urlencode($search_date_startday);
401 if ($search_date_startmonth) {
402 $param .=
'&search_date_startmonth='.urlencode($search_date_startmonth);
404 if ($search_date_startyear) {
405 $param .=
'&search_date_startyear='.urlencode($search_date_startyear);
407 if ($search_date_startendday) {
408 $param .=
'&search_date_startendday='.urlencode($search_date_startendday);
410 if ($search_date_startendmonth) {
411 $param .=
'&search_date_startendmonth='.urlencode($search_date_startendmonth);
413 if ($search_date_startendyear) {
414 $param .=
'&search_date_startendyear='.urlencode($search_date_startendyear);
417 if ($search_date_endday) {
418 $param .=
'&search_date_endday='.urlencode($search_date_endday);
420 if ($search_date_endmonth) {
421 $param .=
'&search_date_endmonth='.urlencode($search_date_endmonth);
423 if ($search_date_endyear) {
424 $param .=
'&search_date_endyear='.urlencode($search_date_endyear);
426 if ($search_date_endendday) {
427 $param .=
'&search_date_endendday='.urlencode($search_date_endendday);
429 if ($search_date_endendmonth) {
430 $param .=
'&search_date_endendmonth='.urlencode($search_date_endendmonth);
432 if ($search_date_endendyear) {
433 $param .=
'&search_date_endendyear='.urlencode($search_date_endendyear);
436 $param .=
"&search_user=".urlencode($search_user);
438 if ($search_amount_ht) {
439 $param .=
"&search_amount_ht=".urlencode($search_amount_ht);
441 if ($search_amount_ttc) {
442 $param .=
"&search_amount_ttc=".urlencode($search_amount_ttc);
444 if ($search_status >= 0) {
445 $param .=
"&search_status=".urlencode($search_status);
447 if ($optioncss !=
'') {
448 $param .=
'&optioncss='.urlencode($optioncss);
451 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
454 $arrayofmassactions = array(
455 'generate_doc'=>
img_picto(
'',
'pdf',
'class="pictofixedwidth"').$langs->trans(
"ReGeneratePDF"),
456 'builddoc'=>
img_picto(
'',
'pdf',
'class="pictofixedwidth"').$langs->trans(
"PDFMerge"),
457 'presend'=>
img_picto(
'',
'email',
'class="pictofixedwidth"').$langs->trans(
"SendByMail"),
459 if ($user->rights->expensereport->supprimer) {
460 $arrayofmassactions[
'predelete'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
462 if (in_array($massaction, array(
'presend',
'predelete'))) {
463 $arrayofmassactions = array();
465 $massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
468 print
'<form id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">'.
"\n";
469 if ($optioncss !=
'') {
470 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
472 print
'<input type="hidden" name="token" value="'.newToken().
'">';
473 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
474 print
'<input type="hidden" name="action" value="'.($action ==
'edit' ?
'update' :
'list').
'">';
475 print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
476 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
477 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
478 print
'<input type="hidden" name="mode" value="'.$mode.
'">';
480 print
'<input type="hidden" name="id" value="'.$id.
'">';
484 $title = $langs->trans(
"User");
485 $linkback =
'<a href="'.DOL_URL_ROOT.
'/user/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
490 dol_banner_tab($fuser,
'id', $linkback, $user->rights->user->user->lire || $user->admin);
494 if ($action !=
'edit') {
495 print
'<div class="tabsAction">';
497 $childids = $user->getAllChildIds(1);
499 $canedit = ((in_array($user_id, $childids) && $user->rights->expensereport->creer)
500 || ($conf->global->MAIN_USE_ADVANCED_PERMS && $user->rights->expensereport->writeall_advance));
504 print
'<a href="'.DOL_URL_ROOT.
'/expensereport/card.php?action=create&fk_user_author='.$fuser->id.
'" class="butAction">'.$langs->trans(
"AddTrip").
'</a>';
506 print
'<a href="#" class="butActionRefused" title="'.$langs->trans(
"NotEnoughPermissions").
'">'.$langs->trans(
"AddTrip").
'</a>';
511 print $form->buttonsSaveCancel(
"Save",
'');
514 $title = $langs->trans(
"ListTripsAndExpenses");
516 $url = DOL_URL_ROOT.
'/expensereport/card.php?action=create';
517 if (!empty($socid)) {
518 $url .=
'&socid='.$socid;
521 $newcardbutton .=
dolGetButtonTitle($langs->trans(
'ViewList'),
'',
'fa fa-bars imgforviewmode', $_SERVER[
"PHP_SELF"].
'?mode=common'.preg_replace(
'/(&|\?)*mode=[^&]+/',
'', $param),
'', ((empty($mode) || $mode ==
'common') ? 2 : 1), array(
'morecss'=>
'reposition'));
522 $newcardbutton .=
dolGetButtonTitle($langs->trans(
'ViewKanban'),
'',
'fa fa-th-list imgforviewmode', $_SERVER[
"PHP_SELF"].
'?mode=kanban'.preg_replace(
'/(&|\?)*mode=[^&]+/',
'', $param),
'', ($mode ==
'kanban' ? 2 : 1), array(
'morecss'=>
'reposition'));
523 $newcardbutton .=
dolGetButtonTitle($langs->trans(
'NewTrip'),
'',
'fa fa-plus-circle', $url,
'', $user->rights->expensereport->creer);
525 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'trip', 0, $newcardbutton,
'', $limit, 0, 0, 1);
528 $topicmail =
"SendExpenseReport";
529 $modelmail =
"expensereport";
531 $trackid =
'exp'.$object->id;
532 include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
535 foreach ($fieldstosearchall as $key => $val) {
536 $fieldstosearchall[$key] = $langs->trans($val);
538 print
'<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $sall).join(
', ', $fieldstosearchall).
'</div>';
543 $parameters = array();
544 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters);
545 if (empty($reshook)) {
546 $moreforfilter .= $hookmanager->resPrint;
548 $moreforfilter = $hookmanager->resPrint;
551 if (!empty($moreforfilter)) {
552 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
553 print $moreforfilter;
557 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
558 $selectedfields = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN'));
559 $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
561 print
'<div class="div-table-responsive">';
562 print
'<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
565 print
'<tr class="liste_titre_filter">';
568 print
'<td class="liste_titre maxwidthsearch">';
569 $searchpicto = $form->showFilterButtons(
'left');
573 if (!empty($arrayfields[
'd.ref'][
'checked'])) {
574 print
'<td class="liste_titre" align="left">';
575 print
'<input class="flat" size="15" type="text" name="search_ref" value="'.$search_ref.
'">';
579 if (!empty($arrayfields[
'user'][
'checked'])) {
580 if ($user->rights->expensereport->readall || $user->rights->expensereport->lire_tous) {
581 print
'<td class="liste_titre maxwidthonspartphone" align="left">';
582 print $form->select_dolusers($search_user,
'search_user', 1,
'', 0,
'',
'', 0, 0, 0,
'', 0,
'',
'maxwidth200');
585 print
'<td class="liste_titre"> </td>';
589 if (!empty($arrayfields[
'd.date_debut'][
'checked'])) {
590 print
'<td class="liste_titre" align="center">';
591 print
'<div class="nowrap">';
592 print $form->selectDate($search_date_start ? $search_date_start : -1,
'search_date_start', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
594 print
'<div class="nowrap">';
595 print $form->selectDate($search_date_startend ? $search_date_startend : -1,
'search_date_startend', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
600 if (!empty($arrayfields[
'd.date_fin'][
'checked'])) {
601 print
'<td class="liste_titre" align="center">';
602 print
'<div class="nowrap">';
603 print $form->selectDate($search_date_end ? $search_date_end : -1,
'search_date_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
605 print
'<div class="nowrap">';
606 print $form->selectDate($search_date_endend ? $search_date_endend : -1,
'search_date_endend', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
611 if (!empty($arrayfields[
'd.date_valid'][
'checked'])) {
612 print
'<td class="liste_titre" align="center">';
618 if (!empty($arrayfields[
'd.date_approve'][
'checked'])) {
619 print
'<td class="liste_titre" align="center">';
625 if (!empty($arrayfields[
'd.total_ht'][
'checked'])) {
626 print
'<td class="liste_titre right"><input class="flat" type="text" size="5" name="search_amount_ht" value="'.$search_amount_ht.
'"></td>';
628 if (!empty($arrayfields[
'd.total_vat'][
'checked'])) {
629 print
'<td class="liste_titre right"><input class="flat" type="text" size="5" name="search_amount_vat" value="'.$search_amount_vat.
'"></td>';
632 if (!empty($arrayfields[
'd.total_ttc'][
'checked'])) {
633 print
'<td class="liste_titre right"><input class="flat" type="text" size="5" name="search_amount_ttc" value="'.$search_amount_ttc.
'"></td>';
636 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
639 $parameters = array(
'arrayfields'=>$arrayfields);
640 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters);
641 print $hookmanager->resPrint;
643 if (!empty($arrayfields[
'd.date_create'][
'checked'])) {
644 print
'<td class="liste_titre">';
648 if (!empty($arrayfields[
'd.tms'][
'checked'])) {
649 print
'<td class="liste_titre">';
653 if (!empty($arrayfields[
'd.fk_statut'][
'checked'])) {
654 print
'<td class="liste_titre right">';
655 $formexpensereport->selectExpensereportStatus($search_status,
'search_status', 1, 1);
660 print
'<td class="liste_titre maxwidthsearch">';
661 $searchpicto = $form->showFilterButtons();
668 $totalarray = array();
669 $totalarray[
'nbfield'] = 0;
671 print
'<tr class="liste_titre">';
673 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'align="center"', $sortfield, $sortorder,
'maxwidthsearch ');
674 $totalarray[
'nbfield']++;
676 if (!empty($arrayfields[
'd.ref'][
'checked'])) {
677 print_liste_field_titre($arrayfields[
'd.ref'][
'label'], $_SERVER[
"PHP_SELF"],
"d.ref",
"", $param,
'', $sortfield, $sortorder);
678 $totalarray[
'nbfield']++;
680 if (!empty($arrayfields[
'user'][
'checked'])) {
681 print_liste_field_titre($arrayfields[
'user'][
'label'], $_SERVER[
"PHP_SELF"],
"u.lastname",
"", $param,
'', $sortfield, $sortorder);
682 $totalarray[
'nbfield']++;
684 if (!empty($arrayfields[
'd.date_debut'][
'checked'])) {
685 print_liste_field_titre($arrayfields[
'd.date_debut'][
'label'], $_SERVER[
"PHP_SELF"],
"d.date_debut",
"", $param,
'align="center"', $sortfield, $sortorder);
686 $totalarray[
'nbfield']++;
688 if (!empty($arrayfields[
'd.date_fin'][
'checked'])) {
689 print_liste_field_titre($arrayfields[
'd.date_fin'][
'label'], $_SERVER[
"PHP_SELF"],
"d.date_fin",
"", $param,
'align="center"', $sortfield, $sortorder);
690 $totalarray[
'nbfield']++;
692 if (!empty($arrayfields[
'd.date_valid'][
'checked'])) {
693 print_liste_field_titre($arrayfields[
'd.date_valid'][
'label'], $_SERVER[
"PHP_SELF"],
"d.date_valid",
"", $param,
'align="center"', $sortfield, $sortorder);
694 $totalarray[
'nbfield']++;
696 if (!empty($arrayfields[
'd.date_approve'][
'checked'])) {
697 print_liste_field_titre($arrayfields[
'd.date_approve'][
'label'], $_SERVER[
"PHP_SELF"],
"d.date_approve",
"", $param,
'align="center"', $sortfield, $sortorder);
698 $totalarray[
'nbfield']++;
700 if (!empty($arrayfields[
'd.total_ht'][
'checked'])) {
701 print_liste_field_titre($arrayfields[
'd.total_ht'][
'label'], $_SERVER[
"PHP_SELF"],
"d.total_ht",
"", $param,
'align="right"', $sortfield, $sortorder);
702 $totalarray[
'nbfield']++;
704 if (!empty($arrayfields[
'd.total_vat'][
'checked'])) {
705 print_liste_field_titre($arrayfields[
'd.total_vat'][
'label'], $_SERVER[
"PHP_SELF"],
"d.total_tva",
"", $param,
'align="right"', $sortfield, $sortorder);
706 $totalarray[
'nbfield']++;
708 if (!empty($arrayfields[
'd.total_ttc'][
'checked'])) {
709 print_liste_field_titre($arrayfields[
'd.total_ttc'][
'label'], $_SERVER[
"PHP_SELF"],
"d.total_ttc",
"", $param,
'align="right"', $sortfield, $sortorder);
710 $totalarray[
'nbfield']++;
713 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
715 $parameters = array(
'arrayfields'=>$arrayfields,
'param'=>$param,
'sortfield'=>$sortfield,
'sortorder'=>$sortorder);
716 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters);
717 print $hookmanager->resPrint;
718 if (!empty($arrayfields[
'd.date_create'][
'checked'])) {
719 print_liste_field_titre($arrayfields[
'd.date_create'][
'label'], $_SERVER[
"PHP_SELF"],
"d.date_create",
"", $param,
'align="center" class="nowrap"', $sortfield, $sortorder);
720 $totalarray[
'nbfield']++;
722 if (!empty($arrayfields[
'd.tms'][
'checked'])) {
723 print_liste_field_titre($arrayfields[
'd.tms'][
'label'], $_SERVER[
"PHP_SELF"],
"d.tms",
"", $param,
'align="center" class="nowrap"', $sortfield, $sortorder);
724 $totalarray[
'nbfield']++;
726 if (!empty($arrayfields[
'd.fk_statut'][
'checked'])) {
727 print_liste_field_titre($arrayfields[
'd.fk_statut'][
'label'], $_SERVER[
"PHP_SELF"],
"d.fk_statut",
"", $param,
'align="right"', $sortfield, $sortorder);
728 $totalarray[
'nbfield']++;
731 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'align="center"', $sortfield, $sortorder,
'maxwidthsearch ');
732 $totalarray[
'nbfield']++;
737 $total_total_ttc = 0;
738 $total_total_tva = 0;
741 $usertmp =
new User($db);
745 $savnbfield = $totalarray[
'nbfield'];
746 $totalarray = array();
747 $totalarray[
'nbfield'] = 0;
748 $totalarray[
'val'] = array();
749 $totalarray[
'val'][
'd.total_ht'] = 0;
750 $totalarray[
'val'][
'd.total_tva'] = 0;
751 $totalarray[
'val'][
'd.total_ttc'] = 0;
752 $totalarray[
'totalizable'] = array();
754 $imaxinloop = ($limit ? min($num, $limit) : $num);
755 while ($i < min($num, $limit)) {
756 $obj = $db->fetch_object($resql);
758 $expensereportstatic->id = $obj->rowid;
759 $expensereportstatic->ref = $obj->ref;
760 $expensereportstatic->status = $obj->status;
761 $expensereportstatic->date_debut = $db->jdate($obj->date_debut);
762 $expensereportstatic->date_fin = $db->jdate($obj->date_fin);
763 $expensereportstatic->date_create = $db->jdate($obj->date_create);
764 $expensereportstatic->date_modif = $db->jdate($obj->date_modif);
765 $expensereportstatic->date_valid = $db->jdate($obj->date_valid);
766 $expensereportstatic->date_approve = $db->jdate($obj->date_approve);
767 $expensereportstatic->note_private = $obj->note_private;
768 $expensereportstatic->note_public = $obj->note_public;
770 if ($mode ==
'kanban') {
772 print
'<tr class="trkanban"><td colspan="'.$savnbfield.
'">';
773 print
'<div class="box-flex-container kanban">';
776 $usertmp->fetch($obj->id_user);
779 if ($massactionbutton || $massaction) {
782 print $expensereportstatic->getKanbanView(
'', array(
'userauthor' => $usertmp->getNomUrl(1),
'selected' => in_array($expensereportstatic->id, $arrayofselected)));
784 if ($i == ($imaxinloop - 1)) {
789 print
'<tr class="oddeven">';
792 print
'<td class="nowrap center">';
793 if ($massactionbutton || $massaction) {
795 if (in_array($obj->rowid, $arrayofselected)) {
798 print
'<input id="cb'.$obj->rowid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
802 $totalarray[
'nbfield']++;
806 if (!empty($arrayfields[
'd.ref'][
'checked'])) {
808 print
'<table class="nobordernopadding"><tr class="nocellnopadd">';
809 print
'<td class="nobordernopadding nowrap">';
810 print $expensereportstatic->getNomUrl(1);
813 print
'<td class="nobordernopadding nowrap">';
814 if ($expensereportstatic->status == 2 && $expensereportstatic->hasDelay(
'toappove')) {
817 if ($expensereportstatic->status == 5 && $expensereportstatic->hasDelay(
'topay')) {
820 if (!empty($obj->note_private) || !empty($obj->note_public)) {
821 print
' <span class="note">';
822 print
'<a href="'.DOL_URL_ROOT.
'/expensereport/note.php?id='.$obj->rowid.
'">'.
img_picto($langs->trans(
"ViewPrivateNote"),
'object_generic').
'</a>';
826 print
'<td width="16" class="nobordernopadding hideonsmartphone right">';
829 $urlsource = $_SERVER[
'PHP_SELF'].
'?id='.$obj->rowid;
830 print $formfile->getDocumentsLink($expensereportstatic->element, $filename, $filedir);
832 print
'</tr></table>';
835 $totalarray[
'nbfield']++;
839 if (!empty($arrayfields[
'user'][
'checked'])) {
840 print
'<td class="left">';
841 $usertmp->id = $obj->id_user;
842 $usertmp->lastname = $obj->lastname;
843 $usertmp->firstname = $obj->firstname;
844 $usertmp->login = $obj->login;
845 $usertmp->statut = $obj->statut;
846 $usertmp->photo = $obj->photo;
847 $usertmp->email = $obj->email;
848 print $usertmp->getNomUrl(-1);
851 $totalarray[
'nbfield']++;
855 if (!empty($arrayfields[
'd.date_debut'][
'checked'])) {
856 print
'<td class="center">'.($obj->date_debut > 0 ?
dol_print_date($db->jdate($obj->date_debut),
'day') :
'').
'</td>';
858 $totalarray[
'nbfield']++;
862 if (!empty($arrayfields[
'd.date_fin'][
'checked'])) {
863 print
'<td class="center">'.($obj->date_fin > 0 ?
dol_print_date($db->jdate($obj->date_fin),
'day') :
'').
'</td>';
865 $totalarray[
'nbfield']++;
869 if (!empty($arrayfields[
'd.date_valid'][
'checked'])) {
870 print
'<td class="center">'.($obj->date_valid > 0 ?
dol_print_date($db->jdate($obj->date_valid),
'day') :
'').
'</td>';
872 $totalarray[
'nbfield']++;
876 if (!empty($arrayfields[
'd.date_approve'][
'checked'])) {
877 print
'<td class="center">'.($obj->date_approve > 0 ?
dol_print_date($db->jdate($obj->date_approve),
'day') :
'').
'</td>';
879 $totalarray[
'nbfield']++;
883 if (!empty($arrayfields[
'd.total_ht'][
'checked'])) {
884 print
'<td class="right">'.price($obj->total_ht).
"</td>\n";
886 $totalarray[
'nbfield']++;
889 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'd.total_ht';
891 $totalarray[
'val'][
'd.total_ht'] += $obj->total_ht;
894 if (!empty($arrayfields[
'd.total_vat'][
'checked'])) {
895 print
'<td class="right">'.price($obj->total_tva).
"</td>\n";
897 $totalarray[
'nbfield']++;
900 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'd.total_tva';
902 $totalarray[
'val'][
'd.total_tva'] += $obj->total_tva;
905 if (!empty($arrayfields[
'd.total_ttc'][
'checked'])) {
906 print
'<td class="right">'.price($obj->total_ttc).
"</td>\n";
908 $totalarray[
'nbfield']++;
911 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'd.total_ttc';
913 $totalarray[
'val'][
'd.total_ttc'] += $obj->total_ttc;
917 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
919 $parameters = array(
'arrayfields'=>$arrayfields,
'obj'=>$obj,
'i'=>$i,
'totalarray'=>&$totalarray);
920 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters);
921 print $hookmanager->resPrint;
924 if (!empty($arrayfields[
'd.date_create'][
'checked'])) {
925 print
'<td class="nowrap center">';
929 $totalarray[
'nbfield']++;
933 if (!empty($arrayfields[
'd.tms'][
'checked'])) {
934 print
'<td class="nowrap center">';
938 $totalarray[
'nbfield']++;
942 if (!empty($arrayfields[
'd.fk_statut'][
'checked'])) {
943 print
'<td class="nowrap right">'.$expensereportstatic->getLibStatut(5).
'</td>';
945 $totalarray[
'nbfield']++;
950 print
'<td class="nowrap center">';
951 if ($massactionbutton || $massaction) {
953 if (in_array($obj->rowid, $arrayofselected)) {
956 print
'<input id="cb'.$obj->rowid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
960 $totalarray[
'nbfield']++;
967 $total_total_ht = $total_total_ht + $obj->total_ht;
968 $total_total_tva = $total_total_tva + $obj->total_tva;
969 $total_total_ttc = $total_total_ttc + $obj->total_ttc;
975 foreach ($arrayfields as $key => $val) {
976 if (!empty($val[
'checked'])) {
980 print
'<tr><td colspan="'.$colspan.
'" class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</td></tr>';
984 include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
988 $parameters = array(
'arrayfields'=>$arrayfields,
'sql'=>$sql);
989 $reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters);
990 print $hookmanager->resPrint;
992 print
'</table>'.
"\n";
995 print
'</form>'.
"\n";
998 $hidegeneratedfilelistifempty = 1;
999 if ($massaction ==
'builddoc' || $action ==
'remove_file' || $show_files) {
1000 $hidegeneratedfilelistifempty = 0;
1004 $urlsource = $_SERVER[
'PHP_SELF'].
'?sortfield='.$sortfield.
'&sortorder='.$sortorder;
1005 $urlsource .= str_replace(
'&',
'&', $param);
1007 $filedir = $diroutputmassaction;
1008 $genallowed = $user->rights->expensereport->lire;
1009 $delallowed = $user->rights->expensereport->creer;
1011 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.
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...
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
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...
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
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.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
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.