everything is implemented backend wise for schedule dialog, just need to add html/css changes

This commit is contained in:
Naomi 2011-01-27 18:38:02 -05:00
parent be4d3f5466
commit f18f500e1e
7 changed files with 124 additions and 134 deletions

View File

@ -132,20 +132,14 @@ class LibraryController extends Zend_Controller_Action
$this->_helper->viewRenderer->setResponseSegment('library'); $this->_helper->viewRenderer->setResponseSegment('library');
$format = $this->_getParam('format'); $format = $this->_getParam('format');
$echo = $this->_getParam('sEcho');
$offset = $this->_getParam('iDisplayStart');
$limit = $this->_getParam('iDisplayLength');
$post = $this->getRequest()->getPost(); $post = $this->getRequest()->getPost();
if($format == "json") { if($format == "json") {
$datatables = array("sEcho" => $echo); $datatables = StoredFile::searchFilesForPlaylistBuilder($post);
$files = StoredFile::searchFiles($offset, $limit, $post);
$datatables = array_merge($datatables, $files);
die(json_encode($datatables)); die(json_encode($datatables));
} }
} }

View File

@ -22,7 +22,7 @@ class ScheduleController extends Zend_Controller_Action
->addActionContext('schedule-show-dialog', 'json') ->addActionContext('schedule-show-dialog', 'json')
->addActionContext('clear-show', 'json') ->addActionContext('clear-show', 'json')
->addActionContext('get-current-playlist', 'json') ->addActionContext('get-current-playlist', 'json')
->addActionContext('find-playlists', 'html') ->addActionContext('find-playlists', 'json')
->addActionContext('remove-group', 'json') ->addActionContext('remove-group', 'json')
->initContext(); ->initContext();
@ -33,6 +33,7 @@ class ScheduleController extends Zend_Controller_Action
{ {
$this->view->headScript()->appendFile('/js/fullcalendar/fullcalendar.min.js','text/javascript'); $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/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/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/full-calendar-functions.js','text/javascript');
$this->view->headScript()->appendFile('/js/airtime/schedule/schedule.js','text/javascript'); $this->view->headScript()->appendFile('/js/airtime/schedule/schedule.js','text/javascript');
@ -198,18 +199,13 @@ class ScheduleController extends Zend_Controller_Action
$show->scheduleShow($start_timestamp, array($plId)); $show->scheduleShow($start_timestamp, array($plId));
$this->view->playlists = $show->searchPlaylistsForShow($start_timestamp, $search);
$this->view->showContent = $show->getShowContent($start_timestamp); $this->view->showContent = $show->getShowContent($start_timestamp);
$this->view->timeFilled = $show->getTimeScheduled($start_timestamp, $end_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->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'); $this->view->chosen = $this->view->render('schedule/scheduled-content.phtml');
unset($this->view->showContent); unset($this->view->showContent);
unset($this->view->playlists);
} }
public function clearShowAction() public function clearShowAction()
@ -234,13 +230,16 @@ class ScheduleController extends Zend_Controller_Action
public function findPlaylistsAction() public function findPlaylistsAction()
{ {
$search = $this->_getParam('search');
$show_id = $this->sched_sess->showId; $show_id = $this->sched_sess->showId;
$start_timestamp = $this->sched_sess->showStart; $start_timestamp = $this->sched_sess->showStart;
$post = $this->getRequest()->getPost();
$userInfo = Zend_Auth::getInstance()->getStorage()->read(); $userInfo = Zend_Auth::getInstance()->getStorage()->read();
$show = new Show(new User($userInfo->id, $userInfo->type), $show_id); $show = new Show(new User($userInfo->id, $userInfo->type), $show_id);
$this->view->playlists = $show->searchPlaylistsForShow($start_timestamp, $search); $playlists = $show->searchPlaylistsForShow($start_timestamp, $post);
//for datatables
die(json_encode($playlists));
} }
public function removeGroupAction() public function removeGroupAction()
@ -256,18 +255,13 @@ class ScheduleController extends Zend_Controller_Action
$show->removeGroupFromShow($start_timestamp, $group_id); $show->removeGroupFromShow($start_timestamp, $group_id);
$this->view->playlists = $show->searchPlaylistsForShow($start_timestamp, $search);
$this->view->showContent = $show->getShowContent($start_timestamp); $this->view->showContent = $show->getShowContent($start_timestamp);
$this->view->timeFilled = $show->getTimeScheduled($start_timestamp, $end_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->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'); $this->view->chosen = $this->view->render('schedule/scheduled-content.phtml');
unset($this->view->showContent); unset($this->view->showContent);
unset($this->view->playlists);
} }
public function scheduleShowDialogAction() public function scheduleShowDialogAction()
@ -285,19 +279,15 @@ class ScheduleController extends Zend_Controller_Action
$user = new User($userInfo->id, $userInfo->type); $user = new User($userInfo->id, $userInfo->type);
$show = new Show($user, $showId); $show = new Show($user, $showId);
$this->view->playlists = $show->searchPlaylistsForShow($start_timestamp);
$this->view->showContent = $show->getShowContent($start_timestamp); $this->view->showContent = $show->getShowContent($start_timestamp);
$this->view->timeFilled = $show->getTimeScheduled($start_timestamp, $end_timestamp); $this->view->timeFilled = $show->getTimeScheduled($start_timestamp, $end_timestamp);
$this->view->showLength = $show->getShowLength($start_timestamp, $end_timestamp); $this->view->showLength = $show->getShowLength($start_timestamp, $end_timestamp);
$this->view->percentFilled = Schedule::getPercentScheduledInRange($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'); $this->view->chosen = $this->view->render('schedule/scheduled-content.phtml');
$this->view->dialog = $this->view->render('schedule/schedule-show-dialog.phtml'); $this->view->dialog = $this->view->render('schedule/schedule-show-dialog.phtml');
unset($this->view->showContent); unset($this->view->showContent);
unset($this->view->playlists);
} }

