diff --git a/application/configs/conf.php b/application/configs/conf.php index 12b253bfd..be67fb6cc 100644 --- a/application/configs/conf.php +++ b/application/configs/conf.php @@ -141,6 +141,7 @@ $CC_CONFIG['playListTimeView'] = $CC_CONFIG['tblNamePrefix'].'playlisttimes'; $CC_CONFIG['showSchedule'] = $CC_CONFIG['tblNamePrefix'].'show_schedule'; $CC_CONFIG['showDays'] = $CC_CONFIG['tblNamePrefix'].'show_days'; $CC_CONFIG['showTable'] = $CC_CONFIG['tblNamePrefix'].'show'; +$CC_CONFIG['showInstances'] = $CC_CONFIG['tblNamePrefix'].'show_instances'; $CC_CONFIG['playListSequence'] = $CC_CONFIG['playListTable'].'_id'; $CC_CONFIG['filesSequence'] = $CC_CONFIG['filesTable'].'_id'; diff --git a/application/models/Schedule.php b/application/models/Schedule.php index 734eef4ee..b0f395740 100644 --- a/application/models/Schedule.php +++ b/application/models/Schedule.php @@ -484,11 +484,11 @@ class Schedule { public static function Get_Scheduled_Item_Data($timeNow, $timePeriod=0, $count = 0, $interval="0 hours"){ global $CC_CONFIG, $CC_DBC; $sql = "SELECT DISTINCT pt.name, ft.track_title, ft.artist_name, ft.album_title, st.starts, st.ends, st.clip_length, st.group_id, show.name as show_name" - ." FROM $CC_CONFIG[scheduleTable] st, $CC_CONFIG[filesTable] ft, $CC_CONFIG[playListTable] pt, $CC_CONFIG[showSchedule] ss, $CC_CONFIG[showTable] show" + ." FROM $CC_CONFIG[scheduleTable] st, $CC_CONFIG[filesTable] ft, $CC_CONFIG[playListTable] pt, $CC_CONFIG[showInstances] si, $CC_CONFIG[showTable] show" ." WHERE st.playlist_id = pt.id" ." AND st.file_id = ft.id" - ." AND st.group_id = ss.group_id" - ." AND ss.show_id = show.id"; + ." AND st.instance_id = si.id" + ." AND si.show_id = show.id"; if ($timePeriod < 0){ $sql .= " AND st.ends < TIMESTAMP '$timeNow'" @@ -509,49 +509,6 @@ class Schedule { return $rows; } - /* - public static function GetPreviousItems($timeNow, $prevCount = 1, $prevInterval="24 hours"){ - global $CC_CONFIG, $CC_DBC; - $sql = "SELECT pt.name, ft.track_title, ft.artist_name, ft.album_title, st.starts, st.ends, st.clip_length, st.group_id" - ." FROM $CC_CONFIG[scheduleTable] st, $CC_CONFIG[filesTable] ft, $CC_CONFIG[playListTable] pt" - ." WHERE st.ends < TIMESTAMP '$timeNow'" - ." AND st.ends > (TIMESTAMP '$timeNow' - INTERVAL '$prevInterval')" - ." AND st.playlist_id = pt.id" - ." AND st.file_id = ft.id" - ." ORDER BY st.starts DESC" - ." LIMIT $prevCount"; - $rows = $CC_DBC->GetAll($sql); - return $rows; - } - - public static function GetCurrentlyPlaying($timeNow){ - global $CC_CONFIG, $CC_DBC; - - $sql = "SELECT pt.name, ft.track_title, ft.artist_name, ft.album_title, st.starts, st.ends, st.clip_length, st.group_id" - ." FROM $CC_CONFIG[scheduleTable] st," - ."$CC_CONFIG[filesTable] ft, $CC_CONFIG[playListTable] pt" - ." WHERE st.starts < TIMESTAMP '$timeNow'" - ." AND st.ends > TIMESTAMP '$timeNow'" - ." AND st.playlist_id = pt.id" - ." AND st.file_id = ft.id"; - $rows = $CC_DBC->GetAll($sql); - return $rows; - } - - public static function GetNextItems($timeNow, $nextCount = 1) { - global $CC_CONFIG, $CC_DBC; - $sql = "SELECT pt.name, ft.track_title, ft.artist_name, ft.album_title, st.starts, st.ends, st.clip_length, st.group_id" - ." FROM $CC_CONFIG[scheduleTable] st, $CC_CONFIG[filesTable] ft, $CC_CONFIG[playListTable] pt" - ." WHERE st.starts > TIMESTAMP '$timeNow'" - ." AND st.ends < (TIMESTAMP '$timeNow' + INTERVAL '7 days')" - ." AND st.playlist_id = pt.id" - ." AND st.file_id = ft.id" - ." ORDER BY st.starts" - ." LIMIT $nextCount"; - $rows = $CC_DBC->GetAll($sql); - return $rows; - } -*/ public static function GetCurrentShow($timeNow) { global $CC_CONFIG, $CC_DBC; @@ -559,13 +516,11 @@ class Schedule { $date = $timestamp[0]; $time = $timestamp[1]; - $sql = "SELECT current_date + sd.start_time as start_timestamp, current_date + sd.end_time as end_timestamp, s.name, s.id" - ." FROM $CC_CONFIG[showDays] sd, $CC_CONFIG[showTable] s" - ." WHERE sd.show_id = s.id" - ." AND sd.first_show <= DATE '$date'" - ." AND sd.start_time <= TIME '$time'" - ." AND sd.last_show > DATE '$date'" - ." AND sd.end_time > TIME '$time'"; + $sql = "SELECT si.starts as start_timestamp, si.ends as end_timestamp, s.name, s.id" + ." FROM $CC_CONFIG[showInstances] si, $CC_CONFIG[showTable] s" + ." WHERE si.show_id = s.id" + ." AND si.starts <= TIMESTAMP '$timeNow'" + ." AND si.ends > TIMESTAMP '$timeNow'"; $rows = $CC_DBC->GetAll($sql); return $rows; @@ -574,15 +529,12 @@ class Schedule { public static function GetNextShow($timeNow) { global $CC_CONFIG, $CC_DBC; - $datetime = explode(" ", $timeNow); - - $sql = "SELECT *, (current_date + start_time) as start_timestamp, (current_date + end_time) as end_timestamp FROM " - ." $CC_CONFIG[showDays] sd, $CC_CONFIG[showTable] s" - ." WHERE sd.show_id = s.id" - ." AND ((sd.last_show + sd.end_time) > TIMESTAMP '$timeNow' OR sd.last_show = NULL)" - ." AND TIME '$datetime[1]' < sd.start_time " - ." AND sd.day = EXTRACT(DOW FROM TIMESTAMP '$timeNow')" - ." ORDER BY sd.start_time" + $sql = "SELECT *, si.starts as start_timestamp, si.ends as end_timestamp FROM " + ." $CC_CONFIG[showInstances] si, $CC_CONFIG[showTable] s" + ." WHERE si.show_id = s.id" + ." AND si.starts > TIMESTAMP '$timeNow'" + ." AND si.starts < TIMESTAMP '$timeNow' + INTERVAL '48 hours'" + ." ORDER BY si.starts" ." LIMIT 1"; $rows = $CC_DBC->GetAll($sql);