diff --git a/airtime_mvc/application/models/LiveLog.php b/airtime_mvc/application/models/LiveLog.php index dc3090239..b641ef6ef 100644 --- a/airtime_mvc/application/models/LiveLog.php +++ b/airtime_mvc/application/models/LiveLog.php @@ -237,8 +237,9 @@ class Application_Model_LiveLog public static function SetNewLogTime($state, $dateTime){ try { $con = Propel::getConnection(); - - if ($state == 'L') { + + $scheduled = Application_Model_Preference::GetSourceSwitchStatus('scheduled_play'); + if ($state == 'L' && $scheduled == 'on') { self::SetEndTime('S', $dateTime); } @@ -253,6 +254,10 @@ class Application_Model_LiveLog $sql_insert = "INSERT INTO CC_LIVE_LOG (state, start_time)" ." VALUES ('$state', '{$dateTime->format("Y-m-d H:i:s")}')"; $con->exec($sql_insert); + if($state == "S"){ + // if scheduled play source is getting broadcasted + Application_Model_Schedule::UpdateBrodcastedStatus($dateTime, 1); + } } } catch (Exception $e) { @@ -298,4 +303,4 @@ class Application_Model_LiveLog } } -} \ No newline at end of file +} diff --git a/airtime_mvc/application/models/PlayoutHistory.php b/airtime_mvc/application/models/PlayoutHistory.php index 8e453f2ba..a5e4b9fb1 100644 --- a/airtime_mvc/application/models/PlayoutHistory.php +++ b/airtime_mvc/application/models/PlayoutHistory.php @@ -66,7 +66,7 @@ class Application_Model_PlayoutHistory { select count(schedule.file_id) as played, schedule.file_id as file_id from cc_schedule as schedule where schedule.starts >= '{$start}' and schedule.starts < '{$end}' - and schedule.playout_status > 0 and schedule.media_item_played != FALSE + and schedule.playout_status > 0 and schedule.media_item_played != FALSE and schedule.broadcasted = 1 group by schedule.file_id ) AS playout left join cc_files as file on (file.id = playout.file_id)"; diff --git a/airtime_mvc/application/models/Preference.php b/airtime_mvc/application/models/Preference.php index 2505a563f..369315f58 100644 --- a/airtime_mvc/application/models/Preference.php +++ b/airtime_mvc/application/models/Preference.php @@ -412,7 +412,13 @@ class Application_Model_Preference $key == 'FREE_RAM' || $key == 'AIRTIME_VERSION' || $key == 'KERNAL_VERSION' || $key == 'MACHINE_ARCHITECTURE' || $key == 'TOTAL_MEMORY_MBYTES' || $key == 'TOTAL_SWAP_MBYTES' || $key == 'PLAYOUT_ENGINE_CPU_PERC' ) { - $systemInfoArray[$key] = $info[1]; + if($key == 'AIRTIME_VERSION'){ + // remove hash tag on the version string + list($version, $dump) = explode('+', $info[1]); + $systemInfoArray[$key] = $version; + }else{ + $systemInfoArray[$key] = $info[1]; + } } } } diff --git a/airtime_mvc/application/models/Schedule.php b/airtime_mvc/application/models/Schedule.php index 931eeab2b..05b527ee0 100644 --- a/airtime_mvc/application/models/Schedule.php +++ b/airtime_mvc/application/models/Schedule.php @@ -291,8 +291,30 @@ class Application_Model_Schedule { global $CC_CONFIG; $con = Propel::getConnection(); $sql = "UPDATE ".$CC_CONFIG['scheduleTable'] - ." SET media_item_played=TRUE" - ." WHERE id=$p_id"; + ." SET media_item_played=TRUE"; + // we need to update 'broadcasted' column as well + // check the current switch status + $live_dj = Application_Model_Preference::GetSourceSwitchStatus('live_dj') == 'on'?true:false; + $master_dj = Application_Model_Preference::GetSourceSwitchStatus('master_dj') == 'on'?true:false; + $scheduled_play = Application_Model_Preference::GetSourceSwitchStatus('scheduled_play') == 'on'?true:false; + + if(!$live_dj && !$master_dj && $scheduled_play){ + $sql .= ", broadcasted=1"; + } + + $sql .= " WHERE id=$p_id"; + + $retVal = $con->exec($sql); + return $retVal; + } + + public static function UpdateBrodcastedStatus($dateTime, $value){ + global $CC_CONFIG; + $con = Propel::getConnection(); + $now = $dateTime->format("Y-m-d H:i:s"); + $sql = "UPDATE ".$CC_CONFIG['scheduleTable'] + ." SET broadcasted=$value" + ." WHERE starts <= '$now' AND ends >= '$now'"; $retVal = $con->exec($sql); return $retVal; } diff --git a/airtime_mvc/application/models/Show.php b/airtime_mvc/application/models/Show.php index dc8c29026..2392cc81a 100644 --- a/airtime_mvc/application/models/Show.php +++ b/airtime_mvc/application/models/Show.php @@ -848,7 +848,7 @@ class Application_Model_Show { $showId = $this->getId(); $sql = "SELECT id FROM cc_show_instances" ." WHERE date(starts) = date(TIMESTAMP '$timestamp') " - ." AND show_id = $showId"; + ." AND show_id = $showId AND rebroadcast = 0"; $query = $con->query($sql); $row = ($query !== false) ? $query->fetchColumn(0) : null; @@ -1519,8 +1519,6 @@ class Application_Model_Show { $sql = $sql." AND ({$exclude})"; } - Logging::debug("getShows"); - Logging::debug($sql); $result = $con->query($sql)->fetchAll(); return $result; } diff --git a/airtime_mvc/public/js/airtime/dashboard/dashboard.js b/airtime_mvc/public/js/airtime/dashboard/dashboard.js index a09e909eb..44ea06970 100644 --- a/airtime_mvc/public/js/airtime/dashboard/dashboard.js +++ b/airtime_mvc/public/js/airtime/dashboard/dashboard.js @@ -76,7 +76,7 @@ function updateProgressBarValue(){ var scheduled_play_line_to_switch = scheduled_play_div.parent().find(".line-to-switch"); if (currentSong !== null){ - var songElpasedTime = 0; + var songElapsedTime = 0; songPercentDone = (estimatedSchedulePosixTime - currentSong.songStartPosixTime)/currentSong.songLengthMs*100; songElapsedTime = estimatedSchedulePosixTime - currentSong.songStartPosixTime; if (songPercentDone < 0 || songPercentDone > 100){ diff --git a/airtime_mvc/public/js/airtime/library/events/library_playlistbuilder.js b/airtime_mvc/public/js/airtime/library/events/library_playlistbuilder.js index 73dbd210d..249af5d55 100644 --- a/airtime_mvc/public/js/airtime/library/events/library_playlistbuilder.js +++ b/airtime_mvc/public/js/airtime/library/events/library_playlistbuilder.js @@ -48,14 +48,20 @@ var AIRTIME = (function(AIRTIME){ $('#library_display tr.lib-audio').draggable({ helper: function(){ - var selected = mod.getChosenAudioFilesLength(), + var $el = $(this), + selected = mod.getChosenAudioFilesLength(), container, message, li = $("#side_playlist ul li:first"), width = li.width(), height = li.height(); + + //dragging an element that has an unselected checkbox. + if (mod.isChosenItem($el) === false) { + selected++; + } - if (selected === 0 || selected === 1) { + if (selected === 1) { message = "Adding 1 Item."; } else { diff --git a/airtime_mvc/public/js/airtime/library/events/library_showbuilder.js b/airtime_mvc/public/js/airtime/library/events/library_showbuilder.js index 58e4b4453..7d841c56d 100644 --- a/airtime_mvc/public/js/airtime/library/events/library_showbuilder.js +++ b/airtime_mvc/public/js/airtime/library/events/library_showbuilder.js @@ -48,14 +48,20 @@ var AIRTIME = (function(AIRTIME){ $('#library_display tr.lib-audio, tr.lib-pl').draggable({ helper: function(){ - var selected = mod.getChosenItemsLength(), + var $el = $(this), + selected = mod.getChosenItemsLength(), container, thead = $("#show_builder_table thead"), colspan = thead.find("th").length, width = thead.find("tr:first").width(), message; - if (selected === 0 || selected === 1) { + //dragging an element that has an unselected checkbox. + if (mod.isChosenItem($el) === false) { + selected++; + } + + if (selected === 1) { message = "Adding 1 Item."; } else { diff --git a/airtime_mvc/public/js/airtime/library/library.js b/airtime_mvc/public/js/airtime/library/library.js index 401eb041e..c5e1b7495 100644 --- a/airtime_mvc/public/js/airtime/library/library.js +++ b/airtime_mvc/public/js/airtime/library/library.js @@ -98,6 +98,13 @@ var AIRTIME = (function(AIRTIME) { } }; + mod.isChosenItem = function($el) { + var id = $el.attr("id"), + item = chosenItems[id]; + + return item !== undefined ? true : false; + }; + mod.addToChosen = function($el) { var id = $el.attr("id"); diff --git a/airtime_mvc/public/js/airtime/showbuilder/builder.js b/airtime_mvc/public/js/airtime/showbuilder/builder.js index bab69b0f3..67ee70aee 100644 --- a/airtime_mvc/public/js/airtime/showbuilder/builder.js +++ b/airtime_mvc/public/js/airtime/showbuilder/builder.js @@ -2,6 +2,8 @@ var AIRTIME = (function(AIRTIME){ var mod, oSchedTable, SB_SELECTED_CLASS = "sb-selected", + CURSOR_SELECTED_CLASS = "cursor-selected-row", + NOW_PLAYING_CLASS = "sb-now-playing", $sbContent, $sbTable, $toolbar, @@ -79,7 +81,7 @@ var AIRTIME = (function(AIRTIME){ }; mod.checkJumpToCurrentButton = function() { - var $current = $sbTable.find(".sb-now-playing"); + var $current = $sbTable.find("."+NOW_PLAYING_CLASS); if ($current.length !== 0) { AIRTIME.button.enableButton("sb-button-current"); @@ -108,13 +110,32 @@ var AIRTIME = (function(AIRTIME){ mod.checkJumpToCurrentButton(); mod.checkCancelButton(); }; + + mod.selectCursor = function($el) { + + $el.addClass(CURSOR_SELECTED_CLASS); + mod.checkToolBarIcons(); + }; + + mod.removeCursor = function($el) { + + $el.removeClass(CURSOR_SELECTED_CLASS); + mod.checkToolBarIcons(); + }; - mod.getSelectedData = function() { + /* + * sNot is an optional string to filter selected elements by. (ex removing the currently playing item) + */ + mod.getSelectedData = function(sNot) { var $selected = $sbTable.find("tbody").find("input:checkbox").filter(":checked").parents("tr"), aData = [], i, length, $item; + if (sNot !== undefined) { + $selected = $selected.not("."+sNot); + } + for (i = 0, length = $selected.length; i < length; i++) { $item = $($selected.get(i)); aData.push($item.data('aData')); @@ -513,7 +534,7 @@ var AIRTIME = (function(AIRTIME){ $nRow.data({"aData": aData}); if (aData.scheduled === 1) { - $nRow.addClass("sb-now-playing"); + $nRow.addClass(NOW_PLAYING_CLASS); } else if (aData.scheduled === 0) { $nRow.addClass("sb-past"); @@ -618,7 +639,7 @@ var AIRTIME = (function(AIRTIME){ //order of importance of elements for setting the next timeout. elements = [ - $sbTable.find("tr.sb-now-playing"), + $sbTable.find("tr."+NOW_PLAYING_CLASS), $sbTable.find("tbody").find("tr.sb-future.sb-footer, tr.sb-future.sb-header").filter(":first") ]; @@ -776,7 +797,7 @@ var AIRTIME = (function(AIRTIME){ forcePlaceholderSize: true, distance: 10, helper: function(event, item) { - var selected = mod.getSelectedData(), + var selected = mod.getSelectedData(NOW_PLAYING_CLASS), thead = $("#show_builder_table thead"), colspan = thead.find("th").length, trfirst = thead.find("tr:first"), @@ -816,7 +837,17 @@ var AIRTIME = (function(AIRTIME){ receive: fnReceive, update: fnUpdate, start: function(event, ui) { - var elements = $sbTable.find('tr:not(:first) input:checked').parents('tr'); + /* + var elements = $sbTable.find('tr input:checked').parents('tr') + .not(ui.item) + .not("."+NOW_PLAYING_CLASS); + + //remove all other items from the screen, + //don't remove ui.item or else we can not get position information when the user drops later. + elements.remove(); + */ + + var elements = $sbTable.find('tr input:checked').parents('tr'); elements.hide(); } @@ -895,7 +926,7 @@ var AIRTIME = (function(AIRTIME){ var $scroll = $sbContent.find(".dataTables_scrolling"), scrolled = $scroll.scrollTop(), scrollingTop = $scroll.offset().top, - current = $sbTable.find(".sb-now-playing"), + current = $sbTable.find("."+NOW_PLAYING_CLASS), currentTop = current.offset().top; $scroll.scrollTop(currentTop - scrollingTop + scrolled); @@ -935,22 +966,20 @@ var AIRTIME = (function(AIRTIME){ //add events to cursors. $sbTable.find("tbody").on("click", "div.marker", function(event) { var $tr = $(this).parents("tr"), - cursorSelClass = "cursor-selected-row"; + $trs; - if ($tr.hasClass(cursorSelClass)) { - $tr.removeClass(cursorSelClass); + if ($tr.hasClass(CURSOR_SELECTED_CLASS)) { + mod.removeCursor($tr); } else { - $tr.addClass(cursorSelClass); + mod.selectCursor($tr); } if (event.ctrlKey === false) { - $sbTable.find('.'+cursorSelClass).not($tr) - .removeClass(cursorSelClass); + $trs = $sbTable.find('.'+CURSOR_SELECTED_CLASS).not($tr); + mod.removeCursor($trs); } - mod.checkToolBarIcons(); - return false; }); @@ -983,7 +1012,9 @@ var AIRTIME = (function(AIRTIME){ if (oItems.selCurs !== undefined) { callback = function() { - $(this).parents('tr').next().addClass(cursorClass); + var $tr = $(this).parents('tr').next(); + + mod.selectCursor($tr); }; oItems.selCurs.callback = callback; @@ -993,7 +1024,9 @@ var AIRTIME = (function(AIRTIME){ if (oItems.delCurs !== undefined) { callback = function() { - $(this).parents('tr').next().removeClass(cursorClass); + var $tr = $(this).parents('tr').next(); + + mod.removeCursor($tr); }; oItems.delCurs.callback = callback;