From 91cc3d1b73ed567bc5f429b0312e7f6fcd6946d3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 19 Mar 2018 16:11:42 +0100 Subject: [PATCH] FIX navigation and filters on holiday list --- htdocs/core/class/html.form.class.php | 3 +- htdocs/holiday/card.php | 24 ++--- htdocs/holiday/class/holiday.class.php | 9 +- htdocs/holiday/list.php | 123 ++++++++++++++----------- htdocs/theme/eldy/style.css.php | 4 +- htdocs/theme/md/style.css.php | 4 +- 6 files changed, 94 insertions(+), 73 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 3b773412861..2424523ec0a 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -1451,7 +1451,7 @@ class Form * @param int $force_entity 0 or Id of environment to force * @param int $maxlength Maximum length of string into list (0=no limit) * @param int $showstatus 0=show user status only if status is disabled, 1=always show user status into label, -1=never show user status - * @param string $morefilter Add more filters into sql request + * @param string $morefilter Add more filters into sql request (Example: 'employee = 1') * @param integer $show_every 0=default list, 1=add also a value "Everybody" at beginning of list * @param string $enableonlytext If option $enableonlytext is set, we use this text to explain into label why record is disabled. Not used if enableonly is empty. * @param string $morecss More css @@ -1524,7 +1524,6 @@ class Form $sql.= " ORDER BY u.lastname ASC"; } - dol_syslog(get_class($this)."::select_dolusers", LOG_DEBUG); $resql=$this->db->query($sql); if ($resql) diff --git a/htdocs/holiday/card.php b/htdocs/holiday/card.php index b84e8599e41..14ee964a935 100644 --- a/htdocs/holiday/card.php +++ b/htdocs/holiday/card.php @@ -852,7 +852,7 @@ if (empty($id) || $action == 'add' || $action == 'request' || $action == 'create print $form->select_dolusers($fuserid, 'useridbis', 0, '', 1, '', '', 0, 0, 0, '', 0, '', 'maxwidth300'); print ''; } - else print $form->select_dolusers(GETPOST('fuserid','int')?GETPOST('fuserid','int'):$user->id,'fuserid',0,'',0); + else print $form->select_dolusers(GETPOST('fuserid','int')?GETPOST('fuserid','int'):$user->id, 'fuserid', 0, '', 0, '', '', 0, 0, 0, 'AND employee = 1'); print ''; print ''; @@ -868,7 +868,7 @@ if (empty($id) || $action == 'add' || $action == 'request' || $action == 'create $labeltoshow .= ($val['delay'] > 0 ? ' ('.$langs->trans("NoticePeriod").': '.$val['delay'].' '.$langs->trans("days").')':''); $arraytypeleaves[$val['rowid']]=$labeltoshow; } - print $form->selectarray('type', $arraytypeleaves, (GETPOST('type')?GETPOST('type'):''), 1); + print $form->selectarray('type', $arraytypeleaves, (GETPOST('type','alpha')?GETPOST('type','alpha'):''), 1); if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); print ''; print ''; @@ -884,11 +884,11 @@ if (empty($id) || $action == 'add' || $action == 'request' || $action == 'create if (! GETPOST('date_debut_')) { $form->select_date(-1, 'date_debut_', 0, 0, 0, '', 1, 1); } else { - $tmpdate = dol_mktime(0, 0, 0, GETPOST('date_debut_month'), GETPOST('date_debut_day'), GETPOST('date_debut_year')); + $tmpdate = dol_mktime(0, 0, 0, GETPOST('date_debut_month','int'), GETPOST('date_debut_day','int'), GETPOST('date_debut_year','int')); $form->select_date($tmpdate, 'date_debut_', 0, 0, 0, '', 1, 1); } print '     '; - print $form->selectarray('starthalfday', $listhalfday, (GETPOST('starthalfday')?GETPOST('starthalfday'):'morning')); + print $form->selectarray('starthalfday', $listhalfday, (GETPOST('starthalfday','alpha')?GETPOST('starthalfday','alpha'):'morning')); print ''; print ''; @@ -903,11 +903,11 @@ if (empty($id) || $action == 'add' || $action == 'request' || $action == 'create if (! GETPOST('date_fin_')) { $form->select_date(-1,'date_fin_', 0, 0, 0, '', 1, 1); } else { - $tmpdate = dol_mktime(0, 0, 0, GETPOST('date_fin_month'), GETPOST('date_fin_day'), GETPOST('date_fin_year')); + $tmpdate = dol_mktime(0, 0, 0, GETPOST('date_fin_month','int'), GETPOST('date_fin_day','int'), GETPOST('date_fin_year','int')); $form->select_date($tmpdate,'date_fin_', 0, 0, 0, '', 1, 1); } print '     '; - print $form->selectarray('endhalfday', $listhalfday, (GETPOST('endhalfday')?GETPOST('endhalfday'):'afternoon')); + print $form->selectarray('endhalfday', $listhalfday, (GETPOST('endhalfday','alpha')?GETPOST('endhalfday','alpha'):'afternoon')); print ''; print ''; @@ -915,7 +915,7 @@ if (empty($id) || $action == 'add' || $action == 'request' || $action == 'create print ''; print ''.$langs->trans("ReviewedByCP").''; print ''; - print $form->select_dolusers((GETPOST('valideur')>0?GETPOST('valideur'):$user->fk_user), "valideur", 1, ($user->admin ? '' : array($user->id)), 0, '', 0, 0, 0, 0, '', 0, '', '', 1); // By default, hierarchical parent + print $form->select_dolusers((GETPOST('valideur','int')>0?GETPOST('valideur','int'):$user->fk_user), "valideur", 1, ($user->admin ? '' : array($user->id)), 0, '', 0, 0, 0, 0, '', 0, '', '', 1); // By default, hierarchical parent print ''; print ''; @@ -923,7 +923,7 @@ if (empty($id) || $action == 'add' || $action == 'request' || $action == 'create print ''; print ''.$langs->trans("DescCP").''; print ''; - $doleditor = new DolEditor('description', GETPOST('description'), '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); + $doleditor = new DolEditor('description', GETPOST('description','none'), '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); print $doleditor->Create(1); print ''; @@ -1093,7 +1093,7 @@ else if(!$edit) { print ''; - print ''.$langs->trans('DateDebCP').' ('.$langs->trans("FirstDayOfHoliday").')'; + print ''.$langs->trans('DateDebCP').' ('.$langs->trans("FirstDayOfHoliday").')'; print ''.dol_print_date($object->date_debut,'day'); print '     '; print ''.$langs->trans($listhalfday[$starthalfday]).''; @@ -1103,7 +1103,7 @@ else else { print ''; - print ''.$langs->trans('DateDebCP').' ('.$langs->trans("FirstDayOfHoliday").')'; + print ''.$langs->trans('DateDebCP').' ('.$langs->trans("FirstDayOfHoliday").')'; print ''; $form->select_date($object->date_debut,'date_debut_'); print '     '; @@ -1115,7 +1115,7 @@ else if (!$edit) { print ''; - print ''.$langs->trans('DateFinCP').' ('.$langs->trans("LastDayOfHoliday").')'; + print ''.$langs->trans('DateFinCP').' ('.$langs->trans("LastDayOfHoliday").')'; print ''.dol_print_date($object->date_fin,'day'); print '     '; print ''.$langs->trans($listhalfday[$endhalfday]).''; @@ -1125,7 +1125,7 @@ else else { print ''; - print ''.$langs->trans('DateFinCP').' ('.$langs->trans("LastDayOfHoliday").')'; + print ''.$langs->trans('DateFinCP').' ('.$langs->trans("LastDayOfHoliday").')'; print ''; $form->select_date($object->date_fin,'date_fin_'); print '     '; diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index 26551847772..6e230fac7b2 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -957,10 +957,11 @@ class Holiday extends CommonObject /** * Affiche un select HTML des statuts de congés payés * - * @param int $selected int du statut séléctionné par défaut - * @return string affiche le select des statuts + * @param int $selected Id of preselected status + * @param string $select_statut Name of HTML select field + * @return string Show select of status */ - function selectStatutCP($selected='') { + function selectStatutCP($selected='', $htmlname='select_statut') { global $langs; @@ -969,7 +970,7 @@ class Holiday extends CommonObject $nb = count($name)+1; // Select HTML - $statut = ''."\n"; $statut.= ''."\n"; // Boucle des statuts diff --git a/htdocs/holiday/list.php b/htdocs/holiday/list.php index bb2b3c31bf0..e0894ecb355 100644 --- a/htdocs/holiday/list.php +++ b/htdocs/holiday/list.php @@ -73,18 +73,21 @@ if (! $sortorder) $sortorder="DESC"; $id = GETPOST('id','int'); -$sall = trim((GETPOST('search_all', 'alphanohtml')!='')?GETPOST('search_all', 'alphanohtml'):GETPOST('sall', 'alphanohtml')); -$search_ref = GETPOST('search_ref'); -$month_create = GETPOST('month_create'); -$year_create = GETPOST('year_create'); -$month_start = GETPOST('month_start'); -$year_start = GETPOST('year_start'); -$month_end = GETPOST('month_end'); -$year_end = GETPOST('year_end'); -$search_employee = GETPOST('search_employee'); -$search_valideur = GETPOST('search_valideur'); -$search_statut = GETPOST('select_statut'); -$search_type = GETPOST('search_type','int'); +$sall = trim((GETPOST('search_all', 'alphanohtml')!='')?GETPOST('search_all', 'alphanohtml'):GETPOST('sall', 'alphanohtml')); +$search_ref = GETPOST('search_ref','alpha'); +$search_day_create = GETPOST('search_day_create','int'); +$search_month_create = GETPOST('search_month_create','int'); +$search_year_create = GETPOST('search_year_create','int'); +$search_day_start = GETPOST('search_day_start','int'); +$search_month_start = GETPOST('search_month_start','int'); +$search_year_start = GETPOST('search_year_start','int'); +$search_day_end = GETPOST('search_day_end','int'); +$search_month_end = GETPOST('search_month_end','int'); +$search_year_end = GETPOST('search_year_end','int'); +$search_employee = GETPOST('search_employee','int'); +$search_valideur = GETPOST('search_valideur','int'); +$search_statut = GETPOST('search_statut','int'); +$search_type = GETPOST('search_type','int'); // List of fields to search into when doing a "search in all" $fieldstosearchall = array( @@ -115,12 +118,12 @@ 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=""; - $month_create=""; - $year_create=""; - $month_start=""; - $year_start=""; - $month_end=""; - $year_end=""; + $search_month_create=""; + $search_year_create=""; + $search_month_start=""; + $search_year_start=""; + $search_month_end=""; + $search_year_end=""; $search_employee=""; $search_valideur=""; $search_statut=""; @@ -178,47 +181,47 @@ if(!empty($search_ref)) } // Start date -if($year_start > 0) { - if($month_start > 0) { - $filter .= " AND (cp.date_debut BETWEEN '".$db->idate(dol_get_first_day($year_start,$month_start,1))."' AND '".$db->idate(dol_get_last_day($year_start,$month_start,1))."')"; - //$filter.= " AND date_format(cp.date_debut, '%Y-%m') = '$year_start-$month_start'"; +if($search_year_start > 0) { + if($search_month_start > 0) { + $filter .= " AND (cp.date_debut BETWEEN '".$db->idate(dol_get_first_day($search_year_start,$search_month_start,1))."' AND '".$db->idate(dol_get_last_day($search_year_start,$search_month_start,1))."')"; + //$filter.= " AND date_format(cp.date_debut, '%Y-%m') = '$search_year_start-$search_month_start'"; } else { - $filter .= " AND (cp.date_debut BETWEEN '".$db->idate(dol_get_first_day($year_start,1,1))."' AND '".$db->idate(dol_get_last_day($year_start,12,1))."')"; - //$filter.= " AND date_format(cp.date_debut, '%Y') = '$year_start'"; + $filter .= " AND (cp.date_debut BETWEEN '".$db->idate(dol_get_first_day($search_year_start,1,1))."' AND '".$db->idate(dol_get_last_day($search_year_start,12,1))."')"; + //$filter.= " AND date_format(cp.date_debut, '%Y') = '$search_year_start'"; } } else { - if($month_start > 0) { - $filter.= " AND date_format(cp.date_debut, '%m') = '".$db->escape($month_start)."'"; + if($search_month_start > 0) { + $filter.= " AND date_format(cp.date_debut, '%m') = '".$db->escape($search_month_start)."'"; } } // End date -if($year_end > 0) { - if($month_end > 0) { - $filter .= " AND (cp.date_fin BETWEEN '".$db->idate(dol_get_first_day($year_end,$month_end,1))."' AND '".$db->idate(dol_get_last_day($year_end,$month_end,1))."')"; - //$filter.= " AND date_format(cp.date_fin, '%Y-%m') = '$year_end-$month_end'"; +if($search_year_end > 0) { + if($search_month_end > 0) { + $filter .= " AND (cp.date_fin BETWEEN '".$db->idate(dol_get_first_day($search_year_end,$search_month_end,1))."' AND '".$db->idate(dol_get_last_day($search_year_end,$search_month_end,1))."')"; + //$filter.= " AND date_format(cp.date_fin, '%Y-%m') = '$search_year_end-$search_month_end'"; } else { - $filter .= " AND (cp.date_fin BETWEEN '".$db->idate(dol_get_first_day($year_end,1,1))."' AND '".$db->idate(dol_get_last_day($year_end,12,1))."')"; - //$filter.= " AND date_format(cp.date_fin, '%Y') = '$year_end'"; + $filter .= " AND (cp.date_fin BETWEEN '".$db->idate(dol_get_first_day($search_year_end,1,1))."' AND '".$db->idate(dol_get_last_day($search_year_end,12,1))."')"; + //$filter.= " AND date_format(cp.date_fin, '%Y') = '$search_year_end'"; } } else { - if($month_end > 0) { - $filter.= " AND date_format(cp.date_fin, '%m') = '".$db->escape($month_end)."'"; + if($search_month_end > 0) { + $filter.= " AND date_format(cp.date_fin, '%m') = '".$db->escape($search_month_end)."'"; } } // Create date -if($year_create > 0) { - if($month_create > 0) { - $filter .= " AND (cp.date_create BETWEEN '".$db->idate(dol_get_first_day($year_create,$month_create,1))."' AND '".$db->idate(dol_get_last_day($year_create,$month_create,1))."')"; - //$filter.= " AND date_format(cp.date_create, '%Y-%m') = '$year_create-$month_create'"; +if($search_year_create > 0) { + if($search_month_create > 0) { + $filter .= " AND (cp.date_create BETWEEN '".$db->idate(dol_get_first_day($search_year_create,$search_month_create,1))."' AND '".$db->idate(dol_get_last_day($search_year_create,$search_month_create,1))."')"; + //$filter.= " AND date_format(cp.date_create, '%Y-%m') = '$search_year_create-$search_month_create'"; } else { - $filter .= " AND (cp.date_create BETWEEN '".$db->idate(dol_get_first_day($year_create,1,1))."' AND '".$db->idate(dol_get_last_day($year_create,12,1))."')"; - //$filter.= " AND date_format(cp.date_create, '%Y') = '$year_create'"; + $filter .= " AND (cp.date_create BETWEEN '".$db->idate(dol_get_first_day($search_year_create,1,1))."' AND '".$db->idate(dol_get_last_day($search_year_create,12,1))."')"; + //$filter.= " AND date_format(cp.date_create, '%Y') = '$search_year_create'"; } } else { - if($month_create > 0) { - $filter.= " AND date_format(cp.date_create, '%m') = '".$db->escape($month_create)."'"; + if($search_month_create > 0) { + $filter.= " AND date_format(cp.date_create, '%m') = '".$db->escape($search_month_create)."'"; } } @@ -289,9 +292,23 @@ $num = count($holiday->holiday); $arrayofselected=is_array($toselect)?$toselect:array(); $param=''; -if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; -if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; -if ($optioncss != '') $param.='&optioncss='.$optioncss; +if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); +if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); +if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); +if ($search_ref) $param.='&search_ref='.urlencode($search_ref); +if ($search_day_create) $param.='&search_day_create='.urlencode($search_day_create); +if ($search_month_create) $param.='&search_month_create='.urlencode($search_month_create); +if ($search_year_create) $param.='&search_year_create='.urlencode($search_year_create); +if ($search_search_day_start) $param.='&search_day_start='.urlencode($search_day_start); +if ($search_month_start) $param.='&search_month_start='.urlencode($search_month_start); +if ($search_year_start) $param.='&search_year_start='.urlencode($search_year_start); +if ($day_end) $param.='&day_end='.urlencode($day_end); +if ($search_month_end) $param.='&search_month_end='.urlencode($search_month_end); +if ($search_year_end) $param.='&search_year_end='.urlencode($search_year_end); +if ($search_employee > 0) $param.='&search_employee='.urlencode($search_employee); +if ($search_valideur > 0) $param.='&search_valideur='.urlencode($search_valideur); +if ($search_type > 0) $param.='&search_type='.urlencode($search_type); +if ($search_statut > 0) $param.='&search_statut='.urlencode($search_statut); // List of mass actions available $arrayofmassactions = array( @@ -380,8 +397,8 @@ print ''; // Create date print ''; -print ''; -$formother->select_year($year_create,'year_create',1, $min_year, 0); +print ''; +$formother->select_year($search_year_create,'search_year_create',1, $min_year, 0); print ''; // User @@ -435,19 +452,19 @@ print ' '; // Start date print ''; -print ''; -$formother->select_year($year_start,'year_start',1, $min_year, $max_year); +print ''; +$formother->select_year($search_year_start,'search_year_start',1, $min_year, $max_year); print ''; // End date print ''; -print ''; -$formother->select_year($year_end,'year_end',1, $min_year, $max_year); +print ''; +$formother->select_year($search_year_end,'search_year_end',1, $min_year, $max_year); print ''; // Status print ''; -$holiday->selectStatutCP($search_statut); +$holiday->selectStatutCP($search_statut, 'search_statut'); print ''; // Actions @@ -468,7 +485,7 @@ print_liste_field_titre("Duration",$_SERVER["PHP_SELF"],'','',$pram,'align="righ print_liste_field_titre("DateDebCP",$_SERVER["PHP_SELF"],"cp.date_debut","",$param,'align="center"',$sortfield,$sortorder); print_liste_field_titre("DateFinCP",$_SERVER["PHP_SELF"],"cp.date_fin","",$param,'align="center"',$sortfield,$sortorder); print_liste_field_titre("Status",$_SERVER["PHP_SELF"],"cp.statut","",$param,'align="right"',$sortfield,$sortorder); -print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch ')."\n"; +print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"],"",'',$param,'align="center"',$sortfield,$sortorder,'maxwidthsearch ')."\n"; print "\n"; $listhalfday=array('morning'=>$langs->trans("Morning"),"afternoon"=>$langs->trans("Afternoon")); diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 8d0936d7d80..6a3daaf6cfb 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -278,7 +278,9 @@ input.select2-input { .liste_titre input[name=month_date_when], .liste_titre input[name=monthvalid], .liste_titre input[name=search_ordermonth], .liste_titre input[name=search_deliverymonth], .liste_titre input[name=search_smonth], .liste_titre input[name=search_month], .liste_titre input[name=search_emonth], .liste_titre input[name=smonth], .liste_titre input[name=month], .liste_titre select[name=month], .liste_titre input[name=month_lim], .liste_titre input[name=month_start], .liste_titre input[name=month_end], .liste_titre input[name=month_create], -.liste_titre input[name=search_day_date_when], .liste_titre input[name=search_month_date_when], .liste_titre input[name=search_year_date_when] { +.liste_titre input[name=search_day_date_when], .liste_titre input[name=search_month_date_when], .liste_titre input[name=search_year_date_when], +.liste_titre input[name=search_month_create], .liste_titre input[name=search_month_start], .liste_titre input[name=search_month_end] +{ margin-right: 4px; } input[type=submit] { diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index b27cf3e5034..c36edde7ddc 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -291,7 +291,9 @@ textarea.cke_source:focus .liste_titre input[name=month_date_when], .liste_titre input[name=monthvalid], .liste_titre input[name=search_ordermonth], .liste_titre input[name=search_deliverymonth], .liste_titre input[name=search_smonth], .liste_titre input[name=search_month], .liste_titre input[name=search_emonth], .liste_titre input[name=smonth], .liste_titre input[name=month], .liste_titre input[name=month_lim], .liste_titre input[name=month_start], .liste_titre input[name=month_end], .liste_titre input[name=month_create], -.liste_titre input[name=search_day_date_when], .liste_titre input[name=search_month_date_when], .liste_titre input[name=search_year_date_when] { +.liste_titre input[name=search_day_date_when], .liste_titre input[name=search_month_date_when], .liste_titre input[name=search_year_date_when], +.liste_titre input[name=search_month_create], .liste_titre input[name=search_month_start], .liste_titre input[name=search_month_end] +{ margin-right: 4px; } input, input.flat, textarea, textarea.flat, form.flat select, select, select.flat, .dataTables_length label select {