Skip to content

Commit

Permalink
Fixed issue #7246: Impossible to filter by date
Browse files Browse the repository at this point in the history
  • Loading branch information
c-schmitz committed Jan 31, 2013
1 parent 505c647 commit f5e1650
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
15 changes: 8 additions & 7 deletions application/helpers/admin/statistics_helper.php
Expand Up @@ -356,13 +356,14 @@ function buildSelects($allfields, $surveyid, $language) {
foreach ($postvars as $pv)
{
//Only do this if there is actually a value for the $pv

if (
in_array($pv, $allfields) || in_array(substr($pv,1),$aQuestionMap) || in_array($pv,$aQuestionMap)
|| (
(
$pv[0]=='D' || $pv[0]=='N' || $pv[0]=='K'
)
&& in_array(substr($pv,1,strlen($pv)-2),$aQuestionMap)
&& (in_array(substr($pv,1,strlen($pv)-2),$aQuestionMap) || in_array(substr($pv,1,strlen($pv)-3),$aQuestionMap) || in_array(substr($pv,1,strlen($pv)-5),$aQuestionMap))
)
)
{
Expand Down Expand Up @@ -485,22 +486,22 @@ function buildSelects($allfields, $surveyid, $language) {
elseif ($firstletter == "D" && $_POST[$pv] != "")
{
//Date equals
if (substr($pv, -1, 1) == "eq")
if (substr($pv, -2) == "eq")
{
$selects[]=Yii::app()->db->quoteColumnName(substr($pv, 1, strlen($pv)-2))." = ".dbQuoteAll($_POST[$pv]);
$selects[]=Yii::app()->db->quoteColumnName(substr($pv, 1, strlen($pv)-3))." = ".dbQuoteAll($_POST[$pv]);
}
else
{
//date less than
if (substr($pv, -1, 1) == "less")
if (substr($pv, -4) == "less")
{
$selects[]= Yii::app()->db->quoteColumnName(substr($pv, 1, strlen($pv)-2)) . " >= ".dbQuoteAll($_POST[$pv]);
$selects[]= Yii::app()->db->quoteColumnName(substr($pv, 1, strlen($pv)-5)) . " >= ".dbQuoteAll($_POST[$pv]);
}

//date greater than
if (substr($pv, -1, 1) == "more")
if (substr($pv, -4) == "more")
{
$selects[]= Yii::app()->db->quoteColumnName(substr($pv, 1, strlen($pv)-2)) . " <= ".dbQuoteAll($_POST[$pv]);
$selects[]= Yii::app()->db->quoteColumnName(substr($pv, 1, strlen($pv)-5)) . " <= ".dbQuoteAll($_POST[$pv]);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion application/views/admin/export/statistics_view.php
Expand Up @@ -445,7 +445,7 @@
."<br />\n"

."\t<span class='smalltext'>".$clang->gT("Date (YYYY-MM-DD) equals").":<br />\n"
.CHtml::textField($myfield3,isset($_POST[$myfield3])?$_POST[$myfield2]:'',array() )
.CHtml::textField($myfield3,isset($_POST[$myfield3])?$_POST[$myfield3]:'',array() )
."<br />\n"
."\t&nbsp;&nbsp;".$clang->gT("Date is")." >=<br />\n"
.CHtml::textField($myfield4,isset($_POST[$myfield4])?$_POST[$myfield4]:'',array() )
Expand Down

0 comments on commit f5e1650

Please sign in to comment.