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(); $user = Application_Model_User::getCurrentUser();
$this->view->userType = $user->getType(); $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() public function fileHistoryFeedAction()
{ {
try { try {
$request = $this->getRequest(); $request = $this->getRequest();
$current_time = time(); $params = $request->getParams();
$instance = $request->getParam("instance_id", null);
$params = $request->getParams();
list($startsDT, $endsDT) = $this->getStartEnd();
$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"));
$historyService = new Application_Service_HistoryService(); $historyService = new Application_Service_HistoryService();
$r = $historyService->getFileSummaryData($startsDT, $endsDT, $params); $r = $historyService->getFileSummaryData($startsDT, $endsDT, $params);
@ -114,18 +152,12 @@ class PlayouthistoryController extends Zend_Controller_Action
public function itemHistoryFeedAction() public function itemHistoryFeedAction()
{ {
try { try {
$request = $this->getRequest(); $request = $this->getRequest();
$current_time = time(); $params = $request->getParams();
$instance = $request->getParam("instance_id", null);
$params = $request->getParams();
list($startsDT, $endsDT) = $this->getStartEnd();
$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"));
$historyService = new Application_Service_HistoryService(); $historyService = new Application_Service_HistoryService();
$r = $historyService->getPlayedItemData($startsDT, $endsDT, $params, $instance); $r = $historyService->getPlayedItemData($startsDT, $endsDT, $params, $instance);
@ -144,12 +176,10 @@ class PlayouthistoryController extends Zend_Controller_Action
{ {
try { try {
$request = $this->getRequest(); $request = $this->getRequest();
$current_time = time(); $params = $request->getParams();
$starts_epoch = $request->getParam("start", $current_time - (60*60*24)); $instance = $request->getParam("instance_id", null);
$ends_epoch = $request->getParam("end", $current_time);
list($startsDT, $endsDT) = $this->getStartEnd();
$startsDT = DateTime::createFromFormat("U", $starts_epoch, new DateTimeZone("UTC"));
$endsDT = DateTime::createFromFormat("U", $ends_epoch, new DateTimeZone("UTC"));
$historyService = new Application_Service_HistoryService(); $historyService = new Application_Service_HistoryService();
$shows = $historyService->getShowList($startsDT, $endsDT); $shows = $historyService->getShowList($startsDT, $endsDT);

View File

@ -401,13 +401,12 @@ var AIRTIME = (function(AIRTIME) {
return oTable; return oTable;
} }
function showSummaryList() { function showSummaryList(start, end) {
var url = baseUrl+"playouthistory/show-history-feed", var url = baseUrl+"playouthistory/show-history-feed",
oRange = AIRTIME.utilities.fnGetScheduleRange(dateStartId, timeStartId, dateEndId, timeEndId),
data = { data = {
format: "json", format: "json",
start: oRange.start, start: start,
end: oRange.end end: end
}; };
$.post(url, data, function(json) { $.post(url, data, function(json) {
@ -460,7 +459,9 @@ var AIRTIME = (function(AIRTIME) {
}, },
always: function() { always: function() {
inShowsTab = true; inShowsTab = true;
showSummaryList();
var info = getStartEnd();
showSummaryList(info.start, info.end);
emptySelectedLogItems(); 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){ $historyContentDiv.find("#his_submit").click(function(ev){
var fn, var fn,
oRange; info;
oRange = AIRTIME.utilities.fnGetScheduleRange(dateStartId, timeStartId, dateEndId, timeEndId); info = getStartEnd();
fn = fnServerData; fn = fnServerData;
fn.start = oRange.start; fn.start = info.start;
fn.end = oRange.end; fn.end = info.end;
if (inShowsTab) { if (inShowsTab) {
showSummaryList(); showSummaryList(info.start, info.end);
} }
else { else {
redrawTables(); redrawTables();