FIX navigation and filters on holiday list

This commit is contained in:
Laurent Destailleur 2018-03-19 16:11:42 +01:00
parent e0164884ee
commit 91cc3d1b73
6 changed files with 94 additions and 73 deletions

View File

@ -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)

View File

@ -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 '<input type="hidden" name="fuserid" value="'.($fuserid?$fuserid:$user->id).'">';
}
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 '</td>';
print '</tr>';
@ -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 '</td>';
print '</tr>';
@ -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 ' &nbsp; &nbsp; ';
print $form->selectarray('starthalfday', $listhalfday, (GETPOST('starthalfday')?GETPOST('starthalfday'):'morning'));
print $form->selectarray('starthalfday', $listhalfday, (GETPOST('starthalfday','alpha')?GETPOST('starthalfday','alpha'):'morning'));
print '</td>';
print '</tr>';
@ -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 ' &nbsp; &nbsp; ';
print $form->selectarray('endhalfday', $listhalfday, (GETPOST('endhalfday')?GETPOST('endhalfday'):'afternoon'));
print $form->selectarray('endhalfday', $listhalfday, (GETPOST('endhalfday','alpha')?GETPOST('endhalfday','alpha'):'afternoon'));
print '</td>';
print '</tr>';
@ -915,7 +915,7 @@ if (empty($id) || $action == 'add' || $action == 'request' || $action == 'create
print '<tr>';
print '<td class="fieldrequired">'.$langs->trans("ReviewedByCP").'</td>';
print '<td>';
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 '</td>';
print '</tr>';
@ -923,7 +923,7 @@ if (empty($id) || $action == 'add' || $action == 'request' || $action == 'create
print '<tr>';
print '<td>'.$langs->trans("DescCP").'</td>';
print '<td class="tdtop">';
$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 '</td></tr>';
@ -1093,7 +1093,7 @@ else
if(!$edit)
{
print '<tr>';
print '<td>'.$langs->trans('DateDebCP').' ('.$langs->trans("FirstDayOfHoliday").')</td>';
print '<td class="nowrap">'.$langs->trans('DateDebCP').' ('.$langs->trans("FirstDayOfHoliday").')</td>';
print '<td>'.dol_print_date($object->date_debut,'day');
print ' &nbsp; &nbsp; ';
print '<span class="opacitymedium">'.$langs->trans($listhalfday[$starthalfday]).'</span>';
@ -1103,7 +1103,7 @@ else
else
{
print '<tr>';
print '<td>'.$langs->trans('DateDebCP').' ('.$langs->trans("FirstDayOfHoliday").')</td>';
print '<td class="nowrap">'.$langs->trans('DateDebCP').' ('.$langs->trans("FirstDayOfHoliday").')</td>';
print '<td>';
$form->select_date($object->date_debut,'date_debut_');
print ' &nbsp; &nbsp; ';
@ -1115,7 +1115,7 @@ else
if (!$edit)
{
print '<tr>';
print '<td>'.$langs->trans('DateFinCP').' ('.$langs->trans("LastDayOfHoliday").')</td>';
print '<td class="nowrap">'.$langs->trans('DateFinCP').' ('.$langs->trans("LastDayOfHoliday").')</td>';
print '<td>'.dol_print_date($object->date_fin,'day');
print ' &nbsp; &nbsp; ';
print '<span class="opacitymedium">'.$langs->trans($listhalfday[$endhalfday]).'</span>';
@ -1125,7 +1125,7 @@ else
else
{
print '<tr>';
print '<td>'.$langs->trans('DateFinCP').' ('.$langs->trans("LastDayOfHoliday").')</td>';
print '<td class="nowrap">'.$langs->trans('DateFinCP').' ('.$langs->trans("LastDayOfHoliday").')</td>';
print '<td>';
$form->select_date($object->date_fin,'date_fin_');
print ' &nbsp; &nbsp; ';

View File

@ -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 = '<select name="select_statut" class="flat">'."\n";
$statut = '<select name="'.$htmlname.'" class="flat">'."\n";
$statut.= '<option value="-1">&nbsp;</option>'."\n";
// Boucle des statuts

View File

@ -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 '</td>';
// Create date
print '<td class="liste_titre" align="center">';
print '<input class="flat" type="text" size="1" maxlength="2" name="month_create" value="'.dol_escape_htmltag($month_create).'">';
$formother->select_year($year_create,'year_create',1, $min_year, 0);
print '<input class="flat" type="text" size="1" maxlength="2" name="search_month_create" value="'.dol_escape_htmltag($search_month_create).'">';
$formother->select_year($search_year_create,'search_year_create',1, $min_year, 0);
print '</td>';
// User
@ -435,19 +452,19 @@ print '<td class="liste_titre">&nbsp;</td>';
// Start date
print '<td class="liste_titre" align="center">';
print '<input class="flat" type="text" size="1" maxlength="2" name="month_start" value="'.dol_escape_htmltag($month_start).'">';
$formother->select_year($year_start,'year_start',1, $min_year, $max_year);
print '<input class="flat" type="text" size="1" maxlength="2" name="search_month_start" value="'.dol_escape_htmltag($search_month_start).'">';
$formother->select_year($search_year_start,'search_year_start',1, $min_year, $max_year);
print '</td>';
// End date
print '<td class="liste_titre" align="center">';
print '<input class="flat" type="text" size="1" maxlength="2" name="month_end" value="'.dol_escape_htmltag($month_end).'">';
$formother->select_year($year_end,'year_end',1, $min_year, $max_year);
print '<input class="flat" type="text" size="1" maxlength="2" name="search_month_end" value="'.dol_escape_htmltag($search_month_end).'">';
$formother->select_year($search_year_end,'search_year_end',1, $min_year, $max_year);
print '</td>';
// Status
print '<td class="liste_titre maxwidthonsmartphone maxwidth200" align="right">';
$holiday->selectStatutCP($search_statut);
$holiday->selectStatutCP($search_statut, 'search_statut');
print '</td>';
// 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 "</tr>\n";
$listhalfday=array('morning'=>$langs->trans("Morning"),"afternoon"=>$langs->trans("Afternoon"));

View File

@ -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] {

View File

@ -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 {