when deleting a group following groups in show update their times.
This commit is contained in:
parent
2de6944a20
commit
f2560a6aa6
5 changed files with 126 additions and 36 deletions
|
@ -63,6 +63,7 @@
|
|||
<actionMethod actionName="scheduleShow"/>
|
||||
<actionMethod actionName="clearShow"/>
|
||||
<actionMethod actionName="findPlaylists"/>
|
||||
<actionMethod actionName="removeGroup"/>
|
||||
</controllerFile>
|
||||
<controllerFile controllerName="Api">
|
||||
<actionMethod actionName="index"/>
|
||||
|
@ -242,6 +243,9 @@
|
|||
<viewControllerScriptsDirectory forControllerName="Schedule">
|
||||
<viewScriptFile forActionName="findPlaylists"/>
|
||||
</viewControllerScriptsDirectory>
|
||||
<viewControllerScriptsDirectory forControllerName="Schedule">
|
||||
<viewScriptFile forActionName="removeGroup"/>
|
||||
</viewControllerScriptsDirectory>
|
||||
</viewScriptsDirectory>
|
||||
<viewHelpersDirectory/>
|
||||
<viewFiltersDirectory enabled="false"/>
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
@ -142,10 +143,8 @@ class ScheduleController extends Zend_Controller_Action
|
|||
{
|
||||
$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()
|
||||
|
@ -204,14 +202,37 @@ class ScheduleController extends Zend_Controller_Action
|
|||
public function findPlaylistsAction()
|
||||
{
|
||||
$search = $this->_getParam('search');
|
||||
$show_id = $this->_getParam('id');
|
||||
$dofw = $this->_getParam('day');
|
||||
$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
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -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];
|
||||
|
|
1
application/views/scripts/schedule/remove-group.phtml
Normal file
1
application/views/scripts/schedule/remove-group.phtml
Normal file
|
@ -0,0 +1 @@
|
|||
<br /><br /><center>View script for controller <b>Schedule</b> and script/action name <b>removeGroup</b></center>
|
|
@ -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();
|
||||
start_date = makeTimeStamp(show.start);
|
||||
|
||||
$.post(url, {search: string, id: show.id, day: day}, function(html){
|
||||
$.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);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue