diff --git a/airtime_mvc/application/services/ShowFormService.php b/airtime_mvc/application/services/ShowFormService.php index 2494b9c0d..e9cb8c5ea 100644 --- a/airtime_mvc/application/services/ShowFormService.php +++ b/airtime_mvc/application/services/ShowFormService.php @@ -343,22 +343,16 @@ class Application_Service_ShowFormService */ public function getNextFutureRepeatShowTime() { - $sql = << now() at time zone 'UTC' -AND show_id = :showId -AND modified_instance = FALSE -ORDER BY starts -LIMIT 1 -SQL; - $result = Application_Common_Database::prepareAndExecute( $sql, - array( 'showId' => $this->ccShow->getDbId() ), 'all' ); - - foreach ($result as $r) { - $starts = new DateTime($r["starts"], new DateTimeZone('UTC')); - $ends = new DateTime($r["ends"], new DateTimeZone('UTC')); - } + $ccShowInstance = CcShowInstancesQuery::create() + ->filterByDbShowId($this->ccShow->getDbId()) + ->filterByDbModifiedInstance(false) + ->filterByDbEnds(gmdate("Y-m-d H:i:s"), Criteria::GREATER_THAN) + ->orderByDbStarts() + ->limit(1) + ->findOne(); + $starts = new DateTime($ccShowInstance->getDbStarts(), new DateTimeZone("UTC")); + $ends = new DateTime($ccShowInstance->getDbEnds(), new DateTimeZone("UTC")); $userTimezone = Application_Model_Preference::GetTimezone(); $starts->setTimezone(new DateTimeZone($userTimezone)); diff --git a/airtime_mvc/application/services/ShowService.php b/airtime_mvc/application/services/ShowService.php index f737cf3b6..b5806a638 100644 --- a/airtime_mvc/application/services/ShowService.php +++ b/airtime_mvc/application/services/ShowService.php @@ -91,6 +91,9 @@ class Application_Service_ShowService $ccSchedule->save(); } + $con = Propel::getConnection(CcShowInstancesPeer::DATABASE_NAME); + $ccShowInstance->updateDbTimeFilled($con); + //delete the edited instance from the repeating sequence $ccShowInstanceOrig->setDbModifiedInstance(true)->save();