View File

@ -151,71 +151,6 @@ class Playlist {
return $res; 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.<br> * Fetch instance of Playlist object.<br>
* *

View File

@ -638,7 +638,7 @@ class Show {
return $length; return $length;
} }
public function searchPlaylistsForShow($start_timestamp, $search=null){ public function searchPlaylistsForShow($start_timestamp, $datatables){
global $CC_DBC; global $CC_DBC;
$sql = "SELECT EXTRACT(DOW FROM TIMESTAMP '{$start_timestamp}')"; $sql = "SELECT EXTRACT(DOW FROM TIMESTAMP '{$start_timestamp}')";
@ -655,7 +655,6 @@ class Show {
$length = $this->getTimeUnScheduled($start_date, $start_date, $start_time, $end_time); $length = $this->getTimeUnScheduled($start_date, $start_date, $start_time, $end_time);
return Playlist::searchPlaylists($length, $search); return StoredFile::searchPlaylistsForSchedule($length, $datatables);
} }
} }

View File

@ -1742,14 +1742,9 @@ class StoredFile {
return $CC_CONFIG['accessDir']."/$p_token.$p_ext"; return $CC_CONFIG['accessDir']."/$p_token.$p_ext";
} }
public static function searchFiles($offset, $limit, $data) public static function searchFilesForPlaylistBuilder($datatables) {
{
global $CC_CONFIG, $CC_DBC, $g_metadata_xml_to_db_mapping;
$columnsDisplayed = explode(",", $data["sColumns"]); global $CC_CONFIG, $g_metadata_xml_to_db_mapping;
if($data["sSearch"] !== "")
$searchTerms = explode(" ", $data["sSearch"]);
$plSelect = "SELECT "; $plSelect = "SELECT ";
$fileSelect = "SELECT "; $fileSelect = "SELECT ";
@ -1781,11 +1776,7 @@ class StoredFile {
} }
} }
$fromTable = " ((".$plSelect."PL.id
$selectorCount = "SELECT COUNT(*)";
$selectorRows = "SELECT ". join("," , $columnsDisplayed);
$fromTable = " FROM ((".$plSelect."PL.id
FROM ".$CC_CONFIG["playListTable"]." AS PL FROM ".$CC_CONFIG["playListTable"]." AS PL
LEFT JOIN ".$CC_CONFIG['playListTimeView']." AS PLT USING(id)) LEFT JOIN ".$CC_CONFIG['playListTimeView']." AS PLT USING(id))
@ -1793,11 +1784,42 @@ class StoredFile {
(".$fileSelect."id FROM ".$CC_CONFIG["filesTable"]." AS FILES)) AS RESULTS"; (".$fileSelect."id FROM ".$CC_CONFIG["filesTable"]." AS FILES)) AS RESULTS";
$sql = $selectorCount." ".$fromTable; 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);
$sql = $selectorCount." FROM ".$fromTable;
$totalRows = $CC_DBC->getOne($sql); $totalRows = $CC_DBC->getOne($sql);
// Where clause // Where clause
if(isset($data["optWhere"])) {
$where[] = join(" AND ", $data["optWhere"]);
}
if(isset($searchTerms)) { if(isset($searchTerms)) {
$searchCols = array(); $searchCols = array();
@ -1819,14 +1841,9 @@ class StoredFile {
$innerCond[] = "{$col}::text ILIKE '%{$term}%'"; $innerCond[] = "{$col}::text ILIKE '%{$term}%'";
} }
$outerCond[] = "(".join(" OR ", $innerCond).")";
$outerCond[] = join(" OR ", $innerCond);
} }
$where[] = "(".join(" AND ", $outerCond).")";
$where = join(" AND ", $outerCond);
$sql = $selectorCount." ".$fromTable." WHERE ".$where;
$totalDisplayRows = $CC_DBC->getOne($sql);
} }
// End Where clause // End Where clause
@ -1846,10 +1863,16 @@ class StoredFile {
$CC_DBC->setFetchMode(DB_FETCHMODE_ORDERED); $CC_DBC->setFetchMode(DB_FETCHMODE_ORDERED);
if(isset($where)) { 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 { 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); $results = $CC_DBC->getAll($sql);
@ -1863,7 +1886,7 @@ class StoredFile {
$totalDisplayRows = $totalRows; $totalDisplayRows = $totalRows;
} }
return array("iTotalDisplayRecords" => $totalDisplayRows, "iTotalRecords" => $totalRows, "aaData" => $results); return array("sEcho" => intval($data["sEcho"]), "iTotalDisplayRecords" => $totalDisplayRows, "iTotalRecords" => $totalRows, "aaData" => $results);

View File

@ -1,7 +1,18 @@
<div id="schedule_playlist_dialog"> <div id="schedule_playlist_dialog">
<div> <div>
<input id="schedule_playlist_search" type="text"></input> <table id="schedule_playlists" cellpadding="0" cellspacing="0" class="datatable">
<ul id="schedule_playlist_choice"></ul> <thead>
<tr>
<th>Id</th>
<th>Description</th>
<th>Title</th>
<th>Creator</th>
<th>Length</th>
<th>Editing</th>
</tr>
</thead>
<tbody></tbody>
</table>
</div> </div>
<div> <div>
<div>Items In This Show:</div> <div>Items In This Show:</div>

View File

@ -11,14 +11,10 @@ function closeDialog(event, ui) {
function setScheduleDialogHtml(json) { function setScheduleDialogHtml(json) {
var dt;
$("#schedule_playlist_choice") dt = $('#schedule_playlists').dataTable();
.empty() dt.fnDraw();
.append(json.choice)
.find('li')
.draggable({
helper: 'clone'
});
$("#schedule_playlist_chosen") $("#schedule_playlist_chosen")
.empty() .empty()
@ -70,6 +66,26 @@ function setScheduleDialogEvents(dialog) {
}); });
} }
function dtRowCallback( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
var id = "pl_" + aData[0];
$(nRow).attr("id", id);
return nRow;
}
function addDtPlaylistEvents() {
$('#schedule_playlists tbody tr')
.draggable({
helper: 'clone'
});
}
function dtDrawCallback() {
addDtPlaylistEvents();
}
function makeScheduleDialog(dialog, json) { function makeScheduleDialog(dialog, json) {
dialog.find("#schedule_playlist_search").keyup(function(){ dialog.find("#schedule_playlist_search").keyup(function(){
@ -91,11 +107,33 @@ function makeScheduleDialog(dialog, json) {
}); });
}); });
dialog.find('#schedule_playlist_choice') dialog.find('#schedule_playlists').dataTable( {
.append(json.choice) "bProcessing": true,
.find('li') "bServerSide": true,
.draggable({ "sAjaxSource": "/Schedule/find-playlists/format/json",
helper: 'clone' "fnServerData": function ( sSource, aoData, fnCallback ) {
$.ajax( {
"dataType": 'json',
"type": "POST",
"url": sSource,
"data": aoData,
"success": fnCallback
} );
},
"fnRowCallback": dtRowCallback,
"fnDrawCallback": dtDrawCallback,
"aoColumns": [
/* Id */ { "sName": "pl.id", "bSearchable": false, "bVisible": false },
/* Description */ { "sName": "pl.description", "bVisible": false },
/* Name */ { "sName": "pl.name" },
/* Creator */ { "sName": "pl.creator" },
/* Length */ { "sName": "plt.length" },
/* Editing */ { "sName": "sub.login" }
],
"aaSorting": [[2,'asc']],
"sPaginationType": "full_numbers",
"bJQueryUI": true,
"bAutoWidth": false
}); });
dialog.find("#schedule_playlist_chosen") dialog.find("#schedule_playlist_chosen")