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();
|
||||
|
||||
if($request->isPost()) {
|
||||
|
||||
$plId = $this->_getParam('plId');
|
||||
$start = $this->_getParam('start');
|
||||
$end = $this->_getParam('end');
|
||||
$showId = $this->_getParam('showId');
|
||||
|
||||
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
|
||||
|
||||
$user = new User($userInfo->id, $userInfo->type);
|
||||
$show = new Show($user, $showId);
|
||||
$show->scheduleShow($start, $plId);
|
||||
$show->scheduleShow($start, array($plId));
|
||||
|
||||
$this->view->showContent = $show->getShowContent($start);
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
$length = $this->_getParam('length');
|
||||
|
||||
$this->view->playlists = Playlist::searchPlaylists($length);
|
||||
|
@ -174,8 +179,8 @@ class ScheduleController extends Zend_Controller_Action
|
|||
|
||||
if($user->isHost($showId)) {
|
||||
|
||||
$sched = new ScheduleGroup();
|
||||
$this->view->res = $sched->removeAtTime($start);
|
||||
$show = new Show($user, $showId);
|
||||
$show->clearShow($start);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -164,32 +164,26 @@ class ScheduleGroup {
|
|||
public function addAfter($p_groupId, $p_audioFileId) {
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
// 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";
|
||||
$startTime = $CC_DBC->GetOne($sql);
|
||||
return $this->add($startTime, $p_audioFileId);
|
||||
}
|
||||
|
||||
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 update() {
|
||||
|
||||
}
|
||||
|
||||
public function removeAtTime($p_datetime) {
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the group from the schedule.
|
||||
* Note: does not check if it is in the past, you can remove anything.
|
||||
|
|
|
@ -189,19 +189,72 @@ class Show {
|
|||
|
||||
}
|
||||
|
||||
public function scheduleShow($start, $plId) {
|
||||
private function getNextPos($day) {
|
||||
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();
|
||||
$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->setDbShowId($this->_showId);
|
||||
$groupsched->setDbGroupId($groupId);
|
||||
$groupsched->setDbShowDay($day);
|
||||
$groupsched->setDbPosition($pos);
|
||||
$groupsched->save();
|
||||
}
|
||||
|
||||
public function scheduleShow($start_timestamp, $plIds) {
|
||||
if($this->_user->isHost($this->_showId)) {
|
||||
|
||||
$sched = new ScheduleGroup();
|
||||
$groupId = $sched->add($start, null, $plId);
|
||||
|
||||
$groupsched = new CcShowSchedule();
|
||||
$groupsched->setDbShowId($this->_showId);
|
||||
$groupsched->setDbGroupId($groupId);
|
||||
$groupsched->save();
|
||||
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) {
|
||||
|
||||
$start_timestamp = $start_date ." ".$start_time;
|
||||
|
@ -222,6 +275,39 @@ class Show {
|
|||
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) {
|
||||
$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")
|
||||
.droppable({
|
||||
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();
|
||||
|
||||
start_date = makeTimeStamp(show.start);
|
||||
end_date = makeTimeStamp(show.end);
|
||||
|
||||
url = '/Schedule/schedule-show/format/json';
|
||||
|
||||
/*$.post(url,
|
||||
{plId: pl_id, start: start_date, showId: show.id},
|
||||
//$("#schedule_playlist_chosen")
|
||||
// .append(ui.helper);
|
||||
|
||||
|
||||
$.post(url,
|
||||
{plId: pl_id, start: start_date, end: end_date, showId: show.id},
|
||||
function(json){
|
||||
var x;
|
||||
}); */
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue