diff --git a/airtime_mvc/application/controllers/LibraryController.php b/airtime_mvc/application/controllers/LibraryController.php
index 4acb26ee8..4e9077abd 100644
--- a/airtime_mvc/application/controllers/LibraryController.php
+++ b/airtime_mvc/application/controllers/LibraryController.php
@@ -240,6 +240,7 @@ class LibraryController extends Zend_Controller_Action
$datatables = Application_Model_StoredFile::searchFilesForPlaylistBuilder($params);
//format clip lengh to 1 decimal
+ /*
foreach($datatables["aaData"] as &$data){
if($data['ftype'] == 'audioclip'){
$file = Application_Model_StoredFile::Recall($data['id']);
@@ -255,6 +256,7 @@ class LibraryController extends Zend_Controller_Action
$sec = Application_Model_Playlist::playlistTimeToSeconds($data['length']);
$data['length'] = Application_Model_Playlist::secondsToPlaylistTime($sec);
}
+ */
die(json_encode($datatables));
}
diff --git a/airtime_mvc/application/controllers/ShowbuilderController.php b/airtime_mvc/application/controllers/ShowbuilderController.php
index 39dfc4f99..bed0c2145 100644
--- a/airtime_mvc/application/controllers/ShowbuilderController.php
+++ b/airtime_mvc/application/controllers/ShowbuilderController.php
@@ -61,10 +61,23 @@ class ShowbuilderController extends Zend_Controller_Action
$request = $this->getRequest();
- $id = $request->getParam("id", null);
- $instance = $request->getParam("instance", null);
+ $mediaItems = $request->getParam("mediaIds", null);
+ $scheduledIds = $request->getParam("schedIds", null);
- $items = $request->getParam("items", array());
+ $json = array();
+
+ try {
+ $scheduler = new Application_Model_Scheduler();
+ $scheduler->scheduleAfter($scheduledIds, $mediaItems);
+
+ $json["message"]="success... maybe";
+ }
+ catch (Exception $e) {
+ $json["message"]=$e->getMessage();
+ Logging::log($e->getMessage());
+ }
+
+ $this->view->data = $json;
}
public function scheduleRemoveAction()
@@ -73,12 +86,12 @@ class ShowbuilderController extends Zend_Controller_Action
$ids = $request->getParam("ids", null);
- Logging::log($ids);
-
$json = array();
try {
- Application_Model_Scheduler::removeItems($ids);
+ $scheduler = new Application_Model_Scheduler();
+ $scheduler->removeItems($ids);
+
$json["message"]="success... maybe";
}
catch (Exception $e) {
diff --git a/airtime_mvc/application/models/Scheduler.php b/airtime_mvc/application/models/Scheduler.php
index ef66458e7..724ef8ba0 100644
--- a/airtime_mvc/application/models/Scheduler.php
+++ b/airtime_mvc/application/models/Scheduler.php
@@ -2,17 +2,10 @@
class Application_Model_Scheduler {
- private $propSched;
private $con;
public function __construct($id = null) {
- if (is_null($id)) {
- $this->propSched = new CcSchedule();
- }
- else {
- $this->propSched = CcScheduleQuery::create()->findPK($id);
- }
}
/*
@@ -21,7 +14,7 @@ class Application_Model_Scheduler {
*
* @return $files
*/
- private static function retrieveMediaFiles($id, $type) {
+ private function retrieveMediaFiles($id, $type) {
$fileInfo = array(
"id" => "",
@@ -34,8 +27,8 @@ class Application_Model_Scheduler {
$files = array();
- if ($type === "file") {
- $file = CcFilesQuery::create()->findByPK($id);
+ if ($type === "audioclip") {
+ $file = CcFilesQuery::create()->findPK($id);
$data = $fileInfo;
$data["id"] = $id;
@@ -50,29 +43,61 @@ class Application_Model_Scheduler {
return $files;
}
+ /*
+ * @param DateTime startDT
+ * @param string duration
+ * in format H:i:s.u (could be more that 24 hours)
+ */
+ private function findEndTime($startDT, $duration) {
+
+ }
+
/*
* @param array $scheduledIds
* @param array $fileIds
* @param array $playlistIds
*/
- public static function scheduleAfter($scheduledIds, $mediaIds, $adjustSched = true) {
+ public function scheduleAfter($scheduleItems, $mediaItems, $adjustSched = true) {
- $con = Propel::getConnection(CcSchedulePeer::DATABASE_NAME);
+ $this->con = Propel::getConnection(CcSchedulePeer::DATABASE_NAME);
- $con->beginTransaction();
+ $this->con->beginTransaction();
+
+ $schedFiles = array();
try {
- $schedFiles = array();
- foreach($mediaIds as $id => $type) {
- $schedFiles = array_merge($schedFiles, self::retrieveMediaFiles($id, $type));
+ foreach($mediaItems as $media) {
+ Logging::log("Media Id ".$media["id"]);
+ Logging::log("Type ".$media["type"]);
+
+ $schedFiles = array_merge($schedFiles, $this->retrieveMediaFiles($media["id"], $media["type"]));
}
- foreach ($scheduledIds as $id) {
+ foreach ($scheduleItems as $schedule) {
+ $id = intval($schedule["id"]);
- $schedItem = CcScheduleQuery::create()->findByPK($id);
+ Logging::log("scheduling after scheduled item: ".$id);
- if ($adjustSched === true) {
+ if ($id !== 0) {
+ $schedItem = CcScheduleQuery::create()->findPK($id);
+ $instance = $schedItem->getDbInstanceId();
+
+ //user has an old copy of the time line opened.
+ if ($instance !== intval($schedule["instance"])) {
+ return;
+ }
+
+ $nextStartDT = $schedItem->getDbEnds(null);
+ }
+ //selected empty row to add after
+ else {
+ $showInstance = CcShowInstancesQuery::create()->findPK($schedule["instance"]);
+ $nextStartDT = $showInstance->getDbStarts(null);
+ $instance = intval($schedule["instance"]);
+ }
+
+ if ($id !== 0 && $adjustSched === true) {
$followingSchedItems = CcScheduleQuery::create()
->filterByDBStarts($schedItem->getDbStarts("Y-m-d H:i:s.u"), Criteria::GREATER_THAN)
->filterByDbInstanceId($instance)
@@ -80,49 +105,54 @@ class Application_Model_Scheduler {
->find();
}
- $nextItemDT = $schedItem->getDbEnds(null);
- $instance = $schedItem->getDbInstanceId();
-
foreach($schedFiles as $file) {
- $durationDT = DateTime::createFromFormat("Y-m-d H:i:s.u", "1970-01-01 {$file['cliplength']}", new DateTimeZone("UTC"));
- $endTimeEpoch = $nextItemDT->format("U.u") + $durationDT->format("U.u");
- $endTimeDT = DateTime::createFromFormat("U.u", $endTimeEpoch, new DateTimeZone("UTC"));
+ Logging::log("adding file with id: ".$file["id"]);
+
+ $durationDT = new DateTime("1970-01-01 {$file['cliplength']}", new DateTimeZone("UTC"));
+ $endTimeEpoch = $nextStartDT->format("U") + $durationDT->format("U");
+ $endTimeDT = DateTime::createFromFormat("U", $endTimeEpoch, new DateTimeZone("UTC"));
$newItem = new CcSchedule();
- $newItem->setDbStarts($nextItemDT);
+ $newItem->setDbStarts($nextStartDT);
$newItem->setDbEnds($endTimeDT);
$newItem->setDbFileId($file['id']);
$newItem->setDbCueIn($file['cuein']);
$newItem->setDbCueOut($file['cueout']);
$newItem->setDbFadeIn($file['fadein']);
$newItem->setDbFadeOut($file['fadeout']);
+ $newItem->setDbClipLength($durationDT->format("H:i:s.u"));
$newItem->setDbInstanceId($instance);
- $newItem->save($con);
+ $newItem->save($this->con);
- $nextItemDT = $endTimeDT;
+ $nextStartDT = $endTimeDT;
}
- if ($adjustSched === true) {
+ if ($id !== 0 && $adjustSched === true) {
//recalculate the start/end times after the inserted items.
- foreach($followingSchedItems as $followingItem) {
+ foreach($followingSchedItems as $item) {
- $durationDT = DateTime::createFromFormat("Y-m-d H:i:s.u", "1970-01-01 {$file['cliplength']}", new DateTimeZone("UTC"));
- $endTimeEpoch = $nextItemDT->format("U.u") + $durationDT->format("U.u");
- $endTimeDT = DateTime::createFromFormat("U.u", $endTimeEpoch, new DateTimeZone("UTC"));
+ $durationDT = new DateTime("1970-01-01 {$item->getDbClipLength()}", new DateTimeZone("UTC"));
+ $a = $nextStartDT->format("U");
+ $b = $durationDT->format("U");
+ $endTimeEpoch = $a + $b;
+ //$endTimeEpoch = $nextStartDT->format("U") + $durationDT->format("U");
+ $endTimeDT = DateTime::createFromFormat("U", $endTimeEpoch, new DateTimeZone("UTC"));
- $followingItem->setDbStarts($nextItemDT);
- $followingItem->setDbEnds($endTimeDT);
- $followingItem->save($con);
+ $item->setDbStarts($nextStartDT);
+ $item->setDbEnds($endTimeDT);
+ $item->save($this->con);
- $nextItemDT = $endTimeDT;
+ $nextStartDT = $endTimeDT;
}
}
}
+
+ $this->con->commit();
}
catch (Exception $e) {
- $con->rollback();
+ $this->con->rollback();
throw $e;
}
}
@@ -151,7 +181,7 @@ class Application_Model_Scheduler {
}
foreach($showInstances as $instance) {
- self::removeGaps($instance);
+ $this->removeGaps($instance);
}
}
@@ -205,49 +235,4 @@ class Application_Model_Scheduler {
}
}
}
-
- public function addScheduledItem($starts, $duration, $adjustSched = true) {
-
- }
-
- /*
- * @param DateTime $starts
- */
- public function updateScheduledItem($p_newStarts, $p_adjustSched = true) {
-
- $origStarts = $this->propSched->getDbStarts(null);
-
- $diff = $origStarts->diff($p_newStarts);
-
- //item is scheduled further in future
- if ($diff->format("%R") === "+") {
-
- CcScheduleQuery::create()
- ->filterByDbStarts($this->propSched->getDbStarts(), Criteria::GREATER_THAN)
- ->filterByDbId($this->propSched->getDbId(), Criteria::NOT_EQUAL)
- ->find();
-
- }
- //item has been scheduled earlier
- else {
- CcScheduleQuery::create()
- ->filterByDbStarts($this->propSched->getDbStarts(), Criteria::GREATER_THAN)
- ->filterByDbId($this->propSched->getDbId(), Criteria::NOT_EQUAL)
- ->find();
- }
- }
-
- public function removeScheduledItem($adjustSched = true) {
-
- if ($adjustSched === true) {
- $duration = $this->propSched->getDbEnds('U') - $this->propSched->getDbStarts('U');
-
- CcScheduleQuery::create()
- ->filterByDbInstanceId()
- ->filterByDbStarts()
- ->find();
- }
-
- $this->propSched->delete();
- }
}
\ No newline at end of file
diff --git a/airtime_mvc/application/models/ShowBuilder.php b/airtime_mvc/application/models/ShowBuilder.php
index 34aaa7d75..65f8ac475 100644
--- a/airtime_mvc/application/models/ShowBuilder.php
+++ b/airtime_mvc/application/models/ShowBuilder.php
@@ -117,6 +117,8 @@ class Application_Model_ShowBuilder {
//show is empty
else {
$row["empty"] = true;
+ $row["id"] = 0 ;
+ $row["instance"] = intval($p_item["si_id"]);
}
return $row;
diff --git a/airtime_mvc/application/models/StoredFile.php b/airtime_mvc/application/models/StoredFile.php
index 5ddcc08c3..16d1adc80 100644
--- a/airtime_mvc/application/models/StoredFile.php
+++ b/airtime_mvc/application/models/StoredFile.php
@@ -688,6 +688,9 @@ class Application_Model_StoredFile {
$results = Application_Model_StoredFile::searchFiles($fromTable, $datatables);
foreach($results['aaData'] as &$row){
+
+ $row['id'] = intval($row['id']);
+
// add checkbox row
$row['checkbox'] = "";
@@ -698,16 +701,16 @@ class Application_Model_StoredFile {
$type = substr($row['ftype'], 0, 2);
- $row['id'] = "{$type}_{$row['id']}";
+ $row['row_id'] = "{$type}_{$row['id']}";
//TODO url like this to work on both playlist/showbuilder screens.
//datatable stuff really needs to be pulled out and generalized within the project
//access to zend view methods to access url helpers is needed.
if($type == "au") {
- $row['ftype'] = '
';
+ $row['image'] = '
';
}
else {
- $row['ftype'] = '
';
+ $row['image'] = '
';
}
}
diff --git a/airtime_mvc/public/js/airtime/library/events/library_playlistbuilder.js b/airtime_mvc/public/js/airtime/library/events/library_playlistbuilder.js
index 956eb2477..64925b935 100644
--- a/airtime_mvc/public/js/airtime/library/events/library_playlistbuilder.js
+++ b/airtime_mvc/public/js/airtime/library/events/library_playlistbuilder.js
@@ -1,6 +1,6 @@
function fnLibraryTableRowCallback( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
- $(nRow).attr("id", aData["id"]);
+ $(nRow).attr("id", aData["row_id"]);
return nRow;
}
@@ -30,13 +30,22 @@ function addLibraryItemEvents() {
}
-function setupLibraryToolbar() {
+/*
+ * @param oTable the datatables instance for the library.
+ */
+function setupLibraryToolbar(oTable) {
+ var aButtons,
+ oSettings;
+
//[0] = button text
//[1] = id
//[2] = enabled
- var aButtons = [["Reset Order", "library_order_reset", true],
+ aButtons = [["Reset Order", "library_order_reset", true],
["Delete", "library_group_delete", false],
["Add", "library_group_add", false]];
addToolBarButtonsLibrary(aButtons);
+
+ oSettings = oTable.fnSettings();
+ oSettings.fnServerData.start = oRange.start;
}
diff --git a/airtime_mvc/public/js/airtime/library/events/library_showbuilder.js b/airtime_mvc/public/js/airtime/library/events/library_showbuilder.js
index e2c46ad85..f8fc4a490 100644
--- a/airtime_mvc/public/js/airtime/library/events/library_showbuilder.js
+++ b/airtime_mvc/public/js/airtime/library/events/library_showbuilder.js
@@ -26,28 +26,55 @@ function addLibraryItemEvents() {
function setupLibraryToolbar() {
var aButtons,
fnTest,
- fnAddSelectedItems;
+ fnAddSelectedItems,
+ oSettings,
+ oLibTable = $("#library_display").dataTable(),
+ oSchedTable = $("#show_builder_table").dataTable(),
+ oLibTT = TableTools.fnGetInstance('library_display'),
+ oSchedTT = TableTools.fnGetInstance('show_builder_table');
fnTest = function() {
alert("hi");
};
fnAddSelectedItems = function() {
- var oTT = TableTools.fnGetInstance('show_builder_table'),
- aData = oTT.fnGetSelectedData(),
- i,
- length = aData.length;
+ var aData = oLibTT.fnGetSelectedData(),
+ item,
+ temp,
+ aMediaIds = [],
+ aSchedIds = [];
- for (i=0, i>t<"F">',
- //options for infinite scrolling
- //"bScrollInfinite": true,
- //"bScrollCollapse": true,
- //"sScrollY": "400px",
-
"sAjaxDataProp": "schedule",
- "sAjaxSource": "/showbuilder/builder-feed"
-
+ "sAjaxSource": "/showbuilder/builder-feed"
});
$('[name="sb_cb_all"]').click(function(){
var oTT = TableTools.fnGetInstance('show_builder_table');
if ($(this).is(":checked")) {
- oTT.fnSelectAll();
+ var allowedNodes;
+
+ allowedNodes = oTable.find('tr:not(.show-builder-header):not(.show-builder-footer):not(.show-builder-not-allowed)');
+
+ allowedNodes.each(function(i, el){
+ oTT.fnSelect(el);
+ });
}
else {
oTT.fnSelectNone();
@@ -299,7 +312,7 @@ $(document).ready(function() {
placeholder: "placeholder show-builder-placeholder",
forceHelperSize: true,
forcePlaceholderSize: true,
- items: 'tr:not(.show-builder-header):not(.show-builder-footer)',
+ items: 'tr:not(.show-builder-header):not(.show-builder-footer):not(.show-builder-not-allowed):not(.show-builder-empty)',
//cancel: ".show-builder-header .show-builder-footer",
receive: function(event, ui) {
var x;