diff --git a/airtime_mvc/application/controllers/ShowbuilderController.php b/airtime_mvc/application/controllers/ShowbuilderController.php
index 10648cd6b..fe6caad4f 100644
--- a/airtime_mvc/application/controllers/ShowbuilderController.php
+++ b/airtime_mvc/application/controllers/ShowbuilderController.php
@@ -111,7 +111,7 @@ class ShowbuilderController extends Zend_Controller_Action
$item = CcScheduleQuery::create()->findPK($id);
$instance = $item->getCcShowInstances();
- if ($now < intval($item->getDbStarts("U")) && $user->canSchedule($instance->getDbShowId())) {
+ if ($now < intval($item->getDbEnds("U")) && $user->canSchedule($instance->getDbShowId())) {
$menu["del"] = array("name"=> "Delete", "icon" => "delete", "url" => "/showbuilder/schedule-remove");
}
diff --git a/airtime_mvc/application/models/Scheduler.php b/airtime_mvc/application/models/Scheduler.php
index bb2727feb..8501db518 100644
--- a/airtime_mvc/application/models/Scheduler.php
+++ b/airtime_mvc/application/models/Scheduler.php
@@ -130,11 +130,11 @@ class Application_Model_Scheduler {
//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);
+ ->setDbEnds($nowDT)
+ ->setDbClipLength($cliplength)
+ ->setDbPlayoutStatus(-1)
+ ->setDbInstanceId($instance->getDbId())
+ ->save($this->con);
}
else {
$nextDT = $DT;
@@ -425,6 +425,8 @@ class Application_Model_Scheduler {
$removedItems = CcScheduleQuery::create()->findPks(array_keys($scheduledIds));
+ //check to see if the current item is being deleted so we can truncate the record.
+ $currentItem = null;
//check to make sure all items selected are up to date
foreach ($removedItems as $removedItem) {
$ts = $scheduledIds[$removedItem->getDbId()];
@@ -438,10 +440,25 @@ class Application_Model_Scheduler {
$show = $instance->getCcShow($this->con);
throw new OutDatedScheduleException("The show {$show->getDbName()} has been previously updated!");
}
+
+ //check to truncate the currently playing item instead of deleting it.
+ if ($removedItem->isCurrentItem()) {
+ $now = new DateTime("now", new DateTimeZone("UTC"));
+
+ $nEpoch = $now->format('U');
+ $sEpoch = $removedItem->getDbStarts('U');
+ $length = $nEpoch - $sEpoch;
+ $cliplength = Application_Model_Playlist::secondsToPlaylistTime($length);
+
+ $removedItem->setDbClipLength($cliplength);
+ $removedItem->setDbEnds($now);
+ $removedItem->save($this->con);
+ }
+ else {
+ $removedItem->delete($this->con);
+ }
}
- $removedItems->delete($this->con);
-
if ($adjustSched === true) {
//get the show instances of the shows we must adjust times for.
foreach ($removedItems as $item) {
diff --git a/airtime_mvc/application/models/ShowBuilder.php b/airtime_mvc/application/models/ShowBuilder.php
index 7628f8923..da9a52f3f 100644
--- a/airtime_mvc/application/models/ShowBuilder.php
+++ b/airtime_mvc/application/models/ShowBuilder.php
@@ -62,20 +62,9 @@ class Application_Model_ShowBuilder {
return;
}
- /*
- $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"));
-
- $showStartEpoch = intval($showStartDT->format('U'));
- $showEndEpoch = intval($showEndDT->format('U'));
- $schedStartEpoch = intval($schedStartDT->format('U'));
- */
-
if ($this->user->canSchedule($p_item["show_id"]) == true) {
$row["allowed"] = true;
- }
-
+ }
}
private function getItemColor($p_item, &$row) {
diff --git a/airtime_mvc/application/models/airtime/CcSchedule.php b/airtime_mvc/application/models/airtime/CcSchedule.php
index 0a15b7a3c..bf279d356 100644
--- a/airtime_mvc/application/models/airtime/CcSchedule.php
+++ b/airtime_mvc/application/models/airtime/CcSchedule.php
@@ -223,5 +223,18 @@ class CcSchedule extends BaseCcSchedule {
return $this;
} // setDbEnds()
+
+ public function isCurrentItem() {
+
+ $epochNow = time();
+ $epochStart = intval($this->getDbStarts('U'));
+ $epochEnd = intval($this->getDbEnds('U'));
+
+ if ($epochStart < $epochNow && $epochEnd > $epochNow) {
+ return true;
+ }
+
+ return false;
+ }
} // CcSchedule
diff --git a/airtime_mvc/public/js/airtime/showbuilder/builder.js b/airtime_mvc/public/js/airtime/showbuilder/builder.js
index 7f016cf66..c57554987 100644
--- a/airtime_mvc/public/js/airtime/showbuilder/builder.js
+++ b/airtime_mvc/public/js/airtime/showbuilder/builder.js
@@ -220,15 +220,109 @@ var AIRTIME = (function(AIRTIME){
r,g,b,a,
$nRow = $(nRow);
- //call the context menu so we can prevent the event from propagating.
- $(nRow).find('td:not(.sb-checkbox)').click(function(e){
-
- $(this).contextMenu({x: e.pageX, y: e.pageY});
-
- return false;
- });
+ fnPrepareSeparatorRow = function(sRowContent, sClass, iNodeIndex) {
+
+ node = nRow.children[iNodeIndex];
+ node.innerHTML = sRowContent;
+ node.setAttribute('colspan',100);
+ for (i = iNodeIndex + 1; i < nRow.children.length; i = i+1) {
+ node = nRow.children[i];
+ node.innerHTML = "";
+ node.setAttribute("style", "display : none");
+ }
+
+ $(nRow).addClass(sClass);
+ };
+
+ if (aData.header === true) {
+ //remove the column classes from all tds.
+ $(nRow).find('td').removeClass();
+
+ node = nRow.children[0];
+ node.innerHTML = '';
+ cl = 'sb-header';
+
+ sSeparatorHTML = ''+aData.title+'';
+ sSeparatorHTML += ''+aData.starts+'-'+aData.ends+'';
+ fnPrepareSeparatorRow(sSeparatorHTML, cl, 1);
+ }
+ else if (aData.footer === true) {
+ //remove the column classes from all tds.
+ $(nRow).find('td').removeClass();
+
+ node = nRow.children[0];
+ cl = 'sb-footer';
+
+ //check the show's content status.
+ if (aData.runtime > 0) {
+ node.innerHTML = '';
+ cl = cl + ' ui-state-highlight';
+ }
+ else {
+ node.innerHTML = '';
+ cl = cl + ' ui-state-error';
+ }
+
+ sSeparatorHTML = ''+aData.fRuntime+'';
+ fnPrepareSeparatorRow(sSeparatorHTML, cl, 1);
+ }
+ else if (aData.empty === true) {
+ //remove the column classes from all tds.
+ $(nRow).find('td').removeClass();
+
+ node = nRow.children[0];
+ node.innerHTML = '';
+
+ sSeparatorHTML = 'Show Empty';
+ cl = cl + " sb-empty odd";
+
+ fnPrepareSeparatorRow(sSeparatorHTML, cl, 1);
+ }
+ else if (aData.record === true) {
+ //remove the column classes from all tds.
+ $(nRow).find('td').removeClass();
+
+ node = nRow.children[0];
+ node.innerHTML = '';
+
+ sSeparatorHTML = 'Recording From Line In';
+ cl = cl + " sb-record odd";
+
+ fnPrepareSeparatorRow(sSeparatorHTML, cl, 1);
+ }
+ else {
+
+ node = nRow.children[0];
+ if (aData.allowed === true && aData.scheduled >= 1) {
+ node.innerHTML = '';
+ }
+ else {
+ node.innerHTML = '';
+ }
+ }
- //save some info for reordering purposes.
+ //add the show colour to the leftmost td
+ if (aData.footer !== true) {
+
+ if ($nRow.hasClass('sb-header')) {
+ a = 1;
+ }
+ else if ($nRow.hasClass('odd')) {
+ a = 0.3;
+ }
+ else if ($nRow.hasClass('even')) {
+ a = 0.4;
+ }
+
+ //convert from hex to rgb.
+ r = parseInt((aData.backgroundColor).substring(0,2), 16);
+ g = parseInt((aData.backgroundColor).substring(2,4), 16);
+ b = parseInt((aData.backgroundColor).substring(4,6), 16);
+
+ $nRow.find('td:first').css('background', 'rgba('+r+', '+g+', '+b+', '+a+')');
+ }
+
+ //save some info for reordering purposes.
$(nRow).data({"aData": aData});
if (aData.scheduled === 1) {
@@ -256,101 +350,19 @@ var AIRTIME = (function(AIRTIME){
$(nRow).addClass("sb-over");
}
- fnPrepareSeparatorRow = function(sRowContent, sClass, iNodeIndex) {
-
- node = nRow.children[iNodeIndex];
- node.innerHTML = sRowContent;
- node.setAttribute('colspan',100);
- for (i = iNodeIndex + 1; i < nRow.children.length; i = i+1) {
- node = nRow.children[i];
- node.innerHTML = "";
- node.setAttribute("style", "display : none");
- }
-
- $(nRow).addClass(sClass);
- };
-
- //add the play function to the library_type td or the speaker
- $(nRow).find('td.library_image').click(function(){
+ //add the play function
+ $(nRow).find('td.sb-image').click(function(){
open_show_preview(aData.instance, iDisplayIndex);
return false;
});
-
- if (aData.header === true) {
- node = nRow.children[0];
- node.innerHTML = '';
- cl = 'sb-header';
-
- sSeparatorHTML = ''+aData.title+'';
- sSeparatorHTML += ''+aData.starts+'-'+aData.ends+'';
- fnPrepareSeparatorRow(sSeparatorHTML, cl, 1);
- }
- else if (aData.footer === true) {
- node = nRow.children[0];
- cl = 'sb-footer';
-
- //check the show's content status.
- if (aData.runtime > 0) {
- node.innerHTML = '';
- cl = cl + ' ui-state-highlight';
- }
- else {
- node.innerHTML = '';
- cl = cl + ' ui-state-error';
- }
-
- sSeparatorHTML = ''+aData.fRuntime+'';
- fnPrepareSeparatorRow(sSeparatorHTML, cl, 1);
- }
- else if (aData.empty === true) {
- node = nRow.children[0];
- node.innerHTML = '';
-
- sSeparatorHTML = 'Show Empty';
- cl = cl + " sb-empty odd";
-
- fnPrepareSeparatorRow(sSeparatorHTML, cl, 1);
- }
- else if (aData.record === true) {
- node = nRow.children[0];
- node.innerHTML = '';
-
- sSeparatorHTML = 'Recording From Line In';
- cl = cl + " sb-record odd";
-
- fnPrepareSeparatorRow(sSeparatorHTML, cl, 1);
- }
- else {
-
- node = nRow.children[0];
- if (aData.allowed === true && aData.scheduled === 2) {
- node.innerHTML = '';
- }
- else {
- node.innerHTML = '';
- }
- }
-
- //add the show colour to the leftmost td
- if (aData.footer !== true) {
-
- if ($nRow.hasClass('sb-header')) {
- a = 1;
- }
- else if ($nRow.hasClass('odd')) {
- a = 0.3;
- }
- else if ($nRow.hasClass('even')) {
- a = 0.4;
- }
-
- //convert from hex to rgb.
- r = parseInt((aData.backgroundColor).substring(0,2), 16);
- g = parseInt((aData.backgroundColor).substring(2,4), 16);
- b = parseInt((aData.backgroundColor).substring(4,6), 16);
-
- $nRow.find('td.sb-checkbox').css('background', 'rgba('+r+', '+g+', '+b+', '+a+')');
- }
+
+ //call the context menu so we can prevent the event from propagating.
+ $(nRow).find('td:gt(1)').click(function(e){
+
+ $(this).contextMenu({x: e.pageX, y: e.pageY});
+
+ return false;
+ });
},
"fnDrawCallback": function(oSettings, json) {
var wrapperDiv,
@@ -659,7 +671,8 @@ var AIRTIME = (function(AIRTIME){
return draggingContainer;
},
- items: 'tr:not(:first, :last, .sb-header, .sb-footer, .sb-not-allowed, .sb-past, .sb-now-playing)',
+ items: 'tr:not(:first, :last, .sb-header, .sb-not-allowed, .sb-past, .sb-now-playing)',
+ cancel: '.sb-footer',
receive: fnReceive,
update: fnUpdate,
start: function(event, ui) {
@@ -759,7 +772,7 @@ var AIRTIME = (function(AIRTIME){
//begin context menu initialization.
$.contextMenu({
- selector: '#show_builder_table td:not(.sb-checkbox)',
+ selector: '.sb-content table tbody tr:not(.sb-empty, .sb-footer, .sb-header) td:not(.sb-checkbox, .sb-image)',
trigger: "left",
ignoreRightClick: true,