diff --git a/.zfproject.xml b/.zfproject.xml
index 92d0359f5..432033fc5 100644
--- a/.zfproject.xml
+++ b/.zfproject.xml
@@ -64,6 +64,7 @@
+
@@ -246,6 +247,9 @@
+
+
+
diff --git a/application/controllers/ScheduleController.php b/application/controllers/ScheduleController.php
index c25ac79b9..0ea3fe80c 100644
--- a/application/controllers/ScheduleController.php
+++ b/application/controllers/ScheduleController.php
@@ -2,6 +2,7 @@
class ScheduleController extends Zend_Controller_Action
{
+ protected $sched_sess = null;
public function init()
{
@@ -18,11 +19,14 @@ class ScheduleController extends Zend_Controller_Action
->addActionContext('resize-show', 'json')
->addActionContext('delete-show', 'json')
->addActionContext('schedule-show', 'json')
+ ->addActionContext('schedule-show-dialog', 'json')
->addActionContext('clear-show', 'json')
->addActionContext('get-current-playlist', 'json')
->addActionContext('find-playlists', 'html')
->addActionContext('remove-group', 'json')
->initContext();
+
+ $this->sched_sess = new Zend_Session_Namespace("schedule");
}
public function indexAction()
@@ -127,7 +131,7 @@ class ScheduleController extends Zend_Controller_Action
public function deleteShowAction()
{
$showId = $this->_getParam('showId');
-
+
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
$show = new Show(new User($userInfo->id, $userInfo->type));
@@ -142,10 +146,11 @@ class ScheduleController extends Zend_Controller_Action
public function scheduleShowAction()
{
$request = $this->getRequest();
-
- $start_timestamp = $this->_getParam('start');
- $showId = $this->_getParam('showId');
+
+ $start_timestamp = $this->sched_sess->showStart;
+ $showId = $this->sched_sess->showId;
$search = $this->_getParam('search', null);
+ $plId = $this->_getParam('plId');
if($search == "") {
$search = null;
@@ -156,12 +161,7 @@ class ScheduleController extends Zend_Controller_Action
$user = new User($userInfo->id, $userInfo->type);
$show = new Show($user, $showId);
- if($request->isPost()) {
-
- $plId = $this->_getParam('plId');
-
- $show->scheduleShow($start_timestamp, array($plId));
- }
+ $show->scheduleShow($start_timestamp, array($plId));
$this->view->playlists = $show->searchPlaylistsForShow($start_timestamp, $search);
$this->view->showContent = $show->getShowContent($start_timestamp);
@@ -202,8 +202,8 @@ class ScheduleController extends Zend_Controller_Action
public function findPlaylistsAction()
{
$search = $this->_getParam('search');
- $show_id = $this->_getParam('showId');
- $start_timestamp = $this->_getParam('start');
+ $show_id = $this->sched_sess->showId;
+ $start_timestamp = $this->sched_sess->showStart;
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
$show = new Show(new User($userInfo->id, $userInfo->type), $show_id);
@@ -213,8 +213,8 @@ class ScheduleController extends Zend_Controller_Action
public function removeGroupAction()
{
$group_id = $this->_getParam('groupId');
- $start_timestamp = $this->_getParam('start');
- $show_id = $this->_getParam('showId');
+ $start_timestamp = $this->sched_sess->showStart;
+ $show_id = $this->sched_sess->showId;
$search = $this->_getParam('search', null);
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
@@ -232,6 +232,30 @@ class ScheduleController extends Zend_Controller_Action
unset($this->view->playlists);
}
+ public function scheduleShowDialogAction()
+ {
+ $start_timestamp = $this->_getParam('start');
+ $showId = $this->_getParam('showId');
+
+ $this->sched_sess->showId = $showId;
+ $this->sched_sess->showStart = $start_timestamp;
+
+ $userInfo = Zend_Auth::getInstance()->getStorage()->read();
+
+ $user = new User($userInfo->id, $userInfo->type);
+ $show = new Show($user, $showId);
+
+ $this->view->playlists = $show->searchPlaylistsForShow($start_timestamp);
+ $this->view->showContent = $show->getShowContent($start_timestamp);
+
+ $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->showContent);
+ unset($this->view->playlists);
+ }
+
}
@@ -254,6 +278,8 @@ class ScheduleController extends Zend_Controller_Action
+
+
diff --git a/application/views/scripts/schedule/schedule-show-dialog.phtml b/application/views/scripts/schedule/schedule-show-dialog.phtml
new file mode 100644
index 000000000..4101f836f
--- /dev/null
+++ b/application/views/scripts/schedule/schedule-show-dialog.phtml
@@ -0,0 +1 @@
+
View script for controller Schedule and script/action name scheduleShowDialog
\ No newline at end of file
diff --git a/build/sql/triggers.sql b/build/sql/triggers.sql
index a190be622..c03e9d746 100644
--- a/build/sql/triggers.sql
+++ b/build/sql/triggers.sql
@@ -30,13 +30,9 @@ DROP FUNCTION show_content() CASCADE;
CREATE FUNCTION show_content() RETURNS trigger AS
'
BEGIN
- IF(TG_OP=''INSERT'') THEN
- UPDATE cc_show_schedule SET position = (position + 1)
- WHERE (id = new.id AND position >= new.position AND id != new.id);
- END IF;
IF(TG_OP=''DELETE'') THEN
UPDATE cc_show_schedule SET position = (position - 1)
- WHERE (id = old.id AND position > old.position);
+ WHERE (show_id = old.show_id AND show_day = old.show_day AND position > old.position);
END IF;
RETURN NULL;
END;
diff --git a/public/js/airtime/schedule/schedule.js b/public/js/airtime/schedule/schedule.js
index 0acfc5836..92610d462 100644
--- a/public/js/airtime/schedule/schedule.js
+++ b/public/js/airtime/schedule/schedule.js
@@ -161,16 +161,51 @@ function openShowDialog() {
});
}
-function makeScheduleDialog(dialog, json, show) {
+function setScheduleDialogHtml(json) {
+
+ $("#schedule_playlist_choice")
+ .empty()
+ .append(json.choice)
+ .find('li')
+ .draggable({
+ helper: 'clone'
+ });
+
+ $("#schedule_playlist_chosen")
+ .empty()
+ .append(json.chosen);
+}
+
+function setScheduleDialogEvents() {
+
+ $(".ui-icon-triangle-1-e").parent().click(function(){
+ $(this).parent().find(".group_list").toggle();
+ });
+
+ $(".ui-icon-close").parent().click(function(){
+ var groupId, url;
+
+ groupId = $(this).parent().attr("id").split("_").pop();
+ url = '/Schedule/remove-group/format/json';
+
+ $.post(url,
+ {groupId: groupId},
+ function(json){
+ setScheduleDialogHtml(json);
+ setScheduleDialogEvents();
+ });
+ });
+}
+
+function makeScheduleDialog(dialog, json) {
dialog.find("#schedule_playlist_search").keyup(function(){
- var url, string, start_date;
+ var url, string;
url = "/Schedule/find-playlists/format/html";
string = $(this).val();
- start_date = makeTimeStamp(show.start);
- $.post(url, {search: string, showId: show.id, start: start_date}, function(html){
+ $.post(url, {search: string}, function(html){
$("#schedule_playlist_choice")
.empty()
@@ -194,35 +229,19 @@ function makeScheduleDialog(dialog, json, show) {
.append(json.chosen)
.droppable({
drop: function(event, ui) {
- var li, pl_id, url, start_date, search;
+ var pl_id, url, search;
search = $("#schedule_playlist_search").val();
-
pl_id = $(ui.helper).attr("id").split("_").pop();
- start_date = makeTimeStamp(show.start);
-
url = '/Schedule/schedule-show/format/json';
$.post(url,
- {plId: pl_id, start: start_date, showId: show.id, search: search},
+ {plId: pl_id, 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);
-
- });
-
+ setScheduleDialogHtml(json);
+ setScheduleDialogEvents();
+ });
}
});
@@ -231,27 +250,17 @@ function makeScheduleDialog(dialog, json, show) {
});
dialog.find(".ui-icon-close").parent().click(function(){
- var groupId, url, start_date;
+ var groupId, url, search;
- start_date = makeTimeStamp(show.start);
+ search = $("#schedule_playlist_search").val();
groupId = $(this).parent().attr("id").split("_").pop();
url = '/Schedule/remove-group/format/json';
$.post(url,
- {start: start_date, showId: show.id, groupId: groupId},
+ {groupId: groupId, search: search},
function(json){
-
- $("#schedule_playlist_choice")
- .empty()
- .append(json.choice)
- .find('li')
- .draggable({
- helper: 'clone'
- });
-
- $("#schedule_playlist_chosen")
- .empty()
- .append(json.chosen);
+ setScheduleDialogHtml(json);
+ setScheduleDialogEvents();
});
});
}
@@ -259,13 +268,12 @@ function makeScheduleDialog(dialog, json, show) {
function openScheduleDialog(show) {
var url, start_date, end_date;
- url = '/Schedule/schedule-show/format/json';
+ url = '/Schedule/schedule-show-dialog/format/json';
start_date = makeTimeStamp(show.start);
- end_date = makeTimeStamp(show.end);
- $.get(url,
- {start: start_date, end: end_date, showId: show.id},
+ $.post(url,
+ {start: start_date, showId: show.id},
function(json){
var dialog = $(json.dialog);
@@ -471,6 +479,5 @@ $(document).ready(function() {
$('#schedule_add_show').click(openShowDialog);
-
});