This commit is contained in:
Naomi 2013-08-01 16:37:10 -04:00
parent a5a99da21e
commit 557b3f9c9b
2 changed files with 85 additions and 85 deletions

View file

@ -197,9 +197,9 @@ class PlayouthistoryController extends Zend_Controller_Action
public function templateAction() public function templateAction()
{ {
$CC_CONFIG = Config::getConfig(); $CC_CONFIG = Config::getConfig();
$baseUrl = Application_Common_OsPath::getBaseDir(); $baseUrl = Application_Common_OsPath::getBaseDir();
$this->view->headScript()->appendFile($baseUrl.'js/airtime/playouthistory/template.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); $this->view->headScript()->appendFile($baseUrl.'js/airtime/playouthistory/template.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$historyService = new Application_Service_HistoryService(); $historyService = new Application_Service_HistoryService();
@ -284,25 +284,25 @@ class PlayouthistoryController extends Zend_Controller_Action
public function updateTemplateAction() public function updateTemplateAction()
{ {
$request = $this->getRequest(); $request = $this->getRequest();
$params = $request->getPost(); $params = $request->getPost();
Logging::info($params); Logging::info($params);
$template_id = $this->_getParam('id', null); $template_id = $this->_getParam('id', null);
$name = $this->_getParam('name', null); $name = $this->_getParam('name', null);
$fields = $this->_getParam('fields', array()); $fields = $this->_getParam('fields', array());
if (empty($template_id)) { if (empty($template_id)) {
return; return;
} }
try { try {
$historyService = new Application_Service_HistoryService(); $historyService = new Application_Service_HistoryService();
$historyService->updateItemTemplate($template_id, $name, $fields); $historyService->updateItemTemplate($template_id, $name, $fields);
} }
catch (Exception $e) { catch (Exception $e) {
Logging::info($e); Logging::info($e);
Logging::info($e->getMessage()); Logging::info($e->getMessage());
} }
} }
@ -310,13 +310,13 @@ class PlayouthistoryController extends Zend_Controller_Action
{ {
$template_id = $this->_getParam('id'); $template_id = $this->_getParam('id');
try { try {
$historyService = new Application_Service_HistoryService(); $historyService = new Application_Service_HistoryService();
$historyService->deleteTemplate($template_id); $historyService->deleteTemplate($template_id);
} }
catch (Exception $e) { catch (Exception $e) {
Logging::info($e); Logging::info($e);
Logging::info($e->getMessage()); Logging::info($e->getMessage());
} }
} }
} }

View file

@ -556,19 +556,19 @@ class Application_Service_HistoryService
return $fields; return $fields;
} }
private function getSqlTypes() { private function getSqlTypes() {
$fields = array( $fields = array(
TEMPLATE_DATE => "date", TEMPLATE_DATE => "date",
TEMPLATE_TIME => "time", TEMPLATE_TIME => "time",
TEMPLATE_DATETIME => "datetime", TEMPLATE_DATETIME => "datetime",
TEMPLATE_STRING => "text", TEMPLATE_STRING => "text",
TEMPLATE_BOOLEAN => "boolean", TEMPLATE_BOOLEAN => "boolean",
TEMPLATE_INT => "integer", TEMPLATE_INT => "integer",
TEMPLATE_FLOAT => "float", TEMPLATE_FLOAT => "float",
); );
return $fields; return $fields;
} }
public function getFileMetadataTypes() { public function getFileMetadataTypes() {
@ -728,13 +728,13 @@ class Application_Service_HistoryService
public function getConfiguredTemplateIds() { public function getConfiguredTemplateIds() {
try { try {
$id = Application_Model_Preference::GetHistoryItemTemplate(); $id = Application_Model_Preference::GetHistoryItemTemplate();
return array($id); return array($id);
} }
catch (Exception $e) { catch (Exception $e) {
throw $e; throw $e;
} }
} }
@ -784,13 +784,13 @@ class Application_Service_HistoryService
} }
} }
public function updateItemTemplate($id, $name, $fields, $doSetDefault=false) { public function updateItemTemplate($id, $name, $fields, $doSetDefault=false) {
$this->con->beginTransaction(); $this->con->beginTransaction();
try { try {
$template = CcPlayoutHistoryTemplateQuery::create()->findPk($id, $this->con); $template = CcPlayoutHistoryTemplateQuery::create()->findPk($id, $this->con);
$template->setDbName($name); $template->setDbName($name);
if (count($fields) === 0) { if (count($fields) === 0) {
@ -798,33 +798,33 @@ class Application_Service_HistoryService
$fields = $t["fields"]; $fields = $t["fields"];
} }
$template->getCcPlayoutHistoryTemplateFields()->delete($this->con); $template->getCcPlayoutHistoryTemplateFields()->delete($this->con);
foreach ($fields as $index=>$field) { foreach ($fields as $index=>$field) {
$isMd = ($field["isFileMd"] == 'true') ? true : false; $isMd = ($field["isFileMd"] == 'true') ? true : false;
$templateField = new CcPlayoutHistoryTemplateField(); $templateField = new CcPlayoutHistoryTemplateField();
$templateField->setDbName($field["name"]); $templateField->setDbName($field["name"]);
$templateField->setDbType($field["type"]); $templateField->setDbType($field["type"]);
$templateField->setDbIsFileMD($isMd); $templateField->setDbIsFileMD($isMd);
$templateField->setDbPosition($index); $templateField->setDbPosition($index);
$template->addCcPlayoutHistoryTemplateField($templateField); $template->addCcPlayoutHistoryTemplateField($templateField);
} }
$template->save($this->con); $template->save($this->con);
if ($doSetDefault) { if ($doSetDefault) {
$this->setConfiguredItemTemplate($template->getDbid()); $this->setConfiguredItemTemplate($template->getDbid());
} }
$this->con->commit(); $this->con->commit();
} }
catch (Exception $e) { catch (Exception $e) {
$this->con->rollback(); $this->con->rollback();
throw $e; throw $e;
} }
} }
public function deleteTemplate($id) { public function deleteTemplate($id) {
@ -836,11 +836,11 @@ class Application_Service_HistoryService
$template = CcPlayoutHistoryTemplateQuery::create()->findPk($id, $this->con); $template = CcPlayoutHistoryTemplateQuery::create()->findPk($id, $this->con);
$template->delete($this->con); $template->delete($this->con);
$this->con->commit(); $this->con->commit();
} }
catch (Exception $e) { catch (Exception $e) {
$this->con->rollback(); $this->con->rollback();
throw $e; throw $e;
} }
} }
} }