Merge branch '2.0.x' into devel
Conflicts: VERSION airtime_mvc/application/models/Schedule.php airtime_mvc/application/models/Show.php airtime_mvc/public/js/airtime/dashboard/helperfunctions.js install_minimal/include/airtime-constants.php python_apps/api_clients/api_client.py python_apps/pypo/pypocli.py python_apps/pypo/pypofetch.py
This commit is contained in:
commit
6f270bfb3d
21 changed files with 1664 additions and 293 deletions
|
@ -3,24 +3,31 @@
|
|||
class Application_Model_Nowplaying
|
||||
{
|
||||
|
||||
private static function CreateHeaderRow($p_showName, $p_showStart, $p_showEnd){
|
||||
return array("h", "", $p_showStart, $p_showEnd, $p_showName, "", "", "", "", "", "");
|
||||
}
|
||||
private static function CreateHeaderRow($p_showName, $p_showStart, $p_showEnd){
|
||||
return array("h", "", $p_showStart, $p_showEnd, $p_showName, "", "", "", "", "", "");
|
||||
}
|
||||
|
||||
private static function CreateDatatableRows($p_dbRows){
|
||||
private static function CreateDatatableRows($p_dbRows){
|
||||
$dataTablesRows = array();
|
||||
|
||||
$epochNow = time();
|
||||
|
||||
foreach ($p_dbRows as $dbRow){
|
||||
|
||||
$showStartDateTime = Application_Model_DateHelper::ConvertToLocalDateTime($dbRow['show_starts']);
|
||||
$showEndDateTime = Application_Model_DateHelper::ConvertToLocalDateTime($dbRow['show_ends']);
|
||||
$itemStartDateTime = Application_Model_DateHelper::ConvertToLocalDateTime($dbRow['item_starts']);
|
||||
$itemEndDateTime = Application_Model_DateHelper::ConvertToLocalDateTime($dbRow['item_ends']);
|
||||
|
||||
$lastRow = end($p_dbRows);
|
||||
|
||||
//Information about show is true for all rows in parameter so only check the last row's show
|
||||
//start and end times.
|
||||
if (isset($lastRow)){
|
||||
$showStartDateTime = Application_Model_DateHelper::ConvertToLocalDateTime($lastRow['show_starts']);
|
||||
$showEndDateTime = Application_Model_DateHelper::ConvertToLocalDateTime($lastRow['show_ends']);
|
||||
$showStarts = $showStartDateTime->format("Y-m-d H:i:s");
|
||||
$showEnds = $showEndDateTime->format("Y-m-d H:i:s");
|
||||
}
|
||||
|
||||
foreach ($p_dbRows as $dbRow) {
|
||||
|
||||
$itemStartDateTime = Application_Model_DateHelper::ConvertToLocalDateTime($dbRow['item_starts']);
|
||||
$itemEndDateTime = Application_Model_DateHelper::ConvertToLocalDateTime($dbRow['item_ends']);
|
||||
|
||||
$itemStarts = $itemStartDateTime->format("Y-m-d H:i:s");
|
||||
$itemEnds = $itemEndDateTime->format("Y-m-d H:i:s");
|
||||
|
||||
|
@ -44,54 +51,82 @@ class Application_Model_Nowplaying
|
|||
$dbRow['playlist_name'], $dbRow['show_name'], $status);
|
||||
}
|
||||
|
||||
return $dataTablesRows;
|
||||
}
|
||||
//Modify the last entry in the data table to adjust its end time to be equal to the
|
||||
//shows end time if it exceeds it.
|
||||
$lastRow = end($dataTablesRows);
|
||||
if (isset($lastRow) && strtotime($showEnds) < strtotime($lastRow[3])){
|
||||
$dataTablesRows[sizeof($dataTablesRows)-1][3] = $showEnds;
|
||||
}
|
||||
return $dataTablesRows;
|
||||
}
|
||||
|
||||
private static function CreateGapRow($p_gapTime){
|
||||
return array("g", "", "", "", $p_gapTime, "", "", "", "", "", "");
|
||||
}
|
||||
private static function CreateGapRow($p_gapTime){
|
||||
return array("g", "", "", "", $p_gapTime, "", "", "", "", "", "");
|
||||
}
|
||||
|
||||
private static function CreateRecordingRow($p_showInstance){
|
||||
return array("r", "", "", "", $p_showInstance->getName(), "", "", "", "", "", "");
|
||||
}
|
||||
private static function CreateRecordingRow($p_showInstance){
|
||||
return array("r", "", "", "", $p_showInstance->getName(), "", "", "", "", "", "");
|
||||
}
|
||||
|
||||
public static function GetDataGridData($viewType, $dateString){
|
||||
|
||||
if ($viewType == "now"){
|
||||
$dateTime = new DateTime("now", new DateTimeZone("UTC"));
|
||||
$timeNow = $dateTime->format("Y-m-d H:i:s");
|
||||
/*
|
||||
* The purpose of this function is to return an array of scheduled
|
||||
* items. There are two parameters. $p_viewType can be either "now"
|
||||
* or "day". If "now", we show all scheduled items in the near future.
|
||||
*
|
||||
* If "day" we need to find what day was requested by the user, and return
|
||||
* scheduled items for that day.
|
||||
*
|
||||
* $p_dateString is only used when $p_viewType is "day" it is in the format
|
||||
* "2012-12-31". In this case it tells us which day to use.
|
||||
*/
|
||||
public static function GetDataGridData($p_viewType, $p_dateString){
|
||||
|
||||
$startCutoff = 60;
|
||||
$endCutoff = 86400; //60*60*24 - seconds in a day
|
||||
if ($p_viewType == "now"){
|
||||
$start_dt = new DateTime("now", new DateTimeZone("UTC"));
|
||||
$end_dt = clone $start_dt;
|
||||
|
||||
$start_dt->sub(new DateInterval("PT60S"));
|
||||
$end_dt->add(new DateInterval("PT24H"));
|
||||
} else {
|
||||
$date = new Application_Model_DateHelper;
|
||||
$time = $date->getTime();
|
||||
$date->setDate($dateString." ".$time);
|
||||
$timeNow = $date->getUtcTimestamp();
|
||||
//convert to UTC
|
||||
$utc_dt = Application_Model_DateHelper::ConvertToUtcDateTime($p_dateString);
|
||||
$start_dt = $utc_dt;
|
||||
|
||||
$end_dt = clone $utc_dt;
|
||||
$end_dt->add(new DateInterval("PT24H"));
|
||||
}
|
||||
|
||||
$starts = $start_dt->format("Y-m-d H:i:s");
|
||||
$ends = $end_dt->format("Y-m-d H:i:s");
|
||||
|
||||
$startCutoff = $date->getNowDayStartDiff();
|
||||
$endCutoff = $date->getNowDayEndDiff();
|
||||
$showIds = Application_Model_ShowInstance::GetShowsInstancesIdsInRange($starts, $ends);
|
||||
|
||||
//get all the pieces to be played between the start cut off and the end cut off.
|
||||
$scheduledItems = Application_Model_Schedule::getScheduleItemsInRange($starts, $ends);
|
||||
|
||||
$orderedScheduledItems;
|
||||
foreach ($scheduledItems as $scheduledItem){
|
||||
$orderedScheduledItems[$scheduledItem['instance_id']][] = $scheduledItem;
|
||||
}
|
||||
|
||||
$data = array();
|
||||
|
||||
$showIds = Application_Model_ShowInstance::GetShowsInstancesIdsInRange($timeNow, $startCutoff, $endCutoff);
|
||||
foreach ($showIds as $showId){
|
||||
$instanceId = $showId['id'];
|
||||
|
||||
//gets the show information
|
||||
$si = new Application_Model_ShowInstance($instanceId);
|
||||
|
||||
$showId = $si->getShowId();
|
||||
$show = new Application_Model_Show($showId);
|
||||
|
||||
|
||||
$showStartDateTime = Application_Model_DateHelper::ConvertToLocalDateTime($si->getShowInstanceStart());
|
||||
$showEndDateTime = Application_Model_DateHelper::ConvertToLocalDateTime($si->getShowInstanceEnd());
|
||||
|
||||
//append show header row
|
||||
$data[] = self::CreateHeaderRow($show->getName(), $showStartDateTime->format("Y-m-d H:i:s"), $showEndDateTime->format("Y-m-d H:i:s"));
|
||||
|
||||
$scheduledItems = $si->getScheduleItemsInRange($timeNow, $startCutoff, $endCutoff);
|
||||
$dataTablesRows = self::CreateDatatableRows($scheduledItems);
|
||||
$dataTablesRows = self::CreateDatatableRows($orderedScheduledItems[$instanceId]);
|
||||
|
||||
//append show audio item rows
|
||||
$data = array_merge($data, $dataTablesRows);
|
||||
|
@ -99,11 +134,12 @@ class Application_Model_Nowplaying
|
|||
//append show gap time row
|
||||
$gapTime = self::FormatDuration($si->getShowEndGapTime(), true);
|
||||
if ($si->isRecorded())
|
||||
$data[] = self::CreateRecordingRow($si);
|
||||
$data[] = self::CreateRecordingRow($si);
|
||||
else if ($gapTime > 0)
|
||||
$data[] = self::CreateGapRow($gapTime);
|
||||
$data[] = self::CreateGapRow($gapTime);
|
||||
}
|
||||
|
||||
$timeNow = gmdate("Y-m-d H:i:s");
|
||||
$rows = Application_Model_Show::GetCurrentShow($timeNow);
|
||||
Application_Model_Show::ConvertToLocalTimeZone($rows, array("starts", "ends", "start_timestamp", "end_timestamp"));
|
||||
return array("currentShow"=>$rows, "rows"=>$data);
|
||||
|
|
|
@ -65,18 +65,76 @@ class Application_Model_Schedule {
|
|||
$date = new Application_Model_DateHelper;
|
||||
$timeNow = $date->getTimestamp();
|
||||
$utcTimeNow = $date->getUtcTimestamp();
|
||||
$currentShow = Application_Model_Show::GetCurrentShow($utcTimeNow);
|
||||
$results = Application_Model_Schedule::GetPrevCurrentNext($utcTimeNow);
|
||||
|
||||
$range = array("env"=>APPLICATION_ENV,
|
||||
"schedulerTime"=>$timeNow,
|
||||
"previous"=>Application_Model_Dashboard::GetPreviousItem($utcTimeNow),
|
||||
"current"=>Application_Model_Dashboard::GetCurrentItem($utcTimeNow),
|
||||
"next"=>Application_Model_Dashboard::GetNextItem($utcTimeNow),
|
||||
"currentShow"=>Application_Model_Show::GetCurrentShow($utcTimeNow),
|
||||
"nextShow"=>Application_Model_Show::GetNextShows($utcTimeNow, 1),
|
||||
"previous"=>$results['previous'],
|
||||
"current"=>$results['current'],
|
||||
"next"=>$results['next'],
|
||||
"currentShow"=>$currentShow,
|
||||
"nextShow"=>"",//Application_Model_Show::GetNextShows($utcTimeNow, 1),
|
||||
"timezone"=> date("T"),
|
||||
"timezoneOffset"=> date("Z"));
|
||||
|
||||
return $range;
|
||||
}
|
||||
|
||||
/**
|
||||
* Queries the database for the set of schedules one hour before and after the given time.
|
||||
* If a show starts and ends within that time that is considered the current show. Then the
|
||||
* scheduled item before it is the previous show, and the scheduled item after it is the next
|
||||
* show. This way the dashboard getCurrentPlaylist is very fast. But if any one of the three
|
||||
* show types are not found through this mechanism a call is made to the old way of querying
|
||||
* the database to find the track info.
|
||||
**/
|
||||
public static function GetPrevCurrentNext($p_timeNow)
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
|
||||
|
||||
$sql = "Select ft.artist_name, ft.track_title, st.starts as starts, st.ends as ends, st.media_item_played as media_item_played
|
||||
FROM cc_schedule st LEFT JOIN cc_files ft ON st.file_id = ft.id LEFT JOIN cc_show_instances sit ON st.instance_id = sit.id
|
||||
WHERE st.starts > (TIMESTAMP '$p_timeNow'-INTERVAL '24 hours') AND st.starts < (TIMESTAMP '$p_timeNow'+INTERVAL '24 hours') AND st.starts < sit.ends
|
||||
ORDER BY st.starts";
|
||||
$row = $CC_DBC->GetAll($sql);
|
||||
|
||||
$numberOfRows = count($row);
|
||||
$results;
|
||||
|
||||
$timeNowAsMillis = strtotime($p_timeNow);
|
||||
for( $i = 0; $i < $numberOfRows && !isset($results); ++$i ){
|
||||
if ((strtotime($row[$i]['starts']) <= $timeNowAsMillis) && (strtotime($row[$i]['ends']) >= $timeNowAsMillis)){
|
||||
if ( $i - 1 >= 0){
|
||||
$results['previous'] = array("name"=>$row[$i-1]["artist_name"]." - ".$row[$i-1]["track_title"],
|
||||
"starts"=>$row[$i-1]["starts"],
|
||||
"ends"=>$row[$i-1]["ends"]);
|
||||
}
|
||||
$results['current'] = array("name"=>$row[$i]["artist_name"]." - ".$row[$i]["track_title"],
|
||||
"starts"=>$row[$i]["starts"],
|
||||
"ends"=>$row[$i]["ends"],
|
||||
"media_item_played"=>$row[$i]["media_item_played"],
|
||||
"record"=>0);
|
||||
if ( isset($row[$i+1])){
|
||||
$results['next'] = array("name"=>$row[$i+1]["artist_name"]." - ".$row[$i+1]["track_title"],
|
||||
"starts"=>$row[$i+1]["starts"],
|
||||
"ends"=>$row[$i+1]["ends"]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($results['previous'])){
|
||||
$results['previous'] = Application_Model_Dashboard::GetPreviousItem($p_timeNow);
|
||||
}
|
||||
if (!isset($results['current'])){
|
||||
$results['current'] = Application_Model_Dashboard::GetCurrentItem($p_timeNow);
|
||||
}
|
||||
if (!isset($results['next'])) {
|
||||
$results['next'] = Application_Model_Dashboard::GetNextItem($p_timeNow);
|
||||
}
|
||||
return $results;
|
||||
}
|
||||
|
||||
public static function GetLastScheduleItem($p_timeNow){
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
|
@ -195,23 +253,59 @@ class Application_Model_Schedule {
|
|||
." WHERE st.starts < si.ends";
|
||||
|
||||
if ($timePeriod < 0){
|
||||
$sql .= " AND st.ends < TIMESTAMP '$timeStamp'"
|
||||
." AND st.ends > (TIMESTAMP '$timeStamp' - INTERVAL '$interval')"
|
||||
." ORDER BY st.starts DESC"
|
||||
." LIMIT $count";
|
||||
} else if ($timePeriod == 0){
|
||||
$sql .= " AND st.starts <= TIMESTAMP '$timeStamp'"
|
||||
." AND st.ends >= TIMESTAMP '$timeStamp'";
|
||||
} else if ($timePeriod > 0){
|
||||
$sql .= " AND st.starts > TIMESTAMP '$timeStamp'"
|
||||
." AND st.starts < (TIMESTAMP '$timeStamp' + INTERVAL '$interval')"
|
||||
." ORDER BY st.starts"
|
||||
." LIMIT $count";
|
||||
}
|
||||
$sql .= " AND st.ends < TIMESTAMP '$timeStamp'"
|
||||
." AND st.ends > (TIMESTAMP '$timeStamp' - INTERVAL '$interval')"
|
||||
." ORDER BY st.starts DESC"
|
||||
." LIMIT $count";
|
||||
} else if ($timePeriod == 0){
|
||||
$sql .= " AND st.starts <= TIMESTAMP '$timeStamp'"
|
||||
." AND st.ends >= TIMESTAMP '$timeStamp'";
|
||||
} else if ($timePeriod > 0){
|
||||
$sql .= " AND st.starts > TIMESTAMP '$timeStamp'"
|
||||
." AND st.starts < (TIMESTAMP '$timeStamp' + INTERVAL '$interval')"
|
||||
." ORDER BY st.starts"
|
||||
." LIMIT $count";
|
||||
}
|
||||
|
||||
$rows = $CC_DBC->GetAll($sql);
|
||||
return $rows;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static function getScheduleItemsInRange($starts, $ends)
|
||||
{
|
||||
global $CC_DBC, $CC_CONFIG;
|
||||
|
||||
$sql = "SELECT"
|
||||
." si.starts as show_starts,"
|
||||
." si.ends as show_ends,"
|
||||
." si.rebroadcast as rebroadcast,"
|
||||
." st.starts as item_starts,"
|
||||
." st.ends as item_ends,"
|
||||
." st.clip_length as clip_length,"
|
||||
." ft.track_title as track_title,"
|
||||
." ft.artist_name as artist_name,"
|
||||
." ft.album_title as album_title,"
|
||||
." s.name as show_name,"
|
||||
." si.id as instance_id,"
|
||||
." pt.name as playlist_name"
|
||||
." FROM ".$CC_CONFIG["showInstances"]." si"
|
||||
." LEFT JOIN ".$CC_CONFIG["scheduleTable"]." st"
|
||||
." ON st.instance_id = si.id"
|
||||
." LEFT JOIN ".$CC_CONFIG["playListTable"]." pt"
|
||||
." ON st.playlist_id = pt.id"
|
||||
." LEFT JOIN ".$CC_CONFIG["filesTable"]." ft"
|
||||
." ON st.file_id = ft.id"
|
||||
." LEFT JOIN ".$CC_CONFIG["showTable"]." s"
|
||||
." ON si.show_id = s.id"
|
||||
." WHERE ((si.starts < TIMESTAMP '$starts' AND si.ends > TIMESTAMP '$starts')"
|
||||
." OR (si.starts > TIMESTAMP '$starts' AND si.ends < TIMESTAMP '$ends')"
|
||||
." OR (si.starts < TIMESTAMP '$ends' AND si.ends > TIMESTAMP '$ends'))"
|
||||
." AND (st.starts < si.ends)"
|
||||
." ORDER BY si.id, si.starts, st.starts";
|
||||
|
||||
return $CC_DBC->GetAll($sql);
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
|
@ -295,7 +389,7 @@ class Application_Model_Schedule {
|
|||
}
|
||||
|
||||
public static function getSchduledPlaylistCount(){
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$sql = "SELECT count(*) as cnt FROM ".$CC_CONFIG['scheduleTable'];
|
||||
return $CC_DBC->GetOne($sql);
|
||||
}
|
||||
|
@ -635,16 +729,16 @@ class Application_Model_Schedule {
|
|||
$isSaas = Application_Model_Preference::GetPlanLevel() == 'disabled'?false:true;
|
||||
|
||||
$formWhat = new Application_Form_AddShowWhat();
|
||||
$formWho = new Application_Form_AddShowWho();
|
||||
$formWhen = new Application_Form_AddShowWhen();
|
||||
$formRepeats = new Application_Form_AddShowRepeats();
|
||||
$formStyle = new Application_Form_AddShowStyle();
|
||||
$formWho = new Application_Form_AddShowWho();
|
||||
$formWhen = new Application_Form_AddShowWhen();
|
||||
$formRepeats = new Application_Form_AddShowRepeats();
|
||||
$formStyle = new Application_Form_AddShowStyle();
|
||||
|
||||
$formWhat->removeDecorator('DtDdWrapper');
|
||||
$formWho->removeDecorator('DtDdWrapper');
|
||||
$formWhen->removeDecorator('DtDdWrapper');
|
||||
$formRepeats->removeDecorator('DtDdWrapper');
|
||||
$formStyle->removeDecorator('DtDdWrapper');
|
||||
$formWhat->removeDecorator('DtDdWrapper');
|
||||
$formWho->removeDecorator('DtDdWrapper');
|
||||
$formWhen->removeDecorator('DtDdWrapper');
|
||||
$formRepeats->removeDecorator('DtDdWrapper');
|
||||
$formStyle->removeDecorator('DtDdWrapper');
|
||||
|
||||
$p_view->what = $formWhat;
|
||||
$p_view->when = $formWhen;
|
||||
|
@ -655,11 +749,11 @@ class Application_Model_Schedule {
|
|||
$formWhat->populate(array('add_show_id' => '-1'));
|
||||
$formWhen->populate(array('add_show_start_date' => date("Y-m-d"),
|
||||
'add_show_start_time' => '00:00',
|
||||
'add_show_end_date_no_repeate' => date("Y-m-d"),
|
||||
'add_show_end_time' => '01:00',
|
||||
'add_show_end_date_no_repeate' => date("Y-m-d"),
|
||||
'add_show_end_time' => '01:00',
|
||||
'add_show_duration' => '1h'));
|
||||
|
||||
$formRepeats->populate(array('add_show_end_date' => date("Y-m-d")));
|
||||
$formRepeats->populate(array('add_show_end_date' => date("Y-m-d")));
|
||||
|
||||
if(!$isSaas){
|
||||
$formRecord = new Application_Form_AddShowRR();
|
||||
|
@ -677,4 +771,3 @@ class Application_Model_Schedule {
|
|||
$p_view->addNewShow = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -239,22 +239,22 @@ class Application_Model_Show {
|
|||
}
|
||||
|
||||
foreach($showDays as $showDay) {
|
||||
Logging::log("Local show day is: {$showDay->getDbDay()}");
|
||||
Logging::log("Local show day is: {$showDay->getDbDay()}");
|
||||
Logging::log("First show day is: {$showDay->getDbFirstShow()}");
|
||||
Logging::log("Id show days is: {$showDay->getDbId()}");
|
||||
|
||||
if (in_array($showDay->getDbDay(), $p_uncheckedDays)) {
|
||||
$showDay->reload();
|
||||
//Logging::log("Local show day is: {$showDay->getDbDay()}");
|
||||
//Logging::log("First show day is: {$showDay->getDbFirstShow()}");
|
||||
//Logging::log("Id show days is: {$showDay->getDbId()}");
|
||||
$startDay = new DateTime("{$showDay->getDbFirstShow()} {$showDay->getDbStartTime()}", new DateTimeZone($showDay->getDbTimezone()));
|
||||
Logging::log("Show start day: {$startDay->format('Y-m-d H:i:s')}");
|
||||
if (in_array($showDay->getDbDay(), $p_uncheckedDays)) {
|
||||
$showDay->reload();
|
||||
//Logging::log("Local show day is: {$showDay->getDbDay()}");
|
||||
//Logging::log("First show day is: {$showDay->getDbFirstShow()}");
|
||||
//Logging::log("Id show days is: {$showDay->getDbId()}");
|
||||
$startDay = new DateTime("{$showDay->getDbFirstShow()} {$showDay->getDbStartTime()}", new DateTimeZone($showDay->getDbTimezone()));
|
||||
Logging::log("Show start day: {$startDay->format('Y-m-d H:i:s')}");
|
||||
$startDay->setTimezone(new DateTimeZone("UTC"));
|
||||
Logging::log("Show start day UTC: {$startDay->format('Y-m-d H:i:s')}");
|
||||
$daysRemovedUTC[] = $startDay->format('w');
|
||||
Logging::log("UTC show day is: {$startDay->format('w')}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$uncheckedDaysImploded = implode(",", $daysRemovedUTC);
|
||||
|
@ -867,18 +867,18 @@ class Application_Model_Show {
|
|||
}
|
||||
}
|
||||
|
||||
if ($p_data['add_show_start_date'] != $this->getStartDate()
|
||||
|| $p_data['add_show_start_time'] != $this->getStartTime()){
|
||||
//start date/time has changed
|
||||
if ($p_data['add_show_start_date'] != $this->getStartDate()
|
||||
|| $p_data['add_show_start_time'] != $this->getStartTime()){
|
||||
//start date/time has changed
|
||||
|
||||
$newDate = strtotime($p_data['add_show_start_date']);
|
||||
$oldDate = strtotime($this->getStartDate());
|
||||
if ($newDate > $oldDate){
|
||||
$this->removeAllInstancesBeforeDate($p_data['add_show_start_date']);
|
||||
}
|
||||
$newDate = strtotime($p_data['add_show_start_date']);
|
||||
$oldDate = strtotime($this->getStartDate());
|
||||
if ($newDate > $oldDate){
|
||||
$this->removeAllInstancesBeforeDate($p_data['add_show_start_date']);
|
||||
}
|
||||
|
||||
$this->updateStartDateTime($p_data, $p_endDate);
|
||||
}
|
||||
$this->updateStartDateTime($p_data, $p_endDate);
|
||||
}
|
||||
}
|
||||
|
||||
//Check if end date for the repeat option has changed. If so, need to take care
|
||||
|
@ -1449,7 +1449,7 @@ class Application_Model_Show {
|
|||
|
||||
$sql = "SELECT starts, ends, record, rebroadcast, instance_id, show_id, name,
|
||||
color, background_color, file_id, cc_show_instances.id AS instance_id,
|
||||
last_scheduled
|
||||
last_scheduled, time_filled
|
||||
FROM cc_show_instances
|
||||
LEFT JOIN cc_show ON cc_show.id = cc_show_instances.show_id
|
||||
WHERE cc_show_instances.modified_instance = FALSE";
|
||||
|
@ -1541,14 +1541,15 @@ class Application_Model_Show {
|
|||
* -in UTC time
|
||||
* @param boolean $editable
|
||||
*/
|
||||
public static function getFullCalendarEvents($start, $end, $editable=false)
|
||||
public static function getFullCalendarEvents($p_start, $p_end, $p_editable=false)
|
||||
{
|
||||
|
||||
$events = array();
|
||||
|
||||
$interval = $start->diff($end);
|
||||
$days = $interval->format('%a');
|
||||
$interval = $p_start->diff($p_end);
|
||||
$days = $interval->format('%a');
|
||||
|
||||
$shows = Application_Model_Show::getShows($start, $end);
|
||||
$shows = Application_Model_Show::getShows($p_start, $p_end);
|
||||
|
||||
$today_timestamp = gmdate("Y-m-d H:i:s");
|
||||
|
||||
|
@ -1556,20 +1557,32 @@ class Application_Model_Show {
|
|||
$options = array();
|
||||
|
||||
//only bother calculating percent for week or day view.
|
||||
if(intval($days) <= 7) {
|
||||
$show_instance = new Application_Model_ShowInstance($show["instance_id"]);
|
||||
$options["percent"] = $show_instance->getPercentScheduled();
|
||||
|
||||
if(intval($days) <= 7) {
|
||||
$options["percent"] = Application_Model_Show::getPercentScheduled($show["starts"], $show["ends"], $show["time_filled"]);
|
||||
}
|
||||
|
||||
if ($editable && (strtotime($today_timestamp) < strtotime($show["starts"]))) {
|
||||
if ($p_editable && (strtotime($today_timestamp) < strtotime($show["starts"]))) {
|
||||
$options["editable"] = true;
|
||||
}
|
||||
|
||||
$events[] = Application_Model_Show::makeFullCalendarEvent($show, $options);
|
||||
}
|
||||
|
||||
|
||||
return $events;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the percentage of a show scheduled given the start and end times in date/time format
|
||||
* and the time_filled as the total time the schow is scheduled for in time format.
|
||||
**/
|
||||
private static function getPercentScheduled($p_starts, $p_ends, $p_time_filled){
|
||||
$durationSeconds = (strtotime($p_ends) - strtotime($p_starts));
|
||||
$time_filled = Application_Model_Schedule::WallTimeToMillisecs($p_time_filled) / 1000;
|
||||
$percent = ceil(( $time_filled / $durationSeconds) * 100);
|
||||
|
||||
return $percent;
|
||||
}
|
||||
|
||||
private static function makeFullCalendarEvent($show, $options=array())
|
||||
{
|
||||
|
|
|
@ -677,20 +677,22 @@ class Application_Model_ShowInstance {
|
|||
return $results;
|
||||
}
|
||||
|
||||
public static function GetShowsInstancesIdsInRange($p_timeNow, $p_start, $p_end)
|
||||
public static function GetShowsInstancesIdsInRange($p_start, $p_end)
|
||||
{
|
||||
global $CC_DBC;
|
||||
|
||||
$sql = "SELECT id FROM cc_show_instances AS si "
|
||||
."WHERE modified_instance != TRUE AND ("
|
||||
."(si.starts < TIMESTAMP '$p_timeNow' - INTERVAL '$p_start seconds' "
|
||||
."AND si.ends > TIMESTAMP '$p_timeNow' - INTERVAL '$p_start seconds') "
|
||||
."OR (si.starts > TIMESTAMP '$p_timeNow' - INTERVAL '$p_start seconds' "
|
||||
."AND si.ends < TIMESTAMP '$p_timeNow' + INTERVAL '$p_end seconds') "
|
||||
."OR (si.starts < TIMESTAMP '$p_timeNow' + INTERVAL '$p_end seconds' "
|
||||
."AND si.ends > TIMESTAMP '$p_timeNow' + INTERVAL '$p_end seconds') "
|
||||
."(si.starts < TIMESTAMP '$p_start'"
|
||||
."AND si.ends > TIMESTAMP '$p_start') "
|
||||
."OR (si.starts > TIMESTAMP '$p_start' "
|
||||
."AND si.ends < TIMESTAMP '$p_end') "
|
||||
."OR (si.starts < TIMESTAMP '$p_end' "
|
||||
."AND si.ends > TIMESTAMP '$p_end') "
|
||||
.") "
|
||||
." ORDER BY si.starts";
|
||||
|
||||
Logging::debug($sql);
|
||||
|
||||
$rows = $CC_DBC->GetAll($sql);
|
||||
return $rows;
|
||||
|
@ -732,7 +734,7 @@ class Application_Model_ShowInstance {
|
|||
|
||||
return $CC_DBC->GetAll($sql);
|
||||
}
|
||||
|
||||
|
||||
public function getLastAudioItemEnd(){
|
||||
global $CC_DBC;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue