Advanced Search: Dates between

SVN:b1162[5508]
This commit is contained in:
Eric Espié
2018-03-23 13:55:44 +00:00
parent 965e7b48df
commit b0332b6ef5
2 changed files with 12 additions and 3 deletions

View File

@@ -360,12 +360,17 @@ class CriterionToSearchForm extends CriterionConversionAbstract
$sDate = $aCriteria['values'][0]['value'];
$oDate = new DateTime($sDate);
$sFirstDateValue = $oDate->format(AttributeDateTime::GetSQLFormat());
$sFirstDateLabel = AttributeDateTime::GetFormat()->Format($sFirstDateValue);
$aCriteria['values'][0] = array('value' => $sFirstDateValue, 'label' => $sFirstDateLabel);
$oDate->add(DateInterval::createFromDateString('1 day'));
$oDate->sub(DateInterval::createFromDateString('1 second'));
$sLastDate = $oDate->format(AttributeDateTime::GetSQLFormat());
$sLastDate = AttributeDateTime::GetFormat()->Format($sLastDate);
$aCriteria['values'][1] = array('value' => $sLastDate, 'label' => $sLastDate);
$sLastDateValue = $oDate->format(AttributeDateTime::GetSQLFormat());
$sLastDateLabel = AttributeDateTime::GetFormat()->Format($sLastDateValue);
$aCriteria['values'][1] = array('value' => $sLastDateValue, 'label' => $sLastDateLabel);
}
}

View File

@@ -361,6 +361,10 @@ class CriterionConversionTest extends ItopDataTestCase
'Date between 3' => array('OQL' => "SELECT UserRequest WHERE start_date >= '2017-01-01 00:00:00' AND '2017-01-01 00:00:00' >= start_date"),
'Date between 4' => array('OQL' => "SELECT UserRequest WHERE start_date >= '2017-01-01 00:00:00' AND '2017-01-01 01:00:00' > start_date"),
'Date between 5' => array('OQL' => "SELECT UserRequest WHERE start_date >= '2017-01-01 00:00:00' AND '2017-01-02 00:00:00' > start_date"),
'Date between 6' => array('OQL' => "SELECT UserRequest WHERE start_date >= '2017-01-01' AND '2017-01-02' >= start_date"),
'Date between 7' => array('OQL' => "SELECT CustomerContract WHERE ((start_date >= '2018-03-01') AND (start_date < '2018-04-01'))"),
'Date =' => array('OQL' => "SELECT CustomerContract WHERE (start_date = '2018-03-01')"),
'Date =2' => array('OQL' => "SELECT UserRequest WHERE (DATE_FORMAT(start_date, '%Y-%m-%d') = '2018-03-21')"),
'Num between 1' => array('OQL' => "SELECT Server WHERE nb_u >= 0 AND 1 >= nb_u"),
);
}