mirror of
https://github.com/Combodo/iTop.git
synced 2026-05-18 23:08:46 +02:00
Advanced Search: Dates between
SVN:b1162[5501]
This commit is contained in:
@@ -239,53 +239,6 @@ class CriterionToOQL extends CriterionConversionAbstract
|
|||||||
return "({$sRef} IN ('$sInList'))";
|
return "({$sRef} IN ('$sInList'))";
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static function BetweenDaysToOql($sRef, $aCriteria)
|
|
||||||
{
|
|
||||||
$aOQL = array();
|
|
||||||
|
|
||||||
$aValues = self::GetValues($aCriteria);
|
|
||||||
if (count($aValues) != 2)
|
|
||||||
{
|
|
||||||
return "1";
|
|
||||||
}
|
|
||||||
|
|
||||||
$oFormat = AttributeDateTime::GetFormat();
|
|
||||||
|
|
||||||
$sStartDate = $aValues[0]['value'];
|
|
||||||
if (!empty($sStartDate))
|
|
||||||
{
|
|
||||||
$oDate = $oFormat->parse($sStartDate);
|
|
||||||
$sStartDate = $oDate->format(AttributeDateTime::GetSQLFormat());
|
|
||||||
$aOQL[] = "({$sRef} >= '$sStartDate')";
|
|
||||||
}
|
|
||||||
|
|
||||||
$sEndDate = $aValues[1]['value'];
|
|
||||||
if (!empty($sEndDate))
|
|
||||||
{
|
|
||||||
$oDate = $oFormat->parse($sEndDate);
|
|
||||||
if ($aCriteria['widget'] == AttributeDefinition::SEARCH_WIDGET_TYPE_DATE_TIME)
|
|
||||||
{
|
|
||||||
$oDate->add(DateInterval::createFromDateString('1 day'));
|
|
||||||
$sEndDate = $oDate->format(AttributeDateTime::GetSQLFormat());
|
|
||||||
$aOQL[] = "({$sRef} < '$sEndDate')";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$sEndDate = $oDate->format(AttributeDateTime::GetSQLFormat());
|
|
||||||
$aOQL[] = "({$sRef} <= '$sEndDate')";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$sOQL = implode(' AND ', $aOQL);
|
|
||||||
|
|
||||||
if (empty($sOQL))
|
|
||||||
{
|
|
||||||
$sOQL = "1";
|
|
||||||
}
|
|
||||||
|
|
||||||
return $sOQL;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected static function BetweenDatesToOql($sRef, $aCriteria)
|
protected static function BetweenDatesToOql($sRef, $aCriteria)
|
||||||
{
|
{
|
||||||
$aOQL = array();
|
$aOQL = array();
|
||||||
@@ -301,15 +254,7 @@ class CriterionToOQL extends CriterionConversionAbstract
|
|||||||
$sStartDate = $aValues[0]['value'];
|
$sStartDate = $aValues[0]['value'];
|
||||||
if (!empty($sStartDate))
|
if (!empty($sStartDate))
|
||||||
{
|
{
|
||||||
try
|
$oDate = $oFormat->parse($sStartDate);
|
||||||
{
|
|
||||||
$oDate = $oFormat->parse($sStartDate);
|
|
||||||
}
|
|
||||||
catch (\Exception $e)
|
|
||||||
{
|
|
||||||
// Not the date time format, try the date format
|
|
||||||
return self::BetweenDaysToOql($sRef, $aCriteria);
|
|
||||||
}
|
|
||||||
$sStartDate = $oDate->format(AttributeDateTime::GetSQLFormat());
|
$sStartDate = $oDate->format(AttributeDateTime::GetSQLFormat());
|
||||||
$aOQL[] = "({$sRef} >= '$sStartDate')";
|
$aOQL[] = "({$sRef} >= '$sStartDate')";
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user