creating a separate controller for playouthistory templates.

This commit is contained in:
Naomi 2013-08-28 18:25:46 -04:00
parent 5aa983be36
commit 653a6384b9
14 changed files with 217 additions and 162 deletions

View File

@ -23,6 +23,7 @@ $ccAcl->add(new Zend_Acl_Resource('library'))
->add(new Zend_Acl_Resource('preference'))
->add(new Zend_Acl_Resource('showbuilder'))
->add(new Zend_Acl_Resource('playouthistory'))
->add(new Zend_Acl_Resource('playouthistorytemplate'))
->add(new Zend_Acl_Resource('listenerstat'))
->add(new Zend_Acl_Resource('usersettings'))
->add(new Zend_Acl_Resource('audiopreview'))
@ -46,7 +47,8 @@ $ccAcl->allow('G', 'index')
->allow('H', 'plupload')
->allow('H', 'library')
->allow('H', 'playlist')
->allow('A', 'playouthistory')
->allow('H', 'playouthistory')
->allow('A', 'playouthistorytemplate')
->allow('A', 'listenerstat')
->allow('A', 'user')
->allow('A', 'systemstatus')

View File

@ -38,6 +38,12 @@ define('MDATA_KEY_CUE_OUT' , 'cueout');
define('UI_MDATA_VALUE_FORMAT_FILE' , 'File');
define('UI_MDATA_VALUE_FORMAT_STREAM' , 'live stream');
//User types
define('UTYPE_HOST' , 'H');
define('UTYPE_ADMIN' , 'A');
define('UTYPE_GUEST' , 'G');
define('UTYPE_PROGRAM_MANAGER' , 'P');
//Constants for playout history template fields
define('TEMPLATE_DATE', 'date');
define('TEMPLATE_TIME', 'time');

View File

@ -20,7 +20,7 @@ $pages = array(
'module' => 'default',
'controller' => 'Plupload',
'action' => 'index',
'resource' => 'plupload'
'resource' => 'plupload'
),
array(
'label' => _('Library'),
@ -103,9 +103,9 @@ $pages = array(
array(
'label' => _('History Templates'),
'module' => 'default',
'controller' => 'playouthistory',
'action' => 'template',
'resource' => 'playouthistory'
'controller' => 'playouthistorytemplate',
'action' => 'index',
'resource' => 'playouthistorytemplate'
),
)
),

View File

