mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-22 01:58:47 +02:00
Advanced Search: Dates between
SVN:b1162[5498]
This commit is contained in:
@@ -56,8 +56,7 @@ class CriterionToOQL extends CriterionConversionAbstract
|
||||
self::OP_ENDS_WITH => 'EndsWithToOql',
|
||||
self::OP_EMPTY => 'EmptyToOql',
|
||||
self::OP_NOT_EMPTY => 'NotEmptyToOql',
|
||||
self::OP_BETWEEN_DAYS => 'BetweenDaysToOql',
|
||||
self::OP_BETWEEN_HOURS => 'BetweenHoursToOql',
|
||||
self::OP_BETWEEN_DATES => 'BetweenDatesToOql',
|
||||
self::OP_BETWEEN => 'BetweenToOql',
|
||||
self::OP_IN => 'InToOql',
|
||||
self::OP_ALL => 'AllToOql',
|
||||
@@ -287,7 +286,7 @@ class CriterionToOQL extends CriterionConversionAbstract
|
||||
return $sOQL;
|
||||
}
|
||||
|
||||
protected static function BetweenHoursToOql($sRef, $aCriteria)
|
||||
protected static function BetweenDatesToOql($sRef, $aCriteria)
|
||||
{
|
||||
$aOQL = array();
|
||||
|
||||
@@ -302,7 +301,15 @@ class CriterionToOQL extends CriterionConversionAbstract
|
||||
$sStartDate = $aValues[0]['value'];
|
||||
if (!empty($sStartDate))
|
||||
{
|
||||
$oDate = $oFormat->parse($sStartDate);
|
||||
try
|
||||
{
|
||||
$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());
|
||||
$aOQL[] = "({$sRef} >= '$sStartDate')";
|
||||
}
|
||||
|
||||
@@ -168,7 +168,7 @@ class CriterionToSearchForm extends CriterionConversionAbstract
|
||||
|
||||
// Merge into 'between' operation.
|
||||
// The ends of the interval are included
|
||||
$aCurrCriterion['operator'] = 'between_days';
|
||||
$aCurrCriterion['operator'] = 'between_dates';
|
||||
$sFormat = AttributeDateTime::GetFormat()->ToMomentJS();
|
||||
$sLastDate = $aPrevCriterion['values'][0]['value'];
|
||||
if ($sPrevOperator == '<')
|
||||
@@ -259,14 +259,13 @@ class CriterionToSearchForm extends CriterionConversionAbstract
|
||||
$sLastDate = $aPrevCriterion['values'][0]['value'];
|
||||
$sFirstDate = $aCurrCriterion['values'][0]['value'];
|
||||
$oDate = new DateTime($sLastDate);
|
||||
$aCurrCriterion['operator'] = 'between_dates';
|
||||
if ((strpos($sFirstDate, '00:00:00') != false) && (strpos($sLastDate, '00:00:00') != false))
|
||||
{
|
||||
$aCurrCriterion['operator'] = 'between_days';
|
||||
$sInterval = '1 day';
|
||||
}
|
||||
else
|
||||
{
|
||||
$aCurrCriterion['operator'] = 'between_hours';
|
||||
$sInterval = '1 second';
|
||||
}
|
||||
|
||||
|
||||
@@ -32,8 +32,7 @@ abstract class CriterionConversionAbstract
|
||||
const OP_EMPTY = 'empty';
|
||||
const OP_NOT_EMPTY = 'not_empty';
|
||||
const OP_IN = 'IN';
|
||||
const OP_BETWEEN_DAYS = 'between_days';
|
||||
const OP_BETWEEN_HOURS = 'between_hours';
|
||||
const OP_BETWEEN_DATES = 'between_dates';
|
||||
const OP_BETWEEN = 'between';
|
||||
const OP_ALL = 'all';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user