From 0ffa232b6d2f8916bd037ee1481c5ae126797c83 Mon Sep 17 00:00:00 2001 From: naomiaro Date: Thu, 13 Jan 2011 16:24:10 -0500 Subject: [PATCH] schedule show finds playlists available and returns show content better --- .../controllers/ScheduleController.php | 38 +++++++++---------- application/models/Shows.php | 2 +- public/js/airtime/schedule/schedule.js | 28 ++++++-------- 3 files changed, 31 insertions(+), 37 deletions(-) diff --git a/application/controllers/ScheduleController.php b/application/controllers/ScheduleController.php index 827351760..d941e958b 100644 --- a/application/controllers/ScheduleController.php +++ b/application/controllers/ScheduleController.php @@ -141,35 +141,33 @@ class ScheduleController extends Zend_Controller_Action public function scheduleShowAction() { $request = $this->getRequest(); - + + $start = $this->_getParam('start'); + $end = $this->_getParam('end'); + $showId = $this->_getParam('showId'); + $day = $this->_getParam('day'); + + $userInfo = Zend_Auth::getInstance()->getStorage()->read(); + + $user = new User($userInfo->id, $userInfo->type); + $show = new Show($user, $showId); + if($request->isPost()) { $plId = $this->_getParam('plId'); - $start = $this->_getParam('start'); - $end = $this->_getParam('end'); - $showId = $this->_getParam('showId'); - $userInfo = Zend_Auth::getInstance()->getStorage()->read(); - - $user = new User($userInfo->id, $userInfo->type); - $show = new Show($user, $showId); $show->scheduleShow($start, array($plId)); - - $this->view->showContent = $show->getShowContent($start); - $this->view->chosen = $this->view->render('schedule/scheduled-content.phtml'); - - unset($this->view->showContent); - } - else { - $length = $this->_getParam('length'); + $this->view->playlists = $show->searchPlaylistsForShow($day); + $this->view->showContent = $show->getShowContent($start); - $this->view->playlists = Playlist::searchPlaylists($length); - $this->view->dialog = $this->view->render('schedule/schedule-show.phtml'); + $this->view->chosen = $this->view->render('schedule/scheduled-content.phtml'); + $this->view->dialog = $this->view->render('schedule/schedule-show.phtml'); - unset($this->view->playlists); - } + unset($this->view->showContent); + unset($this->view->playlists); + } public function clearShowAction() diff --git a/application/models/Shows.php b/application/models/Shows.php index 24a93ebff..80ab2f43e 100644 --- a/application/models/Shows.php +++ b/application/models/Shows.php @@ -515,7 +515,7 @@ class Show { return $event; } - public function searchPlaylistsForShow($day, $search){ + public function searchPlaylistsForShow($day, $search=null){ global $CC_DBC; $sql = "SELECT * FROM cc_show_days WHERE show_id = '{$this->_showId}' AND day = '{$day}'"; diff --git a/public/js/airtime/schedule/schedule.js b/public/js/airtime/schedule/schedule.js index eb47d9169..d0cdd2025 100644 --- a/public/js/airtime/schedule/schedule.js +++ b/public/js/airtime/schedule/schedule.js @@ -185,9 +185,10 @@ function makeScheduleDialog(dialog, show) { dialog.find("#schedule_playlist_chosen") .droppable({ drop: function(event, ui) { - var li, pl_id, url, start_date, end_date; + var li, pl_id, url, start_date, end_date, day; pl_id = $(ui.helper).attr("id").split("_").pop(); + day = show.start.getDay(); start_date = makeTimeStamp(show.start); end_date = makeTimeStamp(show.end); @@ -195,7 +196,7 @@ function makeScheduleDialog(dialog, show) { url = '/Schedule/schedule-show/format/json'; $.post(url, - {plId: pl_id, start: start_date, end: end_date, showId: show.id}, + {plId: pl_id, start: start_date, end: end_date, showId: show.id, day: day}, function(json){ var x; @@ -208,13 +209,17 @@ function makeScheduleDialog(dialog, show) { }); } -function openScheduleDialog(show, time) { - var url; +function openScheduleDialog(show) { + var url, start_date, end_date, day; url = '/Schedule/schedule-show/format/json'; + day = show.start.getDay(); + + start_date = makeTimeStamp(show.start); + end_date = makeTimeStamp(show.end); $.get(url, - {length: time}, + {day: day, start: start_date, end: end_date, showId: show.id}, function(json){ var dialog = $(json.dialog); @@ -250,17 +255,8 @@ function eventMenu(action, el, pos) { }); } else if (method === 'schedule-show') { - var length, h, m, s, time; - - length = event.end.getTime() - event.start.getTime(); - - h = Math.floor(length / (1000*60*60)); - m = (length % (1000*60*60)) / (1000*60); - s = ((length % (1000*60*60)) % (1000*60)) / 1000; - - time = h+":"+m+":"+s; - - openScheduleDialog(event, time); + + openScheduleDialog(event); } else if (method === 'clear-show') { start_date = makeTimeStamp(event.start);