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

This commit is contained in:
drigato 2014-03-10 17:42:12 -04:00
commit 725b5da154
2 changed files with 99 additions and 37 deletions

View File

@ -82,20 +82,58 @@ class PlayouthistoryController extends Zend_Controller_Action
$user = Application_Model_User::getCurrentUser();
$this->view->userType = $user->getType();
}
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 fileHistoryFeedAction()
{
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 +152,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 +176,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

@ -401,13 +401,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 +459,9 @@ var AIRTIME = (function(AIRTIME) {
},
always: function() {
inShowsTab = true;
showSummaryList();
var info = getStartEnd();
showSummaryList(info.start, info.end);
emptySelectedLogItems();
}
}
@ -710,18 +711,49 @@ var AIRTIME = (function(AIRTIME) {
});
});
function getStartEnd() {
var start,
end,
time;
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
};
}
$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();