schedule show finds playlists available and returns show content better

This commit is contained in:
naomiaro 2011-01-13 16:24:10 -05:00
parent ad869e0f7f
commit 0ffa232b6d
3 changed files with 31 additions and 37 deletions

View file

@ -141,35 +141,33 @@ class ScheduleController extends Zend_Controller_Action
public function scheduleShowAction() public function scheduleShowAction()
{ {
$request = $this->getRequest(); $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()) { if($request->isPost()) {
$plId = $this->_getParam('plId'); $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)); $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->chosen = $this->view->render('schedule/scheduled-content.phtml');
$this->view->dialog = $this->view->render('schedule/schedule-show.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() public function clearShowAction()

View file

@ -515,7 +515,7 @@ class Show {
return $event; return $event;
} }
public function searchPlaylistsForShow($day, $search){ public function searchPlaylistsForShow($day, $search=null){
global $CC_DBC; global $CC_DBC;
$sql = "SELECT * FROM cc_show_days WHERE show_id = '{$this->_showId}' AND day = '{$day}'"; $sql = "SELECT * FROM cc_show_days WHERE show_id = '{$this->_showId}' AND day = '{$day}'";

View file

@ -185,9 +185,10 @@ function makeScheduleDialog(dialog, show) {
dialog.find("#schedule_playlist_chosen") dialog.find("#schedule_playlist_chosen")
.droppable({ .droppable({
drop: function(event, ui) { 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(); pl_id = $(ui.helper).attr("id").split("_").pop();
day = show.start.getDay();
start_date = makeTimeStamp(show.start); start_date = makeTimeStamp(show.start);
end_date = makeTimeStamp(show.end); end_date = makeTimeStamp(show.end);
@ -195,7 +196,7 @@ function makeScheduleDialog(dialog, show) {
url = '/Schedule/schedule-show/format/json'; url = '/Schedule/schedule-show/format/json';
$.post(url, $.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){ function(json){
var x; var x;
@ -208,13 +209,17 @@ function makeScheduleDialog(dialog, show) {
}); });
} }
function openScheduleDialog(show, time) { function openScheduleDialog(show) {
var url; var url, start_date, end_date, day;
url = '/Schedule/schedule-show/format/json'; url = '/Schedule/schedule-show/format/json';
day = show.start.getDay();
start_date = makeTimeStamp(show.start);
end_date = makeTimeStamp(show.end);
$.get(url, $.get(url,
{length: time}, {day: day, start: start_date, end: end_date, showId: show.id},
function(json){ function(json){
var dialog = $(json.dialog); var dialog = $(json.dialog);
@ -250,17 +255,8 @@ function eventMenu(action, el, pos) {
}); });
} }
else if (method === 'schedule-show') { else if (method === 'schedule-show') {
var length, h, m, s, time;
openScheduleDialog(event);
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);
} }
else if (method === 'clear-show') { else if (method === 'clear-show') {
start_date = makeTimeStamp(event.start); start_date = makeTimeStamp(event.start);