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 @@
- - - + + +
diff --git a/application/views/scripts/schedule/scheduled-content-partial.phtml b/application/views/scripts/schedule/scheduled-content-partial.phtml deleted file mode 100644 index 6e2d847d7..000000000 --- a/application/views/scripts/schedule/scheduled-content-partial.phtml +++ /dev/null @@ -1,2 +0,0 @@ -

First header

-
First content
diff --git a/application/views/scripts/schedule/scheduled-content.phtml b/application/views/scripts/schedule/scheduled-content.phtml new file mode 100644 index 000000000..980ab27ea --- /dev/null +++ b/application/views/scripts/schedule/scheduled-content.phtml @@ -0,0 +1,25 @@ +showContent) > 0) : ?> + showContent as $pl) : ?> +
  • "> +
    + + +
    + +
    +
  • + + +

    Empty

    +
    No Playlists
    + + diff --git a/public/js/airtime/schedule/schedule.js b/public/js/airtime/schedule/schedule.js index 5a1d327d2..f50cd6aca 100644 --- a/public/js/airtime/schedule/schedule.js +++ b/public/js/airtime/schedule/schedule.js @@ -159,7 +159,7 @@ function openShowDialog() { }); } -function makeScheduleDialog(dialog, show) { +function makeScheduleDialog(dialog, json, show) { dialog.find("#schedule_playlist_search").keyup(function(){ var url, string, day; @@ -172,53 +172,84 @@ function makeScheduleDialog(dialog, show) { $("#schedule_playlist_choice") .empty() - .append(html); + .append(html) + .find('li') + .draggable({ + helper: 'clone' + }); }); }); - dialog.find('#schedule_playlist_choice li') - .draggable({ - helper: 'clone' - }); + dialog.find('#schedule_playlist_choice') + .append(json.choice) + .find('li') + .draggable({ + helper: 'clone' + }); dialog.find("#schedule_playlist_chosen") + .append(json.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, search; + + search = $("#schedule_playlist_search").val(); pl_id = $(ui.helper).attr("id").split("_").pop(); + day = show.start.getDay(); start_date = makeTimeStamp(show.start); end_date = makeTimeStamp(show.end); url = '/Schedule/schedule-show/format/json'; - //$("#schedule_playlist_chosen") - // .append(ui.helper); - - $.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, search: search}, function(json){ var x; + + $("#schedule_playlist_choice") + .empty() + .append(json.choice) + .find('li') + .draggable({ + helper: 'clone' + }); + + $("#schedule_playlist_chosen") + .empty() + .append(json.chosen) + .find("li") + .click(function(){ + $(this).find(".group_list").toggle(); + }); }); } }); + + dialog.find("#schedule_playlist_chosen li") + .click(function(){ + $(this).find(".group_list").toggle(); + }); } -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); - makeScheduleDialog(dialog, show); + makeScheduleDialog(dialog, json, show); dialog.dialog({ autoOpen: false, @@ -250,17 +281,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);