diff --git a/application/controllers/LibraryController.php b/application/controllers/LibraryController.php
index 3fdc4a394..297ddbe31 100644
--- a/application/controllers/LibraryController.php
+++ b/application/controllers/LibraryController.php
@@ -132,20 +132,14 @@ class LibraryController extends Zend_Controller_Action
$this->_helper->viewRenderer->setResponseSegment('library');
$format = $this->_getParam('format');
- $echo = $this->_getParam('sEcho');
- $offset = $this->_getParam('iDisplayStart');
- $limit = $this->_getParam('iDisplayLength');
+
$post = $this->getRequest()->getPost();
if($format == "json") {
- $datatables = array("sEcho" => $echo);
- $files = StoredFile::searchFiles($offset, $limit, $post);
-
- $datatables = array_merge($datatables, $files);
+ $datatables = StoredFile::searchFilesForPlaylistBuilder($post);
die(json_encode($datatables));
-
}
}
diff --git a/application/controllers/ScheduleController.php b/application/controllers/ScheduleController.php
index 1f8efc110..a03c205fc 100644
--- a/application/controllers/ScheduleController.php
+++ b/application/controllers/ScheduleController.php
@@ -8,53 +8,53 @@ class ScheduleController extends Zend_Controller_Action
public function init()
{
if(!Zend_Auth::getInstance()->hasIdentity())
- {
- $this->_redirect('login/index');
- }
-
- $ajaxContext = $this->_helper->getHelper('AjaxContext');
- $ajaxContext->addActionContext('event-feed', 'json')
- ->addActionContext('add-show-dialog', 'json')
- ->addActionContext('add-show', 'json')
- ->addActionContext('move-show', 'json')
- ->addActionContext('resize-show', 'json')
- ->addActionContext('delete-show', 'json')
- ->addActionContext('schedule-show', 'json')
- ->addActionContext('schedule-show-dialog', 'json')
- ->addActionContext('clear-show', 'json')
- ->addActionContext('get-current-playlist', 'json')
- ->addActionContext('find-playlists', 'html')
- ->addActionContext('remove-group', 'json')
- ->addActionContext('get-show-data', 'json')
- ->initContext();
-
- $this->sched_sess = new Zend_Session_Namespace("schedule");
+ {
+ $this->_redirect('login/index');
+ }
+
+ $ajaxContext = $this->_helper->getHelper('AjaxContext');
+ $ajaxContext->addActionContext('event-feed', 'json')
+ ->addActionContext('add-show-dialog', 'json')
+ ->addActionContext('add-show', 'json')
+ ->addActionContext('move-show', 'json')
+ ->addActionContext('resize-show', 'json')
+ ->addActionContext('delete-show', 'json')
+ ->addActionContext('schedule-show', 'json')
+ ->addActionContext('schedule-show-dialog', 'json')
+ ->addActionContext('clear-show', 'json')
+ ->addActionContext('get-current-playlist', 'json')
+ ->addActionContext('find-playlists', 'json')
+ ->addActionContext('remove-group', 'json')
+ ->initContext();
+
+ $this->sched_sess = new Zend_Session_Namespace("schedule");
}
public function indexAction()
{
$this->view->headScript()->appendFile('/js/fullcalendar/fullcalendar.min.js','text/javascript');
- $this->view->headScript()->appendFile('/js/contextmenu/jquery.contextMenu.js','text/javascript');
- //$this->view->headScript()->appendFile('/js/qtip/jquery.qtip-1.0.0.min.js','text/javascript');
- $this->view->headScript()->appendFile('/js/airtime/schedule/full-calendar-functions.js','text/javascript');
- $this->view->headScript()->appendFile('/js/airtime/schedule/schedule.js','text/javascript');
-
- $this->view->headLink()->appendStylesheet('/css/jquery.contextMenu.css');
- $this->view->headLink()->appendStylesheet('/css/fullcalendar.css');
- $this->view->headLink()->appendStylesheet('/css/schedule.css');
- $this->view->headLink()->appendStylesheet('/css/pro_dropdown_3.css');
- $this->view->headLink()->appendStylesheet('/css/styles.css');
-
- $eventDefaultMenu = array();
- //$eventDefaultMenu[] = array('action' => '/Schedule/delete-show', 'text' => 'Delete');
-
- $this->view->eventDefaultMenu = $eventDefaultMenu;
-
- $eventHostMenu[] = array('action' => '/Schedule/delete-show', 'text' => 'Delete');
- $eventHostMenu[] = array('action' => '/Schedule/schedule-show', 'text' => 'Schedule');
- $eventHostMenu[] = array('action' => '/Schedule/clear-show', 'text' => 'Clear');
-
- $this->view->eventHostMenu = $eventHostMenu;
+ $this->view->headScript()->appendFile('/js/contextmenu/jquery.contextMenu.js','text/javascript');
+ $this->view->headScript()->appendFile('/js/datatables/js/jquery.dataTables.js','text/javascript');
+ //$this->view->headScript()->appendFile('/js/qtip/jquery.qtip-1.0.0.min.js','text/javascript');
+ $this->view->headScript()->appendFile('/js/airtime/schedule/full-calendar-functions.js','text/javascript');
+ $this->view->headScript()->appendFile('/js/airtime/schedule/schedule.js','text/javascript');
+
+ $this->view->headLink()->appendStylesheet('/css/jquery.contextMenu.css');
+ $this->view->headLink()->appendStylesheet('/css/fullcalendar.css');
+ $this->view->headLink()->appendStylesheet('/css/schedule.css');
+ $this->view->headLink()->appendStylesheet('/css/pro_dropdown_3.css');
+ $this->view->headLink()->appendStylesheet('/css/styles.css');
+
+ $eventDefaultMenu = array();
+ //$eventDefaultMenu[] = array('action' => '/Schedule/delete-show', 'text' => 'Delete');
+
+ $this->view->eventDefaultMenu = $eventDefaultMenu;
+
+ $eventHostMenu[] = array('action' => '/Schedule/delete-show', 'text' => 'Delete');
+ $eventHostMenu[] = array('action' => '/Schedule/schedule-show', 'text' => 'Schedule');
+ $eventHostMenu[] = array('action' => '/Schedule/clear-show', 'text' => 'Clear');
+
+ $this->view->eventHostMenu = $eventHostMenu;
}
public function eventFeedAction()
@@ -182,36 +182,31 @@ class ScheduleController extends Zend_Controller_Action
}
public function scheduleShowAction()
- {
- $start_timestamp = $this->sched_sess->showStart;
- $end_timestamp = $this->sched_sess->showEnd;
- $showId = $this->sched_sess->showId;
- $search = $this->_getParam('search', null);
- $plId = $this->_getParam('plId');
-
- if($search == "") {
- $search = null;
- }
-
- $userInfo = Zend_Auth::getInstance()->getStorage()->read();
-
- $user = new User($userInfo->id, $userInfo->type);
- $show = new Show($user, $showId);
-
- $show->scheduleShow($start_timestamp, array($plId));
-
- $this->view->playlists = $show->searchPlaylistsForShow($start_timestamp, $search);
- $this->view->showContent = $show->getShowContent($start_timestamp);
-
- $this->view->timeFilled = $show->getTimeScheduled($start_timestamp, $end_timestamp);
- $this->view->showLength = $show->getShowLength($start_timestamp, $end_timestamp);
- $this->view->percentFilled = Schedule::getPercentScheduledInRange($start_timestamp, $end_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);
+ {
+ $start_timestamp = $this->sched_sess->showStart;
+ $end_timestamp = $this->sched_sess->showEnd;
+ $showId = $this->sched_sess->showId;
+ $search = $this->_getParam('search', null);
+ $plId = $this->_getParam('plId');
+
+ if($search == "") {
+ $search = null;
+ }
+
+ $userInfo = Zend_Auth::getInstance()->getStorage()->read();
+
+ $user = new User($userInfo->id, $userInfo->type);
+ $show = new Show($user, $showId);
+
+ $show->scheduleShow($start_timestamp, array($plId));
+
+ $this->view->showContent = $show->getShowContent($start_timestamp);
+ $this->view->timeFilled = $show->getTimeScheduled($start_timestamp, $end_timestamp);
+ $this->view->percentFilled = Schedule::getPercentScheduledInRange($start_timestamp, $end_timestamp);
+
+ $this->view->chosen = $this->view->render('schedule/scheduled-content.phtml');
+
+ unset($this->view->showContent);
}
public function clearShowAction()
@@ -236,40 +231,38 @@ class ScheduleController extends Zend_Controller_Action
public function findPlaylistsAction()
{
- $search = $this->_getParam('search');
- $show_id = $this->sched_sess->showId;
- $start_timestamp = $this->sched_sess->showStart;
-
- $userInfo = Zend_Auth::getInstance()->getStorage()->read();
- $show = new Show(new User($userInfo->id, $userInfo->type), $show_id);
- $this->view->playlists = $show->searchPlaylistsForShow($start_timestamp, $search);
+ $show_id = $this->sched_sess->showId;
+ $start_timestamp = $this->sched_sess->showStart;
+ $post = $this->getRequest()->getPost();
+
+ $userInfo = Zend_Auth::getInstance()->getStorage()->read();
+ $show = new Show(new User($userInfo->id, $userInfo->type), $show_id);
+ $playlists = $show->searchPlaylistsForShow($start_timestamp, $post);
+
+ //for datatables
+ die(json_encode($playlists));
}
public function removeGroupAction()
{
$group_id = $this->_getParam('groupId');
- $start_timestamp = $this->sched_sess->showStart;
- $end_timestamp = $this->sched_sess->showEnd;
- $show_id = $this->sched_sess->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->timeFilled = $show->getTimeScheduled($start_timestamp, $end_timestamp);
- $this->view->showLength = $show->getShowLength($start_timestamp, $end_timestamp);
- $this->view->percentFilled = Schedule::getPercentScheduledInRange($start_timestamp, $end_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);
+ $start_timestamp = $this->sched_sess->showStart;
+ $end_timestamp = $this->sched_sess->showEnd;
+ $show_id = $this->sched_sess->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->showContent = $show->getShowContent($start_timestamp);
+ $this->view->timeFilled = $show->getTimeScheduled($start_timestamp, $end_timestamp);
+ $this->view->percentFilled = Schedule::getPercentScheduledInRange($start_timestamp, $end_timestamp);
+
+ $this->view->chosen = $this->view->render('schedule/scheduled-content.phtml');
+
+ unset($this->view->showContent);
}
public function scheduleShowDialogAction()
@@ -315,11 +308,16 @@ class ScheduleController extends Zend_Controller_Action
public function getShowDataAction()
{
$this->view->data = Show::getShows("2011-01-27");
+ $this->view->showContent = $show->getShowContent($start_timestamp);
+ $this->view->timeFilled = $show->getTimeScheduled($start_timestamp, $end_timestamp);
+ $this->view->showLength = $show->getShowLength($start_timestamp, $end_timestamp);
+ $this->view->percentFilled = Schedule::getPercentScheduledInRange($start_timestamp, $end_timestamp);
+
+ $this->view->chosen = $this->view->render('schedule/scheduled-content.phtml');
+ $this->view->dialog = $this->view->render('schedule/schedule-show-dialog.phtml');
+
+ unset($this->view->showContent);
}
}
-
-
-
-
diff --git a/application/models/Playlist.php b/application/models/Playlist.php
index f158056bc..dee382093 100644
--- a/application/models/Playlist.php
+++ b/application/models/Playlist.php
@@ -151,71 +151,6 @@ class Playlist {
return $res;
}
- public static function findPlaylistMaxLength($p_length)
- {
- $con = Propel::getConnection(CcPlaylistPeer::DATABASE_NAME);
-
- $sql = "SELECT sub.login, plt.length, pl.state, pl.creator, pl.description, pl.name, pl.id
- FROM cc_playlist AS pl LEFT JOIN cc_playlisttimes AS plt USING(id) LEFT JOIN cc_subjs AS sub ON pl.editedby = sub.id
- WHERE plt.length <= '{$p_length}' ";
-
- $r = $con->query($sql);
- return $r->fetchAll();
- }
-
- public static function searchPlaylists($p_length, $search=null)
- {
- $con = Propel::getConnection(CcPlaylistPeer::DATABASE_NAME);
-
- $sql = "SELECT sub.login, plt.length, pl.state, pl.creator, pl.description, pl.name, pl.id
- FROM cc_playlist AS pl LEFT JOIN cc_playlisttimes AS plt USING(id) LEFT JOIN cc_subjs AS sub ON pl.editedby = sub.id
- WHERE plt.length <= '{$p_length}' ";
-
-
- if(!is_null($search)) {
- $keywords = explode(" ", $search);
-
- $categories = array("pl.description", "pl.name", "pl.creator", "sub.login");
-
- for($group_id=1; $group_id <= count($keywords); $group_id++) {
-
- for($row_id=1; $row_id <= count($categories); $row_id++) {
-
- $md["group_".$group_id]["row_".$row_id]["metadata"] = $categories[$row_id-1];
- $md["group_".$group_id]["row_".$row_id]["match"] = "ILIKE";
- $md["group_".$group_id]["row_".$row_id]["search"] = $keywords[$group_id-1];
- }
- }
-
- $and_cond = array();
- foreach (array_keys($md) as $group) {
-
- $or_cond = array();
- foreach (array_keys($md[$group]) as $row) {
-
- $string = $md[$group][$row]["metadata"];
- $string = $string ." ".$md[$group][$row]["match"];
- $string = $string." '%". $md[$group][$row]["search"]."%'";
-
- $or_cond[] = $string;
- }
-
- if(count($or_cond) > 0) {
- $and_cond[] = "(".join(" OR ", $or_cond).")";
- }
- }
-
- $where_search = " AND ". join(" AND ", $and_cond);
- $sql = $sql . $where_search;
- }
-
- //echo $sql;
-
- $r = $con->query($sql);
- return $r->fetchAll();
- }
-
-
/**
* Fetch instance of Playlist object.
*
diff --git a/application/models/Shows.php b/application/models/Shows.php
index 7a442a452..7313d9711 100644
--- a/application/models/Shows.php
+++ b/application/models/Shows.php
@@ -639,7 +639,7 @@ class Show {
return $length;
}
- public function searchPlaylistsForShow($start_timestamp, $search=null){
+ public function searchPlaylistsForShow($start_timestamp, $datatables){
global $CC_DBC;
$sql = "SELECT EXTRACT(DOW FROM TIMESTAMP '{$start_timestamp}')";
@@ -656,7 +656,6 @@ class Show {
$length = $this->getTimeUnScheduled($start_date, $start_date, $start_time, $end_time);
- return Playlist::searchPlaylists($length, $search);
-
+ return StoredFile::searchPlaylistsForSchedule($length, $datatables);
}
}
diff --git a/application/models/StoredFile.php b/application/models/StoredFile.php
index b6ab13d10..e25e54ebf 100644
--- a/application/models/StoredFile.php
+++ b/application/models/StoredFile.php
@@ -1742,14 +1742,9 @@ class StoredFile {
return $CC_CONFIG['accessDir']."/$p_token.$p_ext";
}
- public static function searchFiles($offset, $limit, $data)
- {
- global $CC_CONFIG, $CC_DBC, $g_metadata_xml_to_db_mapping;
+ public static function searchFilesForPlaylistBuilder($datatables) {
- $columnsDisplayed = explode(",", $data["sColumns"]);
-
- if($data["sSearch"] !== "")
- $searchTerms = explode(" ", $data["sSearch"]);
+ global $CC_CONFIG, $g_metadata_xml_to_db_mapping;
$plSelect = "SELECT ";
$fileSelect = "SELECT ";
@@ -1781,23 +1776,50 @@ class StoredFile {
}
}
+ $fromTable = " ((".$plSelect."PL.id
+ FROM ".$CC_CONFIG["playListTable"]." AS PL
+ LEFT JOIN ".$CC_CONFIG['playListTimeView']." AS PLT USING(id))
+
+ UNION
+
+ (".$fileSelect."id FROM ".$CC_CONFIG["filesTable"]." AS FILES)) AS RESULTS";
+
+ return StoredFile::searchFiles($fromTable, $datatables);
+ }
+
+ public static function searchPlaylistsForSchedule($p_length, $datatables) {
+
+ $fromTable = "cc_playlist AS pl LEFT JOIN cc_playlisttimes AS plt USING(id) LEFT JOIN cc_subjs AS sub ON pl.editedby = sub.id";
+
+ $datatables["optWhere"][] = "plt.length <= '{$p_length}'";
+
+
+ return StoredFile::searchFiles($fromTable, $datatables);
+ }
+
+ private static function searchFiles($fromTable, $data)
+ {
+ global $CC_CONFIG, $CC_DBC;
+
+ $columnsDisplayed = explode(",", $data["sColumns"]);
+
+ if($data["sSearch"] !== "")
+ $searchTerms = explode(" ", $data["sSearch"]);
+
$selectorCount = "SELECT COUNT(*)";
$selectorRows = "SELECT ". join("," , $columnsDisplayed);
- $fromTable = " FROM ((".$plSelect."PL.id
- FROM ".$CC_CONFIG["playListTable"]." AS PL
- LEFT JOIN ".$CC_CONFIG['playListTimeView']." AS PLT USING(id))
-
- UNION
-
- (".$fileSelect."id FROM ".$CC_CONFIG["filesTable"]." AS FILES)) AS RESULTS";
-
- $sql = $selectorCount." ".$fromTable;
+ $sql = $selectorCount." FROM ".$fromTable;
$totalRows = $CC_DBC->getOne($sql);
// Where clause
+ if(isset($data["optWhere"])) {
+
+ $where[] = join(" AND ", $data["optWhere"]);
+ }
+
if(isset($searchTerms)) {
$searchCols = array();
@@ -1819,14 +1841,9 @@ class StoredFile {
$innerCond[] = "{$col}::text ILIKE '%{$term}%'";
}
-
- $outerCond[] = join(" OR ", $innerCond);
+ $outerCond[] = "(".join(" OR ", $innerCond).")";
}
-
- $where = join(" AND ", $outerCond);
-
- $sql = $selectorCount." ".$fromTable." WHERE ".$where;
- $totalDisplayRows = $CC_DBC->getOne($sql);
+ $where[] = "(".join(" AND ", $outerCond).")";
}
// End Where clause
@@ -1846,10 +1863,16 @@ class StoredFile {
$CC_DBC->setFetchMode(DB_FETCHMODE_ORDERED);
if(isset($where)) {
- $sql = $selectorRows." ".$fromTable." WHERE ".$where." ORDER BY ".$orderby." OFFSET ".$offset." LIMIT ".$limit;
+
+ $where = join(" AND ", $where);
+
+ $sql = $selectorCount." FROM ".$fromTable." WHERE ".$where;
+ $totalDisplayRows = $CC_DBC->getOne($sql);
+
+ $sql = $selectorRows." FROM ".$fromTable." WHERE ".$where." ORDER BY ".$orderby." OFFSET ".$data["iDisplayStart"]." LIMIT ".$data["iDisplayLength"];
}
else {
- $sql = $selectorRows." ".$fromTable." ORDER BY ".$orderby." OFFSET ".$offset." LIMIT ".$limit;
+ $sql = $selectorRows." FROM ".$fromTable." ORDER BY ".$orderby." OFFSET ".$data["iDisplayStart"]." LIMIT ".$data["iDisplayLength"];
}
$results = $CC_DBC->getAll($sql);
@@ -1863,7 +1886,7 @@ class StoredFile {
$totalDisplayRows = $totalRows;
}
- return array("iTotalDisplayRecords" => $totalDisplayRows, "iTotalRecords" => $totalRows, "aaData" => $results);
+ return array("sEcho" => intval($data["sEcho"]), "iTotalDisplayRecords" => $totalDisplayRows, "iTotalRecords" => $totalRows, "aaData" => $results);
diff --git a/application/views/scripts/schedule/schedule-show-dialog.phtml b/application/views/scripts/schedule/schedule-show-dialog.phtml
index ecde98bcc..30b300b32 100644
--- a/application/views/scripts/schedule/schedule-show-dialog.phtml
+++ b/application/views/scripts/schedule/schedule-show-dialog.phtml
@@ -1,7 +1,18 @@
Id | +Description | +Title | +Creator | +Length | +Editing | +
---|