34require
'../main.inc.php';
35require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
36require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
37require_once DOL_DOCUMENT_ROOT.
'/expensereport/class/expensereport.class.php';
38require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
39require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
40require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formexpensereport.class.php';
41require_once DOL_DOCUMENT_ROOT.
'/core/lib/usergroups.lib.php';
42require_once DOL_DOCUMENT_ROOT.
'/expensereport/class/expensereport_ik.class.php';
53$langs->loadLangs(array(
'companies',
'users',
'trips'));
55$action =
GETPOST(
'action',
'aZ09');
56$massaction =
GETPOST(
'massaction',
'alpha');
58$confirm =
GETPOST(
'confirm',
'alpha');
59$cancel =
GETPOST(
'cancel',
'alpha');
60$toselect =
GETPOST(
'toselect',
'array');
61$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'expensereportlist';
62$mode =
GETPOST(
'mode',
'alpha');
64$childids = $user->getAllChildIds(1);
70 if (
$id == $user->id) {
73 if ($user->hasRight(
'expensereport',
'readall')) {
76 if ($user->hasRight(
'expensereport',
'lire') && in_array(
$id, $childids)) {
84$diroutputmassaction =
$conf->expensereport->dir_output.
'/temp/massgeneration/'.$user->id;
89$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
90$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
92if (empty($page) || $page == -1) {
95$offset = $limit * $page;
102 $sortfield =
"d.date_debut";
106$search_all = trim(
GETPOST(
'search_all',
'alphanohtml'));
108$search_ref =
GETPOST(
'search_ref',
'alpha');
109$search_user =
GETPOST(
'search_user',
'intcomma');
110$search_amount_ht =
GETPOST(
'search_amount_ht',
'alpha');
111$search_amount_vat =
GETPOST(
'search_amount_vat',
'alpha');
112$search_amount_ttc =
GETPOST(
'search_amount_ttc',
'alpha');
113$search_status = (
GETPOST(
'search_status',
'intcomma') !=
'' ?
GETPOST(
'search_status',
'intcomma') :
GETPOST(
'statut',
'intcomma'));
115$search_date_startday =
GETPOSTINT(
'search_date_startday');
116$search_date_startmonth =
GETPOSTINT(
'search_date_startmonth');
117$search_date_startyear =
GETPOSTINT(
'search_date_startyear');
118$search_date_startendday =
GETPOSTINT(
'search_date_startendday');
119$search_date_startendmonth =
GETPOSTINT(
'search_date_startendmonth');
120$search_date_startendyear =
GETPOSTINT(
'search_date_startendyear');
121$search_date_start =
dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear);
122$search_date_startend =
dol_mktime(23, 59, 59, $search_date_startendmonth, $search_date_startendday, $search_date_startendyear);
124$search_date_endday =
GETPOSTINT(
'search_date_endday');
125$search_date_endmonth =
GETPOSTINT(
'search_date_endmonth');
126$search_date_endyear =
GETPOSTINT(
'search_date_endyear');
127$search_date_endendday =
GETPOSTINT(
'search_date_endendday');
128$search_date_endendmonth =
GETPOSTINT(
'search_date_endendmonth');
129$search_date_endendyear =
GETPOSTINT(
'search_date_endendyear');
130$search_date_end =
dol_mktime(0, 0, 0, $search_date_endmonth, $search_date_endday, $search_date_endyear);
131$search_date_endend =
dol_mktime(23, 59, 59, $search_date_endendmonth, $search_date_endendday, $search_date_endendyear);
133$optioncss =
GETPOST(
'optioncss',
'alpha');
135if ($search_status ==
'') {
138if ($search_user ==
'') {
145 $socid = $user->socid;
147$hookmanager->initHooks(array(
'expensereportlist'));
155$extrafields->fetch_name_optionals_label(
$object->table_element);
157$search_array_options = $extrafields->getOptionalsFromPost(
$object->table_element,
'',
'search_');
161$fieldstosearchall = array(
163 'd.note_public' =>
"NotePublic",
164 'u.lastname' =>
'EmployeeLastname',
165 'u.firstname' =>
"EmployeeFirstname",
166 'u.login' =>
"Login",
168if (empty($user->socid)) {
169 $fieldstosearchall[
"d.note_private"] =
"NotePrivate";
173 'd.ref' => array(
'label' => $langs->trans(
"Ref"),
'checked' => 1),
174 'user' => array(
'label' => $langs->trans(
"User"),
'checked' => 1),
175 'd.date_debut' => array(
'label' => $langs->trans(
"DateStart"),
'checked' => 1),
176 'd.date_fin' => array(
'label' => $langs->trans(
"DateEnd"),
'checked' => 1),
177 'd.date_valid' => array(
'label' => $langs->trans(
"DateValidation"),
'checked' => 1),
178 'd.date_approve' => array(
'label' => $langs->trans(
"DateApprove"),
'checked' => 1),
179 'd.total_ht' => array(
'label' => $langs->trans(
"AmountHT"),
'checked' => 1),
180 'd.total_vat' => array(
'label' => $langs->trans(
"AmountVAT"),
'checked' => -1),
181 'd.total_ttc' => array(
'label' => $langs->trans(
"AmountTTC"),
'checked' => 1),
182 'd.date_create' => array(
'label' => $langs->trans(
"DateCreation"),
'checked' => 0,
'position' => 500),
183 'd.tms' => array(
'label' => $langs->trans(
"DateModificationShort"),
'checked' => 0,
'position' => 500),
184 'd.fk_statut' => array(
'label' => $langs->trans(
"Status"),
'checked' => 1,
'position' => 1000),
187include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_array_fields.tpl.php';
189$canedituser = (!empty($user->admin) || $user->hasRight(
'user',
'user',
'creer'));
191$permissiontoread = $user->hasRight(
'expensereport',
'lire');
192$permissiontodelete = $user->hasRight(
'expensereport',
'supprimer');
194$objectuser =
new User($db);
201if (
GETPOST(
'cancel',
'alpha')) {
205if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
209$parameters = array(
'socid' => $socid);
210$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
215if (empty($reshook)) {
217 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
220 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
223 $search_amount_ht =
"";
224 $search_amount_vat =
"";
225 $search_amount_ttc =
"";
227 $search_date_startday =
'';
228 $search_date_startmonth =
'';
229 $search_date_startyear =
'';
230 $search_date_startendday =
'';
231 $search_date_startendmonth =
'';
232 $search_date_startendyear =
'';
233 $search_date_start =
'';
234 $search_date_startend =
'';
235 $search_date_endday =
'';
236 $search_date_endmonth =
'';
237 $search_date_endyear =
'';
238 $search_date_endendday =
'';
239 $search_date_endendmonth =
'';
240 $search_date_endendyear =
'';
241 $search_date_end =
'';
242 $search_date_endend =
'';
244 $search_array_options = array();
246 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')
247 ||
GETPOST(
'button_search_x',
'alpha') ||
GETPOST(
'button_search.x',
'alpha') ||
GETPOST(
'button_search',
'alpha')) {
252 $objectclass =
'ExpenseReport';
253 $objectlabel =
'ExpenseReport';
254 $uploaddir =
$conf->expensereport->dir_output;
255 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
263$form =
new Form($db);
268$fuser =
new User($db);
270$title = $langs->trans(
"TripsAndExpenses");
283 $fuser->fetch(
$id,
'',
'', 1);
284 $fuser->loadRights();
285 $user_id = $fuser->id;
287 $search_user = $user_id;
292$sql =
"SELECT d.rowid, d.ref, d.fk_user_author, d.total_ht, d.total_tva, d.total_ttc, d.fk_statut as status,";
293$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,";
294$sql .=
" u.rowid as id_user, u.firstname, u.lastname, u.login, u.email, u.statut as user_status, u.photo";
296if (!empty($extrafields->attributes[
$object->table_element][
'label'])) {
297 foreach ($extrafields->attributes[
$object->table_element][
'label'] as $key => $val) {
298 $sql .= ($extrafields->attributes[
$object->table_element][
'type'][$key] !=
'separate' ?
", ef.".$key.
" as options_".$key :
'');
302$parameters = array();
303$reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters, $object, $action);
304$sql .= $hookmanager->resPrint;
305$sql = preg_replace(
'/,\s*$/',
'', $sql);
309$sql .=
" FROM ".MAIN_DB_PREFIX.
"expensereport as d";
310if (isset($extrafields->attributes[
$object->table_element][
'label']) && is_array($extrafields->attributes[
$object->table_element][
'label']) && count($extrafields->attributes[
$object->table_element][
'label'])) {
311 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element.
"_extrafields as ef on (d.rowid = ef.fk_object)";
313$sql .=
", ".MAIN_DB_PREFIX.
"user as u";
314$sql .=
" WHERE d.fk_user_author = u.rowid AND d.entity IN (".getEntity(
'expensereport').
")";
316if (!empty($search_all)) {
317 $sql .=
natural_search(array_keys($fieldstosearchall), $search_all);
320if (!empty($search_ref)) {
324if ($search_date_start) {
325 $sql .=
" AND d.date_debut >= '".$db->idate($search_date_start).
"'";
327if ($search_date_startend) {
328 $sql .=
" AND d.date_debut <= '".$db->idate($search_date_startend).
"'";
331if ($search_date_end) {
332 $sql .=
" AND d.date_fin >= '".$db->idate($search_date_end).
"'";
334if ($search_date_endend) {
335 $sql .=
" AND d.date_fin <= '".$db->idate($search_date_endend).
"'";
338if ($search_amount_ht !=
'') {
341if ($search_amount_ttc !=
'') {
345if ($search_user !=
'' && $search_user >= 0) {
346 $sql .=
" AND u.rowid = '".$db->escape($search_user).
"'";
349if ($search_status !=
'' && $search_status >= 0) {
350 $sql .=
" AND d.fk_statut IN (".$db->sanitize($search_status).
")";
353if (!$user->hasRight(
'expensereport',
'readall') && !$user->hasRight(
'expensereport',
'lire_tous')
354 && (!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') || !$user->hasRight(
'expensereport',
'writeall_advance'))) {
355 $sql .=
" AND d.fk_user_author IN (".$db->sanitize(implode(
',', $childids)).
")\n";
358include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
360$parameters = array();
361$reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $object, $action);
362$sql .= $hookmanager->resPrint;
365$nbtotalofrecords =
'';
368 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords', $sql);
369 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
370 $resql = $db->query($sqlforcount);
372 $objforcount = $db->fetch_object($resql);
373 $nbtotalofrecords = $objforcount->nbtotalofrecords;
378 if (($page * $limit) > $nbtotalofrecords) {
386$sql .= $db->order($sortfield, $sortorder);
388 $sql .= $db->plimit($limit + 1, $offset);
392$resql = $db->query($sql);
398$num = $db->num_rows($resql);
404llxHeader(
'', $title, $help_url,
'', 0, 0, $morejs, $morecss,
'',
'bodyforlist');
406$arrayofselected = is_array($toselect) ? $toselect : array();
410 $param .=
'&mode='.urlencode($mode);
412if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
413 $param .=
'&contextpage='.urlencode($contextpage);
415if ($limit > 0 && $limit !=
$conf->liste_limit) {
416 $param .=
'&limit='.((int) $limit);
418if ($optioncss !=
'') {
419 $param .=
'&optioncss='.urlencode($optioncss);
422 $param .=
"&search_all=".urlencode($search_all);
425 $param .=
"&search_ref=".urlencode($search_ref);
428if ($search_date_startday) {
429 $param .=
'&search_date_startday='.urlencode((
string) ($search_date_startday));
431if ($search_date_startmonth) {
432 $param .=
'&search_date_startmonth='.urlencode((
string) ($search_date_startmonth));
434if ($search_date_startyear) {
435 $param .=
'&search_date_startyear='.urlencode((
string) ($search_date_startyear));
437if ($search_date_startendday) {
438 $param .=
'&search_date_startendday='.urlencode((
string) ($search_date_startendday));
440if ($search_date_startendmonth) {
441 $param .=
'&search_date_startendmonth='.urlencode((
string) ($search_date_startendmonth));
443if ($search_date_startendyear) {
444 $param .=
'&search_date_startendyear='.urlencode((
string) ($search_date_startendyear));
447if ($search_date_endday) {
448 $param .=
'&search_date_endday='.urlencode((
string) ($search_date_endday));
450if ($search_date_endmonth) {
451 $param .=
'&search_date_endmonth='.urlencode((
string) ($search_date_endmonth));
453if ($search_date_endyear) {
454 $param .=
'&search_date_endyear='.urlencode((
string) ($search_date_endyear));
456if ($search_date_endendday) {
457 $param .=
'&search_date_endendday='.urlencode((
string) ($search_date_endendday));
459if ($search_date_endendmonth) {
460 $param .=
'&search_date_endendmonth='.urlencode((
string) ($search_date_endendmonth));
462if ($search_date_endendyear) {
463 $param .=
'&search_date_endendyear='.urlencode((
string) ($search_date_endendyear));
466 $param .=
"&search_user=".urlencode($search_user);
468if ($search_amount_ht) {
469 $param .=
"&search_amount_ht=".urlencode($search_amount_ht);
471if ($search_amount_ttc) {
472 $param .=
"&search_amount_ttc=".urlencode($search_amount_ttc);
474if ($search_status >= 0) {
475 $param .=
"&search_status=".urlencode($search_status);
478include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
481$arrayofmassactions = array(
482 'generate_doc' =>
img_picto(
'',
'pdf',
'class="pictofixedwidth"').$langs->trans(
"ReGeneratePDF"),
483 'builddoc' =>
img_picto(
'',
'pdf',
'class="pictofixedwidth"').$langs->trans(
"PDFMerge"),
484 'presend' =>
img_picto(
'',
'email',
'class="pictofixedwidth"').$langs->trans(
"SendByMail"),
486if ($user->hasRight(
'expensereport',
'supprimer')) {
487 $arrayofmassactions[
'predelete'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
489if (
GETPOSTINT(
'nomassaction') || in_array($massaction, array(
'presend',
'predelete'))) {
490 $arrayofmassactions = array();
492$massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
495print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
496if ($optioncss !=
'') {
497 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
499print
'<input type="hidden" name="token" value="'.newToken().
'">';
500print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
501print
'<input type="hidden" name="action" value="'.($action ==
'edit' ?
'update' :
'list').
'">';
502print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
503print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
504print
'<input type="hidden" name="page" value="'.$page.
'">';
505print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
506print
'<input type="hidden" name="page_y" value="">';
507print
'<input type="hidden" name="mode" value="'.$mode.
'">';
509 print
'<input type="hidden" name="id" value="'.$id.
'">';
513 $title = $langs->trans(
"User");
514 $linkback =
'<a href="'.DOL_URL_ROOT.
'/user/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
519 dol_banner_tab($fuser,
'id', $linkback, $user->hasRight(
'user',
'user',
'lire') || $user->admin);
523 if ($action !=
'edit') {
524 print
'<div class="tabsAction">';
526 $childids = $user->getAllChildIds(1);
528 $canedit = ((in_array($user_id, $childids) && $user->hasRight(
'expensereport',
'creer'))
529 || (
$conf->global->MAIN_USE_ADVANCED_PERMS && $user->hasRight(
'expensereport',
'writeall_advance')));
533 print
'<a href="'.DOL_URL_ROOT.
'/expensereport/card.php?action=create&fk_user_author='.$fuser->id.
'" class="butAction">'.$langs->trans(
"AddTrip").
'</a>';
535 print
'<a href="#" class="butActionRefused" title="'.$langs->trans(
"NotEnoughPermissions").
'">'.$langs->trans(
"AddTrip").
'</a>';
540 print $form->buttonsSaveCancel(
"Save",
'');
543 $title = $langs->trans(
"ListTripsAndExpenses");
545 $url = DOL_URL_ROOT.
'/expensereport/card.php?action=create';
546 if (!empty($socid)) {
547 $url .=
'&socid='.$socid;
550 $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'));
551 $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'));
553 $newcardbutton .=
dolGetButtonTitle($langs->trans(
'New'),
'',
'fa fa-plus-circle', $url,
'', $user->hasRight(
'expensereport',
'creer'));
555 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'expensereport', 0, $newcardbutton,
'', $limit, 0, 0, 1);
559$topicmail =
"SendExpenseReport";
560$modelmail =
"expensereport";
562$trackid =
'exp'.$object->id;
563include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
567 foreach ($fieldstosearchall as $key => $val) {
568 $fieldstosearchall[$key] = $langs->trans($val);
569 $setupstring .= $key.
"=".$val.
";";
571 print
'<!-- Search done like if EXPENSEREPORT_QUICKSEARCH_ON_FIELDS = '.$setupstring.
' -->'.
"\n";
572 print
'<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $search_all).implode(
', ', $fieldstosearchall).
'</div>'.
"\n";
577$parameters = array();
578$reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
579if (empty($reshook)) {
580 $moreforfilter .= $hookmanager->resPrint;
582 $moreforfilter = $hookmanager->resPrint;
585if (!empty($moreforfilter)) {
586 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
587 print $moreforfilter;
591$varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
592$htmlofselectarray = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN'));
593$selectedfields = ($mode !=
'kanban' ? $htmlofselectarray :
'');
594$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
596print
'<div class="div-table-responsive">';
597print
'<table class="tagtable nobottomiftotal liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
601print
'<tr class="liste_titre_filter">';
604 print
'<td class="liste_titre center maxwidthsearch">';
605 $searchpicto = $form->showFilterButtons(
'left');
609if (!empty($arrayfields[
'd.ref'][
'checked'])) {
610 print
'<td class="liste_titre" align="left">';
611 print
'<input class="flat" size="15" type="text" name="search_ref" value="'.$search_ref.
'">';
615if (!empty($arrayfields[
'user'][
'checked'])) {
616 if ($user->hasRight(
'expensereport',
'readall') || $user->hasRight(
'expensereport',
'lire_tous')) {
617 print
'<td class="liste_titre maxwidthonsmartphone" align="left">';
618 print $form->select_dolusers($search_user,
'search_user', 1,
'', 0,
'',
'', 0, 0, 0,
'', 0,
'',
'maxwidth200');
621 print
'<td class="liste_titre"> </td>';
625if (!empty($arrayfields[
'd.date_debut'][
'checked'])) {
626 print
'<td class="liste_titre" align="center">';
627 print
'<div class="nowrapfordate">';
628 print $form->selectDate($search_date_start ? $search_date_start : -1,
'search_date_start', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
630 print
'<div class="nowrapfordate">';
631 print $form->selectDate($search_date_startend ? $search_date_startend : -1,
'search_date_startend', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
636if (!empty($arrayfields[
'd.date_fin'][
'checked'])) {
637 print
'<td class="liste_titre" align="center">';
638 print
'<div class="nowrapfordate">';
639 print $form->selectDate($search_date_end ? $search_date_end : -1,
'search_date_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
641 print
'<div class="nowrapfordate">';
642 print $form->selectDate($search_date_endend ? $search_date_endend : -1,
'search_date_endend', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
647if (!empty($arrayfields[
'd.date_valid'][
'checked'])) {
648 print
'<td class="liste_titre" align="center">';
654if (!empty($arrayfields[
'd.date_approve'][
'checked'])) {
655 print
'<td class="liste_titre" align="center">';
661if (!empty($arrayfields[
'd.total_ht'][
'checked'])) {
662 print
'<td class="liste_titre right"><input class="flat" type="text" size="5" name="search_amount_ht" value="'.$search_amount_ht.
'"></td>';
664if (!empty($arrayfields[
'd.total_vat'][
'checked'])) {
665 print
'<td class="liste_titre right"><input class="flat" type="text" size="5" name="search_amount_vat" value="'.$search_amount_vat.
'"></td>';
668if (!empty($arrayfields[
'd.total_ttc'][
'checked'])) {
669 print
'<td class="liste_titre right"><input class="flat" type="text" size="5" name="search_amount_ttc" value="'.$search_amount_ttc.
'"></td>';
672include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
675$parameters = array(
'arrayfields' => $arrayfields);
676$reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters, $object, $action);
677print $hookmanager->resPrint;
679if (!empty($arrayfields[
'd.date_create'][
'checked'])) {
680 print
'<td class="liste_titre">';
684if (!empty($arrayfields[
'd.tms'][
'checked'])) {
685 print
'<td class="liste_titre">';
689if (!empty($arrayfields[
'd.fk_statut'][
'checked'])) {
690 print
'<td class="liste_titre center parentonrightofpage">';
691 print $formexpensereport->selectExpensereportStatus($search_status,
'search_status', 1, 1,
'search_status width100 onrightofpage');
696 print
'<td class="liste_titre center maxwidthsearch">';
697 $searchpicto = $form->showFilterButtons();
704$totalarray = array();
705$totalarray[
'nbfield'] = 0;
709print
'<tr class="liste_titre">';
711 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'maxwidthsearch center ');
712 $totalarray[
'nbfield']++;
714if (!empty($arrayfields[
'd.ref'][
'checked'])) {
715 print_liste_field_titre($arrayfields[
'd.ref'][
'label'], $_SERVER[
"PHP_SELF"],
"d.ref",
"", $param,
'', $sortfield, $sortorder);
716 $totalarray[
'nbfield']++;
718if (!empty($arrayfields[
'user'][
'checked'])) {
719 print_liste_field_titre($arrayfields[
'user'][
'label'], $_SERVER[
"PHP_SELF"],
"u.lastname",
"", $param,
'', $sortfield, $sortorder);
720 $totalarray[
'nbfield']++;
722if (!empty($arrayfields[
'd.date_debut'][
'checked'])) {
723 print_liste_field_titre($arrayfields[
'd.date_debut'][
'label'], $_SERVER[
"PHP_SELF"],
"d.date_debut",
"", $param,
'', $sortfield, $sortorder,
'center ');
724 $totalarray[
'nbfield']++;
726if (!empty($arrayfields[
'd.date_fin'][
'checked'])) {
727 print_liste_field_titre($arrayfields[
'd.date_fin'][
'label'], $_SERVER[
"PHP_SELF"],
"d.date_fin",
"", $param,
'', $sortfield, $sortorder,
'center ');
728 $totalarray[
'nbfield']++;
730if (!empty($arrayfields[
'd.date_valid'][
'checked'])) {
731 print_liste_field_titre($arrayfields[
'd.date_valid'][
'label'], $_SERVER[
"PHP_SELF"],
"d.date_valid",
"", $param,
'', $sortfield, $sortorder,
'center ');
732 $totalarray[
'nbfield']++;
734if (!empty($arrayfields[
'd.date_approve'][
'checked'])) {
735 print_liste_field_titre($arrayfields[
'd.date_approve'][
'label'], $_SERVER[
"PHP_SELF"],
"d.date_approve",
"", $param,
'', $sortfield, $sortorder,
'center ');
736 $totalarray[
'nbfield']++;
738if (!empty($arrayfields[
'd.total_ht'][
'checked'])) {
739 print_liste_field_titre($arrayfields[
'd.total_ht'][
'label'], $_SERVER[
"PHP_SELF"],
"d.total_ht",
"", $param,
'', $sortfield, $sortorder,
'right ');
740 $totalarray[
'nbfield']++;
742if (!empty($arrayfields[
'd.total_vat'][
'checked'])) {
743 print_liste_field_titre($arrayfields[
'd.total_vat'][
'label'], $_SERVER[
"PHP_SELF"],
"d.total_tva",
"", $param,
'', $sortfield, $sortorder,
'right ');
744 $totalarray[
'nbfield']++;
746if (!empty($arrayfields[
'd.total_ttc'][
'checked'])) {
747 print_liste_field_titre($arrayfields[
'd.total_ttc'][
'label'], $_SERVER[
"PHP_SELF"],
"d.total_ttc",
"", $param,
'', $sortfield, $sortorder,
'right ');
748 $totalarray[
'nbfield']++;
751include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
753$parameters = array(
'arrayfields' => $arrayfields,
'param' => $param,
'sortfield' => $sortfield,
'sortorder' => $sortorder);
754$reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object, $action);
755print $hookmanager->resPrint;
756if (!empty($arrayfields[
'd.date_create'][
'checked'])) {
757 print_liste_field_titre($arrayfields[
'd.date_create'][
'label'], $_SERVER[
"PHP_SELF"],
"d.date_create",
"", $param,
'', $sortfield, $sortorder,
'nowraponall center');
758 $totalarray[
'nbfield']++;
760if (!empty($arrayfields[
'd.tms'][
'checked'])) {
761 print_liste_field_titre($arrayfields[
'd.tms'][
'label'], $_SERVER[
"PHP_SELF"],
"d.tms",
"", $param,
'', $sortfield, $sortorder,
'nowraponall center');
762 $totalarray[
'nbfield']++;
764if (!empty($arrayfields[
'd.fk_statut'][
'checked'])) {
765 print_liste_field_titre($arrayfields[
'd.fk_statut'][
'label'], $_SERVER[
"PHP_SELF"],
"d.fk_statut",
"", $param,
'', $sortfield, $sortorder,
'center ');
766 $totalarray[
'nbfield']++;
769 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ');
770 $totalarray[
'nbfield']++;
783$usertmp =
new User($db);
787 $savnbfield = $totalarray[
'nbfield'];
788 $totalarray = array();
789 $totalarray[
'nbfield'] = 0;
790 $totalarray[
'val'] = array();
791 $totalarray[
'val'][
'd.total_ht'] = 0;
792 $totalarray[
'val'][
'd.total_tva'] = 0;
793 $totalarray[
'val'][
'd.total_ttc'] = 0;
794 $totalarray[
'totalizable'] = array();
796 $imaxinloop = ($limit ? min($num, $limit) : $num);
797 while ($i < $imaxinloop) {
798 $obj = $db->fetch_object($resql);
803 $expensereportstatic->id = $obj->rowid;
804 $expensereportstatic->ref = $obj->ref;
805 $expensereportstatic->status = $obj->status;
806 $expensereportstatic->date_debut = $db->jdate($obj->date_debut);
807 $expensereportstatic->date_fin = $db->jdate($obj->date_fin);
808 $expensereportstatic->date_create = $db->jdate($obj->date_create);
809 $expensereportstatic->date_modif = $db->jdate($obj->date_modif);
810 $expensereportstatic->date_valid = $db->jdate($obj->date_valid);
811 $expensereportstatic->date_approve = $db->jdate($obj->date_approve);
812 $expensereportstatic->note_private = $obj->note_private;
813 $expensereportstatic->note_public = $obj->note_public;
814 $expensereportstatic->fk_user = $obj->id_user;
816 $usertmp->id = $obj->id_user;
817 $usertmp->lastname = $obj->lastname;
818 $usertmp->firstname = $obj->firstname;
819 $usertmp->login = $obj->login;
820 $usertmp->statut = $obj->user_status;
821 $usertmp->status = $obj->user_status;
822 $usertmp->photo = $obj->photo;
823 $usertmp->email = $obj->email;
825 if ($mode ==
'kanban') {
827 print
'<tr class="trkanban"><td colspan="'.$savnbfield.
'">';
828 print
'<div class="box-flex-container kanban">';
831 $usertmp->fetch($obj->id_user);
834 if ($massactionbutton || $massaction) {
837 print $expensereportstatic->getKanbanView(
'', array(
'userauthor' => $usertmp,
'selected' => in_array($expensereportstatic->id, $arrayofselected)));
839 if ($i == ($imaxinloop - 1)) {
846 print
'<tr data-rowid="'.$object->id.
'" class="oddeven">';
850 print
'<td class="nowrap center">';
851 if ($massactionbutton || $massaction) {
853 if (in_array($obj->rowid, $arrayofselected)) {
856 print
'<input id="cb'.$obj->rowid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
860 $totalarray[
'nbfield']++;
864 if (!empty($arrayfields[
'd.ref'][
'checked'])) {
866 print
'<table class="nobordernopadding"><tr class="nocellnopadd">';
867 print
'<td class="nobordernopadding nowrap">';
868 print $expensereportstatic->getNomUrl(1);
871 print
'<td class="nobordernopadding nowrap">';
872 if ($expensereportstatic->status == 2 && $expensereportstatic->hasDelay(
'toappove')) {
875 if ($expensereportstatic->status == 5 && $expensereportstatic->hasDelay(
'topay')) {
878 if (!empty($obj->note_private) || !empty($obj->note_public)) {
879 print
' <span class="note">';
880 print
'<a href="'.DOL_URL_ROOT.
'/expensereport/note.php?id='.$obj->rowid.
'">'.
img_picto($langs->trans(
"ViewPrivateNote"),
'object_generic').
'</a>';
884 print
'<td width="16" class="nobordernopadding hideonsmartphone right">';
887 $urlsource = $_SERVER[
'PHP_SELF'].
'?id='.$obj->rowid;
888 print $formfile->getDocumentsLink($expensereportstatic->element, $filename, $filedir);
890 print
'</tr></table>';
893 $totalarray[
'nbfield']++;
897 if (!empty($arrayfields[
'user'][
'checked'])) {
898 print
'<td class="left">';
899 print $usertmp->getNomUrl(-1);
902 $totalarray[
'nbfield']++;
906 if (!empty($arrayfields[
'd.date_debut'][
'checked'])) {
907 print
'<td class="center">'.($obj->date_debut > 0 ?
dol_print_date($db->jdate($obj->date_debut),
'day') :
'').
'</td>';
909 $totalarray[
'nbfield']++;
913 if (!empty($arrayfields[
'd.date_fin'][
'checked'])) {
914 print
'<td class="center">'.($obj->date_fin > 0 ?
dol_print_date($db->jdate($obj->date_fin),
'day') :
'').
'</td>';
916 $totalarray[
'nbfield']++;
920 if (!empty($arrayfields[
'd.date_valid'][
'checked'])) {
921 print
'<td class="center">'.($obj->date_valid > 0 ?
dol_print_date($db->jdate($obj->date_valid),
'day') :
'').
'</td>';
923 $totalarray[
'nbfield']++;
927 if (!empty($arrayfields[
'd.date_approve'][
'checked'])) {
928 print
'<td class="center">'.($obj->date_approve > 0 ?
dol_print_date($db->jdate($obj->date_approve),
'day') :
'').
'</td>';
930 $totalarray[
'nbfield']++;
934 if (!empty($arrayfields[
'd.total_ht'][
'checked'])) {
935 print
'<td class="right">'.price($obj->total_ht).
"</td>\n";
937 $totalarray[
'nbfield']++;
940 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'd.total_ht';
942 $totalarray[
'val'][
'd.total_ht'] += $obj->total_ht;
945 if (!empty($arrayfields[
'd.total_vat'][
'checked'])) {
946 print
'<td class="right">'.price($obj->total_tva).
"</td>\n";
948 $totalarray[
'nbfield']++;
951 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'd.total_tva';
953 $totalarray[
'val'][
'd.total_tva'] += $obj->total_tva;
956 if (!empty($arrayfields[
'd.total_ttc'][
'checked'])) {
957 print
'<td class="right">'.price($obj->total_ttc).
"</td>\n";
959 $totalarray[
'nbfield']++;
962 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'd.total_ttc';
964 $totalarray[
'val'][
'd.total_ttc'] += $obj->total_ttc;
968 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
970 $parameters = array(
'arrayfields' => $arrayfields,
'obj' => $obj,
'i' => $i,
'totalarray' => &$totalarray);
971 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action);
972 print $hookmanager->resPrint;
975 if (!empty($arrayfields[
'd.date_create'][
'checked'])) {
976 print
'<td class="nowrap center">';
980 $totalarray[
'nbfield']++;
984 if (!empty($arrayfields[
'd.tms'][
'checked'])) {
985 print
'<td class="nowrap center">';
989 $totalarray[
'nbfield']++;
993 if (!empty($arrayfields[
'd.fk_statut'][
'checked'])) {
994 print
'<td class="nowrap center">'.$expensereportstatic->getLibStatut(5).
'</td>';
996 $totalarray[
'nbfield']++;
1001 print
'<td class="nowrap center">';
1002 if ($massactionbutton || $massaction) {
1004 if (in_array($obj->rowid, $arrayofselected)) {
1007 print
'<input id="cb'.$obj->rowid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
1011 $totalarray[
'nbfield']++;
1018 $total_total_ht += $obj->total_ht;
1019 $total_total_tva += $obj->total_tva;
1020 $total_total_ttc += $obj->total_ttc;
1027include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
1032 foreach ($arrayfields as $key => $val) {
1033 if (!empty($val[
'checked'])) {
1037 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
1042$parameters = array(
'arrayfields' => $arrayfields,
'sql' => $sql);
1043$reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object, $action);
1044print $hookmanager->resPrint;
1046print
'</table>'.
"\n";
1049print
'</form>'.
"\n";
1052 $hidegeneratedfilelistifempty = 1;
1053 if ($massaction ==
'builddoc' || $action ==
'remove_file' || $show_files) {
1054 $hidegeneratedfilelistifempty = 0;
1058 $urlsource = $_SERVER[
'PHP_SELF'].
'?sortfield='.$sortfield.
'&sortorder='.$sortorder;
1059 $urlsource .= str_replace(
'&',
'&', $param);
1061 $filedir = $diroutputmassaction;
1062 $genallowed = $user->hasRight(
'expensereport',
'lire');
1063 $delallowed = $user->hasRight(
'expensereport',
'creer');
1065 print $formfile->showdocuments(
'massfilesarea_expensereport',
'', $filedir, $urlsource, 0, $delallowed,
'', 1, 1, 0, 48, 1, $param, $title,
'',
'',
'',
null, $hidegeneratedfilelistifempty);
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Class to manage Trips and Expenses.
Class to manage Dolibarr users.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $selectlimitsuffix=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
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.
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...
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
dolGetButtonTitleSeparator($moreClass="")
Add space between dolGetButtonTitle.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
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.