clear a show, schedule a playlist during a show.

This commit is contained in:
naomiaro 2010-12-15 22:33:45 -05:00
parent bef06bd0ff
commit ce6a3f0278
4 changed files with 119 additions and 44 deletions

View file

@ -58,6 +58,7 @@
<actionMethod actionName="deleteShow"/> <actionMethod actionName="deleteShow"/>
<actionMethod actionName="makeContextMenu"/> <actionMethod actionName="makeContextMenu"/>
<actionMethod actionName="scheduleShow"/> <actionMethod actionName="scheduleShow"/>
<actionMethod actionName="clearShow"/>
</controllerFile> </controllerFile>
<controllerFile controllerName="Api"> <controllerFile controllerName="Api">
<actionMethod actionName="index"/> <actionMethod actionName="index"/>
@ -194,6 +195,9 @@
<viewControllerScriptsDirectory forControllerName="Schedule"> <viewControllerScriptsDirectory forControllerName="Schedule">
<viewScriptFile forActionName="scheduleShow"/> <viewScriptFile forActionName="scheduleShow"/>
</viewControllerScriptsDirectory> </viewControllerScriptsDirectory>
<viewControllerScriptsDirectory forControllerName="Schedule">
<viewScriptFile forActionName="clearShow"/>
</viewControllerScriptsDirectory>
</viewScriptsDirectory> </viewScriptsDirectory>
<viewHelpersDirectory/> <viewHelpersDirectory/>
<viewFiltersDirectory enabled="false"/> <viewFiltersDirectory enabled="false"/>

View file

@ -18,6 +18,7 @@ class ScheduleController extends Zend_Controller_Action
->addActionContext('resize-show', 'json') ->addActionContext('resize-show', 'json')
->addActionContext('delete-show', 'json') ->addActionContext('delete-show', 'json')
->addActionContext('schedule-show', 'json') ->addActionContext('schedule-show', 'json')
->addActionContext('clear-show', 'json')
->initContext(); ->initContext();
} }
@ -41,6 +42,7 @@ class ScheduleController extends Zend_Controller_Action
$eventHostMenu[] = array('action' => '/Schedule/delete-show', 'text' => 'Delete'); $eventHostMenu[] = array('action' => '/Schedule/delete-show', 'text' => 'Delete');
$eventHostMenu[] = array('action' => '/Schedule/schedule-show', 'text' => 'Schedule'); $eventHostMenu[] = array('action' => '/Schedule/schedule-show', 'text' => 'Schedule');
$eventHostMenu[] = array('action' => '/Schedule/clear-show', 'text' => 'Clear');
$this->view->eventHostMenu = $eventHostMenu; $this->view->eventHostMenu = $eventHostMenu;
} }
@ -135,23 +137,44 @@ class ScheduleController extends Zend_Controller_Action
public function scheduleShowAction() public function scheduleShowAction()
{ {
$request = $this->getRequest(); $request = $this->getRequest();
if($request->isPost()) { if($request->isPost()) {
$plId = $this->_getParam('plId'); $plId = $this->_getParam('plId');
$start = $this->_getParam('start'); $start = $this->_getParam('start');
$showId = $this->_getParam('showId');
$sched = new ScheduleGroup(); $userInfo = Zend_Auth::getInstance()->getStorage()->read();
$this->view->res = $sched->add($start, null, $plId); $user = new User($userInfo->id, $userInfo->type);
if($user->isHost($showId)) {
$sched = new ScheduleGroup();
$this->view->res = $sched->add($start, null, $plId);
}
} }
else { else {
$showId = $this->_getParam('showId');
$length = $this->_getParam('length'); $length = $this->_getParam('length');
$this->view->playlists = Playlist::findPlaylistMaxLength($length); $this->view->playlists = Playlist::findPlaylistMaxLength($length);
} }
} }
public function clearShowAction()
{
$start = $this->_getParam('start');
$showId = $this->_getParam('showId');
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
$user = new User($userInfo->id, $userInfo->type);
if($user->isHost($showId)) {
$sched = new ScheduleGroup();
$this->view->res = $sched->removeAtTime($start);
}
}
} }
@ -171,3 +194,5 @@ class ScheduleController extends Zend_Controller_Action

View file

