diff --git a/application/models/Schedule.php b/application/models/Schedule.php index 6e2c2aa71..9c86a9007 100644 --- a/application/models/Schedule.php +++ b/application/models/Schedule.php @@ -278,12 +278,43 @@ class Schedule { ." WHERE (starts >= '$p_datetime') " ." AND (ends <= (TIMESTAMP '$p_datetime' + INTERVAL '$p_length'))"; //$_SESSION["debug"] = $sql; - //var_dump($sql); + //echo $sql; $count = $CC_DBC->GetOne($sql); //var_dump($count); return ($count == '0'); } + public static function getPercentScheduledInRange($s_datetime, $e_datetime) { + global $CC_CONFIG, $CC_DBC; + + $sql = "SELECT SUM(clip_length) FROM ".$CC_CONFIG["scheduleTable"]." + WHERE (starts >= '{$s_datetime}') + AND (ends <= '{$e_datetime}')"; + + $res = $CC_DBC->GetOne($sql); + + if(is_null($res)) + return 0; + + $con = Propel::getConnection("campcaster"); + + $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 '{$res}')"; + $r = $con->query($sql); + $i_epoch = $r->fetchColumn(0); + + $percent = ceil(($i_epoch / ($e_epoch - $s_epoch)) * 100); + + return $percent; + } + // public function onAddTrackToPlaylist($playlistId, $audioTrackId) { // // } diff --git a/application/models/Shows.php b/application/models/Shows.php index e6da17940..195775e25 100644 --- a/application/models/Shows.php +++ b/application/models/Shows.php @@ -369,9 +369,9 @@ class Show { $start = $date." ".$show["start_time"]; $end = $date." ".$show["end_time"]; - if($this->showHasContent($start, $end)) { - $event["hasContent"] = true; - } + + $percent = Schedule::getPercentScheduledInRange($start, $end); + $event["percent"] = $percent; return $event; } diff --git a/public/js/campcaster/schedule/schedule.js b/public/js/campcaster/schedule/schedule.js index 91671e721..cce763b5c 100644 --- a/public/js/campcaster/schedule/schedule.js +++ b/public/js/campcaster/schedule/schedule.js @@ -272,11 +272,22 @@ function eventRender(event, element, view) { // content: event.description // }); - if(event.hasContent) { - var span = $('').addClass("ui-icon ui-icon-check"); - $(element).find(".fc-event-title").after(span); - } - + if(view.name === 'agendaDay' || view.name === 'agendaWeek') { + var div = $('
'); + div + .height('5px') + .width('100px') + .css('margin-top', '5px') + .progressbar({ + value: event.percent + }); + + div.find("div") + .removeClass("ui-widget-header") + .addClass("ui-state-active"); + + $(element).find(".fc-event-title").after(div); + } } function eventAfterRender( event, element, view ) {