diff --git a/.zfproject.xml b/.zfproject.xml
index 2d7499e2c..cffca41f9 100644
--- a/.zfproject.xml
+++ b/.zfproject.xml
@@ -70,6 +70,7 @@
+
@@ -321,6 +322,9 @@
+
+
+
diff --git a/application/controllers/ScheduleController.php b/application/controllers/ScheduleController.php
index e1d97fe65..f6bf30231 100644
--- a/application/controllers/ScheduleController.php
+++ b/application/controllers/ScheduleController.php
@@ -24,6 +24,7 @@ class ScheduleController extends Zend_Controller_Action
->addActionContext('remove-group', 'json')
->addActionContext('edit-show', 'json')
->addActionContext('add-show', 'json')
+ ->addActionContext('cancel-show', 'json')
->initContext();
$this->sched_sess = new Zend_Session_Namespace("schedule");
@@ -123,7 +124,7 @@ class ScheduleController extends Zend_Controller_Action
public function deleteShowAction()
{
$showInstanceId = $this->_getParam('id');
-
+
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
$user = new User($userInfo->id);
@@ -150,6 +151,8 @@ class ScheduleController extends Zend_Controller_Action
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/cancel-show'.$params, 'callback' => 'window["scheduleRefetchEvents"]'), 'title' => 'Cancel Show');
}
if($user->isHost($show->getShowId()) || $user->isAdmin()) {
@@ -211,7 +214,7 @@ class ScheduleController extends Zend_Controller_Action
public function findPlaylistsAction()
{
$post = $this->getRequest()->getPost();
-
+
$show = new ShowInstance($this->sched_sess->showInstanceId);
$playlists = $show->searchPlaylistsForShow($post);
@@ -302,7 +305,7 @@ class ScheduleController extends Zend_Controller_Action
public function addShowAction()
{
- $js = $this->_getParam('data');
+ $js = $this->_getParam('data');
$data = array();
//need to convert from serialized jQuery array.
@@ -324,6 +327,12 @@ class ScheduleController extends Zend_Controller_Action
$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;
+
$what = $formWhat->isValid($data);
$when = $formWhen->isValid($data);
if($when) {
@@ -333,7 +342,7 @@ class ScheduleController extends Zend_Controller_Action
if($data["add_show_repeats"]) {
$repeats = $formRepeats->isValid($data);
if($repeats) {
- $when = $formRepeats->checkReliantFields($data);
+ $repeats = $formRepeats->checkReliantFields($data);
}
}
else {
@@ -352,37 +361,38 @@ class ScheduleController extends Zend_Controller_Action
}
//send back a new form for the user.
- $formWhat = new Application_Form_AddShowWhat();
- $formWho = new Application_Form_AddShowWho();
- $formWhen = new Application_Form_AddShowWhen();
- $formRepeats = new Application_Form_AddShowRepeats();
- $formStyle = new Application_Form_AddShowStyle();
-
- $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;
+ $formWhat->reset();
+ $formWho->reset();
+ $formWhen->reset();
+ $formWhen->populate(array('add_show_start_date' => date("Y-m-d"),
+ '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();
+
$this->view->newForm = $this->view->render('schedule/add-show-form.phtml');
}
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');
- }
-
+ }
}
+ 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
+
+
diff --git a/application/forms/AddShowWhen.php b/application/forms/AddShowWhen.php
index 4467ee089..d59afa0ef 100644
--- a/application/forms/AddShowWhen.php
+++ b/application/forms/AddShowWhen.php
@@ -23,6 +23,7 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm
'label' => 'Start Time:',
'class' => 'input_text',
'required' => true,
+ 'value' => '0:00',
'filters' => array('StringTrim'),
'validators' => array(
'NotEmpty',
diff --git a/application/models/Shows.php b/application/models/Shows.php
index 1f7d5661f..41ea62c43 100644
--- a/application/models/Shows.php
+++ b/application/models/Shows.php
@@ -49,6 +49,21 @@ class Show {
$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.
public static function addShow($data) {
diff --git a/application/views/scripts/schedule/cancel-show.phtml b/application/views/scripts/schedule/cancel-show.phtml
new file mode 100644
index 000000000..1f2c21d35
--- /dev/null
+++ b/application/views/scripts/schedule/cancel-show.phtml
@@ -0,0 +1 @@
+
View script for controller Schedule and script/action name cancelShow
\ No newline at end of file