@ -8,6 +8,7 @@ class PlayouthistoryController extends Zend_Controller_Action
$ajaxContext
->addActionContext('file-history-feed', 'json')
->addActionContext('item-history-feed', 'json')
->addActionContext('show-history-feed', 'json')
->addActionContext('edit-file-item', 'json')
->addActionContext('create-list-item', 'json')
->addActionContext('edit-list-item', 'json')
@ -15,10 +16,6 @@ class PlayouthistoryController extends Zend_Controller_Action
->addActionContext('delete-list-items', 'json')
->addActionContext('update-list-item', 'json')
->addActionContext('update-file-item', 'json')
->addActionContext('create-template', 'json')
->addActionContext('update-template', 'json')
->addActionContext('delete-template', 'json')
->addActionContext('set-template-default', 'json')
->initContext();
}
@ -56,13 +53,11 @@ class PlayouthistoryController extends Zend_Controller_Action
$this->view->headScript()->appendFile($baseUrl.'js/datatables/plugin/dataTables.fnSetFilteringDelay.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'js/datatables/plugin/TableTools-2.1.5/js/ZeroClipboard.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'js/datatables/plugin/TableTools-2.1.5/js/TableTools.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
//$this->view->headScript()->appendFile($baseUrl.'js/timepicker/jquery-ui-timepicker-addon.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$offset = date("Z") * -1;
$this->view->headScript()->appendScript("var serverTimezoneOffset = {$offset}; //in seconds");
$this->view->headScript()->appendFile($baseUrl.'js/timepicker/jquery.ui.timepicker.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'js/bootstrap-datetime/bootstrap-datetimepicker.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
//$this->view->headScript()->appendFile($baseUrl.'js/bootstrap-datetime/bootstrap-datetimepicker.min.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'js/airtime/buttons/buttons.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'js/airtime/utilities/utilities.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'js/airtime/playouthistory/historytable.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
@ -72,7 +67,6 @@ class PlayouthistoryController extends Zend_Controller_Action
$this->view->headLink()->appendStylesheet($baseUrl.'css/jquery.ui.timepicker.css?'.$CC_CONFIG['airtime_version']);
$this->view->headLink()->appendStylesheet($baseUrl.'css/playouthistory.css?'.$CC_CONFIG['airtime_version']);
$this->view->headLink()->appendStylesheet($baseUrl.'css/history_styles.css?'.$CC_CONFIG['airtime_version']);
//$this->view->headLink()->appendStylesheet($baseUrl.'css/jquery-ui-timepicker-addon.css?'.$CC_CONFIG['airtime_version']);
$this->view->headLink()->appendStylesheet($baseUrl.'css/jquery.contextMenu.css?'.$CC_CONFIG['airtime_version']);
//set datatables columns for display of data.
@ -83,6 +77,9 @@ class PlayouthistoryController extends Zend_Controller_Action
$columns = json_encode($historyService->getDatatablesFileSummaryColumns());
$script.= "localStorage.setItem( 'datatables-historyfile-aoColumns', JSON.stringify($columns) );";
$this->view->headScript()->appendScript($script);
$user = Application_Model_User::getCurrentUser();
$this->view->userType = $user->getType();
}
public function fileHistoryFeedAction()
@ -140,6 +137,27 @@ class PlayouthistoryController extends Zend_Controller_Action
Logging::info($e->getMessage());
}
}
public function showHistoryFeedAction()
{
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"));
$historyService = new Application_Service_HistoryService();
$r = $historyService->getShowList($startsDT, $endsDT);
}
catch (Exception $e) {
Logging::info($e);
Logging::info($e->getMessage());
}
}
public function editFileItemAction()
{
@ -247,132 +265,4 @@ class PlayouthistoryController extends Zend_Controller_Action
$this->_helper->json->sendJson($json);
}
public function templateAction()
{
$CC_CONFIG = Config::getConfig();
$baseUrl = Application_Common_OsPath::getBaseDir();
$this->view->headScript()->appendFile($baseUrl.'js/airtime/playouthistory/template.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headLink()->appendStylesheet($baseUrl.'css/history_styles.css?'.$CC_CONFIG['airtime_version']);
$historyService = new Application_Service_HistoryService();
$this->view->template_list = $historyService->getListItemTemplates();
$this->view->template_file = $historyService->getFileTemplates();
$this->view->configured = $historyService->getConfiguredTemplateIds();
}
public function configureTemplateAction() {
$CC_CONFIG = Config::getConfig();
$baseUrl = Application_Common_OsPath::getBaseDir();
$this->view->headScript()->appendFile($baseUrl.'js/airtime/playouthistory/configuretemplate.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headLink()->appendStylesheet($baseUrl.'css/history_styles.css?'.$CC_CONFIG['airtime_version']);
try {
$templateId = $this->_getParam('id');
$historyService = new Application_Service_HistoryService();
$template = $historyService->loadTemplate($templateId);
$templateType = $template["type"];
$supportedTypes = $historyService->getSupportedTemplateTypes();
if (!in_array($templateType, $supportedTypes)) {
throw new Exception("Error: $templateType is not supported.");
}
$getMandatoryFields = "mandatory".ucfirst($templateType)."Fields";
$mandatoryFields = $historyService->$getMandatoryFields();
$this->view->template_id = $templateId;
$this->view->template_name = $template["name"];
$this->view->template_fields = $template["fields"];
$this->view->template_type = $templateType;
$this->view->fileMD = $historyService->getFileMetadataTypes();
$this->view->fields = $historyService->getFieldTypes();
$this->view->required_fields = $mandatoryFields;
$this->view->configured = $historyService->getConfiguredTemplateIds();
}
catch (Exception $e) {
Logging::info("Error?");
Logging::info($e);
Logging::info($e->getMessage());
$this->_forward('template', 'playouthistory');
}
}
public function createTemplateAction()
{
$templateType = $this->_getParam('type', null);
$request = $this->getRequest();
$params = $request->getPost();
try {
$historyService = new Application_Service_HistoryService();
$supportedTypes = $historyService->getSupportedTemplateTypes();
if (!in_array($templateType, $supportedTypes)) {
throw new Exception("Error: $templateType is not supported.");
}
$id = $historyService->createTemplate($params);
$this->view->url = $this->view->baseUrl("Playouthistory/configure-template/id/{$id}");
}
catch (Exception $e) {
Logging::info($e);
Logging::info($e->getMessage());
$this->view->error = $e->getMessage();
}
}
public function setTemplateDefaultAction()
{
$templateId = $this->_getParam('id', null);
try {
$historyService = new Application_Service_HistoryService();
$historyService->setConfiguredTemplate($templateId);
}
catch (Exception $e) {
Logging::info($e);
Logging::info($e->getMessage());
}
}
public function updateTemplateAction()
{
$templateId = $this->_getParam('id', null);
$name = $this->_getParam('name', null);
$fields = $this->_getParam('fields', array());
try {
$historyService = new Application_Service_HistoryService();
$historyService->updateItemTemplate($templateId, $name, $fields);
}
catch (Exception $e) {
Logging::info($e);
Logging::info($e->getMessage());
}
}
public function deleteTemplateAction()
{
$templateId = $this->_getParam('id');
try {
$historyService = new Application_Service_HistoryService();
$historyService->deleteTemplate($templateId);
}
catch (Exception $e) {
Logging::info($e);
Logging::info($e->getMessage());
}
}
}

View File

@ -0,0 +1,143 @@
<?php
class PlayouthistorytemplateController extends Zend_Controller_Action
{
public function init()
{
$ajaxContext = $this->_helper->getHelper('AjaxContext');
$ajaxContext
->addActionContext('create-template', 'json')
->addActionContext('update-template', 'json')
->addActionContext('delete-template', 'json')
->addActionContext('set-template-default', 'json')
->initContext();
}
public function indexAction()
{
$CC_CONFIG = Config::getConfig();
$baseUrl = Application_Common_OsPath::getBaseDir();
$this->view->headScript()->appendFile($baseUrl.'js/airtime/playouthistory/template.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headLink()->appendStylesheet($baseUrl.'css/history_styles.css?'.$CC_CONFIG['airtime_version']);
$historyService = new Application_Service_HistoryService();
$this->view->template_list = $historyService->getListItemTemplates();
$this->view->template_file = $historyService->getFileTemplates();
$this->view->configured = $historyService->getConfiguredTemplateIds();
}
public function configureTemplateAction() {
$CC_CONFIG = Config::getConfig();
$baseUrl = Application_Common_OsPath::getBaseDir();
$this->view->headScript()->appendFile($baseUrl.'js/airtime/playouthistory/configuretemplate.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headLink()->appendStylesheet($baseUrl.'css/history_styles.css?'.$CC_CONFIG['airtime_version']);
try {
$templateId = $this->_getParam('id');
$historyService = new Application_Service_HistoryService();
$template = $historyService->loadTemplate($templateId);
$templateType = $template["type"];
$supportedTypes = $historyService->getSupportedTemplateTypes();
if (!in_array($templateType, $supportedTypes)) {
throw new Exception("Error: $templateType is not supported.");
}
$getMandatoryFields = "mandatory".ucfirst($templateType)."Fields";
$mandatoryFields = $historyService->$getMandatoryFields();
$this->view->template_id = $templateId;
$this->view->template_name = $template["name"];
$this->view->template_fields = $template["fields"];
$this->view->template_type = $templateType;
$this->view->fileMD = $historyService->getFileMetadataTypes();
$this->view->fields = $historyService->getFieldTypes();
$this->view->required_fields = $mandatoryFields;
$this->view->configured = $historyService->getConfiguredTemplateIds();
}
catch (Exception $e) {
Logging::info("Error?");
Logging::info($e);
Logging::info($e->getMessage());
$this->_forward('index', 'playouthistorytemplate');
}
}
public function createTemplateAction()
{
$templateType = $this->_getParam('type', null);
$request = $this->getRequest();
$params = $request->getPost();
try {
$historyService = new Application_Service_HistoryService();
$supportedTypes = $historyService->getSupportedTemplateTypes();
if (!in_array($templateType, $supportedTypes)) {
throw new Exception("Error: $templateType is not supported.");
}
$id = $historyService->createTemplate($params);
$this->view->url = $this->view->baseUrl("Playouthistorytemplate/configure-template/id/{$id}");
}
catch (Exception $e) {
Logging::info($e);
Logging::info($e->getMessage());
$this->view->error = $e->getMessage();
}
}
public function setTemplateDefaultAction()
{
$templateId = $this->_getParam('id', null);
try {
$historyService = new Application_Service_HistoryService();
$historyService->setConfiguredTemplate($templateId);
}
catch (Exception $e) {
Logging::info($e);
Logging::info($e->getMessage());
}
}
public function updateTemplateAction()
{
$templateId = $this->_getParam('id', null);
$name = $this->_getParam('name', null);
$fields = $this->_getParam('fields', array());
try {
$historyService = new Application_Service_HistoryService();
$historyService->updateItemTemplate($templateId, $name, $fields);
}
catch (Exception $e) {
Logging::info($e);
Logging::info($e->getMessage());
}
}
public function deleteTemplateAction()
{
$templateId = $this->_getParam('id');
try {
$historyService = new Application_Service_HistoryService();
$historyService->deleteTemplate($templateId);
}
catch (Exception $e) {
Logging::info($e);
Logging::info($e->getMessage());
}
}
}

View File

@ -1,10 +1,5 @@
<?php
define('UTYPE_HOST' , 'H');
define('UTYPE_ADMIN' , 'A');
define('UTYPE_GUEST' , 'G');
define('UTYPE_PROGRAM_MANAGER' , 'P');
class Application_Model_User
{
private $_userInstance;

View File

@ -423,9 +423,18 @@ class Application_Service_HistoryService
);
}
public function getShowList($startDT, $endDT, $opts)
public function getShowList($startDT, $endDT)
{
$user = Application_Model_User::getCurrentUser();
$shows = Application_Model_Show::getShows($startDT, $endDT);
Loggin::info($shows);
//need to filter the list to only their shows
if ($user->isHost()) {
}
}
public function insertPlayedItem($schedId) {

View File

@ -8,9 +8,11 @@
</a>
<ul class="sub">
<?php foreach ($page->getPages() as $sub) : ?>
<?php if($this->navigation()->accept($sub)) : ?>
<li>
<a href="<?php echo $sub->getHref(); ?>" <?php echo ($sub->getTarget() != "")?"target=\"".$sub->getTarget()."\"":""; ?>><?php echo _($sub->getLabel()); ?></a>
</li>
<?php endif; ?>
<?php endforeach; ?>
</ul>
<?php else: ?>

View File

@ -3,15 +3,23 @@
<div id="his-tabs">
<ul>
<?php if ($this->userType != UTYPE_HOST): ?>
<li><a href="#his-tabs-1"><?php echo _("Log Sheet"); ?></a></li>
<li><a href="#his-tabs-2"><?php echo _("File Summary"); ?></a></li>
<?php endif; ?>
<li><a href="#his-tabs-3"><?php echo _("Show Summary"); ?></a></li>
</ul>
<?php if ($this->userType != UTYPE_HOST): ?>
<div id="his-tabs-1">
<table id="history_table_list" cellpadding="0" cellspacing="0" class="datatable"></table>
</div>
<div id="his-tabs-2">
<table id="history_table_aggregate" cellpadding="0" cellspacing="0" class="datatable"></table>
</div>
<?php endif; ?>
<div id="his-tabs-3">
<span>Show Summary</span>
</div>
</div>
</div>

View File

@ -1,3 +1,3 @@
<div id="configure_item_template" class="ui-widget ui-widget-content block-shadow alpha-block padded-strong">
<?php echo $this->render('playouthistory/template-contents.phtml'); ?>
<?php echo $this->render('playouthistorytemplate/template-contents.phtml'); ?>
</div>

View File

@ -12,19 +12,19 @@
<?php endif; ?>
<?php if (in_array($id, $this->configured)): ?>
<li data-template="<?php echo $id; ?>" data-name="<?php echo $name; ?>" class="template_configured">
<a class="template_name" href="<?php echo $this->baseUrl("Playouthistory/configure-template/id/{$id}"); ?>">
<a class="template_name" href="<?php echo $this->baseUrl("Playouthistorytemplate/configure-template/id/{$id}"); ?>">
<?php echo $name; ?>
</a>
<i class="icon icon-ok"></i>
<?php else: ?>
<li data-template="<?php echo $id; ?>" data-name="<?php echo $name; ?>">
<a class="template_name" href="<?php echo $this->baseUrl("Playouthistory/configure-template/id/{$id}"); ?>">
<a class="template_name" href="<?php echo $this->baseUrl("Playouthistorytemplate/configure-template/id/{$id}"); ?>">
<?php echo $name; ?>
</a>
<a class="template_remove" href="<?php echo $this->baseUrl("Playouthistory/delete-template/id/{$id}"); ?>">
<a class="template_remove" href="<?php echo $this->baseUrl("Playouthistorytemplate/delete-template/id/{$id}"); ?>">
<i class="icon icon-trash"></i>
</a>
<a class="template_default" href="<?php echo $this->baseUrl("Playouthistory/set-template-default/id/{$id}"); ?>">
<a class="template_default" href="<?php echo $this->baseUrl("Playouthistorytemplate/set-template-default/id/{$id}"); ?>">
Set Default
</a>
<?php endif; ?>
@ -43,19 +43,19 @@
<?php foreach ($this->template_file as $id=>$name): ?>
<?php if (in_array($id, $this->configured)): ?>
<li data-template="<?php echo $id; ?>" data-name="<?php echo $name; ?>" class="template_configured">
<a class="template_name" href="<?php echo $this->baseUrl("Playouthistory/configure-template/id/{$id}"); ?>">
<a class="template_name" href="<?php echo $this->baseUrl("Playouthistorytemplate/configure-template/id/{$id}"); ?>">
<?php echo $name; ?>
</a>
<i class="icon icon-ok"></i>
<?php else: ?>
<li data-template="<?php echo $id; ?>" data-name="<?php echo $name; ?>">
<a class="template_name" href="<?php echo $this->baseUrl("Playouthistory/configure-template/id/{$id}"); ?>">
<a class="template_name" href="<?php echo $this->baseUrl("Playouthistorytemplate/configure-template/id/{$id}"); ?>">
<?php echo $name; ?>
</a>
<a class="template_remove" href="<?php echo $this->baseUrl("Playouthistory/delete-template/id/{$id}"); ?>">
<a class="template_remove" href="<?php echo $this->baseUrl("Playouthistorytemplate/delete-template/id/{$id}"); ?>">
<i class="icon icon-trash"></i>
</a>
<a class="template_default" href="<?php echo $this->baseUrl("Playouthistory/set-template-default/id/{$id}"); ?>">
<a class="template_default" href="<?php echo $this->baseUrl("Playouthistorytemplate/set-template-default/id/{$id}"); ?>">
Set Default
</a>
<?php endif; ?>

View File

@ -123,7 +123,7 @@ var AIRTIME = (function(AIRTIME) {
});
function updateTemplate(template_id, isDefault) {
var url = baseUrl+"Playouthistory/update-template/format/json";
var url = baseUrl+"Playouthistorytemplate/update-template/format/json";
var data = {};
var $lis, $li;
var i, len;
@ -152,7 +152,7 @@ var AIRTIME = (function(AIRTIME) {
$templateDiv.on("click", "#template_set_default", function() {
var $btn = $(this),
template_id = $btn.data("template"),
url = baseUrl+"Playouthistory/set-template-default/format/json";
url = baseUrl+"Playouthistorytemplate/set-template-default/format/json";
$btn.remove();
$.post(url, {id: template_id});

View File

@ -9,9 +9,9 @@ var AIRTIME = (function(AIRTIME) {
function createItemLi(id, name, configured) {
var editUrl = baseUrl+"Playouthistory/configure-template/id/"+id;
var defaultUrl = baseUrl+"Playouthistory/set-template-default/format/json/id/"+id;
var removeUrl = baseUrl+"Playouthistory/delete-template/format/json/id/"+id;
var editUrl = baseUrl+"Playouthistorytemplate/configure-template/id/"+id;
var defaultUrl = baseUrl+"Playouthistorytemplate/set-template-default/format/json/id/"+id;
var removeUrl = baseUrl+"Playouthistorytemplate/delete-template/format/json/id/"+id;
var itemConfigured =
"<li class='template_configured' data-template='<%= id %>' data-name='<%= name %>'>" +
@ -72,7 +72,7 @@ var AIRTIME = (function(AIRTIME) {
function createTemplate(type) {
var createUrl = baseUrl+"Playouthistory/create-template";
var createUrl = baseUrl+"Playouthistorytemplate/create-template";
$.post(createUrl, {format: "json", type: type}, function(json) {