From a119a75fe01b23396b811ccebeb3eb5a48dc9553 Mon Sep 17 00:00:00 2001 From: "Sekan, Tobias" Date: Wed, 7 Oct 2020 14:00:32 +0200 Subject: [PATCH] add more filter on monthly statement list --- htdocs/holiday/month_report.php | 64 ++++++++++++++++++++++++++++----- 1 file changed, 55 insertions(+), 9 deletions(-) diff --git a/htdocs/holiday/month_report.php b/htdocs/holiday/month_report.php index baf444ce295..c8f07d50cc3 100644 --- a/htdocs/holiday/month_report.php +++ b/htdocs/holiday/month_report.php @@ -48,7 +48,10 @@ $massaction = GETPOST('massaction', 'alpha'); $contextpage = GETPOST('contextpage', 'aZ'); $optioncss = GETPOST('optioncss', 'aZ'); -$search_ref = GETPOST('search_ref', 'alpha'); +$search_ref = GETPOST('search_ref', 'alphanohtml'); +$search_employee = GETPOST('search_employee', 'int'); +$search_type = GETPOST('search_type', 'int'); +$search_description = GETPOST('search_description', 'alphanohtml'); $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); @@ -82,6 +85,9 @@ if (empty($reshook)) if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers { $search_ref = ''; + $search_employee = ''; + $search_type = ''; + $search_description = ''; $toselect = ''; $search_array_options = array(); } @@ -135,7 +141,10 @@ $sql.= " WHERE cp.rowid > 0"; $sql.= " AND cp.statut = 3"; // 3 = Approved $sql.= " AND (date_format(cp.date_debut, '%Y-%m') = '".$db->escape($year_month)."' OR date_format(cp.date_fin, '%Y-%m') = '".$db->escape($year_month)."')"; -if ($search_ref != '') $sql.= natural_search('cp.ref', $search_ref, 0); +if (!empty($search_ref)) $sql .= natural_search('cp.ref', $search_ref); +if (!empty($search_employee)) $sql .= " AND cp.fk_user = '".$db->escape($search_employee)."'"; +if (!empty($search_type)) $sql .= ' AND cp.fk_type IN ('.$db->escape($search_type).')'; +if (!empty($search_description)) $sql.= natural_search('cp.description', $search_description); $sql.= $db->order($sortfield, $sortorder); @@ -149,9 +158,12 @@ if (empty($resql)) $num = $db->num_rows($resql); $param = ''; -if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.= '&contextpage='.urlencode($contextpage); -if ($limit > 0 && $limit != $conf->liste_limit) $param.= '&limit='.urlencode($limit); -if ($search_ref) $param = '&search_ref='.urlencode($search_ref); +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.= '&contextpage='.urlencode($contextpage); +if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); +if (!empty($search_ref)) $param .= '&search_ref='.urlencode($search_ref); +if (!empty($search_employee)) $param .= '&search_employee='.urlencode($search_employee); +if (!empty($search_type)) $param .= '&search_type='.urlencode($search_type); +if (!empty($search_description)) $param .= '&search_description='.urlencode($search_description); print '
'; if ($optioncss != '') print ''; @@ -184,16 +196,50 @@ print '
'; print ''; print ''; -if (!empty($arrayfields['cp.ref']['checked'])) print ''; -if (!empty($arrayfields['cp.fk_user']['checked'])) print ''; -if (!empty($arrayfields['ct.label']['checked'])) print ''; + +// Filter: Ref +if (!empty($arrayfields['cp.ref']['checked'])) { + print ''; +} + +// Filter: Employee +if (!empty($arrayfields['cp.fk_user']['checked'])) { + print ''; +} + +// Filter: Type +if (!empty($arrayfields['ct.label']['checked'])) { + $typeleaves = $holidaystatic->getTypes(1, -1); + $arraytypeleaves = array(); + foreach ($typeleaves as $key => $val) + { + $labeltoshow = ($langs->trans($val['code']) != $val['code'] ? $langs->trans($val['code']) : $val['label']); + $arraytypeleaves[$val['rowid']] = $labeltoshow; + } + + print ''; +} + if (!empty($arrayfields['cp.date_debut']['checked'])) print ''; if (!empty($arrayfields['cp.date_fin']['checked'])) print ''; if (!empty($arrayfields['used_days']['checked'])) print ''; if (!empty($arrayfields['date_start_month']['checked'])) print ''; if (!empty($arrayfields['date_end_month']['checked'])) print ''; if (!empty($arrayfields['used_days_month']['checked'])) print ''; -if (!empty($arrayfields['cp.description']['checked'])) print ''; + +// Filter: Description +if (!empty($arrayfields['cp.description']['checked'])) { + print ''; +} + // Action column print '
'; + print ''; + print ''; + print $form->select_dolusers($search_employee, "search_employee", 1, null, 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth200'); + print ''; + print $form->selectarray('search_type', $arraytypeleaves, $search_type, 1); + print ''; + print ''; + print ''; $searchpicto = $form->showFilterButtons();