CC-5727 : History search range using incorrect timezone offset (also Nowplaying)
sending the timestamp string back for nowplaying as well. added error class to history page if end is < start.
This commit is contained in:
parent
1854d76f03
commit
8d2926aeed
|
@ -235,24 +235,61 @@ class ShowbuilderController extends Zend_Controller_Action
|
||||||
|
|
||||||
$this->view->dialog = $this->view->render('showbuilder/builderDialog.phtml');
|
$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()
|
public function checkBuilderFeedAction()
|
||||||
{
|
{
|
||||||
$request = $this->getRequest();
|
$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));
|
|
||||||
$show_filter = intval($request->getParam("showFilter", 0));
|
$show_filter = intval($request->getParam("showFilter", 0));
|
||||||
$my_shows = intval($request->getParam("myShows", 0));
|
$my_shows = intval($request->getParam("myShows", 0));
|
||||||
$timestamp = intval($request->getParam("timestamp", -1));
|
$timestamp = intval($request->getParam("timestamp", -1));
|
||||||
$instances = $request->getParam("instances", array());
|
$instances = $request->getParam("instances", array());
|
||||||
|
|
||||||
$startsDT = DateTime::createFromFormat("U", $starts_epoch, new DateTimeZone("UTC"));
|
list($startsDT, $endsDT) = $this->getStartEnd();
|
||||||
$endsDT = DateTime::createFromFormat("U", $ends_epoch, new DateTimeZone("UTC"));
|
|
||||||
|
|
||||||
$opts = array("myShows" => $my_shows, "showFilter" => $show_filter);
|
$opts = array("myShows" => $my_shows, "showFilter" => $show_filter);
|
||||||
$showBuilder = new Application_Model_ShowBuilder($startsDT, $endsDT, $opts);
|
$showBuilder = new Application_Model_ShowBuilder($startsDT, $endsDT, $opts);
|
||||||
|
|
||||||
//only send the schedule back if updates have been made.
|
//only send the schedule back if updates have been made.
|
||||||
|
@ -263,18 +300,14 @@ class ShowbuilderController extends Zend_Controller_Action
|
||||||
|
|
||||||
public function builderFeedAction()
|
public function builderFeedAction()
|
||||||
{
|
{
|
||||||
$request = $this->getRequest();
|
$current_time = time();
|
||||||
$current_time = time();
|
|
||||||
|
$request = $this->getRequest();
|
||||||
$starts_epoch = $request->getParam("start", $current_time);
|
|
||||||
//default ends is 24 hours after starts.
|
|
||||||
$ends_epoch = $request->getParam("end", $current_time + (60*60*24));
|
|
||||||
$show_filter = intval($request->getParam("showFilter", 0));
|
$show_filter = intval($request->getParam("showFilter", 0));
|
||||||
$show_instance_filter = intval($request->getParam("showInstanceFilter", 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"));
|
list($startsDT, $endsDT) = $this->getStartEnd();
|
||||||
$endsDT = DateTime::createFromFormat("U", $ends_epoch, new DateTimeZone("UTC"));
|
|
||||||
|
|
||||||
$opts = array("myShows" => $my_shows,
|
$opts = array("myShows" => $my_shows,
|
||||||
"showFilter" => $show_filter,
|
"showFilter" => $show_filter,
|
||||||
|
|
|
@ -194,3 +194,7 @@
|
||||||
#history_content .ui-tabs .ui-tabs-panel {
|
#history_content .ui-tabs .ui-tabs-panel {
|
||||||
padding-top: 10px;
|
padding-top: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
div.his-timerange input.error {
|
||||||
|
background-color: rgba(255,0,0,0.2);
|
||||||
|
}
|
||||||
|
|
|
@ -60,6 +60,30 @@ var AIRTIME = (function(AIRTIME) {
|
||||||
oTableShow,
|
oTableShow,
|
||||||
inShowsTab = false;
|
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() {
|
function getSelectedLogItems() {
|
||||||
var items = Object.keys(selectedLogItems);
|
var items = Object.keys(selectedLogItems);
|
||||||
|
|
||||||
|
@ -545,7 +569,8 @@ var AIRTIME = (function(AIRTIME) {
|
||||||
dayNamesMin: i18n_days_short,
|
dayNamesMin: i18n_days_short,
|
||||||
onSelect: function(sDate, oDatePicker) {
|
onSelect: function(sDate, oDatePicker) {
|
||||||
$(this).datepicker( "setDate", sDate );
|
$(this).datepicker( "setDate", sDate );
|
||||||
}
|
},
|
||||||
|
onClose: validateTimeRange
|
||||||
};
|
};
|
||||||
|
|
||||||
oBaseTimePickerSettings = {
|
oBaseTimePickerSettings = {
|
||||||
|
@ -555,13 +580,25 @@ var AIRTIME = (function(AIRTIME) {
|
||||||
showLeadingZero: false,
|
showLeadingZero: false,
|
||||||
defaultTime: '0:00',
|
defaultTime: '0:00',
|
||||||
hourText: $.i18n._("Hour"),
|
hourText: $.i18n._("Hour"),
|
||||||
minuteText: $.i18n._("Minute")
|
minuteText: $.i18n._("Minute"),
|
||||||
|
onClose: validateTimeRange
|
||||||
};
|
};
|
||||||
|
|
||||||
$historyContentDiv.find(dateStartId).datepicker(oBaseDatePickerSettings);
|
$historyContentDiv.find(dateStartId)
|
||||||
$historyContentDiv.find(timeStartId).timepicker(oBaseTimePickerSettings);
|
.datepicker(oBaseDatePickerSettings)
|
||||||
$historyContentDiv.find(dateEndId).datepicker(oBaseDatePickerSettings);
|
.blur(validateTimeRange);
|
||||||
$historyContentDiv.find(timeEndId).timepicker(oBaseTimePickerSettings);
|
|
||||||
|
$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) {
|
$historyContentDiv.on("click", "#his_create", function(e) {
|
||||||
var url = baseUrl+"playouthistory/edit-list-item/format/json" ;
|
var url = baseUrl+"playouthistory/edit-list-item/format/json" ;
|
||||||
|
@ -711,35 +748,9 @@ var AIRTIME = (function(AIRTIME) {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
function getStartEnd() {
|
function getStartEnd() {
|
||||||
var start,
|
|
||||||
end,
|
|
||||||
time;
|
|
||||||
|
|
||||||
start = $(dateStartId).val();
|
return AIRTIME.utilities.fnGetScheduleRange(dateStartId, timeStartId, dateEndId, timeEndId);
|
||||||
start = start === "" ? null : start;
|
|
||||||
|
|
||||||
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: start,
|
|
||||||
end: end
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$historyContentDiv.find("#his_submit").click(function(ev){
|
$historyContentDiv.find("#his_submit").click(function(ev){
|
||||||
|
|
|
@ -46,7 +46,8 @@ AIRTIME = (function(AIRTIME) {
|
||||||
showLeadingZero: false,
|
showLeadingZero: false,
|
||||||
defaultTime: '0:00',
|
defaultTime: '0:00',
|
||||||
hourText: $.i18n._("Hour"),
|
hourText: $.i18n._("Hour"),
|
||||||
minuteText: $.i18n._("Minute")
|
minuteText: $.i18n._("Minute"),
|
||||||
|
onClose: validateTimeRange
|
||||||
};
|
};
|
||||||
|
|
||||||
function setWidgetSize() {
|
function setWidgetSize() {
|
||||||
|
|
|
@ -90,20 +90,34 @@ var AIRTIME = (function(AIRTIME){
|
||||||
*
|
*
|
||||||
* @return Object {"start", "end", "range"}
|
* @return Object {"start", "end", "range"}
|
||||||
*/
|
*/
|
||||||
mod.fnGetScheduleRange = function(dateStart, timeStart, dateEnd, timeEnd) {
|
mod.fnGetScheduleRange = function(dateStartId, timeStartId, dateEndId, timeEndId) {
|
||||||
var iStart,
|
var start,
|
||||||
iEnd,
|
end,
|
||||||
iRange;
|
time;
|
||||||
|
|
||||||
iStart = AIRTIME.utilities.fnGetTimestamp(dateStart, timeStart);
|
start = $(dateStartId).val();
|
||||||
iEnd = AIRTIME.utilities.fnGetTimestamp(dateEnd, timeEnd);
|
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 {
|
return {
|
||||||
start: iStart,
|
start: start,
|
||||||
end: iEnd,
|
end: end
|
||||||
range: iRange
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue