CC-3542 : When you delete the current show it takes all songs from that show out of the playout history
This commit is contained in:
parent
9f0741a684
commit
eeb7273909
6 changed files with 210 additions and 91 deletions
|
@ -22,6 +22,7 @@ class ScheduleController extends Zend_Controller_Action
|
|||
->addActionContext('edit-show', 'json')
|
||||
->addActionContext('add-show', 'json')
|
||||
->addActionContext('cancel-show', 'json')
|
||||
->addActionContext('cancel-current-show', 'json')
|
||||
->addActionContext('get-form', 'json')
|
||||
->addActionContext('upload-to-sound-cloud', 'json')
|
||||
->addActionContext('content-context-menu', 'json')
|
||||
|
@ -816,21 +817,21 @@ class ScheduleController extends Zend_Controller_Action
|
|||
|
||||
public function cancelCurrentShowAction()
|
||||
{
|
||||
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
|
||||
$user = new Application_Model_User($userInfo->id);
|
||||
$user = Application_Model_User::GetCurrentUser();
|
||||
|
||||
if($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))) {
|
||||
$showInstanceId = $this->_getParam('id');
|
||||
try{
|
||||
$showInstance = new Application_Model_ShowInstance($showInstanceId);
|
||||
}catch(Exception $e){
|
||||
$this->view->show_error = true;
|
||||
return false;
|
||||
if ($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))) {
|
||||
$id = $this->_getParam('id');
|
||||
|
||||
try {
|
||||
$scheduler = new Application_Model_Scheduler();
|
||||
$scheduler->cancelShow($id);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
$this->view->error = $e->getMessage();
|
||||
Logging::log($e->getMessage());
|
||||
Logging::log("{$e->getFile()}");
|
||||
Logging::log("{$e->getLine()}");
|
||||
}
|
||||
$showInstance->clearShow();
|
||||
$showInstance->delete();
|
||||
|
||||
Application_Model_RabbitMq::PushSchedule();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -93,10 +93,10 @@ class Application_Model_Scheduler {
|
|||
throw new OutDatedScheduleException("The show {$show->getDbName()} is over and cannot be scheduled.");
|
||||
}
|
||||
|
||||
$origTs = intval($instanceInfo[$id]);
|
||||
$currTs = intval($instance->getDbLastScheduled("U")) ? : 0;
|
||||
if ($origTs !== $currTs) {
|
||||
Logging::log("orig {$origTs} current {$currTs}");
|
||||
$ts = intval($instanceInfo[$id]);
|
||||
$lastSchedTs = intval($instance->getDbLastScheduled("U")) ? : 0;
|
||||
if ($ts < $lastSchedTs) {
|
||||
Logging::log("ts {$ts} last sched {$lastSchedTs}");
|
||||
throw new OutDatedScheduleException("The show {$show->getDbName()} has been previously updated!");
|
||||
}
|
||||
}
|
||||
|
@ -216,6 +216,41 @@ class Application_Model_Scheduler {
|
|||
return $nextDT;
|
||||
}
|
||||
|
||||
/*
|
||||
* @param int $showInstance
|
||||
* @param array $exclude
|
||||
* ids of sched items to remove from the calulation.
|
||||
*/
|
||||
private function removeGaps($showInstance, $exclude=null) {
|
||||
|
||||
Logging::log("removing gaps from show instance #".$showInstance);
|
||||
|
||||
$instance = CcShowInstancesQuery::create()->findPK($showInstance, $this->con);
|
||||
if (is_null($instance)) {
|
||||
throw new OutDatedScheduleException("The schedule you're viewing is out of date!");
|
||||
}
|
||||
|
||||
$itemStartDT = $instance->getDbStarts(null);
|
||||
|
||||
$schedule = CcScheduleQuery::create()
|
||||
->filterByDbInstanceId($showInstance)
|
||||
->filterByDbId($exclude, Criteria::NOT_IN)
|
||||
->orderByDbStarts()
|
||||
->find($this->con);
|
||||
|
||||
|
||||
foreach ($schedule as $item) {
|
||||
|
||||
$itemEndDT = $this->findEndTime($itemStartDT, $item->getDbClipLength());
|
||||
|
||||
$item->setDbStarts($itemStartDT)
|
||||
->setDbEnds($itemEndDT)
|
||||
->save($this->con);
|
||||
|
||||
$itemStartDT = $itemEndDT;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* @param array $scheduledIds
|
||||
* @param array $fileIds
|
||||
|
@ -280,16 +315,16 @@ class Application_Model_Scheduler {
|
|||
$sched = new CcSchedule();
|
||||
}
|
||||
|
||||
$sched->setDbStarts($nextStartDT);
|
||||
$sched->setDbEnds($endTimeDT);
|
||||
$sched->setDbFileId($file['id']);
|
||||
$sched->setDbCueIn($file['cuein']);
|
||||
$sched->setDbCueOut($file['cueout']);
|
||||
$sched->setDbFadeIn($file['fadein']);
|
||||
$sched->setDbFadeOut($file['fadeout']);
|
||||
$sched->setDbClipLength($file['cliplength']);
|
||||
$sched->setDbInstanceId($instance->getDbId());
|
||||
$sched->save($this->con);
|
||||
$sched->setDbStarts($nextStartDT)
|
||||
->setDbEnds($endTimeDT)
|
||||
->setDbFileId($file['id'])
|
||||
->setDbCueIn($file['cuein'])
|
||||
->setDbCueOut($file['cueout'])
|
||||
->setDbFadeIn($file['fadein'])
|
||||
->setDbFadeOut($file['fadeout'])
|
||||
->setDbClipLength($file['cliplength'])
|
||||
->setDbInstanceId($instance->getDbId())
|
||||
->save($this->con);
|
||||
|
||||
$nextStartDT = $endTimeDT;
|
||||
}
|
||||
|
@ -506,37 +541,42 @@ class Application_Model_Scheduler {
|
|||
}
|
||||
|
||||
/*
|
||||
* @param int $showInstance
|
||||
* @param array $exclude
|
||||
* ids of sched items to remove from the calulation.
|
||||
* Used for cancelling the current show instance.
|
||||
*
|
||||
* @param $p_id id of the show instance to cancel.
|
||||
*/
|
||||
private function removeGaps($showInstance, $exclude=null) {
|
||||
public function cancelShow($p_id) {
|
||||
|
||||
Logging::log("removing gaps from show instance #".$showInstance);
|
||||
$this->con->beginTransaction();
|
||||
|
||||
$instance = CcShowInstancesQuery::create()->findPK($showInstance, $this->con);
|
||||
if (is_null($instance)) {
|
||||
throw new OutDatedScheduleException("The schedule you're viewing is out of date!");
|
||||
try {
|
||||
|
||||
$instance = CcShowInstancesQuery::create()->findPK($p_id);
|
||||
|
||||
$items = CcScheduleQuery::create()
|
||||
->filterByDbInstanceId($p_id)
|
||||
->filterByDbEnds($this->nowDT, Criteria::GREATER_THAN)
|
||||
->find($this->con);
|
||||
|
||||
$remove = array();
|
||||
$ts = $this->nowDT->format('U');
|
||||
|
||||
for($i = 0; $i < count($items); $i++) {
|
||||
$remove[$i]["instance"] = $p_id;
|
||||
$remove[$i]["timestamp"] = $ts;
|
||||
$remove[$i]["id"] = $items[$i]->getDbId();
|
||||
}
|
||||
|
||||
$this->removeItems($remove, false);
|
||||
|
||||
$instance->setDbEnds($this->nowDT);
|
||||
$instance->save($this->con);
|
||||
|
||||
$this->con->commit();
|
||||
}
|
||||
|
||||
$itemStartDT = $instance->getDbStarts(null);
|
||||
|
||||
$schedule = CcScheduleQuery::create()
|
||||
->filterByDbInstanceId($showInstance)
|
||||
->filterByDbId($exclude, Criteria::NOT_IN)
|
||||
->orderByDbStarts()
|
||||
->find($this->con);
|
||||
|
||||
|
||||
foreach ($schedule as $item) {
|
||||
|
||||
$itemEndDT = $this->findEndTime($itemStartDT, $item->getDbClipLength());
|
||||
|
||||
$item->setDbStarts($itemStartDT);
|
||||
$item->setDbEnds($itemEndDT);
|
||||
$item->save($this->con);
|
||||
|
||||
$itemStartDT = $itemEndDT;
|
||||
catch (Exception $e) {
|
||||
$this->con->rollback();
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ class Application_Model_ShowBuilder {
|
|||
private $pos;
|
||||
private $contentDT;
|
||||
private $epoch_now;
|
||||
private $currentShow;
|
||||
|
||||
private $defaultRowArray = array(
|
||||
"header" => false,
|
||||
|
@ -54,6 +55,7 @@ class Application_Model_ShowBuilder {
|
|||
$this->user = Application_Model_User::GetCurrentUser();
|
||||
$this->opts = $p_opts;
|
||||
$this->epoch_now = floatval(microtime(true));
|
||||
$this->currentShow = false;
|
||||
}
|
||||
|
||||
//check to see if this row should be editable by the user.
|
||||
|
@ -118,7 +120,7 @@ class Application_Model_ShowBuilder {
|
|||
else if ($row["footer"] === true && $this->epoch_now < $p_epochItemEnd) {
|
||||
$row["scheduled"] = 2;
|
||||
}
|
||||
else if ($row["header"] === true && $this->epoch_now > $p_epochItemStart) {
|
||||
else if ($row["header"] === true && $this->epoch_now >= $p_epochItemStart) {
|
||||
$row["scheduled"] = 0;
|
||||
}
|
||||
else if ($row["header"] === true && $this->epoch_now < $p_epochItemEnd) {
|
||||
|
@ -157,6 +159,14 @@ class Application_Model_ShowBuilder {
|
|||
$showEndDT->setTimezone(new DateTimeZone($this->timezone));
|
||||
$endsEpoch = floatval($showEndDT->format("U.u"));
|
||||
|
||||
if ($startsEpoch < $this->epoch_now && $endsEpoch > $this->epoch_now) {
|
||||
$row["currentShow"] = true;
|
||||
$this->currentShow = true;
|
||||
}
|
||||
else {
|
||||
$this->currentShow = false;
|
||||
}
|
||||
|
||||
$row["header"] = true;
|
||||
$row["starts"] = $showStartDT->format("Y-m-d H:i");
|
||||
$row["refresh"] = floatval($showStartDT->format("U.u")) - $this->epoch_now;
|
||||
|
@ -225,6 +235,10 @@ class Application_Model_ShowBuilder {
|
|||
$row["instance"] = intval($p_item["si_id"]);
|
||||
}
|
||||
|
||||
if ($this->currentShow = true) {
|
||||
$row["currentShow"] = true;
|
||||
}
|
||||
|
||||
$this->getItemColor($p_item, $row);
|
||||
$this->getRowTimestamp($p_item, $row);
|
||||
$this->isAllowed($p_item, $row);
|
||||
|
@ -257,6 +271,10 @@ class Application_Model_ShowBuilder {
|
|||
|
||||
$row["refresh"] = floatval($showEndDT->format("U.u")) - $this->epoch_now;
|
||||
|
||||
if ($this->currentShow = true) {
|
||||
$row["currentShow"] = true;
|
||||
}
|
||||
|
||||
$this->getScheduledStatus($startsEpoch, $endsEpoch, $row);
|
||||
$this->isAllowed($p_item, $row);
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
.sb-content .fg-toolbar ul {
|
||||
float: left;
|
||||
padding: 0;
|
||||
margin: 0.5em 0 0 0;
|
||||
margin: 0.5em 10px 0 0;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
|
@ -176,6 +176,10 @@ table.datatable tr.sb-header.odd:hover td, table.datatable tr.sb-header.even:hov
|
|||
border-bottom-color:#6b6a6a !important;
|
||||
}
|
||||
|
||||
.sb-header div.ui-state-default {
|
||||
float: left;
|
||||
}
|
||||
|
||||
.sb-content table th.ui-state-default {
|
||||
background: -moz-linear-gradient(top, #b2b2b2 0, #a2a2a2 100%);
|
||||
background: -webkit-gradient(linear, left top, left bottom, color-stop(0, #b2b2b2), color-stop(100%, #a2a2a2));
|
||||
|
|
|
@ -1,8 +1,14 @@
|
|||
/**
|
||||
*
|
||||
* Schedule Dialog creation methods.
|
||||
*
|
||||
*/
|
||||
var AIRTIME = (function(AIRTIME){
|
||||
var mod;
|
||||
|
||||
if (AIRTIME.schedule === undefined) {
|
||||
AIRTIME.schedule = {};
|
||||
}
|
||||
mod = AIRTIME.schedule;
|
||||
|
||||
return AIRTIME;
|
||||
|
||||
}(AIRTIME || {}));
|
||||
|
||||
var serverTimezoneOffset = 0;
|
||||
|
||||
|
@ -27,21 +33,27 @@ function checkShowLength(json) {
|
|||
}
|
||||
|
||||
function confirmCancelShow(show_instance_id){
|
||||
if (confirm('Erase current show and stop playback?')){
|
||||
var url = "/Schedule/cancel-current-show/id/"+show_instance_id;
|
||||
if (confirm('Cancel Current Show?')) {
|
||||
var url = "/Schedule/cancel-current-show";
|
||||
$.ajax({
|
||||
url: url,
|
||||
success: function(data){scheduleRefetchEvents(data);}
|
||||
url: url,
|
||||
data: {format: "json", id: show_instance_id},
|
||||
success: function(data){
|
||||
scheduleRefetchEvents(data);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function confirmCancelRecordedShow(show_instance_id){
|
||||
if (confirm('Erase current show and stop recording?')){
|
||||
var url = "/Schedule/cancel-current-show/id/"+show_instance_id;
|
||||
if (confirm('Erase current show and stop recording?')) {
|
||||
var url = "/Schedule/cancel-current-show";
|
||||
$.ajax({
|
||||
url: url,
|
||||
success: function(data){scheduleRefetchEvents(data);}
|
||||
url: url,
|
||||
data: {format: "json", id: show_instance_id},
|
||||
success: function(data){
|
||||
scheduleRefetchEvents(data);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -364,6 +364,10 @@ var AIRTIME = (function(AIRTIME){
|
|||
$(nRow).addClass("sb-over");
|
||||
}
|
||||
|
||||
if (aData.currentShow === true) {
|
||||
$(nRow).addClass("sb-current-show");
|
||||
}
|
||||
|
||||
//call the context menu so we can prevent the event from propagating.
|
||||
$(nRow).find('td:gt(1)').click(function(e){
|
||||
|
||||
|
@ -372,6 +376,20 @@ var AIRTIME = (function(AIRTIME){
|
|||
return false;
|
||||
});
|
||||
},
|
||||
//remove any selected nodes before the draw.
|
||||
"fnPreDrawCallback": function( oSettings ) {
|
||||
var oTT;
|
||||
|
||||
oTT = TableTools.fnGetInstance('show_builder_table');
|
||||
oTT.fnSelectNone();
|
||||
|
||||
//disable jump to current button.
|
||||
AIRTIME.button.disableButton("sb-button-current");
|
||||
//disable deleting of overbooked tracks.
|
||||
AIRTIME.button.disableButton("sb-button-trim");
|
||||
//disable cancelling current show.
|
||||
AIRTIME.button.disableButton("sb-button-cancel");
|
||||
},
|
||||
"fnDrawCallback": function(oSettings, json) {
|
||||
var wrapperDiv,
|
||||
markerDiv,
|
||||
|
@ -454,22 +472,16 @@ var AIRTIME = (function(AIRTIME){
|
|||
//enable deleting of overbooked tracks.
|
||||
AIRTIME.button.enableButton("sb-button-trim");
|
||||
}
|
||||
|
||||
$tr = $sbTable.find('tr.sb-future:first');
|
||||
if ($tr.hasClass('sb-current-show')) {
|
||||
//enable cancelling current show.
|
||||
AIRTIME.button.enableButton("sb-button-cancel");
|
||||
}
|
||||
},
|
||||
"fnHeaderCallback": function(nHead) {
|
||||
$(nHead).find("input[type=checkbox]").attr("checked", false);
|
||||
},
|
||||
//remove any selected nodes before the draw.
|
||||
"fnPreDrawCallback": function( oSettings ) {
|
||||
var oTT;
|
||||
|
||||
oTT = TableTools.fnGetInstance('show_builder_table');
|
||||
oTT.fnSelectNone();
|
||||
|
||||
//disable jump to current button.
|
||||
AIRTIME.button.disableButton("sb-button-current");
|
||||
//disable deleting of overbooked tracks.
|
||||
AIRTIME.button.disableButton("sb-button-trim");
|
||||
},
|
||||
|
||||
"oColVis": {
|
||||
"aiExclude": [ 0, 1 ]
|
||||
|
@ -707,12 +719,44 @@ var AIRTIME = (function(AIRTIME){
|
|||
//start setup of the builder toolbar.
|
||||
$toolbar = $(".sb-content .fg-toolbar");
|
||||
|
||||
$toolbar
|
||||
.append("<ul />")
|
||||
.find('ul')
|
||||
.append('<li class="ui-state-default ui-state-disabled sb-button-current" title="jump to the currently playing track"><span class="ui-icon ui-icon-arrowstop-1-s"></span></li>')
|
||||
.append('<li class="ui-state-default ui-state-disabled sb-button-trim" title="delete all overbooked tracks"><span class="ui-icon ui-icon-scissors"></span></li>')
|
||||
.append('<li class="ui-state-default ui-state-disabled sb-button-delete" title="delete selected items"><span class="ui-icon ui-icon-trash"></span></li>');
|
||||
$ul = $("<ul/>");
|
||||
$ul.append('<li class="ui-state-default ui-state-disabled sb-button-trim" title="delete all overbooked tracks"><span class="ui-icon ui-icon-scissors"></span></li>')
|
||||
.append('<li class="ui-state-default ui-state-disabled sb-button-delete" title="delete selected items"><span class="ui-icon ui-icon-trash"></span></li>');
|
||||
$toolbar.append($ul);
|
||||
|
||||
$ul = $("<ul/>");
|
||||
$ul.append('<li class="ui-state-default ui-state-disabled sb-button-current" title="jump to the currently playing track"><span class="ui-icon ui-icon-arrowstop-1-s"></span></li>')
|
||||
.append('<li class="ui-state-default ui-state-disabled sb-button-cancel" title="cancel current show"><span class="ui-icon ui-icon-eject"></span></li>');
|
||||
$toolbar.append($ul);
|
||||
|
||||
//jump to current
|
||||
$toolbar.find('.sb-button-cancel')
|
||||
.click(function() {
|
||||
var $tr,
|
||||
data;
|
||||
|
||||
if (AIRTIME.button.isDisabled('sb-button-cancel') === true) {
|
||||
return;
|
||||
}
|
||||
|
||||
$tr = $sbTable.find('tr.sb-future:first');
|
||||
|
||||
if ($tr.hasClass('sb-current-show')) {
|
||||
data = $tr.data("aData");
|
||||
|
||||
if (confirm('Cancel Current Show?')) {
|
||||
var url = "/Schedule/cancel-current-show";
|
||||
$.ajax({
|
||||
url: url,
|
||||
data: {format: "json", id: data.instance},
|
||||
success: function(data){
|
||||
var oTable = $sbTable.dataTable();
|
||||
oTable.fnDraw();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
//jump to current
|
||||
$toolbar.find('.sb-button-current')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue