Skip to content

Commit

Permalink
Fixed issue #18546: Menu System: Setting a past survey start date lea…
Browse files Browse the repository at this point in the history
…ds to showing current date as end date at survey overview (#2800)

Co-authored-by: lapiudevgit <devgit@lapiu.biz>
  • Loading branch information
gabrieljenik and lapiudevgit committed Jan 6, 2023
1 parent 1d81bfc commit 1b6fbe4
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions application/models/Survey.php
Original file line number Diff line number Diff line change
Expand Up @@ -1154,7 +1154,7 @@ public function getRunning()
// If it's active, then we check if not expired
// Time adjust
$sNow = date("Y-m-d H:i:s", strtotime(Yii::app()->getConfig('timeadjust'), strtotime(date("Y-m-d H:i:s"))));
$sStop = ($this->expires != '') ? date("Y-m-d H:i:s", strtotime(Yii::app()->getConfig('timeadjust'), strtotime($this->expires))) : $sNow;
$sStop = ($this->expires != '') ? date("Y-m-d H:i:s", strtotime(Yii::app()->getConfig('timeadjust'), strtotime($this->expires))) : null;
$sStart = ($this->startdate != '') ? date("Y-m-d H:i:s", strtotime(Yii::app()->getConfig('timeadjust'), strtotime($this->startdate))) : $sNow;

// Time comparaison
Expand All @@ -1165,10 +1165,11 @@ public function getRunning()
$bExpired = ($oStop < $oNow);
$bWillRun = ($oStart > $oNow);

$sStop = convertToGlobalSettingFormat($sStop);
$sStop = $sStop != null ? convertToGlobalSettingFormat($sStop) : null;
$sStart = convertToGlobalSettingFormat($sStart);

// Icon generaton (for CGridView)
$sIconRunNoEx = '<a href="' . App()->createUrl('/surveyAdministration/view/surveyid/' . $this->sid) . '" class="survey-state" data-toggle="tooltip" title="' . gT('End: Never') . '"><span class="fa fa-play text-success"></span><span class="sr-only">SS' . gT('End: Never') . '</span></a>';
$sIconRunning = '<a href="' . App()->createUrl('/surveyAdministration/view/surveyid/' . $this->sid) . '" class="survey-state" data-toggle="tooltip" title="' . sprintf(gT('End: %s'), $sStop) . '"><span class="fa fa-play text-success"></span><span class="sr-only">' . sprintf(gT('End: %s'), $sStop) . '</span></a>';
$sIconExpired = '<a href="' . App()->createUrl('/surveyAdministration/view/surveyid/' . $this->sid) . '" class="survey-state" data-toggle="tooltip" title="' . sprintf(gT('Expired: %s'), $sStop) . '"><span class="fa fa fa-step-forward text-warning"></span><span class="sr-only">' . sprintf(gT('Expired: %s'), $sStop) . '</span></a>';
$sIconFuture = '<a href="' . App()->createUrl('/surveyAdministration/view/surveyid/' . $this->sid) . '" class="survey-state" data-toggle="tooltip" title="' . sprintf(gT('Start: %s'), $sStart) . '"><span class="fa fa-clock-o text-warning"></span><span class="sr-only">' . sprintf(gT('Start: %s'), $sStart) . '</span></a>';
Expand All @@ -1178,7 +1179,11 @@ public function getRunning()
// Expire prior to will start
$running = ($bExpired) ? $sIconExpired : $sIconFuture;
} else {
$running = $sIconRunning;
if ($sStop == null) {
$running = $sIconRunNoEx;
} else {
$running = $sIconRunning;
}
}
} else {
// If it's active, and doesn't have expire date, it's running
Expand Down Expand Up @@ -1630,13 +1635,11 @@ public function search()
$criteria->compare("t.active", 'Y');
$subCriteria1 = new CDbCriteria();
$subCriteria2 = new CDbCriteria();
$subCriteria1->addCondition("'{$sNow}' > t.startdate", 'OR');
$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');
$subCriteria1->addCondition('t.expires IS NULL', "OR");
$subCriteria1->addCondition("'{$sNow}' < t.expires", 'OR');
$subCriteria2->addCondition('t.startdate IS NULL', "OR");
$criteria->mergeWith($subCriteria1);
$criteria->mergeWith($subCriteria2);
}
}
}
Expand Down

0 comments on commit 1b6fbe4

Please sign in to comment.