CC-3504 : Adding a clip when nothing is playing should schedule the clip at the current time
This commit is contained in:
parent
7a6cdeaf10
commit
275faa1881
7 changed files with 83 additions and 28 deletions
|
@ -89,7 +89,7 @@ class Application_Model_Scheduler {
|
||||||
*
|
*
|
||||||
* @return DateTime endDT in UTC
|
* @return DateTime endDT in UTC
|
||||||
*/
|
*/
|
||||||
public static function findEndTime($p_startDT, $p_duration) {
|
private static function findEndTime($p_startDT, $p_duration) {
|
||||||
|
|
||||||
$startEpoch = $p_startDT->format("U.u");
|
$startEpoch = $p_startDT->format("U.u");
|
||||||
$durationSeconds = Application_Model_Playlist::playlistTimeToSeconds($p_duration);
|
$durationSeconds = Application_Model_Playlist::playlistTimeToSeconds($p_duration);
|
||||||
|
@ -110,6 +110,39 @@ class Application_Model_Scheduler {
|
||||||
return $dt;
|
return $dt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function findNextStartTime($DT, $instance) {
|
||||||
|
|
||||||
|
//check to see if the show has started.
|
||||||
|
$nowDT = new DateTime("now", new DateTimeZone("UTC"));
|
||||||
|
|
||||||
|
$sEpoch = intval($DT->format("U"));
|
||||||
|
$nEpoch = intval($nowDT->format("U"));
|
||||||
|
|
||||||
|
//check for if the show has started.
|
||||||
|
if ($nEpoch > $sEpoch) {
|
||||||
|
//need some kind of placeholder for cc_schedule.
|
||||||
|
//playout_status will be -1.
|
||||||
|
$nextDT = $nowDT;
|
||||||
|
|
||||||
|
$length = $nEpoch - $sEpoch;
|
||||||
|
$cliplength = Application_Model_Playlist::secondsToPlaylistTime($length);
|
||||||
|
|
||||||
|
//fillers are for only storing a chunk of time space that has already passed.
|
||||||
|
$filler = new CcSchedule();
|
||||||
|
$filler->setDbStarts($DT)
|
||||||
|
->setDbEnds($nowDT)
|
||||||
|
->setDbClipLength($cliplength)
|
||||||
|
->setDbPlayoutStatus(-1)
|
||||||
|
->setDbInstanceId($instance->getDbId())
|
||||||
|
->save($this->con);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$nextDT = $DT;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $nextDT;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @param array $scheduledIds
|
* @param array $scheduledIds
|
||||||
* @param array $fileIds
|
* @param array $fileIds
|
||||||
|
@ -145,12 +178,16 @@ class Application_Model_Scheduler {
|
||||||
if (intval($schedule["instance"]) !== $instance->getDbId()) {
|
if (intval($schedule["instance"]) !== $instance->getDbId()) {
|
||||||
throw new OutDatedScheduleException("The schedule you're viewing is out of date!");
|
throw new OutDatedScheduleException("The schedule you're viewing is out of date!");
|
||||||
}
|
}
|
||||||
$nextStartDT = $schedItem->getDbEnds(null);
|
$schedItemEndDT = $schedItem->getDbEnds(null);
|
||||||
|
$nextStartDT = $this->findNextStartTime($schedItemEndDT, $instance);
|
||||||
}
|
}
|
||||||
//selected empty row to add after
|
//selected empty row to add after
|
||||||
else {
|
else {
|
||||||
$instance = CcShowInstancesQuery::create()->findPK($schedule["instance"], $this->con);
|
$instance = CcShowInstancesQuery::create()->findPK($schedule["instance"], $this->con);
|
||||||
$nextStartDT = $instance->getDbStarts(null);
|
|
||||||
|
//check to see if the show has started.
|
||||||
|
$showStartDT = $instance->getDbStarts(null);
|
||||||
|
$nextStartDT = $this->findNextStartTime($showStartDT, $instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
$currTs = intval($instance->getDbLastScheduled("U")) ? : 0;
|
$currTs = intval($instance->getDbLastScheduled("U")) ? : 0;
|
||||||
|
@ -244,6 +281,7 @@ class Application_Model_Scheduler {
|
||||||
->update(array('DbLastScheduled' => new DateTime("now", new DateTimeZone("UTC"))), $this->con);
|
->update(array('DbLastScheduled' => new DateTime("now", new DateTimeZone("UTC"))), $this->con);
|
||||||
}
|
}
|
||||||
catch (Exception $e) {
|
catch (Exception $e) {
|
||||||
|
Logging::debug($e->getMessage());
|
||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,7 +54,7 @@ class Application_Model_ShowBuilder {
|
||||||
$this->epoch_now = time();
|
$this->epoch_now = time();
|
||||||
}
|
}
|
||||||
|
|
||||||
//check to see if this row should be editable.
|
//check to see if this row should be editable by the user.
|
||||||
private function isAllowed($p_item, &$row) {
|
private function isAllowed($p_item, &$row) {
|
||||||
|
|
||||||
//cannot schedule in a recorded show.
|
//cannot schedule in a recorded show.
|
||||||
|
@ -62,17 +62,20 @@ class Application_Model_ShowBuilder {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
$showStartDT = new DateTime($p_item["si_starts"], new DateTimeZone("UTC"));
|
$showStartDT = new DateTime($p_item["si_starts"], new DateTimeZone("UTC"));
|
||||||
|
$showEndDT = new DateTime($p_item["si_ends"], new DateTimeZone("UTC"));
|
||||||
$schedStartDT = new DateTime($p_item["sched_starts"], new DateTimeZone("UTC"));
|
$schedStartDT = new DateTime($p_item["sched_starts"], new DateTimeZone("UTC"));
|
||||||
|
|
||||||
$showStartEpoch = intval($showStartDT->format('U'));
|
$showStartEpoch = intval($showStartDT->format('U'));
|
||||||
|
$showEndEpoch = intval($showEndDT->format('U'));
|
||||||
$schedStartEpoch = intval($schedStartDT->format('U'));
|
$schedStartEpoch = intval($schedStartDT->format('U'));
|
||||||
|
*/
|
||||||
|
|
||||||
//can only schedule the show if item hasn't started and you are allowed.
|
if ($this->user->canSchedule($p_item["show_id"]) == true) {
|
||||||
if ($this->epoch_now < max($showStartEpoch, $schedStartEpoch)
|
|
||||||
&& $this->user->canSchedule($p_item["show_id"]) == true) {
|
|
||||||
$row["allowed"] = true;
|
$row["allowed"] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getItemColor($p_item, &$row) {
|
private function getItemColor($p_item, &$row) {
|
||||||
|
@ -154,7 +157,7 @@ class Application_Model_ShowBuilder {
|
||||||
$row = $this->defaultRowArray;
|
$row = $this->defaultRowArray;
|
||||||
$this->isAllowed($p_item, $row);
|
$this->isAllowed($p_item, $row);
|
||||||
$this->getRowTimestamp($p_item, $row);
|
$this->getRowTimestamp($p_item, $row);
|
||||||
$this->getItemColor($p_item, &$row);
|
$this->getItemColor($p_item, $row);
|
||||||
|
|
||||||
$showStartDT = new DateTime($p_item["si_starts"], new DateTimeZone("UTC"));
|
$showStartDT = new DateTime($p_item["si_starts"], new DateTimeZone("UTC"));
|
||||||
$showStartDT->setTimezone(new DateTimeZone($this->timezone));
|
$showStartDT->setTimezone(new DateTimeZone($this->timezone));
|
||||||
|
@ -182,10 +185,6 @@ class Application_Model_ShowBuilder {
|
||||||
private function makeScheduledItemRow($p_item) {
|
private function makeScheduledItemRow($p_item) {
|
||||||
$row = $this->defaultRowArray;
|
$row = $this->defaultRowArray;
|
||||||
|
|
||||||
$this->getItemColor($p_item, &$row);
|
|
||||||
$this->getRowTimestamp($p_item, $row);
|
|
||||||
$this->isAllowed($p_item, $row);
|
|
||||||
|
|
||||||
if (isset($p_item["sched_starts"])) {
|
if (isset($p_item["sched_starts"])) {
|
||||||
|
|
||||||
$schedStartDT = new DateTime($p_item["sched_starts"], new DateTimeZone("UTC"));
|
$schedStartDT = new DateTime($p_item["sched_starts"], new DateTimeZone("UTC"));
|
||||||
|
@ -236,6 +235,10 @@ class Application_Model_ShowBuilder {
|
||||||
$row["image"] = '';
|
$row["image"] = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->getItemColor($p_item, $row);
|
||||||
|
$this->getRowTimestamp($p_item, $row);
|
||||||
|
$this->isAllowed($p_item, $row);
|
||||||
|
|
||||||
return $row;
|
return $row;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -264,6 +267,7 @@ class Application_Model_ShowBuilder {
|
||||||
$endsEpoch = intval($showEndDT->format("U"));
|
$endsEpoch = intval($showEndDT->format("U"));
|
||||||
|
|
||||||
$this->getScheduledStatus($startsEpoch, $endsEpoch, $row);
|
$this->getScheduledStatus($startsEpoch, $endsEpoch, $row);
|
||||||
|
$this->isAllowed($p_item, $row);
|
||||||
|
|
||||||
return $row;
|
return $row;
|
||||||
}
|
}
|
||||||
|
@ -328,6 +332,11 @@ class Application_Model_ShowBuilder {
|
||||||
|
|
||||||
$item = $scheduled_items[$i];
|
$item = $scheduled_items[$i];
|
||||||
|
|
||||||
|
//don't send back data for filler rows.
|
||||||
|
if (isset($item["playout_status"]) && $item["playout_status"] < 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
//make a header row.
|
//make a header row.
|
||||||
if ($current_id !== $item["si_id"]) {
|
if ($current_id !== $item["si_id"]) {
|
||||||
|
|
||||||
|
|
|
@ -113,9 +113,12 @@ class CcShowInstances extends BaseCcShowInstances {
|
||||||
|
|
||||||
Logging::log("in post save for showinstances");
|
Logging::log("in post save for showinstances");
|
||||||
|
|
||||||
|
$now = time();
|
||||||
|
|
||||||
//scheduled track is in the show
|
//scheduled track is in the show
|
||||||
CcScheduleQuery::create()
|
CcScheduleQuery::create()
|
||||||
->filterByDbInstanceId($this->id)
|
->filterByDbInstanceId($this->id)
|
||||||
|
->filterByDbPlayoutStatus(0, Criteria::GREATER_EQUAL)
|
||||||
->filterByDbEnds($this->ends, Criteria::LESS_EQUAL)
|
->filterByDbEnds($this->ends, Criteria::LESS_EQUAL)
|
||||||
->update(array('DbPlayoutStatus' => 1), $con);
|
->update(array('DbPlayoutStatus' => 1), $con);
|
||||||
|
|
||||||
|
@ -124,6 +127,7 @@ class CcShowInstances extends BaseCcShowInstances {
|
||||||
//scheduled track is a boundary track
|
//scheduled track is a boundary track
|
||||||
CcScheduleQuery::create()
|
CcScheduleQuery::create()
|
||||||
->filterByDbInstanceId($this->id)
|
->filterByDbInstanceId($this->id)
|
||||||
|
->filterByDbPlayoutStatus(0, Criteria::GREATER_EQUAL)
|
||||||
->filterByDbStarts($this->ends, Criteria::LESS_THAN)
|
->filterByDbStarts($this->ends, Criteria::LESS_THAN)
|
||||||
->filterByDbEnds($this->ends, Criteria::GREATER_THAN)
|
->filterByDbEnds($this->ends, Criteria::GREATER_THAN)
|
||||||
->update(array('DbPlayoutStatus' => 2), $con);
|
->update(array('DbPlayoutStatus' => 2), $con);
|
||||||
|
@ -131,6 +135,7 @@ class CcShowInstances extends BaseCcShowInstances {
|
||||||
//scheduled track is overbooked.
|
//scheduled track is overbooked.
|
||||||
CcScheduleQuery::create()
|
CcScheduleQuery::create()
|
||||||
->filterByDbInstanceId($this->id)
|
->filterByDbInstanceId($this->id)
|
||||||
|
->filterByDbPlayoutStatus(0, Criteria::GREATER_EQUAL)
|
||||||
->filterByDbStarts($this->ends, Criteria::GREATER_THAN)
|
->filterByDbStarts($this->ends, Criteria::GREATER_THAN)
|
||||||
->update(array('DbPlayoutStatus' => 0), $con);
|
->update(array('DbPlayoutStatus' => 0), $con);
|
||||||
|
|
||||||
|
|
|
@ -727,6 +727,8 @@ abstract class BaseCcSchedule extends BaseObject implements Persistent
|
||||||
$v = (int) $v;
|
$v = (int) $v;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Logging::log('$v status is '.$v);
|
||||||
|
|
||||||
if ($this->playout_status !== $v || $this->isNew()) {
|
if ($this->playout_status !== $v || $this->isNew()) {
|
||||||
$this->playout_status = $v;
|
$this->playout_status = $v;
|
||||||
$this->modifiedColumns[] = CcSchedulePeer::PLAYOUT_STATUS;
|
$this->modifiedColumns[] = CcSchedulePeer::PLAYOUT_STATUS;
|
||||||
|
|
|
@ -75,10 +75,6 @@
|
||||||
width:100px;
|
width:100px;
|
||||||
}
|
}
|
||||||
|
|
||||||
table.datatable tr.cursor-selected-row td, table.datatable tr.cursor-selected-row th {
|
|
||||||
border-bottom: 1px solid rgba(215, 0, 0, 1) !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.sb-starts,
|
.sb-starts,
|
||||||
.sb-ends {
|
.sb-ends {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
@ -90,7 +86,7 @@ table.datatable tr.cursor-selected-row td, table.datatable tr.cursor-selected-ro
|
||||||
}
|
}
|
||||||
.marker {
|
.marker {
|
||||||
background: url(images/tl-arrow.png) no-repeat scroll 3px 4px;
|
background: url(images/tl-arrow.png) no-repeat scroll 3px 4px;
|
||||||
bottom: -14px;
|
top: -14px;
|
||||||
display: block;
|
display: block;
|
||||||
height: 9px;
|
height: 9px;
|
||||||
left: -17px;
|
left: -17px;
|
||||||
|
@ -109,6 +105,10 @@ tr.cursor-selected-row .marker {
|
||||||
background-color: rgba(215, 0, 0, 1);
|
background-color: rgba(215, 0, 0, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
table.datatable tr.cursor-selected-row td, table.datatable tr.cursor-selected-row th {
|
||||||
|
border-top: 1px solid rgba(215, 0, 0, 1) !important;
|
||||||
|
}
|
||||||
|
|
||||||
.sb-content .sb-past {
|
.sb-content .sb-past {
|
||||||
opacity: .6;
|
opacity: .6;
|
||||||
}
|
}
|
||||||
|
|
|
@ -109,7 +109,7 @@ var AIRTIME = (function(AIRTIME){
|
||||||
|
|
||||||
aData = [];
|
aData = [];
|
||||||
$("#show_builder_table tr.cursor-selected-row").each(function(i, el){
|
$("#show_builder_table tr.cursor-selected-row").each(function(i, el){
|
||||||
aData.push($(el).data("aData"));
|
aData.push($(el).prev().data("aData"));
|
||||||
});
|
});
|
||||||
|
|
||||||
//process selected schedule rows to add media after.
|
//process selected schedule rows to add media after.
|
||||||
|
|
|
@ -323,7 +323,7 @@ var AIRTIME = (function(AIRTIME){
|
||||||
else {
|
else {
|
||||||
|
|
||||||
node = nRow.children[0];
|
node = nRow.children[0];
|
||||||
if (aData.allowed === true) {
|
if (aData.allowed === true && aData.scheduled === 2) {
|
||||||
node.innerHTML = '<input type="checkbox" name="'+aData.id+'"></input>';
|
node.innerHTML = '<input type="checkbox" name="'+aData.id+'"></input>';
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -367,7 +367,7 @@ var AIRTIME = (function(AIRTIME){
|
||||||
if ($lib.length > 0 && $lib.filter(":visible").length > 0) {
|
if ($lib.length > 0 && $lib.filter(":visible").length > 0) {
|
||||||
|
|
||||||
//create cursor arrows.
|
//create cursor arrows.
|
||||||
$sbTable.find("tr.sb-now-playing, tr:not(:first, .sb-footer, .sb-empty, .sb-not-allowed)").each(function(i, el) {
|
$sbTable.find("tr:not(:first, .sb-header, .sb-empty, .sb-now-playing, .sb-past, .sb-not-allowed)").each(function(i, el) {
|
||||||
td = $(el).find("td:first");
|
td = $(el).find("td:first");
|
||||||
if (td.hasClass("dataTables_empty")) {
|
if (td.hasClass("dataTables_empty")) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -404,7 +404,7 @@ var AIRTIME = (function(AIRTIME){
|
||||||
}
|
}
|
||||||
//current song is not set, set a timeout to refresh when the first item on the timeline starts.
|
//current song is not set, set a timeout to refresh when the first item on the timeline starts.
|
||||||
else {
|
else {
|
||||||
tr = $sbTable.find("tbody tr.sb-allowed.sb-header:first");
|
tr = $sbTable.find("tbody tr.sb-future.sb-header:first");
|
||||||
|
|
||||||
if (tr.length > 0) {
|
if (tr.length > 0) {
|
||||||
aData = tr.data("aData");
|
aData = tr.data("aData");
|
||||||
|
@ -417,7 +417,7 @@ var AIRTIME = (function(AIRTIME){
|
||||||
}
|
}
|
||||||
|
|
||||||
//check if there are any overbooked tracks on screen to enable the trim button.
|
//check if there are any overbooked tracks on screen to enable the trim button.
|
||||||
tr = $sbTable.find("tr.sb-over");
|
tr = $sbTable.find("tr.sb-over.sb-future");
|
||||||
|
|
||||||
if (tr.length > 0) {
|
if (tr.length > 0) {
|
||||||
//enable deleting of overbooked tracks.
|
//enable deleting of overbooked tracks.
|
||||||
|
@ -457,7 +457,8 @@ var AIRTIME = (function(AIRTIME){
|
||||||
if ($(node).hasClass("sb-header")
|
if ($(node).hasClass("sb-header")
|
||||||
|| $(node).hasClass("sb-footer")
|
|| $(node).hasClass("sb-footer")
|
||||||
|| $(node).hasClass("sb-empty")
|
|| $(node).hasClass("sb-empty")
|
||||||
|| $(node).hasClass("sb-not-allowed")) {
|
|| $(node).hasClass("sb-not-allowed")
|
||||||
|
|| $(node).hasClass("sb-past")) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -466,7 +467,7 @@ var AIRTIME = (function(AIRTIME){
|
||||||
|
|
||||||
//seems to happen if everything is selected
|
//seems to happen if everything is selected
|
||||||
if ( node === null) {
|
if ( node === null) {
|
||||||
oTable.find("input[type=checkbox]").attr("checked", true);
|
$sbTable.find("tbody input[type=checkbox]").attr("checked", true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$(node).find("input[type=checkbox]").attr("checked", true);
|
$(node).find("input[type=checkbox]").attr("checked", true);
|
||||||
|
@ -508,7 +509,7 @@ var AIRTIME = (function(AIRTIME){
|
||||||
if ($(this).is(":checked")) {
|
if ($(this).is(":checked")) {
|
||||||
var allowedNodes;
|
var allowedNodes;
|
||||||
|
|
||||||
allowedNodes = oTable.find('tr:not(:first, .sb-header, .sb-empty, .sb-footer, .sb-not-allowed)');
|
allowedNodes = oTable.find('tr:not(:first, .sb-header, .sb-empty, .sb-footer, .sb-not-allowed, .sb-past)');
|
||||||
|
|
||||||
allowedNodes.each(function(i, el){
|
allowedNodes.each(function(i, el){
|
||||||
oTT.fnSelect(el);
|
oTT.fnSelect(el);
|
||||||
|
@ -658,7 +659,7 @@ var AIRTIME = (function(AIRTIME){
|
||||||
|
|
||||||
return draggingContainer;
|
return draggingContainer;
|
||||||
},
|
},
|
||||||
items: 'tr:not(:first, :last, .sb-header, .sb-footer, .sb-not-allowed)',
|
items: 'tr:not(:first, :last, .sb-header, .sb-footer, .sb-not-allowed, .sb-past, .sb-now-playing)',
|
||||||
receive: fnReceive,
|
receive: fnReceive,
|
||||||
update: fnUpdate,
|
update: fnUpdate,
|
||||||
start: function(event, ui) {
|
start: function(event, ui) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue