starting to populate with the template.
This commit is contained in:
parent
ecb2f81211
commit
c7b5592fa9
|
@ -61,17 +61,17 @@ class Application_Service_HistoryService
|
||||||
left join cc_files as file on (file.id = playout.file_id)";
|
left join cc_files as file on (file.id = playout.file_id)";
|
||||||
|
|
||||||
$results = Application_Model_Datatables::findEntries($this->con, $select, $historyTable, $opts, "history");
|
$results = Application_Model_Datatables::findEntries($this->con, $select, $historyTable, $opts, "history");
|
||||||
|
|
||||||
$timezoneUTC = new DateTimeZone("UTC");
|
$timezoneUTC = new DateTimeZone("UTC");
|
||||||
$timezoneLocal = new DateTimeZone($this->timezone);
|
$timezoneLocal = new DateTimeZone($this->timezone);
|
||||||
|
|
||||||
//need to display the results in the station's timezone.
|
//need to display the results in the station's timezone.
|
||||||
foreach ($results["history"] as $index => &$result) {
|
foreach ($results["history"] as $index => &$result) {
|
||||||
|
|
||||||
$dateTime = new DateTime($result["starts"], $timezoneUTC);
|
$dateTime = new DateTime($result["starts"], $timezoneUTC);
|
||||||
$dateTime->setTimezone($timezoneLocal);
|
$dateTime->setTimezone($timezoneLocal);
|
||||||
$result["starts"] = $dateTime->format("Y-m-d H:i:s");
|
$result["starts"] = $dateTime->format("Y-m-d H:i:s");
|
||||||
|
|
||||||
$dateTime = new DateTime($result["ends"], $timezoneUTC);
|
$dateTime = new DateTime($result["ends"], $timezoneUTC);
|
||||||
$dateTime->setTimezone($timezoneLocal);
|
$dateTime->setTimezone($timezoneLocal);
|
||||||
$result["ends"] = $dateTime->format("Y-m-d H:i:s");
|
$result["ends"] = $dateTime->format("Y-m-d H:i:s");
|
||||||
|
@ -169,13 +169,13 @@ class Application_Service_HistoryService
|
||||||
|
|
||||||
/* id is an id in cc_playout_history */
|
/* id is an id in cc_playout_history */
|
||||||
public function makeHistoryItemForm($id) {
|
public function makeHistoryItemForm($id) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$form = new Application_Form_EditHistoryItem();
|
$form = new Application_Form_EditHistoryItem();
|
||||||
$template = $this->getItemTemplate();
|
$template = $this->getItemTemplate();
|
||||||
|
|
||||||
$form->createFromTemplate($template);
|
$form->createFromTemplate($template);
|
||||||
|
|
||||||
return $form;
|
return $form;
|
||||||
}
|
}
|
||||||
catch (Exception $e) {
|
catch (Exception $e) {
|
||||||
|
@ -207,6 +207,26 @@ class Application_Service_HistoryService
|
||||||
Logging::info($e);
|
Logging::info($e);
|
||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function populateTemplateItem($values) {
|
||||||
|
|
||||||
|
$template = $this->getItemTemplate();
|
||||||
|
$historyRecord = new CcPlayoutHistory();
|
||||||
|
|
||||||
|
$timezoneUTC = new DateTimeZone("UTC");
|
||||||
|
$timezoneLocal = new DateTimeZone($this->timezone);
|
||||||
|
|
||||||
|
$dateTime = new DateTime($values["starts"], $timezoneLocal);
|
||||||
|
$dateTime->setTimezone($timezoneLocal);
|
||||||
|
$historyRecord->setDbStarts($dateTime->format("Y-m-d H:i:s"));
|
||||||
|
|
||||||
|
$dateTime = new DateTime($result["ends"], $timezoneUTC);
|
||||||
|
$dateTime->setTimezone($timezoneUTC);
|
||||||
|
$historyRecord->setDbEnds($dateTime->format("Y-m-d H:i:s"));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function createPlayedItem($data) {
|
public function createPlayedItem($data) {
|
||||||
|
@ -214,20 +234,20 @@ class Application_Service_HistoryService
|
||||||
try {
|
try {
|
||||||
$form = $this->makeHistoryItemForm(null);
|
$form = $this->makeHistoryItemForm(null);
|
||||||
$history_id = $form->getElement("his_item_id");
|
$history_id = $form->getElement("his_item_id");
|
||||||
|
|
||||||
if ($form->isValid($data)) {
|
if ($form->isValid($data)) {
|
||||||
$history_id->setIgnore(true);
|
$history_id->setIgnore(true);
|
||||||
$values = $form->getValues();
|
$values = $form->getValues();
|
||||||
|
|
||||||
Logging::info("created list item");
|
Logging::info("created list item");
|
||||||
Logging::info($values);
|
Logging::info($values);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Logging::info("created list item NOT VALID");
|
Logging::info("created list item NOT VALID");
|
||||||
}
|
}
|
||||||
|
|
||||||
Logging::info($form->getMessages());
|
Logging::info($form->getMessages());
|
||||||
|
|
||||||
//return $json;
|
//return $json;
|
||||||
}
|
}
|
||||||
catch (Exception $e) {
|
catch (Exception $e) {
|
||||||
|
@ -243,8 +263,9 @@ class Application_Service_HistoryService
|
||||||
$form = $this->makeHistoryItemForm($id);
|
$form = $this->makeHistoryItemForm($id);
|
||||||
$history_id = $form->getElement("his_item_id");
|
$history_id = $form->getElement("his_item_id");
|
||||||
$history_id->setRequired(true);
|
$history_id->setRequired(true);
|
||||||
|
|
||||||
if ($form->isValid($data)) {
|
if ($form->isValid($data)) {
|
||||||
|
$history_id->setIgnore(true);
|
||||||
$values = $form->getValues();
|
$values = $form->getValues();
|
||||||
|
|
||||||
Logging::info("edited list item");
|
Logging::info("edited list item");
|
||||||
|
@ -253,7 +274,7 @@ class Application_Service_HistoryService
|
||||||
else {
|
else {
|
||||||
Logging::info("edited list item NOT VALID");
|
Logging::info("edited list item NOT VALID");
|
||||||
}
|
}
|
||||||
|
|
||||||
Logging::info($form->getMessages());
|
Logging::info($form->getMessages());
|
||||||
}
|
}
|
||||||
catch (Exception $e) {
|
catch (Exception $e) {
|
||||||
|
@ -265,28 +286,28 @@ class Application_Service_HistoryService
|
||||||
public function editPlayedFile($data) {
|
public function editPlayedFile($data) {
|
||||||
|
|
||||||
$this->con->beginTransaction();
|
$this->con->beginTransaction();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$form = new Application_Form_EditHistoryFile();
|
$form = new Application_Form_EditHistoryFile();
|
||||||
|
|
||||||
$json = $form->processAjax($data);
|
$json = $form->processAjax($data);
|
||||||
Logging::info($json);
|
Logging::info($json);
|
||||||
|
|
||||||
if ($form->isValid($data)) {
|
if ($form->isValid($data)) {
|
||||||
|
|
||||||
$id = $data["his_file_id"];
|
$id = $data["his_file_id"];
|
||||||
$file = Application_Model_StoredFile::RecallById($id, $this->con);
|
$file = Application_Model_StoredFile::RecallById($id, $this->con);
|
||||||
|
|
||||||
$md = array(
|
$md = array(
|
||||||
MDATA_KEY_TITLE => $data['his_file_title'],
|
MDATA_KEY_TITLE => $data['his_file_title'],
|
||||||
MDATA_KEY_CREATOR => $data['his_file_creator'],
|
MDATA_KEY_CREATOR => $data['his_file_creator'],
|
||||||
MDATA_KEY_COMPOSER => $data['his_file_composer'],
|
MDATA_KEY_COMPOSER => $data['his_file_composer'],
|
||||||
MDATA_KEY_COPYRIGHT => $data['his_file_copyright']
|
MDATA_KEY_COPYRIGHT => $data['his_file_copyright']
|
||||||
);
|
);
|
||||||
|
|
||||||
$file->setDbColMetadata($md);
|
$file->setDbColMetadata($md);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->con->commit();
|
$this->con->commit();
|
||||||
}
|
}
|
||||||
catch (Exception $e) {
|
catch (Exception $e) {
|
||||||
|
@ -297,17 +318,17 @@ class Application_Service_HistoryService
|
||||||
|
|
||||||
return $json;
|
return $json;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* id is an id in cc_playout_history */
|
/* id is an id in cc_playout_history */
|
||||||
public function deletePlayedItem($id) {
|
public function deletePlayedItem($id) {
|
||||||
|
|
||||||
$this->con->beginTransaction();
|
$this->con->beginTransaction();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
$record = CcPlayoutHistoryQuery::create()->findPk($id, $this->con);
|
$record = CcPlayoutHistoryQuery::create()->findPk($id, $this->con);
|
||||||
$record->delete($this->con);
|
$record->delete($this->con);
|
||||||
|
|
||||||
$this->con->commit();
|
$this->con->commit();
|
||||||
}
|
}
|
||||||
catch (Exception $e) {
|
catch (Exception $e) {
|
||||||
|
@ -316,28 +337,28 @@ class Application_Service_HistoryService
|
||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//---------------- Following code is for History Templates --------------------------//
|
//---------------- Following code is for History Templates --------------------------//
|
||||||
|
|
||||||
|
|
||||||
private function defaultItemTemplate() {
|
private function defaultItemTemplate() {
|
||||||
|
|
||||||
$fields = array();
|
$fields = array();
|
||||||
|
|
||||||
//array index is the position of the item in the history template table.
|
//array index is the position of the item in the history template table.
|
||||||
$fields[] = array("name" => "start", "type" => TEMPLATE_DATETIME, "isFileMd" => false);
|
$fields[] = array("name" => "starts", "type" => TEMPLATE_DATETIME, "isFileMd" => false);
|
||||||
$fields[] = array("name" => "end", "type" => TEMPLATE_DATETIME, "isFileMd" => false);
|
$fields[] = array("name" => "ends", "type" => TEMPLATE_DATETIME, "isFileMd" => false);
|
||||||
$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_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);
|
$fields[] = array("name" => MDATA_KEY_CREATOR, "type" => TEMPLATE_STRING, "isFileMd" => true);
|
||||||
|
|
||||||
return $fields;
|
return $fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getItemTemplate() {
|
private function getItemTemplate() {
|
||||||
|
|
||||||
$template_id = Application_Model_Preference::GetHistoryItemTemplate();
|
$template_id = Application_Model_Preference::GetHistoryItemTemplate();
|
||||||
|
|
||||||
if (is_numeric($template_id)) {
|
if (is_numeric($template_id)) {
|
||||||
Logging::info("template id is: $template_id");
|
Logging::info("template id is: $template_id");
|
||||||
}
|
}
|
||||||
|
@ -345,7 +366,7 @@ class Application_Service_HistoryService
|
||||||
Logging::info("Using default template");
|
Logging::info("Using default template");
|
||||||
$template = $this->defaultItemTemplate();
|
$template = $this->defaultItemTemplate();
|
||||||
}
|
}
|
||||||
|
|
||||||
return $template;
|
return $template;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -58,7 +58,8 @@ var AIRTIME = (function(AIRTIME) {
|
||||||
|
|
||||||
if (oConfig.sExtends == "pdf") {
|
if (oConfig.sExtends == "pdf") {
|
||||||
this.fnSetText( oFlash,
|
this.fnSetText( oFlash,
|
||||||
"title:"+ this.fnGetTitle(oConfig) +"\n"+
|
//"title:"+ this.fnGetTitle(oConfig) +"\n"+
|
||||||
|
"title: Testing the Title Out\n"+
|
||||||
"message:"+ oConfig.sPdfMessage +"\n"+
|
"message:"+ oConfig.sPdfMessage +"\n"+
|
||||||
"colWidth:"+ this.fnCalcColRatios(oConfig) +"\n"+
|
"colWidth:"+ this.fnCalcColRatios(oConfig) +"\n"+
|
||||||
"orientation:"+ oConfig.sPdfOrientation +"\n"+
|
"orientation:"+ oConfig.sPdfOrientation +"\n"+
|
||||||
|
|
Loading…
Reference in New Issue