From 12cd80fe13bb0ffba73175686a158424403e974d Mon Sep 17 00:00:00 2001 From: naomiaro Date: Sat, 5 Feb 2011 19:42:03 -0500 Subject: [PATCH] can schedule/remove playlists from a show instance. --- .../controllers/ScheduleController.php | 26 ++++++------------- application/models/Schedule.php | 8 +++--- application/models/Shows.php | 10 +++++-- build/sql/triggers.sql | 2 +- 4 files changed, 21 insertions(+), 25 deletions(-) diff --git a/application/controllers/ScheduleController.php b/application/controllers/ScheduleController.php index 45d763820..28d0f194e 100644 --- a/application/controllers/ScheduleController.php +++ b/application/controllers/ScheduleController.php @@ -279,32 +279,23 @@ class ScheduleController extends Zend_Controller_Action public function scheduleShowDialogAction() { $showInstanceId = $this->_getParam('id'); + $this->sched_sess->showInstanceId = $showInstanceId; $show = new ShowInstance($showInstanceId); - - $start_timestamp = $this->_getParam('start'); - $end_timestamp = $this->_getParam('end'); - - $this->sched_sess->showId = $showId; - $this->sched_sess->showStart = $start_timestamp; - $this->sched_sess->showEnd = $end_timestamp; - + $start_timestamp = $show->getShowStart(); + $end_timestamp = $show->getShowEnd(); + $start = explode(" ", $start_timestamp); $end = explode(" ", $end_timestamp); $startTime = explode(":", $start[1]); $endTime = explode(":", $end[1]); $dateInfo = getDate(strtotime($start_timestamp)); - $userInfo = Zend_Auth::getInstance()->getStorage()->read(); - - $user = new User($userInfo->id, $userInfo->type); - $show = new Show($user, $showId); - - $this->view->showContent = $show->getShowContent($start_timestamp); - $this->view->timeFilled = $show->getTimeScheduled($start_timestamp, $end_timestamp); + $this->view->showContent = $show->getShowContent(); + $this->view->timeFilled = $show->getTimeScheduled(); $this->view->showName = $show->getName(); - $this->view->showLength = $show->getShowLength($start_timestamp, $end_timestamp); - $this->view->percentFilled = Schedule::getPercentScheduledInRange($start_timestamp, $end_timestamp); + $this->view->showLength = $show->getShowLength(); + $this->view->percentFilled = $show->getPercentScheduledInRange(); $this->view->wday = $dateInfo['weekday']; $this->view->month = $dateInfo['month']; @@ -314,7 +305,6 @@ class ScheduleController extends Zend_Controller_Action $this->view->chosen = $this->view->render('schedule/scheduled-content.phtml'); $this->view->dialog = $this->view->render('schedule/schedule-show-dialog.phtml'); - unset($this->view->showContent); } diff --git a/application/models/Schedule.php b/application/models/Schedule.php index d9cbf3137..a017c7164 100644 --- a/application/models/Schedule.php +++ b/application/models/Schedule.php @@ -307,7 +307,7 @@ class Schedule { AND (ends <= '{$e_datetime}')"; $res = $CC_DBC->GetOne($sql); - + if(is_null($res)) return 0; @@ -315,9 +315,9 @@ class Schedule { } public static function getPercentScheduledInRange($s_datetime, $e_datetime) { - + $time = Schedule::getTimeScheduledInRange($s_datetime, $e_datetime); - + $con = Propel::getConnection(CcSchedulePeer::DATABASE_NAME); $sql = "SELECT EXTRACT(EPOCH FROM TIMESTAMP WITH TIME ZONE '{$s_datetime}')"; @@ -333,7 +333,7 @@ class Schedule { $i_epoch = $r->fetchColumn(0); $percent = ceil(($i_epoch / ($e_epoch - $s_epoch)) * 100); - + return $percent; } diff --git a/application/models/Shows.php b/application/models/Shows.php index 971045595..5586764f1 100644 --- a/application/models/Shows.php +++ b/application/models/Shows.php @@ -107,7 +107,7 @@ class Show { $showHost->save(); } - $this->populateShowUntilLastGeneratedDate($showId); + Show::populateShowUntilLastGeneratedDate($showId); } public function deleteShow($timestamp, $dayId=NULL) { @@ -374,6 +374,11 @@ class ShowInstance { return $showInstance->getDbShowId(); } + public function getName() { + $show = CcShowQuery::create()->findPK($this->getShowId()); + return $show->getDbName(); + } + public function getShowStart() { $showInstance = CcShowInstancesQuery::create()->findPK($this->_instanceId); return $showInstance->getDbStarts(); @@ -478,6 +483,7 @@ class ShowInstance { $sched = new ScheduleGroup(); $lastGroupId = $this->getLastGroupId(); + $pos = $this->getNextPos(); if(is_null($lastGroupId)) { @@ -578,7 +584,7 @@ class ShowInstance { $start_timestamp = $this->getShowStart(); $end_timestamp = $this->getShowEnd(); - Schedule::getPercentScheduledInRange($start_timestamp, $end_timestamp); + return Schedule::getPercentScheduledInRange($start_timestamp, $end_timestamp); } public function getShowLength(){ diff --git a/build/sql/triggers.sql b/build/sql/triggers.sql index c03e9d746..e354f644a 100644 --- a/build/sql/triggers.sql +++ b/build/sql/triggers.sql @@ -32,7 +32,7 @@ CREATE FUNCTION show_content() RETURNS trigger AS BEGIN IF(TG_OP=''DELETE'') THEN UPDATE cc_show_schedule SET position = (position - 1) - WHERE (show_id = old.show_id AND show_day = old.show_day AND position > old.position); + WHERE (instance_id = old.instance_id AND position > old.position); END IF; RETURN NULL; END;