file summary table now starting to work with templates.need to change query around to be configurable still.
This commit is contained in:
parent
b480a5ae18
commit
c110b4b4df
10 changed files with 298 additions and 162 deletions
|
@ -17,7 +17,7 @@ class PlayouthistoryController extends Zend_Controller_Action
|
|||
->addActionContext('create-template', 'json')
|
||||
->addActionContext('update-template', 'json')
|
||||
->addActionContext('delete-template', 'json')
|
||||
->addActionContext('set-item-template-default', 'json')
|
||||
->addActionContext('set-template-default', 'json')
|
||||
->initContext();
|
||||
}
|
||||
|
||||
|
@ -71,8 +71,11 @@ class PlayouthistoryController extends Zend_Controller_Action
|
|||
|
||||
//set datatables columns for display of data.
|
||||
$historyService = new Application_Service_HistoryService();
|
||||
$columns = json_encode($historyService->getDatatablesPlayedItemColumns());
|
||||
$script = "localStorage.setItem( 'datatables-historyitem-aoColumns', JSON.stringify($columns) );";
|
||||
$columns = json_encode($historyService->getDatatablesLogSheetColumns());
|
||||
$script = "localStorage.setItem( 'datatables-historyitem-aoColumns', JSON.stringify($columns) ); ";
|
||||
|
||||
$columns = json_encode($historyService->getDatatablesFileSummaryColumns());
|
||||
$script.= "localStorage.setItem( 'datatables-historyfile-aoColumns', JSON.stringify($columns) );";
|
||||
$this->view->headScript()->appendScript($script);
|
||||
}
|
||||
|
||||
|
@ -90,7 +93,7 @@ class PlayouthistoryController extends Zend_Controller_Action
|
|||
$endsDT = DateTime::createFromFormat("U", $ends_epoch, new DateTimeZone("UTC"));
|
||||
|
||||
$historyService = new Application_Service_HistoryService();
|
||||
$r = $historyService->getAggregateView($startsDT, $endsDT, $params);
|
||||
$r = $historyService->getFileSummaryData($startsDT, $endsDT, $params);
|
||||
|
||||
$this->view->sEcho = $r["sEcho"];
|
||||
$this->view->iTotalDisplayRecords = $r["iTotalDisplayRecords"];
|
||||
|
@ -204,53 +207,67 @@ class PlayouthistoryController extends Zend_Controller_Action
|
|||
|
||||
$historyService = new Application_Service_HistoryService();
|
||||
$this->view->template_list = $historyService->getListItemTemplates();
|
||||
$this->view->template_file = $historyService->getFileTemplates();
|
||||
$this->view->configured = $historyService->getConfiguredTemplateIds();
|
||||
}
|
||||
|
||||
public function configureItemTemplateAction() {
|
||||
public function configureTemplateAction() {
|
||||
|
||||
$request = $this->getRequest();
|
||||
$params = $request->getPost();
|
||||
Logging::info($params);
|
||||
$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');
|
||||
|
||||
try {
|
||||
$CC_CONFIG = Config::getConfig();
|
||||
$baseUrl = Application_Common_OsPath::getBaseDir();
|
||||
|
||||
$this->view->headScript()->appendFile($baseUrl.'js/airtime/playouthistory/itemtemplate.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
|
||||
|
||||
$template_id = $this->_getParam('id', null);
|
||||
$templateId = $this->_getParam('id');
|
||||
|
||||
$historyService = new Application_Service_HistoryService();
|
||||
$mandatoryFields = $historyService->mandatoryItemFields();
|
||||
$template = $historyService->getItemTemplate($template_id);
|
||||
|
||||
$this->view->template_id = $template_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_list = $historyService->getListItemTemplates();
|
||||
$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()
|
||||
{
|
||||
$request = $this->getRequest();
|
||||
$params = $request->getPost();
|
||||
Logging::info($params);
|
||||
$templateType = $this->_getParam('type', null);
|
||||
|
||||
try {
|
||||
$historyService = new Application_Service_HistoryService();
|
||||
$id = $historyService->createItemTemplate($params);
|
||||
$supportedTypes = $historyService->getSupportedTemplateTypes();
|
||||
|
||||
$this->view->url = $this->view->baseUrl("Playouthistory/configure-item-template/id/{$id}");
|
||||
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);
|
||||
|
@ -260,21 +277,13 @@ class PlayouthistoryController extends Zend_Controller_Action
|
|||
}
|
||||
}
|
||||
|
||||
public function setItemTemplateDefaultAction()
|
||||
public function setTemplateDefaultAction()
|
||||
{
|
||||
$request = $this->getRequest();
|
||||
$params = $request->getPost();
|
||||
Logging::info($params);
|
||||
$templateId = $this->_getParam('id', null);
|
||||
|
||||
$template_id = $this->_getParam('id', null);
|
||||
|
||||
if (empty($template_id)) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
$historyService = new Application_Service_HistoryService();
|
||||
$historyService->setConfiguredItemTemplate($template_id);
|
||||
$historyService->setConfiguredTemplate($templateId);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
Logging::info($e);
|
||||
|
@ -283,22 +292,14 @@ class PlayouthistoryController extends Zend_Controller_Action
|
|||
}
|
||||
|
||||
public function updateTemplateAction()
|
||||
{
|
||||
$request = $this->getRequest();
|
||||
$params = $request->getPost();
|
||||
Logging::info($params);
|
||||
|
||||
$template_id = $this->_getParam('id', null);
|
||||
{
|
||||
$templateId = $this->_getParam('id', null);
|
||||
$name = $this->_getParam('name', null);
|
||||
$fields = $this->_getParam('fields', array());
|
||||
|
||||
if (empty($template_id)) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
$historyService = new Application_Service_HistoryService();
|
||||
$historyService->updateItemTemplate($template_id, $name, $fields);
|
||||
$historyService->updateItemTemplate($templateId, $name, $fields);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
Logging::info($e);
|
||||
|
@ -308,11 +309,11 @@ class PlayouthistoryController extends Zend_Controller_Action
|
|||
|
||||
public function deleteTemplateAction()
|
||||
{
|
||||
$template_id = $this->_getParam('id');
|
||||
$templateId = $this->_getParam('id');
|
||||
|
||||
try {
|
||||
$historyService = new Application_Service_HistoryService();
|
||||
$historyService->deleteTemplate($template_id);
|
||||
$historyService->deleteTemplate($templateId);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
Logging::info($e);
|
||||
|
|
|
@ -177,18 +177,18 @@ class Application_Model_Datatables
|
|||
|
||||
try {
|
||||
|
||||
Logging::info($sqlTotalRows);
|
||||
//Logging::info($sqlTotalRows);
|
||||
|
||||
$r = $con->query($sqlTotalRows);
|
||||
$totalRows = $r->fetchColumn(0);
|
||||
|
||||
if (isset($sqlTotalDisplayRows)) {
|
||||
Logging::info("sql is set");
|
||||
Logging::info($sqlTotalDisplayRows);
|
||||
//Logging::info("sql is set");
|
||||
//Logging::info($sqlTotalDisplayRows);
|
||||
$totalDisplayRows = Application_Common_Database::prepareAndExecute($sqlTotalDisplayRows, $params, 'column');
|
||||
}
|
||||
else {
|
||||
Logging::info("sql is not set.");
|
||||
//Logging::info("sql is not set.");
|
||||
$totalDisplayRows = $totalRows;
|
||||
}
|
||||
|
||||
|
|
|
@ -1377,4 +1377,12 @@ class Application_Model_Preference
|
|||
public static function GetHistoryItemTemplate() {
|
||||
return self::getValue("history_item_template");
|
||||
}
|
||||
|
||||
public static function SetHistoryFileTemplate($value) {
|
||||
self::setValue("history_file_template", $value);
|
||||
}
|
||||
|
||||
public static function GetHistoryFileTemplate() {
|
||||
return self::getValue("history_file_template");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,36 +8,17 @@ class Application_Service_HistoryService
|
|||
private $timezone;
|
||||
|
||||
const TEMPLATE_TYPE_ITEM = "item";
|
||||
const TEMPLATE_TYPE_AGGREGATE = "aggregate";
|
||||
|
||||
private $mDataPropMap = array (
|
||||
"artist" => "artist_name",
|
||||
"title" => "track_title",
|
||||
"played" => "played",
|
||||
"length" => "length",
|
||||
"composer" => "composer",
|
||||
"copyright" => "copyright",
|
||||
"starts" => "starts",
|
||||
"ends" => "ends"
|
||||
);
|
||||
const TEMPLATE_TYPE_FILE = "file";
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->con = isset($con) ? $con : Propel::getConnection(CcPlayoutHistoryPeer::DATABASE_NAME);
|
||||
$this->timezone = Application_Model_Preference::GetTimezone();
|
||||
}
|
||||
|
||||
/*
|
||||
* map front end mDataProp labels to proper column names for searching etc.
|
||||
*/
|
||||
private function translateColumns($opts)
|
||||
|
||||
public function getSupportedTemplateTypes()
|
||||
{
|
||||
for ($i = 0; $i < $opts["iColumns"]; $i++) {
|
||||
|
||||
if ($opts["bSearchable_{$i}"] === "true") {
|
||||
$opts["mDataProp_{$i}"] = $this->mDataPropMap[$opts["mDataProp_{$i}"]];
|
||||
}
|
||||
}
|
||||
return array(self::TEMPLATE_TYPE_ITEM, self::TEMPLATE_TYPE_FILE);
|
||||
}
|
||||
|
||||
//opts is from datatables.
|
||||
|
@ -293,18 +274,16 @@ class Application_Service_HistoryService
|
|||
);
|
||||
}
|
||||
|
||||
public function getAggregateView($startDT, $endDT, $opts)
|
||||
public function getFileSummaryData($startDT, $endDT, $opts)
|
||||
{
|
||||
$this->translateColumns($opts);
|
||||
|
||||
$select = array (
|
||||
"file.track_title as title",
|
||||
"file.artist_name as artist",
|
||||
"playout.played as played",
|
||||
"file.track_title",
|
||||
"file.artist_name",
|
||||
"playout.played",
|
||||
"playout.file_id",
|
||||
"file.composer as composer",
|
||||
"file.copyright as copyright",
|
||||
"file.length as length"
|
||||
"file.composer",
|
||||
"file.copyright",
|
||||
"file.length"
|
||||
);
|
||||
|
||||
$start = $startDT->format("Y-m-d H:i:s");
|
||||
|
@ -660,6 +639,13 @@ class Application_Service_HistoryService
|
|||
|
||||
return $fields;
|
||||
}
|
||||
|
||||
public function mandatoryFileFields() {
|
||||
|
||||
$fields = array("played", MDATA_KEY_TITLE, MDATA_KEY_CREATOR);
|
||||
|
||||
return $fields;
|
||||
}
|
||||
|
||||
private function defaultItemTemplate() {
|
||||
|
||||
|
@ -671,17 +657,47 @@ class Application_Service_HistoryService
|
|||
$fields[] = array("name" => MDATA_KEY_TITLE, "type" => TEMPLATE_STRING, "isFileMd" => true); //these fields can be populated from an associated file.
|
||||
$fields[] = array("name" => MDATA_KEY_CREATOR, "type" => TEMPLATE_STRING, "isFileMd" => true);
|
||||
|
||||
$template["name"] = "Template".date("Y-m-d H:i:s");
|
||||
$template["name"] = "Log Sheet ".date("Y-m-d H:i:s")." Template";
|
||||
$template["fields"] = $fields;
|
||||
|
||||
return $template;
|
||||
}
|
||||
|
||||
private function loadTemplate($id) {
|
||||
/*
|
||||
* Default File Summary Template. Taken from The Czech radio requirements (customer requested this in the past).
|
||||
*/
|
||||
private function defaultFileTemplate() {
|
||||
|
||||
$template = array();
|
||||
$fields = array();
|
||||
|
||||
$fields[] = array("name" => MDATA_KEY_TITLE, "type" => TEMPLATE_STRING, "isFileMd" => true);
|
||||
$fields[] = array("name" => MDATA_KEY_CREATOR, "type" => TEMPLATE_STRING, "isFileMd" => true);
|
||||
$fields[] = array("name" => "played", "type" => TEMPLATE_INT, "isFileMd" => false);
|
||||
$fields[] = array("name" => MDATA_KEY_DURATION, "type" => TEMPLATE_STRING, "isFileMd" => true);
|
||||
$fields[] = array("name" => MDATA_KEY_COMPOSER, "type" => TEMPLATE_STRING, "isFileMd" => true);
|
||||
$fields[] = array("name" => MDATA_KEY_COPYRIGHT, "type" => TEMPLATE_STRING, "isFileMd" => true);
|
||||
|
||||
$template["name"] = "File Summary ".date("Y-m-d H:i:s")." Template";
|
||||
$template["fields"] = $fields;
|
||||
|
||||
return $template;
|
||||
}
|
||||
|
||||
public function loadTemplate($id) {
|
||||
|
||||
try {
|
||||
|
||||
if (!is_numeric($id)) {
|
||||
throw new Exception("Error: $id is not numeric.");
|
||||
}
|
||||
|
||||
$template = CcPlayoutHistoryTemplateQuery::create()->findPk($id, $this->con);
|
||||
|
||||
if (empty($template)) {
|
||||
throw new Exception("Error: Template $id does not exist.");
|
||||
}
|
||||
|
||||
$c = new Criteria();
|
||||
$c->addAscendingOrderByColumn(CcPlayoutHistoryTemplateFieldPeer::POSITION);
|
||||
$config = $template->getCcPlayoutHistoryTemplateFields($c, $this->con);
|
||||
|
@ -700,6 +716,7 @@ class Application_Service_HistoryService
|
|||
$data = array();
|
||||
$data["name"] = $template->getDbName();
|
||||
$data["fields"] = $fields;
|
||||
$data["type"] = $template->getDbType();
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
@ -722,15 +739,21 @@ class Application_Service_HistoryService
|
|||
return $template;
|
||||
}
|
||||
|
||||
public function getListItemTemplates() {
|
||||
public function getTemplates($type) {
|
||||
|
||||
$list = array();
|
||||
|
||||
try {
|
||||
|
||||
$templates = CcPlayoutHistoryTemplateQuery::create()
|
||||
->setFormatter(ModelCriteria::FORMAT_ON_DEMAND)
|
||||
->findByDbType(self::TEMPLATE_TYPE_ITEM);
|
||||
$query = CcPlayoutHistoryTemplateQuery::create()
|
||||
->setFormatter(ModelCriteria::FORMAT_ON_DEMAND);
|
||||
|
||||
if (isset($type)) {
|
||||
$templates = $query->findByDbType($type);
|
||||
}
|
||||
else {
|
||||
$templates = $query->find();
|
||||
}
|
||||
|
||||
foreach ($templates as $template) {
|
||||
$list[$template->getDbId()] = $template->getDbName();
|
||||
|
@ -743,35 +766,66 @@ class Application_Service_HistoryService
|
|||
}
|
||||
}
|
||||
|
||||
public function getDatatablesPlayedItemColumns() {
|
||||
public function getListItemTemplates() {
|
||||
return $this->getTemplates(self::TEMPLATE_TYPE_ITEM);
|
||||
}
|
||||
|
||||
public function getFileTemplates() {
|
||||
return $this->getTemplates(self::TEMPLATE_TYPE_FILE);
|
||||
}
|
||||
|
||||
private function datatablesColumns($template) {
|
||||
|
||||
$columns = array();
|
||||
|
||||
foreach ($template["fields"] as $index=>$field) {
|
||||
|
||||
$key = $field["name"];
|
||||
|
||||
$columns[] = array(
|
||||
"sTitle"=> $key,
|
||||
"mDataProp"=> $key,
|
||||
"sClass"=> "his_{$key}"
|
||||
);
|
||||
}
|
||||
|
||||
return $columns;
|
||||
}
|
||||
|
||||
public function getDatatablesLogSheetColumns() {
|
||||
|
||||
try {
|
||||
$template = $this->getConfiguredItemTemplate();
|
||||
|
||||
$columns = array();
|
||||
|
||||
foreach ($template["fields"] as $index=>$field) {
|
||||
|
||||
$key = $field["name"];
|
||||
|
||||
$columns[] = array(
|
||||
"sTitle"=> $key,
|
||||
"mDataProp"=> $key,
|
||||
"sClass"=> "his_{$key}"
|
||||
);
|
||||
}
|
||||
|
||||
return $columns;
|
||||
$template = $this->getConfiguredItemTemplate();
|
||||
return $this->datatablesColumns($template);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
public function getDatatablesFileSummaryColumns() {
|
||||
|
||||
try {
|
||||
$template = $this->getConfiguredFileTemplate();
|
||||
return $this->datatablesColumns($template);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
public function getConfiguredItemTemplate() {
|
||||
|
||||
try {
|
||||
$id = Application_Model_Preference::GetHistoryItemTemplate();
|
||||
return $this->getItemTemplate($id);
|
||||
|
||||
if (is_numeric($id)) {
|
||||
$template = $this->loadTemplate($id);
|
||||
}
|
||||
else {
|
||||
$template = $this->defaultItemTemplate();
|
||||
}
|
||||
return $template;
|
||||
}
|
||||
catch (Exception $e) {
|
||||
throw $e;
|
||||
|
@ -787,25 +841,81 @@ class Application_Service_HistoryService
|
|||
}
|
||||
}
|
||||
|
||||
public function getConfiguredFileTemplate() {
|
||||
|
||||
try {
|
||||
$id = Application_Model_Preference::GetHistoryFileTemplate();
|
||||
|
||||
if (is_numeric($id)) {
|
||||
$template = $this->loadTemplate($id);
|
||||
}
|
||||
else {
|
||||
$template = $this->defaultFileTemplate();
|
||||
}
|
||||
return $template;
|
||||
}
|
||||
catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
public function setConfiguredFileTemplate($id) {
|
||||
try {
|
||||
Application_Model_Preference::SetHistoryFileTemplate($id);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
public function setConfiguredTemplate($id) {
|
||||
try {
|
||||
|
||||
$template = $this->loadTemplate($id);
|
||||
$type = $template["type"];
|
||||
|
||||
$setTemplate = "setConfigured".ucfirst($type)."Template";
|
||||
|
||||
$this->$setTemplate($id);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
public function getConfiguredTemplateIds() {
|
||||
|
||||
try {
|
||||
$id = Application_Model_Preference::GetHistoryItemTemplate();
|
||||
$id2 = Application_Model_Preference::GetHistoryFileTemplate();
|
||||
|
||||
return array($id);
|
||||
$configured = array();
|
||||
|
||||
if (is_numeric($id)) {
|
||||
$configured[] = $id;
|
||||
}
|
||||
|
||||
if (is_numeric($id2)) {
|
||||
$configured[] = $id2;
|
||||
}
|
||||
|
||||
return $configured;
|
||||
}
|
||||
catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
public function createItemTemplate($config) {
|
||||
public function createTemplate($config) {
|
||||
|
||||
$this->con->beginTransaction();
|
||||
|
||||
try {
|
||||
|
||||
$default = $this->defaultItemTemplate();
|
||||
$type = $config["type"];
|
||||
|
||||
$method = "default".ucfirst($type)."Template";
|
||||
$default = $this->$method();
|
||||
|
||||
$name = isset($config["name"]) ? $config["name"] : $default["name"];
|
||||
$fields = isset($config["fields"]) ? $config["fields"] : $default["fields"];
|
||||
|
@ -814,7 +924,7 @@ class Application_Service_HistoryService
|
|||
|
||||
$template = new CcPlayoutHistoryTemplate();
|
||||
$template->setDbName($name);
|
||||
$template->setDbType(self::TEMPLATE_TYPE_ITEM);
|
||||
$template->setDbType($type);
|
||||
|
||||
foreach ($fields as $index=>$field) {
|
||||
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
<div id="configure_item_template" class="ui-widget ui-widget-content block-shadow alpha-block padded">
|
||||
<?php echo $this->render('playouthistory/item-template.phtml'); ?>
|
||||
<?php echo $this->render('playouthistory/template-contents.phtml'); ?>
|
||||
</div>
|
|
@ -31,15 +31,17 @@
|
|||
<?php endforeach; ?>
|
||||
</ul>
|
||||
|
||||
<div class="template_item_add">
|
||||
<div>Add New Field</div>
|
||||
<div>
|
||||
<input type="text">
|
||||
<select>
|
||||
<?php foreach ($this->fields as $field): ?>
|
||||
<option value="<?php echo $field; ?>"><?php echo $field; ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<button>Add</button>
|
||||
</div>
|
||||
<?php if ($this->template_type !== Application_Service_HistoryService::TEMPLATE_TYPE_FILE): ?>
|
||||
<div class="template_item_add">
|
||||
<div>Add New Field</div>
|
||||
<div>
|
||||
<input type="text">
|
||||
<select>
|
||||
<?php foreach ($this->fields as $field): ?>
|
||||
<option value="<?php echo $field; ?>"><?php echo $field; ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<button>Add</button>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
|
@ -1,21 +1,45 @@
|
|||
<div id="history_template" class="ui-widget ui-widget-content block-shadow alpha-block padded">
|
||||
|
||||
<div>
|
||||
<div>Edit Existing</div>
|
||||
<div>Edit Log Sheet Template</div>
|
||||
<ul id="template_list">
|
||||
<?php foreach ($this->template_list as $id=>$name): ?>
|
||||
<?php if (count($this->template_list) == 0): ?>
|
||||
<li>No Log Sheet Templates</li>
|
||||
<?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-item-template/id/{$id}"); ?>"><?php echo $name; ?></a>
|
||||
<a class="template_name" href="<?php echo $this->baseUrl("Playouthistory/configure-template/id/{$id}"); ?>"><?php echo $name; ?></a>
|
||||
<?php else: ?>
|
||||
<li data-template="<?php echo $id; ?>" data-name="<?php echo $name; ?>">
|
||||
<a class="template_name" href="<?php echo $this->baseUrl("Playouthistory/configure-item-template/id/{$id}"); ?>"><?php echo $name; ?></a>
|
||||
<a class="template_default" href="<?php echo $this->baseUrl("Playouthistory/set-item-template-default/id/{$id}"); ?>">Set Default</a>
|
||||
<a class="template_name" href="<?php echo $this->baseUrl("Playouthistory/configure-template/id/{$id}"); ?>"><?php echo $name; ?></a>
|
||||
<a class="template_default" href="<?php echo $this->baseUrl("Playouthistory/set-template-default/id/{$id}"); ?>">Set Default</a>
|
||||
<a class="template_remove" href="<?php echo $this->baseUrl("Playouthistory/delete-template/id/{$id}"); ?>">Remove</a>
|
||||
<?php endif; ?>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</div>
|
||||
<button id="new_item_template" class="btn">New Item Template</button>
|
||||
<div>
|
||||
<div>Edit File Summary Template</div>
|
||||
<ul id="template_file">
|
||||
<?php if (count($this->template_file) == 0): ?>
|
||||
<li>No File Summary Templates</li>
|
||||
<?php endif; ?>
|
||||
<?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}"); ?>"><?php echo $name; ?></a>
|
||||
<?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}"); ?>"><?php echo $name; ?></a>
|
||||
<a class="template_default" href="<?php echo $this->baseUrl("Playouthistory/set-template-default/id/{$id}"); ?>">Set Default</a>
|
||||
<a class="template_remove" href="<?php echo $this->baseUrl("Playouthistory/delete-template/id/{$id}"); ?>">Remove</a>
|
||||
<?php endif; ?>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</div>
|
||||
<button id="new_item_template" class="btn">New Log Sheet Template</button>
|
||||
<button id="new_file_template" class="btn">New File Summary Template</button>
|
||||
</div>
|
|
@ -80,17 +80,13 @@ var AIRTIME = (function(AIRTIME) {
|
|||
addField(name, type, false, false);
|
||||
});
|
||||
|
||||
function createUpdateTemplate(template_id, isDefault) {
|
||||
var createUrl = baseUrl+"Playouthistory/create-template/format/json";
|
||||
var updateUrl = baseUrl+"Playouthistory/update-template/format/json";
|
||||
var url;
|
||||
function updateTemplate(template_id, isDefault) {
|
||||
var url = baseUrl+"Playouthistory/update-template/format/json";
|
||||
var data = {};
|
||||
var $lis, $li;
|
||||
var i, len;
|
||||
var templateName;
|
||||
|
||||
url = (isNaN(parseInt(template_id, 10))) ? createUrl : updateUrl;
|
||||
|
||||
templateName = $("#template_name").val();
|
||||
$lis = $templateList.children();
|
||||
|
||||
|
@ -108,24 +104,16 @@ var AIRTIME = (function(AIRTIME) {
|
|||
$templateDiv.on("click", "#template_item_save", function(){
|
||||
var template_id = $(this).data("template");
|
||||
|
||||
createUpdateTemplate(template_id, false);
|
||||
updateTemplate(template_id, false);
|
||||
});
|
||||
|
||||
$templateDiv.on("click", "#template_set_default", function(){
|
||||
var template_id = $(this).data("template");
|
||||
|
||||
if (isNaN(parseInt(template_id, 10))) {
|
||||
|
||||
createUpdateTemplate(template_id, true);
|
||||
}
|
||||
else {
|
||||
|
||||
var url = baseUrl+"Playouthistory/set-item-template-default/format/json";
|
||||
|
||||
$.post(url, {id: template_id}, function(json) {
|
||||
var x;
|
||||
});
|
||||
}
|
||||
var template_id = $(this).data("template");
|
||||
var url = baseUrl+"Playouthistory/set-template-default/format/json";
|
||||
|
||||
$.post(url, {id: template_id}, function(json) {
|
||||
var x;
|
||||
});
|
||||
});
|
||||
|
||||
};
|
|
@ -104,16 +104,11 @@ var AIRTIME = (function(AIRTIME) {
|
|||
nRow.setAttribute('url-edit', editUrl);
|
||||
};
|
||||
|
||||
var columns = JSON.parse(localStorage.getItem('datatables-historyfile-aoColumns'));
|
||||
|
||||
oTable = $historyTableDiv.dataTable( {
|
||||
|
||||
"aoColumns": [
|
||||
{"sTitle": $.i18n._("Title"), "mDataProp": "title", "sClass": "his_title"}, /* Title */
|
||||
{"sTitle": $.i18n._("Creator"), "mDataProp": "artist", "sClass": "his_artist"}, /* Creator */
|
||||
{"sTitle": $.i18n._("Played"), "mDataProp": "played", "sClass": "his_artist"}, /* times played */
|
||||
{"sTitle": $.i18n._("Length"), "mDataProp": "length", "sClass": "his_length library_length"}, /* Length */
|
||||
{"sTitle": $.i18n._("Composer"), "mDataProp": "composer", "sClass": "his_composer"}, /* Composer */
|
||||
{"sTitle": $.i18n._("Copyright"), "mDataProp": "copyright", "sClass": "his_copyright"} /* Copyright */
|
||||
],
|
||||
"aoColumns": columns,
|
||||
|
||||
"bProcessing": true,
|
||||
"bServerSide": true,
|
||||
|
|
|
@ -9,8 +9,8 @@ var AIRTIME = (function(AIRTIME) {
|
|||
|
||||
function createItemLi(id, name, configured) {
|
||||
|
||||
var editUrl = baseUrl+"Playouthistory/configure-item-template/id/"+id;
|
||||
var defaultUrl = baseUrl+"Playouthistory/set-item-template-default/format/json/id/"+id;
|
||||
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 itemConfigured =
|
||||
|
@ -70,10 +70,11 @@ var AIRTIME = (function(AIRTIME) {
|
|||
});
|
||||
});
|
||||
|
||||
$historyTemplate.on("click", "#new_item_template", function() {
|
||||
function createTemplate(type) {
|
||||
|
||||
var createUrl = baseUrl+"Playouthistory/create-template";
|
||||
|
||||
$.post(createUrl, {format: "json"}, function(json) {
|
||||
$.post(createUrl, {format: "json", type: type}, function(json) {
|
||||
|
||||
if (json.error !== undefined) {
|
||||
alert(json.error);
|
||||
|
@ -82,8 +83,15 @@ var AIRTIME = (function(AIRTIME) {
|
|||
|
||||
window.location.href = json.url;
|
||||
});
|
||||
}
|
||||
|
||||
$historyTemplate.on("click", "#new_item_template", function() {
|
||||
createTemplate("item");
|
||||
});
|
||||
|
||||
$historyTemplate.on("click", "#new_file_template", function() {
|
||||
createTemplate("file");
|
||||
});
|
||||
};
|
||||
|
||||
return AIRTIME;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue