show cancelling available (needed for repeating shows)

This commit is contained in:
naomiaro 2011-02-12 17:21:37 -05:00
parent 9a7dda49fe
commit a83a4b6bae
5 changed files with 61 additions and 28 deletions

View file

@ -70,6 +70,7 @@
<actionMethod actionName="showContentDialog"/> <actionMethod actionName="showContentDialog"/>
<actionMethod actionName="editShow"/> <actionMethod actionName="editShow"/>
<actionMethod actionName="addShow"/> <actionMethod actionName="addShow"/>
<actionMethod actionName="cancelShow"/>
</controllerFile> </controllerFile>
<controllerFile controllerName="Api"> <controllerFile controllerName="Api">
<actionMethod actionName="index"/> <actionMethod actionName="index"/>
@ -321,6 +322,9 @@
<viewControllerScriptsDirectory forControllerName="Dashboard"> <viewControllerScriptsDirectory forControllerName="Dashboard">
<viewScriptFile forActionName="help"/> <viewScriptFile forActionName="help"/>
</viewControllerScriptsDirectory> </viewControllerScriptsDirectory>
<viewControllerScriptsDirectory forControllerName="Schedule">
<viewScriptFile forActionName="cancelShow"/>
</viewControllerScriptsDirectory>
</viewScriptsDirectory> </viewScriptsDirectory>
<viewHelpersDirectory/> <viewHelpersDirectory/>
<viewFiltersDirectory enabled="false"/> <viewFiltersDirectory enabled="false"/>

View file

@ -24,6 +24,7 @@ class ScheduleController extends Zend_Controller_Action
->addActionContext('remove-group', 'json') ->addActionContext('remove-group', 'json')
->addActionContext('edit-show', 'json') ->addActionContext('edit-show', 'json')
->addActionContext('add-show', 'json') ->addActionContext('add-show', 'json')
->addActionContext('cancel-show', 'json')
->initContext(); ->initContext();
$this->sched_sess = new Zend_Session_Namespace("schedule"); $this->sched_sess = new Zend_Session_Namespace("schedule");
@ -150,6 +151,8 @@ class ScheduleController extends Zend_Controller_Action
if($user->isAdmin()) { if($user->isAdmin()) {
$menu[] = array('action' => array('type' => 'ajax', 'url' => '/Schedule/delete-show'.$params, 'callback' => 'window["scheduleRefetchEvents"]'), 'title' => 'Delete'); $menu[] = array('action' => array('type' => 'ajax', 'url' => '/Schedule/delete-show'.$params, 'callback' => 'window["scheduleRefetchEvents"]'), 'title' => 'Delete');
$menu[] = array('action' => array('type' => 'ajax', 'url' => '/Schedule/cancel-show'.$params, 'callback' => 'window["scheduleRefetchEvents"]'), 'title' => 'Cancel Show');
} }
if($user->isHost($show->getShowId()) || $user->isAdmin()) { if($user->isHost($show->getShowId()) || $user->isAdmin()) {
@ -302,7 +305,7 @@ class ScheduleController extends Zend_Controller_Action
public function addShowAction() public function addShowAction()
{ {
$js = $this->_getParam('data'); $js = $this->_getParam('data');
$data = array(); $data = array();
//need to convert from serialized jQuery array. //need to convert from serialized jQuery array.
@ -324,6 +327,12 @@ class ScheduleController extends Zend_Controller_Action
$formRepeats->removeDecorator('DtDdWrapper'); $formRepeats->removeDecorator('DtDdWrapper');
$formStyle->removeDecorator('DtDdWrapper'); $formStyle->removeDecorator('DtDdWrapper');
$this->view->what = $formWhat;
$this->view->when = $formWhen;
$this->view->repeats = $formRepeats;
$this->view->who = $formWho;
$this->view->style = $formStyle;
$what = $formWhat->isValid($data); $what = $formWhat->isValid($data);
$when = $formWhen->isValid($data); $when = $formWhen->isValid($data);
if($when) { if($when) {
@ -333,7 +342,7 @@ class ScheduleController extends Zend_Controller_Action
if($data["add_show_repeats"]) { if($data["add_show_repeats"]) {
$repeats = $formRepeats->isValid($data); $repeats = $formRepeats->isValid($data);
if($repeats) { if($repeats) {
$when = $formRepeats->checkReliantFields($data); $repeats = $formRepeats->checkReliantFields($data);
} }
} }
else { else {
@ -352,37 +361,38 @@ class ScheduleController extends Zend_Controller_Action
} }
//send back a new form for the user. //send back a new form for the user.
$formWhat = new Application_Form_AddShowWhat(); $formWhat->reset();
$formWho = new Application_Form_AddShowWho(); $formWho->reset();
$formWhen = new Application_Form_AddShowWhen(); $formWhen->reset();
$formRepeats = new Application_Form_AddShowRepeats(); $formWhen->populate(array('add_show_start_date' => date("Y-m-d"),
$formStyle = new Application_Form_AddShowStyle(); 'add_show_start_time' => '0:00',
'add_show_duration' => '1:00'));
$formRepeats->reset();
$formRepeats->populate(array('add_show_end_date' => date("Y-m-d")));
$formStyle->reset();
$formWhat->removeDecorator('DtDdWrapper');
$formWho->removeDecorator('DtDdWrapper');
$formWhen->removeDecorator('DtDdWrapper');
$formRepeats->removeDecorator('DtDdWrapper');
$formStyle->removeDecorator('DtDdWrapper');
$this->view->what = $formWhat;
$this->view->when = $formWhen;
$this->view->repeats = $formRepeats;
$this->view->who = $formWho;
$this->view->style = $formStyle;
$this->view->newForm = $this->view->render('schedule/add-show-form.phtml'); $this->view->newForm = $this->view->render('schedule/add-show-form.phtml');
} }
else { else {
$this->view->what = $formWhat;
$this->view->when = $formWhen;
$this->view->repeats = $formRepeats;
$this->view->who = $formWho;
$this->view->style = $formStyle;
$this->view->form = $this->view->render('schedule/add-show-form.phtml'); $this->view->form = $this->view->render('schedule/add-show-form.phtml');
} }
} }
public function cancelShowAction()
{
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
$user = new User($userInfo->id);
if($user->isAdmin()) {
$showInstanceId = $this->_getParam('id');
$showInstance = new ShowInstance($showInstanceId);
$show = new Show($showInstance->getShowId());
$show->cancelShow($showInstance->getShowStart());
}
}
} }
@ -390,3 +400,5 @@ class ScheduleController extends Zend_Controller_Action

View file

@ -23,6 +23,7 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm
'label' => 'Start Time:', 'label' => 'Start Time:',
'class' => 'input_text', 'class' => 'input_text',
'required' => true, 'required' => true,
'value' => '0:00',
'filters' => array('StringTrim'), 'filters' => array('StringTrim'),
'validators' => array( 'validators' => array(
'NotEmpty', 'NotEmpty',

View file

@ -49,6 +49,21 @@ class Show {
$show->setDbBackgroundColor($backgroundColor); $show->setDbBackgroundColor($backgroundColor);
} }
public function cancelShow($day_timestamp) {
global $CC_DBC;
$timeinfo = explode(" ", $day_timestamp);
CcShowDaysQuery::create()
->filterByDbShowId($this->_showId)
->update(array('DbLastShow' => $timeinfo[0]));
$sql = "DELETE FROM cc_show_instances
WHERE starts >= '{$day_timestamp}' AND show_id = {$this->_showId}";
$CC_DBC->query($sql);
}
//end dates are non inclusive. //end dates are non inclusive.
public static function addShow($data) { public static function addShow($data) {

View file

@ -0,0 +1 @@
<br /><br /><center>View script for controller <b>Schedule</b> and script/action name <b>cancelShow</b></center>