Merge branch '2.5.x' of github.com:sourcefabric/Airtime into 2.5.x

This commit is contained in:
Albert Santoni 2014-03-11 18:28:47 -04:00
commit 2cf9c5ca1b
12 changed files with 516 additions and 210 deletions

View File

@ -9,6 +9,49 @@ class ListenerstatController extends Zend_Controller_Action
->addActionContext('get-data', 'json')
->initContext();
}
private function getStartEnd()
{
$request = $this->getRequest();
$userTimezone = new DateTimeZone(Application_Model_Preference::GetUserTimezone());
$utcTimezone = new DateTimeZone("UTC");
$utcNow = new DateTime("now", $utcTimezone);
$start = $request->getParam("start");
$end = $request->getParam("end");
if (empty($start) || empty($end)) {
$startsDT = clone $utcNow;
$startsDT->sub(new DateInterval("P1D"));
$endsDT = clone $utcNow;
}
else {
try {
$startsDT = new DateTime($start, $userTimezone);
$startsDT->setTimezone($utcTimezone);
$endsDT = new DateTime($end, $userTimezone);
$endsDT->setTimezone($utcTimezone);
if ($startsDT > $endsDT) {
throw new Exception("start greater than end");
}
}
catch (Exception $e) {
Logging::info($e);
Logging::info($e->getMessage());
$startsDT = clone $utcNow;
$startsDT->sub(new DateInterval("P1D"));
$endsDT = clone $utcNow;
}
}
return array($startsDT, $endsDT);
}
public function indexAction()
{
@ -26,25 +69,17 @@ class ListenerstatController extends Zend_Controller_Action
$this->view->headLink()->appendStylesheet($baseUrl.'css/jquery.ui.timepicker.css?'.$CC_CONFIG['airtime_version']);
//default time is the last 24 hours.
$now = time();
$from = $request->getParam("from", $now - (24*60*60));
$to = $request->getParam("to", $now);
$utcTimezone = new DateTimeZone("UTC");
$displayTimeZone = new DateTimeZone(Application_Model_Preference::GetTimezone());
$start = DateTime::createFromFormat("U", $from, $utcTimezone);
$start->setTimezone($displayTimeZone);
$end = DateTime::createFromFormat("U", $to, $utcTimezone);
$end->setTimezone($displayTimeZone);
list($startsDT, $endsDT) = $this->getStartEnd();
$userTimezone = new DateTimeZone(Application_Model_Preference::GetUserTimezone());
$startsDT->setTimezone($userTimezone);
$endsDT->setTimezone($userTimezone);
$form = new Application_Form_DateRange();
$form->populate(array(
'his_date_start' => $start->format("Y-m-d"),
'his_time_start' => $start->format("H:i"),
'his_date_end' => $end->format("Y-m-d"),
'his_time_end' => $end->format("H:i")
'his_date_start' => $startsDT->format("Y-m-d"),
'his_time_start' => $startsDT->format("H:i"),
'his_date_end' => $endsDT->format("Y-m-d"),
'his_time_end' => $endsDT->format("H:i")
));
$errorStatus = Application_Model_StreamSetting::GetAllListenerStatErrors();
@ -63,17 +98,8 @@ class ListenerstatController extends Zend_Controller_Action
}
public function getDataAction(){
$request = $this->getRequest();
$current_time = time();
$params = $request->getParams();
$starts_epoch = $request->getParam("startTimestamp", $current_time - (60*60*24));
$ends_epoch = $request->getParam("endTimestamp", $current_time);
$startsDT = DateTime::createFromFormat("U", $starts_epoch, new DateTimeZone("UTC"));
$endsDT = DateTime::createFromFormat("U", $ends_epoch, new DateTimeZone("UTC"));
list($startsDT, $endsDT) = $this->getStartEnd();
$data = Application_Model_ListenerStat::getDataPointsWithinRange($startsDT->format("Y-m-d H:i:s"), $endsDT->format("Y-m-d H:i:s"));
$this->_helper->json->sendJson($data);
}

View File

@ -17,35 +17,68 @@ class PlayouthistoryController extends Zend_Controller_Action
->addActionContext('update-list-item', 'json')
->addActionContext('update-file-item', 'json')
->initContext();
}
}
private function getStartEnd()
{
$request = $this->getRequest();
$userTimezone = new DateTimeZone(Application_Model_Preference::GetUserTimezone());
$utcTimezone = new DateTimeZone("UTC");
$utcNow = new DateTime("now", $utcTimezone);
$start = $request->getParam("start");
$end = $request->getParam("end");
if (empty($start) || empty($end)) {
$startsDT = clone $utcNow;
$startsDT->sub(new DateInterval("P1D"));
$endsDT = clone $utcNow;
}
else {
try {
$startsDT = new DateTime($start, $userTimezone);
$startsDT->setTimezone($utcTimezone);
$endsDT = new DateTime($end, $userTimezone);
$endsDT->setTimezone($utcTimezone);
if ($startsDT > $endsDT) {
throw new Exception("start greater than end");
}
}
catch (Exception $e) {
Logging::info($e);
Logging::info($e->getMessage());
$startsDT = clone $utcNow;
$startsDT->sub(new DateInterval("P1D"));
$endsDT = clone $utcNow;
}
}
return array($startsDT, $endsDT);
}
public function indexAction()
{
$CC_CONFIG = Config::getConfig();
$request = $this->getRequest();
$baseUrl = Application_Common_OsPath::getBaseDir();
//default time is the last 24 hours.
$now = time();
$from = $request->getParam("from", $now - (24*60*60));
$to = $request->getParam("to", $now);
$utcTimezone = new DateTimeZone("UTC");
$displayTimeZone = new DateTimeZone(Application_Model_Preference::GetTimezone());
$start = DateTime::createFromFormat("U", $from, $utcTimezone);
$start->setTimezone($displayTimeZone);
$end = DateTime::createFromFormat("U", $to, $utcTimezone);
$end->setTimezone($displayTimeZone);
list($startsDT, $endsDT) = $this->getStartEnd();
$userTimezone = new DateTimeZone(Application_Model_Preference::GetUserTimezone());
$startsDT->setTimezone($userTimezone);
$endsDT->setTimezone($userTimezone);
$form = new Application_Form_DateRange();
$form->populate(array(
'his_date_start' => $start->format("Y-m-d"),
'his_time_start' => $start->format("H:i"),
'his_date_end' => $end->format("Y-m-d"),
'his_time_end' => $end->format("H:i")
'his_date_start' => $startsDT->format("Y-m-d"),
'his_time_start' => $startsDT->format("H:i"),
'his_date_end' => $endsDT->format("Y-m-d"),
'his_time_end' => $endsDT->format("H:i")
));
$this->view->date_form = $form;
@ -87,15 +120,10 @@ class PlayouthistoryController extends Zend_Controller_Action
{
try {
$request = $this->getRequest();
$current_time = time();
$params = $request->getParams();
$starts_epoch = $request->getParam("start", $current_time - (60*60*24));
$ends_epoch = $request->getParam("end", $current_time);
$startsDT = DateTime::createFromFormat("U", $starts_epoch, new DateTimeZone("UTC"));
$endsDT = DateTime::createFromFormat("U", $ends_epoch, new DateTimeZone("UTC"));
$params = $request->getParams();
$instance = $request->getParam("instance_id", null);
list($startsDT, $endsDT) = $this->getStartEnd();
$historyService = new Application_Service_HistoryService();
$r = $historyService->getFileSummaryData($startsDT, $endsDT, $params);
@ -114,18 +142,12 @@ class PlayouthistoryController extends Zend_Controller_Action
public function itemHistoryFeedAction()
{
try {
$request = $this->getRequest();
$current_time = time();
$params = $request->getParams();
$starts_epoch = $request->getParam("start", $current_time - (60*60*24));
$ends_epoch = $request->getParam("end", $current_time);
$instance = $request->getParam("instance_id", null);
$startsDT = DateTime::createFromFormat("U", $starts_epoch, new DateTimeZone("UTC"));
$endsDT = DateTime::createFromFormat("U", $ends_epoch, new DateTimeZone("UTC"));
$request = $this->getRequest();
$params = $request->getParams();
$instance = $request->getParam("instance_id", null);
list($startsDT, $endsDT) = $this->getStartEnd();
$historyService = new Application_Service_HistoryService();
$r = $historyService->getPlayedItemData($startsDT, $endsDT, $params, $instance);
@ -144,12 +166,10 @@ class PlayouthistoryController extends Zend_Controller_Action
{
try {
$request = $this->getRequest();
$current_time = time();
$starts_epoch = $request->getParam("start", $current_time - (60*60*24));
$ends_epoch = $request->getParam("end", $current_time);
$startsDT = DateTime::createFromFormat("U", $starts_epoch, new DateTimeZone("UTC"));
$endsDT = DateTime::createFromFormat("U", $ends_epoch, new DateTimeZone("UTC"));
$params = $request->getParams();
$instance = $request->getParam("instance_id", null);
list($startsDT, $endsDT) = $this->getStartEnd();
$historyService = new Application_Service_HistoryService();
$shows = $historyService->getShowList($startsDT, $endsDT);

View File

@ -235,24 +235,61 @@ class ShowbuilderController extends Zend_Controller_Action
$this->view->dialog = $this->view->render('showbuilder/builderDialog.phtml');
}
private function getStartEnd()
{
$request = $this->getRequest();
$userTimezone = new DateTimeZone(Application_Model_Preference::GetUserTimezone());
$utcTimezone = new DateTimeZone("UTC");
$utcNow = new DateTime("now", $utcTimezone);
$start = $request->getParam("start");
$end = $request->getParam("end");
if (empty($start) || empty($end)) {
$startsDT = clone $utcNow;
$startsDT->sub(new DateInterval("P1D"));
$endsDT = clone $utcNow;
}
else {
try {
$startsDT = new DateTime($start, $userTimezone);
$startsDT->setTimezone($utcTimezone);
$endsDT = new DateTime($end, $userTimezone);
$endsDT->setTimezone($utcTimezone);
if ($startsDT > $endsDT) {
throw new Exception("start greater than end");
}
}
catch (Exception $e) {
Logging::info($e);
Logging::info($e->getMessage());
$startsDT = clone $utcNow;
$startsDT->sub(new DateInterval("P1D"));
$endsDT = clone $utcNow;
}
}
return array($startsDT, $endsDT);
}
public function checkBuilderFeedAction()
{
$request = $this->getRequest();
$current_time = time();
$starts_epoch = $request->getParam("start", $current_time);
//default ends is 24 hours after starts.
$ends_epoch = $request->getParam("end", $current_time + (60*60*24));
$request = $this->getRequest();
$show_filter = intval($request->getParam("showFilter", 0));
$my_shows = intval($request->getParam("myShows", 0));
$timestamp = intval($request->getParam("timestamp", -1));
$instances = $request->getParam("instances", array());
$my_shows = intval($request->getParam("myShows", 0));
$timestamp = intval($request->getParam("timestamp", -1));
$instances = $request->getParam("instances", array());
$startsDT = DateTime::createFromFormat("U", $starts_epoch, new DateTimeZone("UTC"));
$endsDT = DateTime::createFromFormat("U", $ends_epoch, new DateTimeZone("UTC"));
list($startsDT, $endsDT) = $this->getStartEnd();
$opts = array("myShows" => $my_shows, "showFilter" => $show_filter);
$opts = array("myShows" => $my_shows, "showFilter" => $show_filter);
$showBuilder = new Application_Model_ShowBuilder($startsDT, $endsDT, $opts);
//only send the schedule back if updates have been made.
@ -263,18 +300,14 @@ class ShowbuilderController extends Zend_Controller_Action
public function builderFeedAction()
{
$request = $this->getRequest();
$current_time = time();
$starts_epoch = $request->getParam("start", $current_time);
//default ends is 24 hours after starts.
$ends_epoch = $request->getParam("end", $current_time + (60*60*24));
$current_time = time();
$request = $this->getRequest();
$show_filter = intval($request->getParam("showFilter", 0));
$show_instance_filter = intval($request->getParam("showInstanceFilter", 0));
$my_shows = intval($request->getParam("myShows", 0));
$my_shows = intval($request->getParam("myShows", 0));
$startsDT = DateTime::createFromFormat("U", $starts_epoch, new DateTimeZone("UTC"));
$endsDT = DateTime::createFromFormat("U", $ends_epoch, new DateTimeZone("UTC"));
list($startsDT, $endsDT) = $this->getStartEnd();
$opts = array("myShows" => $my_shows,
"showFilter" => $show_filter,

View File

@ -590,15 +590,14 @@ class Application_Model_Scheduler
* to that show
*/
if ($linked) {
$instance_sql = "SELECT * FROM cc_show_instances ".
"WHERE show_id = ".$ccShow["id"];
$instances = Application_Common_Database::prepareAndExecute(
$instance_sql);
$instances = CcShowInstancesQuery::create()
->filterByDbShowId($ccShow["id"])
->filterByDbStarts(gmdate("Y-m-d H:i:s"), Criteria::GREATER_THAN)
->find();
} else {
$instance_sql = "SELECT * FROM cc_show_instances ".
"WHERE id = ".$schedule["instance"];
$instances = Application_Common_Database::prepareAndExecute(
$instance_sql);
$instances = CcShowInstancesQuery::create()
->filterByDbId($schedule["instance"])
->find();
}
$excludePositions = array();
@ -606,7 +605,8 @@ class Application_Model_Scheduler
//reset
$this->applyCrossfades = true;
$instanceId = $instance["id"];
//$instanceId = $instance["id"];
$instanceId = $instance->getDbId();
if ($id !== 0) {
/* We use the selected cursor's position to find the same
* positions in every other linked instance
@ -632,7 +632,7 @@ class Application_Model_Scheduler
//show instance has no scheduled tracks
if (empty($pos)) {
$pos = 0;
$nextStartDT = new DateTime($instance["starts"], new DateTimeZone("UTC"));
$nextStartDT = new DateTime($instance->getDbStarts(), new DateTimeZone("UTC"));
} else {
$linkedItem_sql = "SELECT ends FROM cc_schedule ".
@ -658,7 +658,7 @@ class Application_Model_Scheduler
}
//selected empty row to add after
else {
$showStartDT = new DateTime($instance["starts"], new DateTimeZone("UTC"));
$showStartDT = new DateTime($instance->getDbStarts(), new DateTimeZone("UTC"));
$nextStartDT = $this->findNextStartTime($showStartDT, $instanceId);
//first item in show so start position counter at 0

View File

@ -20,6 +20,7 @@ class Application_Service_ShowService
private $localShowStartHour;
private $localShowStartMin;
private $origCcShowDay;
private $origShowRepeatStatus;
private $instanceIdsForScheduleUpdates;
public function __construct($showId=null, $showData=null, $isUpdate=false)
@ -158,8 +159,10 @@ class Application_Service_ShowService
{
if ($this->ccShow->isRepeating()) {
$this->origCcShowDay = clone $this->ccShow->getFirstRepeatingCcShowDay();
$this->origShowRepeatStatus = true;
} else {
$this->origCcShowDay = clone $this->ccShow->getFirstCcShowDay();
$this->origShowRepeatStatus = false;
}
$this->oldShowTimezone = $this->origCcShowDay->getDbTimezone();
@ -183,6 +186,7 @@ class Application_Service_ShowService
if (!$currentUser->isAdminOrPM()) {
throw new Exception("Permission denied");
}
//update ccShow
$this->setCcShow($showData);
@ -220,12 +224,15 @@ class Application_Service_ShowService
$this->delegateInstanceCreation($daysAdded);
if ($this->isUpdate) {
/* Set the show's start date to the start date of the first instance.
* We need to do this so we get the correct time diff for
* updating show content. CC-5696
/* If the show is repeating and the start date changes we need
* to ignore that difference when re-calculating schedule start times.
* Otherwise it might calculate a difference of a week, for example.
*/
$showData["add_show_start_date"] = $this->ccShow->getFirstCcShowDay()->getDbFirstShow();
$showData["add_show_start_time"] = $this->ccShow->getFirstCcShowDay()->getDbStartTime();
if ($this->ccShow->isRepeating() &&
$this->origCcShowDay->getLocalStartDateAndTime()->format("Y-m-d") != $showData["add_show_start_date"]) {
$showData["add_show_start_date"] = $this->origCcShowDay->getLocalStartDateAndTime()->format("Y-m-d");
}
$this->adjustSchedule($showData);
}
@ -411,6 +418,13 @@ SQL;
':timestamp' => gmdate("Y-m-d H:i:s")), 'execute');
}
private function deleteAllShowDays($showId)
{
CcShowDaysQuery::create()
->filterByDbShowId($showId)
->delete();
}
/**
* TODO: This function is messy. Needs refactoring
*
@ -432,8 +446,14 @@ SQL;
//CcShowDay object
if ($this->ccShow->isRepeating()) {
$currentShowDay = $this->ccShow->getFirstRepeatingCcShowDay();
//all cc_show_days
$ccShowDays = $this->ccShow->getRepeatingCcShowDays();
} else {
$currentShowDay = $this->ccShow->getFirstCcShowDay();
//all cc_show_days
$ccShowDays = $this->ccShow->getCcShowDayss();
}
//new end date in the show's timezone (from the select box)
@ -442,6 +462,11 @@ SQL;
//repeat option was toggled
if ($showData['add_show_repeats'] != $currentShowDay->isRepeating()) {
$this->deleteAllRepeatInstances($currentShowDay, $showId);
if (!$showData["add_show_repeats"]) {
$this->deleteAllShowDays($showId);
}
//if repeat option was checked we need to treat the current show day
//as a new show day so the repeat instances get created properly
//in createWeeklyRepeatInstances()
@ -473,17 +498,13 @@ SQL;
//and the repeat type changed
if ($currentRepeatType != -1 && $this->repeatType != $currentRepeatType) {
$this->deleteAllInstances($showId);
$this->deleteAllShowDays($showId);
// when repeating by day of the month (1st, 2nd, etc.) we do not store the repeat week days
} elseif ($currentRepeatType != 2) {
//repeat type is the same, check if the days of the week are the same
$repeatingDaysChanged = false;
if ($this->ccShow->isRepeating()) {
$ccShowDays = $this->ccShow->getRepeatingCcShowDays();
} else {
$ccShowDays = $this->ccShow->getCcShowDayss();
}
$showDays = array();
foreach ($ccShowDays as $day) {
$showDays[] = $day->getDbDay();
@ -556,11 +577,14 @@ SQL;
private function preserveLinkedShowContent()
{
/* Get show content from any linekd instance. It doesn't
/* Get show content from any linked instance. It doesn't
* matter which instance since content is the same in all.
*/
$ccShowInstance = $this->ccShow->getCcShowInstancess()->getFirst();
if (!$ccShowInstance) {
return;
}
$ccSchedules = CcScheduleQuery::create()
->filterByDbInstanceId($ccShowInstance->getDbId())
->find();
@ -1508,8 +1532,12 @@ SQL;
if ($this->isUpdate) {
$showDay = CcShowDaysQuery::create()
->filterByDbShowId($showId)
->filterByDbRepeatType($showData['add_show_repeat_type'])
->filterByDbRepeatType($this->origCcShowDay->getDbRepeatType())
->findOne();
if (!$showDay) {
//repeat type changed so we have to create a new show_day rule
$showDay = new CcShowDays();
}
} else {
$showDay = new CcShowDays();
}
@ -1541,16 +1569,30 @@ SQL;
if (is_null($endDate) || $startDateTimeClone->getTimestamp() <= $endDateTime->getTimestamp()) {
if ($this->isUpdate) {
if ($this->origCcShowDay->getDbRepeatType() == 2 ||
$this->origCcShowDay->getDbRepeatType() == 3) {
$day = null;
} else if (!$this->origShowRepeatStatus) {
//keep current show day to use for updating cc_show_day rule
$keepDay = $day;
$day = $this->origCcShowDay->getDbDay();
}
$showDay = CcShowDaysQuery::create()
->filterByDbShowId($showId)
->filterByDbRepeatType($this->repeatType)
->filterByDbRepeatType($this->origCcShowDay->getDbRepeatType())
->filterByDbDay($day)
->findOne();
if (!$showDay) {
//if no show day object was found it is because a new
//repeating day of the week was added
//repeating day of the week was added OR the repeat
//type has changed
$showDay = new CcShowDays();
}
if (isset($keepDay)) {
$day = $keepDay;
}
} else {
$showDay = new CcShowDays();
}

View File

@ -194,3 +194,7 @@
#history_content .ui-tabs .ui-tabs-panel {
padding-top: 10px;
}
div.his-timerange input.error {
background-color: rgba(255,0,0,0.2);
}

View File

@ -14,15 +14,17 @@ $(document).ready(function() {
getDataAndPlot();
listenerstat_content.find("#his_submit").click(function(){
startTimestamp = AIRTIME.utilities.fnGetTimestamp(dateStartId, timeStartId);
endTimestamp = AIRTIME.utilities.fnGetTimestamp(dateEndId, timeEndId);
getDataAndPlot(startTimestamp, endTimestamp);
var oRange = AIRTIME.utilities.fnGetScheduleRange(dateStartId, timeStartId, dateEndId, timeEndId);
var start = oRange.start;
var end = oRange.end;
getDataAndPlot(start, end);
});
});
function getDataAndPlot(startTimestamp, endTimestamp){
// get data
$.get(baseUrl+'Listenerstat/get-data', {startTimestamp: startTimestamp, endTimestamp: endTimestamp}, function(data){
$.get(baseUrl+'Listenerstat/get-data', {start: startTimestamp, end: endTimestamp}, function(data){
out = new Object();
$.each(data, function(mpName, v){
plotData = new Object();

View File

@ -60,6 +60,30 @@ var AIRTIME = (function(AIRTIME) {
oTableShow,
inShowsTab = false;
function validateTimeRange() {
var oRange,
inputs = $('.his-timerange > input'),
start, end;
oRange = AIRTIME.utilities.fnGetScheduleRange(dateStartId, timeStartId, dateEndId, timeEndId);
start = oRange.start;
end = oRange.end;
if (end >= start) {
inputs.removeClass('error');
}
else {
inputs.addClass('error');
}
return {
start: start,
end: end,
isValid: end >= start
};
}
function getSelectedLogItems() {
var items = Object.keys(selectedLogItems);
@ -401,13 +425,12 @@ var AIRTIME = (function(AIRTIME) {
return oTable;
}
function showSummaryList() {
function showSummaryList(start, end) {
var url = baseUrl+"playouthistory/show-history-feed",
oRange = AIRTIME.utilities.fnGetScheduleRange(dateStartId, timeStartId, dateEndId, timeEndId),
data = {
format: "json",
start: oRange.start,
end: oRange.end
start: start,
end: end
};
$.post(url, data, function(json) {
@ -460,7 +483,9 @@ var AIRTIME = (function(AIRTIME) {
},
always: function() {
inShowsTab = true;
showSummaryList();
var info = getStartEnd();
showSummaryList(info.start, info.end);
emptySelectedLogItems();
}
}
@ -544,7 +569,8 @@ var AIRTIME = (function(AIRTIME) {
dayNamesMin: i18n_days_short,
onSelect: function(sDate, oDatePicker) {
$(this).datepicker( "setDate", sDate );
}
},
onClose: validateTimeRange
};
oBaseTimePickerSettings = {
@ -554,13 +580,25 @@ var AIRTIME = (function(AIRTIME) {
showLeadingZero: false,
defaultTime: '0:00',
hourText: $.i18n._("Hour"),
minuteText: $.i18n._("Minute")
minuteText: $.i18n._("Minute"),
onClose: validateTimeRange
};
$historyContentDiv.find(dateStartId).datepicker(oBaseDatePickerSettings);
$historyContentDiv.find(timeStartId).timepicker(oBaseTimePickerSettings);
$historyContentDiv.find(dateEndId).datepicker(oBaseDatePickerSettings);
$historyContentDiv.find(timeEndId).timepicker(oBaseTimePickerSettings);
$historyContentDiv.find(dateStartId)
.datepicker(oBaseDatePickerSettings)
.blur(validateTimeRange);
$historyContentDiv.find(timeStartId)
.timepicker(oBaseTimePickerSettings)
.blur(validateTimeRange);
$historyContentDiv.find(dateEndId)
.datepicker(oBaseDatePickerSettings)
.blur(validateTimeRange);
$historyContentDiv.find(timeEndId)
.timepicker(oBaseTimePickerSettings)
.blur(validateTimeRange);
$historyContentDiv.on("click", "#his_create", function(e) {
var url = baseUrl+"playouthistory/edit-list-item/format/json" ;
@ -665,17 +703,16 @@ var AIRTIME = (function(AIRTIME) {
});
$('body').on("click", "#his_instance_retrieve", function(e) {
var startPicker = $hisDialogEl.find('#his_item_starts_datetimepicker').data('datetimepicker'),
endPicker = $hisDialogEl.find('#his_item_ends_datetimepicker').data('datetimepicker'),
var startPicker = $hisDialogEl.find('#his_item_starts'),
endPicker = $hisDialogEl.find('#his_item_ends'),
url = baseUrl+"playouthistory/show-history-feed",
startDate = startPicker.getLocalDate(),
endDate = endPicker.getLocalDate(),
getEpochSeconds = AIRTIME.utilities.fnGetSecondsEpoch,
startDate = startPicker.val(),
endDate = endPicker.val(),
data;
data = {
start: getEpochSeconds(startDate),
end: getEpochSeconds(endDate),
start: startDate,
end: endDate,
format: "json"
};
@ -710,18 +747,23 @@ var AIRTIME = (function(AIRTIME) {
});
});
function getStartEnd() {
return AIRTIME.utilities.fnGetScheduleRange(dateStartId, timeStartId, dateEndId, timeEndId);
}
$historyContentDiv.find("#his_submit").click(function(ev){
var fn,
oRange;
info;
oRange = AIRTIME.utilities.fnGetScheduleRange(dateStartId, timeStartId, dateEndId, timeEndId);
info = getStartEnd();
fn = fnServerData;
fn.start = oRange.start;
fn.end = oRange.end;
fn.start = info.start;
fn.end = info.end;
if (inShowsTab) {
showSummaryList();
showSummaryList(info.start, info.end);
}
else {
redrawTables();

View File

@ -46,7 +46,8 @@ AIRTIME = (function(AIRTIME) {
showLeadingZero: false,
defaultTime: '0:00',
hourText: $.i18n._("Hour"),
minuteText: $.i18n._("Minute")
minuteText: $.i18n._("Minute"),
onClose: validateTimeRange
};
function setWidgetSize() {

View File

@ -35,75 +35,39 @@ var AIRTIME = (function(AIRTIME){
};
};
mod.fnGetSecondsEpoch = function(oDate) {
var iTime,
iUserOffset,
iClientOffset;
iTime = oDate.getTime(); //value is in millisec.
iTime = Math.round(iTime / 1000);
iUserOffset = userTimezoneOffset;
iClientOffset = oDate.getTimezoneOffset() * -60;//function returns minutes
//adjust for the fact the the Date object is in client time.
iTime = iTime + iClientOffset + iUserOffset;
return iTime;
};
/*
* Get the schedule range start in unix timestamp form (in seconds).
* defaults to NOW if nothing is selected.
*
* @param String sDatePickerId
*
* @param String sTimePickerId
*
* @return Number iTime
*/
mod.fnGetTimestamp = function(sDateId, sTimeId) {
var date,
time,
temp;
temp = $(sDateId).val();
if ( temp === "") {
return 0;
}
else {
date = temp;
}
time = $(sTimeId).val();
date = date.split("-");
time = time.split(":");
//0 based month in js.
oDate = new Date(date[0], date[1]-1, date[2], time[0], time[1]);
return mod.fnGetSecondsEpoch(oDate);
};
/*
* Returns an object containing a unix timestamp in seconds for the start/end range
*
* @return Object {"start", "end", "range"}
*/
mod.fnGetScheduleRange = function(dateStart, timeStart, dateEnd, timeEnd) {
var iStart,
iEnd,
iRange;
mod.fnGetScheduleRange = function(dateStartId, timeStartId, dateEndId, timeEndId) {
var start,
end,
time;
iStart = AIRTIME.utilities.fnGetTimestamp(dateStart, timeStart);
iEnd = AIRTIME.utilities.fnGetTimestamp(dateEnd, timeEnd);
start = $(dateStartId).val();
start = start === "" ? null : start;
iRange = iEnd - iStart;
time = $(timeStartId).val();
time = time === "" ? "00:00" : time;
if (start) {
start = start + " " + time;
}
end = $(dateEndId).val();
end = end === "" ? null : end;
time = $(timeEndId).val();
time = time === "" ? "00:00" : time;
if (end) {
end = end + " " + time;
}
return {
start: iStart,
end: iEnd,
range: iRange
start: start,
end: end
};
};

View File

@ -611,7 +611,7 @@ class ShowServiceDbTest extends Zend_Test_PHPUnit_DatabaseTestCase
$data = ShowServiceData::getWeeklyRepeatNoEndNoRRData();
$data["add_show_start_date"] = "2016-01-29";
$data["add_show_day_check"] = array(5);
$data["add_show_day_check"] = array(5, 6);
$data["add_show_linked"] = 1;
$showService = new Application_Service_ShowService(null, $data);
$showService->addUpdateShow($data);
@ -661,4 +661,69 @@ class ShowServiceDbTest extends Zend_Test_PHPUnit_DatabaseTestCase
$ds
);
}
public function testChangeRepeatTypeFromWeeklyToNoRepeat()
{
TestHelper::loginUser();
//test change repeat type from weekly to no-repeat
$data = ShowServiceData::getWeeklyRepeatNoEndNoRRData();
$showService = new Application_Service_ShowService(null, $data);
$showService->addUpdateShow($data);
$data["add_show_repeats"] = 0;
$data["add_show_id"] = 1;
$showService = new Application_Service_ShowService(null, $data, true);
$showService->addUpdateShow($data);
$ds = new Zend_Test_PHPUnit_Db_DataSet_QueryDataSet(
$this->getConnection()
);
$ds->addTable('cc_show', 'select * from cc_show');
$ds->addTable('cc_show_days', 'select * from cc_show_days');
$ds->addTable('cc_show_instances', 'select id, starts, ends, show_id, record, rebroadcast, instance_id, modified_instance from cc_show_instances');
$ds->addTable('cc_show_rebroadcast', 'select * from cc_show_rebroadcast');
$ds->addTable('cc_show_hosts', 'select * from cc_show_hosts');
$this->assertDataSetsEqual(
$this->createXmlDataSet(dirname(__FILE__)."/datasets/test_createNoRepeatNoRRShow.xml"),
$ds
);
}
public function testChangeRepeatTypeFromWeeklyToBiWeekly()
{
TestHelper::loginUser();
//test change repeat type weekly to bi-weekly
$data = ShowServiceData::getWeeklyRepeatNoEndNoRRData();
$showService = new Application_Service_ShowService(null, $data);
$showService->addUpdateShow($data);
$data["add_show_id"] = 1;
$data["add_show_repeat_type"] = 1;
$showService = new Application_Service_ShowService(null, $data, true);
$showService->addUpdateShow($data);
$ds = new Zend_Test_PHPUnit_Db_DataSet_QueryDataSet(
$this->getConnection()
);
$ds->addTable('cc_show', 'select * from cc_show');
$ds->addTable('cc_show_days', 'select * from cc_show_days');
$ds->addTable('cc_show_instances', 'select id, starts, ends, show_id, record, rebroadcast, instance_id, modified_instance from cc_show_instances');
$ds->addTable('cc_show_rebroadcast', 'select * from cc_show_rebroadcast');
$ds->addTable('cc_show_hosts', 'select * from cc_show_hosts');
$this->assertDataSetsEqual(
$this->createXmlDataSet(dirname(__FILE__)."/datasets/test_weeklyToBiWeekly.xml"),
$ds
);
}
public function testChangeRepeatTypeFromMonthlyWeeklyToNoRepeat()
{
}
}

View File

@ -0,0 +1,107 @@
<?xml version="1.0" ?>
<dataset>
<table name="cc_show">
<column>id</column>
<column>name</column>
<column>url</column>
<column>genre</column>
<column>description</column>
<column>color</column>
<column>background_color</column>
<column>live_stream_using_airtime_auth</column>
<column>live_stream_using_custom_auth</column>
<column>live_stream_user</column>
<column>live_stream_pass</column>
<column>linked</column>
<column>is_linkable</column>
<row>
<value>1</value>
<value>test show</value>
<null />
<null />
<null />
<value>ffffff</value>
<value>364492</value>
<value></value>
<value></value>
<null />
<null />
<value></value>
<value>1</value>
</row>
</table>
<table name="cc_show_days">
<column>id</column>
<column>first_show</column>
<column>last_show</column>
<column>start_time</column>
<column>timezone</column>
<column>duration</column>
<column>day</column>
<column>repeat_type</column>
<column>next_pop_date</column>
<column>show_id</column>
<column>record</column>
<row>
<value>2</value>
<value>2016-01-01</value>
<null />
<value>00:00:00</value>
<value>UTC</value>
<value>01:00</value>
<value>5</value>
<value>1</value>
<value>2016-02-12</value>
<value>1</value>
<value>0</value>
</row>
</table>
<table name="cc_show_instances">
<column>id</column>
<column>starts</column>
<column>ends</column>
<column>show_id</column>
<column>record</column>
<column>rebroadcast</column>
<column>instance_id</column>
<column>modified_instance</column>
<row>
<value>7</value>
<value>2016-01-01 00:00:00</value>
<value>2016-01-01 01:00:00</value>
<value>1</value>
<value>0</value>
<value>0</value>
<null />
<value></value>
</row>
<row>
<value>8</value>
<value>2016-01-15 00:00:00</value>
<value>2016-01-15 01:00:00</value>
<value>1</value>
<value>0</value>
<value>0</value>
<null />
<value></value>
</row>
<row>
<value>9</value>
<value>2016-01-29 00:00:00</value>
<value>2016-01-29 01:00:00</value>
<value>1</value>
<value>0</value>
<value>0</value>
<null />
<value></value>
</row>
</table>
<table name="cc_show_rebroadcast">
</table>
<table name="cc_show_hosts">
</table>
</dataset>