edits to show class to support resizing/dragging with overbooking.

This commit is contained in:
Naomi 2011-03-07 12:43:05 -05:00
parent 17e848c549
commit dc0ea0a532
5 changed files with 21 additions and 57 deletions

View File

@ -323,32 +323,9 @@ class Schedule {
return $res;
}
public static function getPercentScheduledInRange($s_datetime, $e_datetime) {
$time = Schedule::getTimeScheduledInRange($s_datetime, $e_datetime);
$con = Propel::getConnection(CcSchedulePeer::DATABASE_NAME);
$sql = "SELECT EXTRACT(EPOCH FROM TIMESTAMP WITH TIME ZONE '{$s_datetime}')";
$r = $con->query($sql);
$s_epoch = $r->fetchColumn(0);
$sql = "SELECT EXTRACT(EPOCH FROM TIMESTAMP WITH TIME ZONE '{$e_datetime}')";
$r = $con->query($sql);
$e_epoch = $r->fetchColumn(0);
$sql = "SELECT EXTRACT(EPOCH FROM INTERVAL '{$time}')";
$r = $con->query($sql);
$i_epoch = $r->fetchColumn(0);
$percent = ceil(($i_epoch / ($e_epoch - $s_epoch)) * 100);
return $percent;
}
public static function GetPercentScheduled($instance_id, $s_datetime, $e_datetime){
$time = Schedule::GetTotalShowTime($instance_id);
$s_epoch = strtotime($s_datetime);
$e_epoch = strtotime($e_datetime);

View File

@ -435,7 +435,7 @@ class Show {
$event[$key] = $value;
}
$percent = Schedule::getPercentScheduledInRange($show["starts"], $show["ends"]);
$percent = Schedule::GetPercentScheduled($show["instance_id"], $show["starts"], $show["ends"]);
$event["percent"] = $percent;
return $event;
@ -491,10 +491,9 @@ class ShowInstance {
global $CC_DBC;
$sql = "UPDATE cc_schedule
SET starts = (starts + interval '{$deltaDay} days' + interval '{$deltaHours}:{$deltaMin}'),
SET starts = (starts + interval '{$deltaDay} days' + interval '{$deltaHours}:{$deltaMin}'),
ends = (ends + interval '{$deltaDay} days' + interval '{$deltaHours}:{$deltaMin}')
WHERE (starts >= '{$this->getShowStart()}')
AND (ends <= '{$this->getShowEnd()}')";
WHERE instance_id = '{$this->_instanceId}'";
$CC_DBC->query($sql);
}
@ -560,17 +559,8 @@ class ShowInstance {
return "Should not overlap shows";
}
}
//have to check if any scheduled content still fits.
else{
$scheduledTime = $this->getTimeScheduled();
$sql = "SELECT (timestamp '{$new_ends}' - timestamp '{$starts}') >= interval '{$scheduledTime}'";
$scheduledContentFits = $CC_DBC->GetOne($sql);
if($scheduledContentFits != "t") {
return "Must remove some scheduled content.";
}
}
//with overbooking no longer need to check already scheduled content still fits.
$this->setShowEnd($new_ends);
}
@ -639,6 +629,7 @@ class ShowInstance {
}
public function getTimeScheduled() {
$instance_id = $this->getShowInstanceId();
$time = Schedule::GetTotalShowTime($instance_id);
@ -656,23 +647,16 @@ class ShowInstance {
return $time;
}
public function getPercentScheduledInRange(){
public function getPercentScheduled() {
$start_timestamp = $this->getShowStart();
$end_timestamp = $this->getShowEnd();
return Schedule::getPercentScheduledInRange($start_timestamp, $end_timestamp);
}
public function getPercentScheduled(){
$start_timestamp = $this->getShowStart();
$end_timestamp = $this->getShowEnd();
$instance_id = $this->getShowInstanceId();
return Schedule::GetPercentScheduled($instance_id, $start_timestamp, $end_timestamp);
}
public function getShowLength(){
public function getShowLength() {
global $CC_DBC;
$start_timestamp = $this->getShowStart();
@ -686,9 +670,9 @@ class ShowInstance {
public function searchPlaylistsForShow($datatables){
$length = $this->getTimeUnScheduled();
return StoredFile::searchPlaylistsForSchedule($length, $datatables);
//$length = $this->getTimeUnScheduled();
//return StoredFile::searchPlaylistsForSchedule($length, $datatables);
return StoredFile::searchPlaylistsForSchedule($datatables);
}
public function getShowListContent() {

View File

@ -1558,10 +1558,11 @@ class StoredFile {
}
public static function searchPlaylistsForSchedule($p_length, $datatables) {
public static function searchPlaylistsForSchedule($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"][] = "INTERVAL '{$p_length}' > INTERVAL '00:00:00'";
$datatables["optWhere"][] = "plt.length > INTERVAL '00:00:00'";
return StoredFile::searchFiles($fromTable, $datatables);
}

View File

@ -4,6 +4,10 @@
*
*/
function scheduleRefetchEvents() {
$("#schedule_calendar").fullCalendar( 'refetchEvents' );
}
function openAddShowForm() {
if(($("#add-show-form").length == 1) && ($("#add-show-form").css('display')=='none')) {
@ -221,6 +225,8 @@ function eventResize( event, dayDelta, minuteDelta, revertFunc, jsEvent, ui, vie
alert(json.error);
revertFunc();
}
scheduleRefetchEvents();
});
}

View File

@ -204,10 +204,6 @@ function buildEditDialog(json){
}
function scheduleRefetchEvents() {
$("#schedule_calendar").fullCalendar( 'refetchEvents' );
}
$(window).load(function() {
var mainHeight = document.documentElement.clientHeight - 200 - 50;