Skip to content
Snippets Groups Projects
Commit 42fc6606 authored by Laurent Destailleur's avatar Laurent Destailleur
Browse files

Fix filter on dates of services

parent 43a7109c
Branches
No related tags found
No related merge requests found
......@@ -52,15 +52,26 @@ $search_status=GETPOST("search_status","alpha");
$statut=GETPOST('statut')?GETPOST('statut'):1;
$socid=GETPOST('socid','int');
$opouvertureprevuemonth=GETPOST('opouvertureprevuemonth');
$opouvertureprevueday=GETPOST('opouvertureprevueday');
$opouvertureprevueyear=GETPOST('opouvertureprevueyear');
$filter_opouvertureprevue=GETPOST('filter_opouvertureprevue');
$op1month=GETPOST('op1month');
$op1day=GETPOST('op1day');
$op1year=GETPOST('op1year');
$filter_op1=GETPOST('filter_op1');
$op2month=GETPOST('op2month');
$op2day=GETPOST('op2day');
$op2year=GETPOST('op2year');
$filter_op2=GETPOST('filter_op2');
$opcloturemonth=GETPOST('opcloturemonth');
$opclotureday=GETPOST('opclotureday');
$opclotureyear=GETPOST('opclotureyear');
$filter_opcloture=GETPOST('filter_opcloture');
// Security check
$contratid = GETPOST('id','int');
if (! empty($user->societe_id)) $socid=$user->societe_id;
......@@ -88,12 +99,20 @@ $staticcontrat=new Contrat($db);
$staticcontratligne=new ContratLigne($db);
$companystatic=new Societe($db);
if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers
/*
* Actions
*/
if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All test are required to be compatible with all browsers
{
$search_name="";
$search_contract="";
$search_service="";
$search_status=-1;
$opouvertureprevuemonth="";
$opouvertureprevueday="";
$opouvertureprevueyear="";
$filter_opouvertureprevue="";
$op1month="";
$op1day="";
$op1year="";
......@@ -102,6 +121,10 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both
$op2day="";
$op2year="";
$filter_op2="";
$opcloturemonth="";
$opclotureday="";
$opclotureyear="";
$filter_opcloture="";
$mode='';
$filter='';
}
......@@ -143,10 +166,14 @@ if ($search_name) $sql.= " AND s.nom LIKE '%".$db->escape($search_name)."%'"
if ($search_contract) $sql.= " AND c.rowid = '".$db->escape($search_contract)."'";
if ($search_service) $sql.= " AND (p.ref LIKE '%".$db->escape($search_service)."%' OR p.description LIKE '%".$db->escape($search_service)."%' OR cd.description LIKE '%".$db->escape($search_service)."%')";
if ($socid > 0) $sql.= " AND s.rowid = ".$socid;
$filter_dateouvertureprevue=dol_mktime(0,0,0,$opouvertureprevuemonth,$opouvertureprevueday,$opouvertureprevueyear);
$filter_date1=dol_mktime(0,0,0,$op1month,$op1day,$op1year);
$filter_date2=dol_mktime(0,0,0,$op2month,$op2day,$op2year);
if (! empty($filter_op1) && $filter_op1 != -1 && $filter_date1 != '') $sql.= " AND date_ouverture_prevue ".$filter_op1." '".$db->idate($filter_date1)."'";
if (! empty($filter_op2) && $filter_op2 != -1 && $filter_date2 != '') $sql.= " AND date_fin_validite ".$filter_op2." '".$db->idate($filter_date2)."'";
$filter_datecloture=dol_mktime(0,0,0,$opcloturemonth,$opclotureday,$opclotureyear);
if (! empty($filter_opouvertureprevue) && $filter_opouvertureprevue != -1 && $filter_dateouvertureprevue != '') $sql.= " AND cd.date_ouverture_prevue ".$filter_opouvertureprevue." '".$db->idate($filter_dateouvertureprevue)."'";
if (! empty($filter_op1) && $filter_op1 != -1 && $filter_date1 != '') $sql.= " AND cd.date_ouverture ".$filter_op1." '".$db->idate($filter_date1)."'";
if (! empty($filter_op2) && $filter_op2 != -1 && $filter_date2 != '') $sql.= " AND cd.date_fin_validite ".$filter_op2." '".$db->idate($filter_date2)."'";
if (! empty($filter_opcloture) && $filter_opcloture != -1 && $filter_datecloture != '') $sql.= " AND cd.date_cloture ".$filter_opcloture." '".$db->idate($filter_datecloture)."'";
$totalnboflines=0;
$result=$db->query($sql);
if ($result)
......@@ -170,10 +197,14 @@ if ($resql)
if ($search_service) $param.='&search_service='.urlencode($search_service);
if ($mode) $param.='&mode='.$mode;
if ($filter) $param.='&filter='.$filter;
if (! empty($filter_opouvertureprevue) && $filter_opouvertureprevue != -1) $param.='&filter_opouvertureprevue='.urlencode($filter_opouvertureprevue);
if (! empty($filter_op1) && $filter_op1 != -1) $param.='&filter_op1='.urlencode($filter_op1);
if (! empty($filter_op2) && $filter_op2 != -1) $param.='&filter_op2='.urlencode($filter_op2);
if (! empty($filter_opcloture) && $filter_opcloture != -1) $param.='&filter_opcloture='.urlencode($filter_opcloture);
if ($filter_dateouvertureprevue != '') $param.='&opouvertureprevueday='.$opouvertureprevueday.'&opouvertureprevuemonth='.$opouvertureprevuemonth.'&opouvertureprevueyear='.$opouvertureprevueyear;
if ($filter_date1 != '') $param.='&op1day='.$op1day.'&op1month='.$op1month.'&op1year='.$op1year;
if ($filter_date2 != '') $param.='&op2day='.$op2day.'&op2month='.$op2month.'&op2year='.$op2year;
if ($filter_datecloture != '') $param.='&opclotureday='.$op2day.'&opcloturemonth='.$op2month.'&opclotureyear='.$op2year;
$title=$langs->trans("ListOfServices");
if ($mode == "0") $title=$langs->trans("ListOfInactiveServices"); // Must use == "0"
......@@ -191,11 +222,11 @@ if ($resql)
print_liste_field_titre($langs->trans("Service"),$_SERVER["PHP_SELF"], "p.description",$param,"","",$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Company"),$_SERVER["PHP_SELF"], "s.nom",$param,"","",$sortfield,$sortorder);
// Date debut
if ($mode == "0") print_liste_field_titre($langs->trans("DateStartPlannedShort"),$_SERVER["PHP_SELF"], "cd.date_ouverture_prevue",$param,'',' align="center"',$sortfield,$sortorder);
if ($mode == "" || $mode > 0) print_liste_field_titre($langs->trans("DateStartRealShort"),$_SERVER["PHP_SELF"], "cd.date_ouverture",$param,'',' align="center"',$sortfield,$sortorder);
if (($mode == "" || $mode == -1) || $mode == "0") print_liste_field_titre($langs->trans("DateStartPlannedShort"),$_SERVER["PHP_SELF"], "cd.date_ouverture_prevue",$param,'',' align="center"',$sortfield,$sortorder);
if (($mode == "" || $mode == -1) || $mode > 0) print_liste_field_titre($langs->trans("DateStartRealShort"),$_SERVER["PHP_SELF"], "cd.date_ouverture",$param,'',' align="center"',$sortfield,$sortorder);
// Date fin
if ($mode == "" || $mode < 5) print_liste_field_titre($langs->trans("DateEndPlannedShort"),$_SERVER["PHP_SELF"], "cd.date_fin_validite",$param,'',' align="center"',$sortfield,$sortorder);
else print_liste_field_titre($langs->trans("DateEndRealShort"),$_SERVER["PHP_SELF"], "cd.date_cloture",$param,'',' align="center"',$sortfield,$sortorder);
if (($mode == "" || $mode == -1) || $mode < 5) print_liste_field_titre($langs->trans("DateEndPlannedShort"),$_SERVER["PHP_SELF"], "cd.date_fin_validite",$param,'',' align="center"',$sortfield,$sortorder);
if (($mode == "" || $mode == -1) || $mode >= 5) print_liste_field_titre($langs->trans("DateEndRealShort"),$_SERVER["PHP_SELF"], "cd.date_cloture",$param,'',' align="center"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"], "cd.statut,c.statut",$param,"","align=\"right\"",$sortfield,$sortorder);
print_liste_field_titre('',$_SERVER["PHP_SELF"],"",'','','',$sortfield,$sortorder,'maxwidthsearch ');
print "</tr>\n";
......@@ -214,6 +245,18 @@ if ($resql)
print '<td class="liste_titre">';
print '<input type="text" class="flat" size="12" name="search_name" value="'.dol_escape_htmltag($search_name).'">';
print '</td>';
if (($mode == "" || $mode == -1) || $mode == "0")
{
print '<td class="liste_titre" align="center">';
$arrayofoperators=array('<'=>'<','>'=>'>');
print $form->selectarray('filter_opouvertureprevue',$arrayofoperators,$filter_opouvertureprevue,1);
print ' ';
$filter_dateouvertureprevue=dol_mktime(0,0,0,$opouvertureprevuemonth,$opouvertureprevueday,$opouvertureprevueyear);
print $form->select_date($filter_dateouvertureprevue,'opouvertureprevue',0,0,1,'',1,0,1);
print '</td>';
}
if (($mode == "" || $mode == -1) || $mode > 0)
{
print '<td class="liste_titre" align="center">';
$arrayofoperators=array('<'=>'<','>'=>'>');
print $form->selectarray('filter_op1',$arrayofoperators,$filter_op1,1);
......@@ -221,6 +264,9 @@ if ($resql)
$filter_date1=dol_mktime(0,0,0,$op1month,$op1day,$op1year);
print $form->select_date($filter_date1,'op1',0,0,1,'',1,0,1);
print '</td>';
}
if (($mode == "" || $mode == -1) || $mode < 5)
{
print '<td class="liste_titre" align="center">';
$arrayofoperators=array('<'=>'<','>'=>'>');
print $form->selectarray('filter_op2',$arrayofoperators,$filter_op2,1);
......@@ -228,6 +274,17 @@ if ($resql)
$filter_date2=dol_mktime(0,0,0,$op2month,$op2day,$op2year);
print $form->select_date($filter_date2,'op2',0,0,1,'',1,0,1);
print '</td>';
}
if (($mode == "" || $mode == -1) || $mode >= 5)
{
print '<td class="liste_titre" align="center">';
$arrayofoperators=array('<'=>'<','>'=>'>');
print $form->selectarray('filter_opcloture',$arrayofoperators,$filter_opcloture,1);
print ' ';
$filter_date_cloture=dol_mktime(0,0,0,$opcloturemonth,$opclotureday,$opclotureyear);
print $form->select_date($filter_date_cloture,'opcloture',0,0,1,'',1,0,1);
print '</td>';
}
print '<td align="right">';
$arrayofstatus=array(
'0'=>$langs->trans("ServiceStatusInitial"),
......@@ -287,7 +344,8 @@ if ($resql)
print '</td>';
// Start date
if ($mode == "0") {
if (($mode == "" || $mode == -1) || $mode == "0")
{
print '<td align="center">';
print ($obj->date_ouverture_prevue?dol_print_date($db->jdate($obj->date_ouverture_prevue)):'&nbsp;');
if ($db->jdate($obj->date_ouverture_prevue) && ($db->jdate($obj->date_ouverture_prevue) < ($now - $conf->contrat->services->inactifs->warning_delay)))
......@@ -295,13 +353,19 @@ if ($resql)
else print '&nbsp;&nbsp;&nbsp;&nbsp;';
print '</td>';
}
if ($mode == "" || $mode > 0) print '<td align="center">'.($obj->date_ouverture?dol_print_date($db->jdate($obj->date_ouverture)):'&nbsp;').'</td>';
if (($mode == "" || $mode == -1) || $mode > 0)
{
print '<td align="center">'.($obj->date_ouverture?dol_print_date($db->jdate($obj->date_ouverture)):'&nbsp;').'</td>';
}
// Date fin
if ($mode == "" || $mode < 5) print '<td align="center">'.($obj->date_fin_validite?dol_print_date($db->jdate($obj->date_fin_validite)):'&nbsp;');
else print '<td align="center">'.dol_print_date($db->jdate($obj->date_cloture));
// Icone warning
if (($mode == "" || $mode == -1) || $mode < 5)
{
print '<td align="center">'.($obj->date_fin_validite?dol_print_date($db->jdate($obj->date_fin_validite)):'&nbsp;');
if ($obj->date_fin_validite && $db->jdate($obj->date_fin_validite) < ($now - $conf->contrat->services->expires->warning_delay) && $obj->statut < 5) print img_warning($langs->trans("Late"));
else print '&nbsp;&nbsp;&nbsp;&nbsp;';
}
if (($mode == "" || $mode == -1) || $mode >= 5) print '<td align="center">'.dol_print_date($db->jdate($obj->date_cloture));
// Icone warning
print '</td>';
print '<td align="right" class="nowrap">';
if ($obj->cstatut == 0) // If contract is draft, we say line is also draft
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment