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');
|
||||
}
|
||||
|
||||
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,
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
@ -545,7 +569,8 @@ var AIRTIME = (function(AIRTIME) {
|
|||
dayNamesMin: i18n_days_short,
|
||||
onSelect: function(sDate, oDatePicker) {
|
||||
$(this).datepicker( "setDate", sDate );
|
||||
}
|
||||
},
|
||||
onClose: validateTimeRange
|
||||
};
|
||||
|
||||
oBaseTimePickerSettings = {
|
||||
|
@ -555,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" ;
|
||||
|
@ -711,35 +748,9 @@ var AIRTIME = (function(AIRTIME) {
|
|||
});
|
||||
});
|
||||
|
||||
function getStartEnd() {
|
||||
var start,
|
||||
end,
|
||||
time;
|
||||
function getStartEnd() {
|
||||
|
||||
start = $(dateStartId).val();
|
||||
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
|
||||
};
|
||||
return AIRTIME.utilities.fnGetScheduleRange(dateStartId, timeStartId, dateEndId, timeEndId);
|
||||
}
|
||||
|
||||
$historyContentDiv.find("#his_submit").click(function(ev){
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -90,20 +90,34 @@ var AIRTIME = (function(AIRTIME){
|
|||
*
|
||||
* @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
|
||||
};
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue