Skip to content

Commit

Permalink
Fixed issue #19245: Search surveys status options do not work (#3662)
Browse files Browse the repository at this point in the history
Co-authored-by: lapiudevgit <devgit@lapiu.biz>
  • Loading branch information
gabrieljenik and lapiudevgit committed Dec 12, 2023
1 parent 92a247a commit 6102024
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions application/models/Survey.php
Expand Up @@ -1615,15 +1615,18 @@ public function search()
$criteria->addCondition("t.startdate >'$sNow'");
}

// Filter for surveys that are running now
// Must be active, started and not expired
if ($this->active == "R") {
$criteria->compare("t.active", 'Y');
$subCriteria1 = new CDbCriteria();
$subCriteria2 = new CDbCriteria();
$subCriteria1->addCondition("'{$sNow}' > t.startdate", 'AND');
$subCriteria1->addCondition("t.startdate IS NULL", 'OR');
$subCriteria2->addCondition("t.expires IS NULL", 'AND');
$subCriteria2->addCondition("'{$sNow}' < t.expires", 'OR');
$criteria->mergeWith($subCriteria1);
$startedCriteria = new CDbCriteria();
$startedCriteria->addCondition("'{$sNow}' > t.startdate");
$startedCriteria->addCondition('t.startdate IS NULL', "OR");
$notExpiredCriteria = new CDbCriteria();
$notExpiredCriteria->addCondition("'{$sNow}' < t.expires");
$notExpiredCriteria->addCondition('t.expires IS NULL', "OR");
$criteria->mergeWith($startedCriteria);
$criteria->mergeWith($notExpiredCriteria);
}
}
}
Expand Down

0 comments on commit 6102024

Please sign in to comment.