@ -174,6 +174,22 @@ class ScheduleGroup {
} }
public function removeAtTime($p_datetime) {
global $CC_CONFIG, $CC_DBC;
$id = $this->dateToId($p_datetime);
$sql = "SELECT group_id FROM ".$CC_CONFIG["scheduleTable"]." WHERE id = ".$id;
$groupId = $CC_DBC->GetOne($sql);
if($groupId === NULL)
return;
$sql = "DELETE FROM ".$CC_CONFIG["scheduleTable"]
." WHERE group_id = ".$groupId;
$CC_DBC->query($sql);
}
/** /**
* Remove the group from the schedule. * Remove the group from the schedule.
* Note: does not check if it is in the past, you can remove anything. * Note: does not check if it is in the past, you can remove anything.

View file

@ -89,29 +89,37 @@ function closeDialog(event, ui) {
} }
function schedulePlaylist() { function schedulePlaylist() {
var li, pl_id, url, start, dialog; var li, pl_id, url, event, start, dialog;
dialog = $(this); dialog = $(this);
li = $("#schedule_playlist_dialog").find(".ui-state-active"); li = $("#schedule_playlist_dialog").find(".ui-state-active");
if(li.length === 0) {
dialog.remove();
return;
}
pl_id = li.data('pl_id'); pl_id = li.data('pl_id');
start = li.data('start'); event = li.parent().data('event');
start = event.start;
var sy, sm, sd, h, m, s; var sy, sm, sd, h, m, s;
sy = start.getFullYear(); sy = start.getFullYear();
sm = start.getMonth() + 1; sm = start.getMonth() + 1;
sd = start.getDate(); sd = start.getDate();
h = start.getHours(); h = start.getHours();
m = start.getMinutes(); m = start.getMinutes();
s = start.getSeconds(); s = start.getSeconds();
start_date = sy+"-"+ sm +"-"+ sd +" "+ h +":"+ m +":"+ s; start_date = sy+"-"+ sm +"-"+ sd +" "+ h +":"+ m +":"+ s;
url = '/Schedule/schedule-show/format/json'; url = '/Schedule/schedule-show/format/json';
$.post(url, $.post(url,
{plId: pl_id, start: start_date}, {plId: pl_id, start: start_date, showId: event.id},
function(json){ function(json){
dialog.remove(); dialog.remove();
$("#schedule_calendar").fullCalendar( 'refetchEvents' );
}); });
} }
@ -154,7 +162,7 @@ function makeScheduleDialog(playlists, event) {
ol = $('<ul/>'); ol = $('<ul/>');
$.each(playlists, function(i, val){ $.each(playlists, function(i, val){
li = $('<li />') li = $('<li />')
.addClass('ui-widget-content ui-selectee') .addClass('ui-widget-content')
.append('<div>'+val.name+'</div>') .append('<div>'+val.name+'</div>')
.append('<div>'+val.description+'</div>') .append('<div>'+val.description+'</div>')
.click(function(){ .click(function(){
@ -162,10 +170,11 @@ function makeScheduleDialog(playlists, event) {
$(this).addClass("ui-state-active"); $(this).addClass("ui-state-active");
}); });
li.data({'pl_id': val.id, 'start': event.start}); li.data({'pl_id': val.id});
ol.append(li); ol.append(li);
}); });
ol.data({'event': event});
dialog.append(ol); dialog.append(ol);
dialog.dialog({ dialog.dialog({
@ -180,6 +189,30 @@ function makeScheduleDialog(playlists, event) {
return dialog; return dialog;
} }
function openShowDialog() {
var url;
url = '/Schedule/add-show-dialog/format/json';
$.get(url, function(json){
var dialog = makeShowDialog(json.form);
dialog.dialog('open');
});
}
function openScheduleDialog(event, time) {
var url;
url = '/Schedule/schedule-show/format/json';
$.get(url,
{length: time},
function(json){
var dialog = makeScheduleDialog(json.playlists, event);
dialog.dialog('open');
});
}
function eventMenu(action, el, pos) { function eventMenu(action, el, pos) {
var method = action.split('/').pop(), var method = action.split('/').pop(),
event; event;
@ -206,6 +239,27 @@ function eventMenu(action, el, pos) {
openScheduleDialog(event, time); openScheduleDialog(event, time);
} }
else if (method === 'clear-show') {
start = event.start;
var sy, sm, sd, h, m, s, start_date;
sy = start.getFullYear();
sm = start.getMonth() + 1;
sd = start.getDate();
h = start.getHours();
m = start.getMinutes();
s = start.getSeconds();
start_date = sy+"-"+ sm +"-"+ sd +" "+ h +":"+ m +":"+ s;
url = '/Schedule/clear-show/format/json';
$.post(url,
{start: start_date, showId: event.id},
function(json){
$("#schedule_calendar").fullCalendar( 'refetchEvents' );
});
}
} }
/** /**
@ -284,30 +338,6 @@ function eventResize( event, dayDelta, minuteDelta, revertFunc, jsEvent, ui, vie
}); });
} }
function openShowDialog() {
var url;
url = '/Schedule/add-show-dialog/format/json';
$.get(url, function(json){
var dialog = makeShowDialog(json.form);
dialog.dialog('open');
});
}
function openScheduleDialog(event, time) {
var url;
url = '/Schedule/schedule-show/format/json';
$.get(url,
{showId: event.id, length: time},
function(json){
var dialog = makeScheduleDialog(json.playlists, event);
dialog.dialog('open');
});
}
$(document).ready(function() { $(document).ready(function() {
$('#schedule_calendar').fullCalendar({ $('#schedule_calendar').fullCalendar({