can add multiple playlists to a show, doesn't check length or update playlists based on time left. GUI is bad.
This commit is contained in:
parent
9c23b86c53
commit
1f8ac9719f
|
@ -143,18 +143,23 @@ class ScheduleController extends Zend_Controller_Action
|
||||||
$request = $this->getRequest();
|
$request = $this->getRequest();
|
||||||
|
|
||||||
if($request->isPost()) {
|
if($request->isPost()) {
|
||||||
|
|
||||||
$plId = $this->_getParam('plId');
|
$plId = $this->_getParam('plId');
|
||||||
$start = $this->_getParam('start');
|
$start = $this->_getParam('start');
|
||||||
|
$end = $this->_getParam('end');
|
||||||
$showId = $this->_getParam('showId');
|
$showId = $this->_getParam('showId');
|
||||||
|
|
||||||
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
|
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
|
||||||
|
|
||||||
$user = new User($userInfo->id, $userInfo->type);
|
$user = new User($userInfo->id, $userInfo->type);
|
||||||
$show = new Show($user, $showId);
|
$show = new Show($user, $showId);
|
||||||
$show->scheduleShow($start, $plId);
|
$show->scheduleShow($start, array($plId));
|
||||||
|
|
||||||
|
$this->view->showContent = $show->getShowContent($start);
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
$length = $this->_getParam('length');
|
$length = $this->_getParam('length');
|
||||||
|
|
||||||
$this->view->playlists = Playlist::searchPlaylists($length);
|
$this->view->playlists = Playlist::searchPlaylists($length);
|
||||||
|
@ -174,8 +179,8 @@ class ScheduleController extends Zend_Controller_Action
|
||||||
|
|
||||||
if($user->isHost($showId)) {
|
if($user->isHost($showId)) {
|
||||||
|
|
||||||
$sched = new ScheduleGroup();
|
$show = new Show($user, $showId);
|
||||||
$this->view->res = $sched->removeAtTime($start);
|
$show->clearShow($start);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -164,30 +164,24 @@ class ScheduleGroup {
|
||||||
public function addAfter($p_groupId, $p_audioFileId) {
|
public function addAfter($p_groupId, $p_audioFileId) {
|
||||||
global $CC_CONFIG, $CC_DBC;
|
global $CC_CONFIG, $CC_DBC;
|
||||||
// Get the end time for the given entry
|
// Get the end time for the given entry
|
||||||
$sql = "SELECT ends FROM ".$CC_CONFIG["scheduleTable"]
|
$sql = "SELECT MAX(ends) FROM ".$CC_CONFIG["scheduleTable"]
|
||||||
." WHERE group_id=$p_groupId";
|
." WHERE group_id=$p_groupId";
|
||||||
$startTime = $CC_DBC->GetOne($sql);
|
$startTime = $CC_DBC->GetOne($sql);
|
||||||
return $this->add($startTime, $p_audioFileId);
|
return $this->add($startTime, $p_audioFileId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function update() {
|
public function addPlaylistAfter($p_groupId, $p_playlistId) {
|
||||||
|
global $CC_CONFIG, $CC_DBC;
|
||||||
|
// Get the end time for the given entry
|
||||||
|
$sql = "SELECT MAX(ends) FROM ".$CC_CONFIG["scheduleTable"]
|
||||||
|
." WHERE group_id=$p_groupId";
|
||||||
|
|
||||||
|
$startTime = $CC_DBC->GetOne($sql);
|
||||||
|
return $this->add($startTime, null, $p_playlistId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function removeAtTime($p_datetime) {
|
public function update() {
|
||||||
global $CC_CONFIG, $CC_DBC;
|
|
||||||
|
|
||||||
$id = $this->dateToId($p_datetime);
|
|
||||||
|
|
||||||
$sql = "SELECT group_id FROM ".$CC_CONFIG["scheduleTable"]." WHERE id = ".$id;
|
|
||||||
$groupId = $CC_DBC->GetOne($sql);
|
|
||||||
|
|
||||||
if($groupId === NULL)
|
|
||||||
return;
|
|
||||||
|
|
||||||
$sql = "DELETE FROM ".$CC_CONFIG["scheduleTable"]
|
|
||||||
." WHERE group_id = ".$groupId;
|
|
||||||
$CC_DBC->query($sql);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -189,17 +189,70 @@ class Show {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function scheduleShow($start, $plId) {
|
private function getNextPos($day) {
|
||||||
if($this->_user->isHost($this->_showId)) {
|
global $CC_DBC;
|
||||||
|
|
||||||
|
$timeinfo = explode(" ", $day);
|
||||||
|
|
||||||
|
$sql = "SELECT MAX(position)+1 from cc_show_schedule WHERE show_id = '{$this->_showId}' AND show_day = '{$timeinfo[0]}'";
|
||||||
|
$res = $CC_DBC->GetOne($sql);
|
||||||
|
|
||||||
|
if(is_null($res))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return $res;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getLastGroupId($start_timestamp) {
|
||||||
|
global $CC_DBC;
|
||||||
|
|
||||||
|
$timeinfo = explode(" ", $start_timestamp);
|
||||||
|
|
||||||
|
$sql = "SELECT MAX(group_id) from cc_show_schedule WHERE show_id = '{$this->_showId}' AND show_day = '{$timeinfo[0]}'";
|
||||||
|
$res = $CC_DBC->GetOne($sql);
|
||||||
|
|
||||||
|
return $res;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addPlaylistToShow($start_timestamp, $plId) {
|
||||||
|
|
||||||
$sched = new ScheduleGroup();
|
$sched = new ScheduleGroup();
|
||||||
$groupId = $sched->add($start, null, $plId);
|
$lastGroupId = $this->getLastGroupId($start_timestamp);
|
||||||
|
|
||||||
|
if(is_null($lastGroupId)) {
|
||||||
|
|
||||||
|
$groupId = $sched->add($start_timestamp, null, $plId);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$groupId = $sched->addPlaylistAfter($lastGroupId, $plId);
|
||||||
|
}
|
||||||
|
|
||||||
|
$timeinfo = explode(" ", $start_timestamp);
|
||||||
|
$day = $timeinfo[0];
|
||||||
|
$pos = $this->getNextPos($day);
|
||||||
|
|
||||||
$groupsched = new CcShowSchedule();
|
$groupsched = new CcShowSchedule();
|
||||||
$groupsched->setDbShowId($this->_showId);
|
$groupsched->setDbShowId($this->_showId);
|
||||||
$groupsched->setDbGroupId($groupId);
|
$groupsched->setDbGroupId($groupId);
|
||||||
|
$groupsched->setDbShowDay($day);
|
||||||
|
$groupsched->setDbPosition($pos);
|
||||||
$groupsched->save();
|
$groupsched->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function scheduleShow($start_timestamp, $plIds) {
|
||||||
|
if($this->_user->isHost($this->_showId)) {
|
||||||
|
|
||||||
|
foreach($plIds as $plId) {
|
||||||
|
$this->addPlaylistToShow($start_timestamp, $plId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getTimeScheduled($start_timestamp, $end_timestamp) {
|
||||||
|
|
||||||
|
$time = Schedule::getTimeScheduledInRange($start_timestamp, $end_timestamp);
|
||||||
|
|
||||||
|
return $time;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTimeUnScheduled($start_date, $end_date, $start_time, $end_time) {
|
public function getTimeUnScheduled($start_date, $end_date, $start_time, $end_time) {
|
||||||
|
@ -222,6 +275,39 @@ class Show {
|
||||||
return !Schedule::isScheduleEmptyInRange($start_timestamp, $length);
|
return !Schedule::isScheduleEmptyInRange($start_timestamp, $length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getShowContent($day) {
|
||||||
|
global $CC_DBC;
|
||||||
|
|
||||||
|
$timeinfo = explode(" ", $day);
|
||||||
|
|
||||||
|
$sql = "SELECT *
|
||||||
|
FROM (cc_show_schedule AS ss LEFT JOIN cc_schedule AS s USING(group_id)
|
||||||
|
LEFT JOIN cc_files AS f ON f.id = s.file_id
|
||||||
|
LEFT JOIN cc_playlist AS p ON p.id = s.playlist_id )
|
||||||
|
|
||||||
|
WHERE ss.show_day = '{$timeinfo[0]}' AND ss.show_id = '{$this->_showId}'";
|
||||||
|
|
||||||
|
return $CC_DBC->GetAll($sql);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function clearShow($day) {
|
||||||
|
$timeinfo = explode(" ", $day);
|
||||||
|
|
||||||
|
$groups = CcShowScheduleQuery::create()
|
||||||
|
->filterByDbShowId($this->_showId)
|
||||||
|
->filterByDbShowDay($timeinfo[0])
|
||||||
|
->find();
|
||||||
|
|
||||||
|
foreach($groups as $group) {
|
||||||
|
$groupId = $group->getDbGroupId();
|
||||||
|
CcScheduleQuery::create()
|
||||||
|
->filterByDbGroupId($groupId)
|
||||||
|
->delete();
|
||||||
|
|
||||||
|
$group->delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function deleteShow($showId, $dayId=NULL) {
|
public function deleteShow($showId, $dayId=NULL) {
|
||||||
$groups = CcShowScheduleQuery::create()->filterByDbShowId($showId)->find();
|
$groups = CcShowScheduleQuery::create()->filterByDbShowId($showId)->find();
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
<h3>First header</h3>
|
||||||
|
<div>First content</div>
|
|
@ -185,19 +185,25 @@ function makeScheduleDialog(dialog, show) {
|
||||||
dialog.find("#schedule_playlist_chosen")
|
dialog.find("#schedule_playlist_chosen")
|
||||||
.droppable({
|
.droppable({
|
||||||
drop: function(event, ui) {
|
drop: function(event, ui) {
|
||||||
var li, pl_id, url, start_date;
|
var li, pl_id, url, start_date, end_date;
|
||||||
|
|
||||||
pl_id = $(ui.helper).attr("id").split("_").pop();
|
pl_id = $(ui.helper).attr("id").split("_").pop();
|
||||||
|
|
||||||
start_date = makeTimeStamp(show.start);
|
start_date = makeTimeStamp(show.start);
|
||||||
|
end_date = makeTimeStamp(show.end);
|
||||||
|
|
||||||
url = '/Schedule/schedule-show/format/json';
|
url = '/Schedule/schedule-show/format/json';
|
||||||
|
|
||||||
/*$.post(url,
|
//$("#schedule_playlist_chosen")
|
||||||
{plId: pl_id, start: start_date, showId: show.id},
|
// .append(ui.helper);
|
||||||
|
|
||||||
|
|
||||||
|
$.post(url,
|
||||||
|
{plId: pl_id, start: start_date, end: end_date, showId: show.id},
|
||||||
function(json){
|
function(json){
|
||||||
var x;
|
var x;
|
||||||
}); */
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue