diff --git a/application/controllers/ScheduleController.php b/application/controllers/ScheduleController.php index 8500453f3..fadbdb161 100644 --- a/application/controllers/ScheduleController.php +++ b/application/controllers/ScheduleController.php @@ -141,32 +141,39 @@ 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'); + $search = $this->_getParam('search', null); + + if($search == "") { + $search = null; + } + + $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); - } - else { - $length = $this->_getParam('length'); + $this->view->playlists = $show->searchPlaylistsForShow($day, $search); + $this->view->showContent = $show->getShowContent($start); - $this->view->playlists = Playlist::searchPlaylists($length); - $this->view->dialog = $this->view->render('schedule/schedule-show.phtml'); + $this->view->choice = $this->view->render('schedule/find-playlists.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 857d7f6bf..80ab2f43e 100644 --- a/application/models/Shows.php +++ b/application/models/Shows.php @@ -285,9 +285,42 @@ class Show { LEFT JOIN cc_files AS f ON f.id = s.file_id LEFT JOIN cc_playlist AS p ON p.id = s.playlist_id ) - WHERE ss.show_day = '{$timeinfo[0]}' AND ss.show_id = '{$this->_showId}'"; + WHERE ss.show_day = '{$timeinfo[0]}' AND ss.show_id = '{$this->_showId}' ORDER BY starts"; - return $CC_DBC->GetAll($sql); + $res = $CC_DBC->GetAll($sql); + + if(count($res) <= 0) { + return $res; + } + + $items = array(); + $currGroupId = -1; + $pl_counter = -1; + $f_counter = -1; + foreach ($res as $row) { + if($currGroupId != $row["group_id"]){ + $currGroupId = $row["group_id"]; + $pl_counter = $pl_counter + 1; + $f_counter = -1; + + $items[$pl_counter]["pl_name"] = $row["name"]; + $items[$pl_counter]["pl_creator"] = $row["creator"]; + $items[$pl_counter]["pl_description"] = $row["description"]; + $items[$pl_counter]["pl_group"] = $row["group_id"]; + + $sql = "SELECT SUM(clip_length) FROM cc_schedule WHERE group_id = '{$currGroupId}'"; + $length = $CC_DBC->GetOne($sql); + + $items[$pl_counter]["pl_length"] = $length; + } + $f_counter = $f_counter + 1; + + $items[$pl_counter]["pl_content"][$f_counter]["f_name"] = $row["track_title"]; + $items[$pl_counter]["pl_content"][$f_counter]["f_artist"] = $row["artist_name"]; + $items[$pl_counter]["pl_content"][$f_counter]["f_length"] = $row["length"]; + } + + return $items; } public function clearShow($day) { @@ -482,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/application/views/scripts/schedule/find-playlists.ajax.phtml b/application/views/scripts/schedule/find-playlists.ajax.phtml index f5d6626cf..185ce5f98 100644 --- a/application/views/scripts/schedule/find-playlists.ajax.phtml +++ b/application/views/scripts/schedule/find-playlists.ajax.phtml @@ -2,4 +2,7 @@ if(count($this->playlists) > 0) { echo $this->partialLoop('schedule/find-playlists-partial.phtml', $this->playlists); } + else { + echo "No Playlists Fit Duration"; + } ?> diff --git a/application/views/scripts/schedule/find-playlists.phtml b/application/views/scripts/schedule/find-playlists.phtml index e69de29bb..185ce5f98 100644 --- a/application/views/scripts/schedule/find-playlists.phtml +++ b/application/views/scripts/schedule/find-playlists.phtml @@ -0,0 +1,8 @@ +playlists) > 0) { + echo $this->partialLoop('schedule/find-playlists-partial.phtml', $this->playlists); + } + else { + echo "No Playlists Fit Duration"; + } +?> diff --git a/application/views/scripts/schedule/schedule-show.phtml b/application/views/scripts/schedule/schedule-show.phtml index eee852c11..b854df484 100644 --- a/application/views/scripts/schedule/schedule-show.phtml +++ b/application/views/scripts/schedule/schedule-show.phtml @@ -1,9 +1,5 @@