diff --git a/.zfproject.xml b/.zfproject.xml
index 56a8aa68c..92d0359f5 100644
--- a/.zfproject.xml
+++ b/.zfproject.xml
@@ -63,6 +63,7 @@
+
@@ -242,6 +243,9 @@
+
+
+
diff --git a/application/controllers/ScheduleController.php b/application/controllers/ScheduleController.php
index fadbdb161..c25ac79b9 100644
--- a/application/controllers/ScheduleController.php
+++ b/application/controllers/ScheduleController.php
@@ -21,6 +21,7 @@ class ScheduleController extends Zend_Controller_Action
->addActionContext('clear-show', 'json')
->addActionContext('get-current-playlist', 'json')
->addActionContext('find-playlists', 'html')
+ ->addActionContext('remove-group', 'json')
->initContext();
}
@@ -126,7 +127,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));
@@ -141,11 +142,9 @@ class ScheduleController extends Zend_Controller_Action
public function scheduleShowAction()
{
$request = $this->getRequest();
-
- $start = $this->_getParam('start');
- $end = $this->_getParam('end');
+
+ $start_timestamp = $this->_getParam('start');
$showId = $this->_getParam('showId');
- $day = $this->_getParam('day');
$search = $this->_getParam('search', null);
if($search == "") {
@@ -161,11 +160,11 @@ class ScheduleController extends Zend_Controller_Action
$plId = $this->_getParam('plId');
- $show->scheduleShow($start, array($plId));
+ $show->scheduleShow($start_timestamp, array($plId));
}
- $this->view->playlists = $show->searchPlaylistsForShow($day, $search);
- $this->view->showContent = $show->getShowContent($start);
+ $this->view->playlists = $show->searchPlaylistsForShow($start_timestamp, $search);
+ $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');
@@ -173,7 +172,6 @@ class ScheduleController extends Zend_Controller_Action
unset($this->view->showContent);
unset($this->view->playlists);
-
}
public function clearShowAction()
@@ -203,15 +201,38 @@ class ScheduleController extends Zend_Controller_Action
public function findPlaylistsAction()
{
- $search = $this->_getParam('search');
- $show_id = $this->_getParam('id');
- $dofw = $this->_getParam('day');
+ $search = $this->_getParam('search');
+ $show_id = $this->_getParam('showId');
+ $start_timestamp = $this->_getParam('start');
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
$show = new Show(new User($userInfo->id, $userInfo->type), $show_id);
- $this->view->playlists = $show->searchPlaylistsForShow($dofw, $search);
-
+ $this->view->playlists = $show->searchPlaylistsForShow($start_timestamp, $search);
}
+
+ public function removeGroupAction()
+ {
+ $group_id = $this->_getParam('groupId');
+ $start_timestamp = $this->_getParam('start');
+ $show_id = $this->_getParam('showId');
+ $search = $this->_getParam('search', null);
+
+ $userInfo = Zend_Auth::getInstance()->getStorage()->read();
+ $show = new Show(new User($userInfo->id, $userInfo->type), $show_id);
+
+ $show->removeGroupFromShow($start_timestamp, $group_id);
+
+ $this->view->playlists = $show->searchPlaylistsForShow($start_timestamp, $search);
+ $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');
+
+ unset($this->view->showContent);
+ unset($this->view->playlists);
+ }
+
+
}
@@ -231,6 +252,8 @@ class ScheduleController extends Zend_Controller_Action
+
+
diff --git a/application/models/Shows.php b/application/models/Shows.php
index 80ab2f43e..b266330f9 100644
--- a/application/models/Shows.php
+++ b/application/models/Shows.php
@@ -248,6 +248,47 @@ class Show {
}
}
+ public function removeGroupFromShow($start_timestamp, $group_id){
+ global $CC_DBC, $CC_CONFIG;
+
+ $timeinfo = explode(" ", $start_timestamp);
+
+ $group = CcShowScheduleQuery::create()
+ ->filterByDbShowId($this->_showId)
+ ->filterByDbGroupId($group_id)
+ ->filterByDbShowDay($timeinfo[0])
+ ->findOne();
+
+ $position = $group->getDbPosition();
+
+ $sql = "SELECT group_id FROM cc_show_schedule
+ WHERE show_id = '{$this->_showId}' AND show_day = '{$timeinfo[0]}'
+ AND position > '{$position}'";
+ $followingGroups = $CC_DBC->GetAll($sql);
+
+ $sql = "SELECT SUM(clip_length) FROM ".$CC_CONFIG["scheduleTable"]." WHERE group_id='{$group_id}'";
+ $group_length = $CC_DBC->GetOne($sql);
+
+ $sql = "DELETE FROM ".$CC_CONFIG["scheduleTable"]." WHERE group_id = '{$group_id}'";
+ $CC_DBC->query($sql);
+
+ if(!is_null($followingGroups)) {
+ $sql_opt = array();
+ foreach ($followingGroups as $row) {
+ $sql_opt[] = "group_id = {$row["group_id"]}";
+ }
+ $sql_group_ids = join(" OR ", $sql_opt);
+
+ $sql = "UPDATE ".$CC_CONFIG["scheduleTable"]."
+ SET starts = (starts - INTERVAL '{$group_length}'), ends = (ends - INTERVAL '{$group_length}')
+ WHERE " . $sql_group_ids;
+ $CC_DBC->query($sql);
+ }
+
+ $group->delete();
+
+ }
+
public function getTimeScheduled($start_timestamp, $end_timestamp) {
$time = Schedule::getTimeScheduledInRange($start_timestamp, $end_timestamp);
@@ -515,9 +556,12 @@ class Show {
return $event;
}
- public function searchPlaylistsForShow($day, $search=null){
+ public function searchPlaylistsForShow($start_timestamp, $search=null){
global $CC_DBC;
+ $sql = "SELECT EXTRACT(DOW FROM TIMESTAMP '{$start_timestamp}')";
+ $day = $CC_DBC->GetOne($sql);
+
$sql = "SELECT * FROM cc_show_days WHERE show_id = '{$this->_showId}' AND day = '{$day}'";
$row = $CC_DBC->GetAll($sql);
$row = $row[0];
diff --git a/application/views/scripts/schedule/remove-group.phtml b/application/views/scripts/schedule/remove-group.phtml
new file mode 100644
index 000000000..4311a14bc
--- /dev/null
+++ b/application/views/scripts/schedule/remove-group.phtml
@@ -0,0 +1 @@
+
View script for controller Schedule and script/action name removeGroup
\ No newline at end of file
diff --git a/public/js/airtime/schedule/schedule.js b/public/js/airtime/schedule/schedule.js
index 9414c3bed..0acfc5836 100644
--- a/public/js/airtime/schedule/schedule.js
+++ b/public/js/airtime/schedule/schedule.js
@@ -164,13 +164,13 @@ function openShowDialog() {
function makeScheduleDialog(dialog, json, show) {
dialog.find("#schedule_playlist_search").keyup(function(){
- var url, string, day;
+ var url, string, start_date;
url = "/Schedule/find-playlists/format/html";
string = $(this).val();
- day = show.start.getDay();
-
- $.post(url, {search: string, id: show.id, day: day}, function(html){
+ start_date = makeTimeStamp(show.start);
+
+ $.post(url, {search: string, showId: show.id, start: start_date}, function(html){
$("#schedule_playlist_choice")
.empty()
@@ -194,20 +194,18 @@ function makeScheduleDialog(dialog, json, show) {
.append(json.chosen)
.droppable({
drop: function(event, ui) {
- var li, pl_id, url, start_date, end_date, day, search;
+ var li, pl_id, url, start_date, search;
search = $("#schedule_playlist_search").val();
pl_id = $(ui.helper).attr("id").split("_").pop();
- day = show.start.getDay();
start_date = makeTimeStamp(show.start);
- end_date = makeTimeStamp(show.end);
url = '/Schedule/schedule-show/format/json';
$.post(url,
- {plId: pl_id, start: start_date, end: end_date, showId: show.id, day: day, search: search},
+ {plId: pl_id, start: start_date, showId: show.id, search: search},
function(json){
var x;
@@ -221,33 +219,53 @@ function makeScheduleDialog(dialog, json, show) {
$("#schedule_playlist_chosen")
.empty()
- .append(json.chosen)
- .find("li")
- .click(function(){
- $(this).find(".group_list").toggle();
- });
+ .append(json.chosen);
+
});
}
});
- dialog.find("#schedule_playlist_chosen li")
- .click(function(){
- $(this).find(".group_list").toggle();
- });
+ dialog.find(".ui-icon-triangle-1-e").parent().click(function(){
+ $(this).parent().find(".group_list").toggle();
+ });
+
+ dialog.find(".ui-icon-close").parent().click(function(){
+ var groupId, url, start_date;
+
+ start_date = makeTimeStamp(show.start);
+ groupId = $(this).parent().attr("id").split("_").pop();
+ url = '/Schedule/remove-group/format/json';
+
+ $.post(url,
+ {start: start_date, showId: show.id, groupId: groupId},
+ function(json){
+
+ $("#schedule_playlist_choice")
+ .empty()
+ .append(json.choice)
+ .find('li')
+ .draggable({
+ helper: 'clone'
+ });
+
+ $("#schedule_playlist_chosen")
+ .empty()
+ .append(json.chosen);
+ });
+ });
}
function openScheduleDialog(show) {
- var url, start_date, end_date, day;
+ var url, start_date, end_date;
url = '/Schedule/schedule-show/format/json';
- day = show.start.getDay();
-
+
start_date = makeTimeStamp(show.start);
end_date = makeTimeStamp(show.end);
$.get(url,
- {day: day, start: start_date, end: end_date, showId: show.id},
+ {start: start_date, end: end_date, showId: show.id},
function(json){
var dialog = $(json.dialog);