editing in progress
This commit is contained in:
parent
c744d88f23
commit
29c8570ade
8 changed files with 551 additions and 338 deletions
|
@ -6,8 +6,11 @@ class PlayouthistoryController extends Zend_Controller_Action
|
||||||
{
|
{
|
||||||
$ajaxContext = $this->_helper->getHelper('AjaxContext');
|
$ajaxContext = $this->_helper->getHelper('AjaxContext');
|
||||||
$ajaxContext
|
$ajaxContext
|
||||||
->addActionContext('playout-history-feed', 'json')
|
->addActionContext('aggregate-history-feed', 'json')
|
||||||
|
->addActionContext('item-history-feed', 'json')
|
||||||
->addActionContext('edit-aggregate-item', 'json')
|
->addActionContext('edit-aggregate-item', 'json')
|
||||||
|
->addActionContext('edit-list-item', 'json')
|
||||||
|
->addActionContext('update-aggregate-item', 'json')
|
||||||
->initContext();
|
->initContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,7 +61,7 @@ class PlayouthistoryController extends Zend_Controller_Action
|
||||||
$this->view->headLink()->appendStylesheet($baseUrl.'css/playouthistory.css?'.$CC_CONFIG['airtime_version']);
|
$this->view->headLink()->appendStylesheet($baseUrl.'css/playouthistory.css?'.$CC_CONFIG['airtime_version']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function playoutHistoryFeedAction()
|
public function aggregateHistoryFeedAction()
|
||||||
{
|
{
|
||||||
$request = $this->getRequest();
|
$request = $this->getRequest();
|
||||||
$current_time = time();
|
$current_time = time();
|
||||||
|
@ -80,6 +83,28 @@ class PlayouthistoryController extends Zend_Controller_Action
|
||||||
$this->view->history = $r["history"];
|
$this->view->history = $r["history"];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function itemHistoryFeedAction()
|
||||||
|
{
|
||||||
|
$request = $this->getRequest();
|
||||||
|
$current_time = time();
|
||||||
|
|
||||||
|
$params = $request->getParams();
|
||||||
|
|
||||||
|
$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->getListView($startsDT, $endsDT, $params);
|
||||||
|
|
||||||
|
$this->view->sEcho = $r["sEcho"];
|
||||||
|
$this->view->iTotalDisplayRecords = $r["iTotalDisplayRecords"];
|
||||||
|
$this->view->iTotalRecords = $r["iTotalRecords"];
|
||||||
|
$this->view->history = $r["history"];
|
||||||
|
}
|
||||||
|
|
||||||
public function editAggregateItemAction()
|
public function editAggregateItemAction()
|
||||||
{
|
{
|
||||||
$file_id = $this->_getParam('id');
|
$file_id = $this->_getParam('id');
|
||||||
|
@ -93,12 +118,28 @@ class PlayouthistoryController extends Zend_Controller_Action
|
||||||
unset($this->view->form);
|
unset($this->view->form);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function editListItemAction()
|
||||||
|
{
|
||||||
|
$file_id = $this->_getParam('id');
|
||||||
|
|
||||||
|
$historyService = new Application_Service_HistoryService();
|
||||||
|
$form = $historyService->makeHistoryFileForm($file_id);
|
||||||
|
|
||||||
|
$this->view->form = $form;
|
||||||
|
$this->view->dialog = $this->view->render('form/edit-history-file.phtml');
|
||||||
|
|
||||||
|
unset($this->view->form);
|
||||||
|
}
|
||||||
|
|
||||||
public function updateAggregateItemAction()
|
public function updateAggregateItemAction()
|
||||||
{
|
{
|
||||||
$file_id = $this->_getParam('id');
|
$request = $this->getRequest();
|
||||||
|
$params = $request->getPost();
|
||||||
|
Logging::info($params);
|
||||||
|
|
||||||
$historyService = new Application_Service_HistoryService();
|
$historyService = new Application_Service_HistoryService();
|
||||||
$historyService->editPlayedFile($file_id);
|
$json = $historyService->editPlayedFile($params);
|
||||||
}
|
|
||||||
|
|
||||||
|
$this->view->data = $json;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,12 @@ class Application_Form_EditHistoryFile extends Zend_Form
|
||||||
$this->setMethod('post');
|
$this->setMethod('post');
|
||||||
|
|
||||||
|
|
||||||
$this->addElement('hidden', 'file_id');
|
$file_id = new Zend_Form_Element_Hidden('his_file_id');
|
||||||
|
$file_id->setValidators(array(
|
||||||
|
new Zend_Validate_Int()
|
||||||
|
));
|
||||||
|
$this->addElement($file_id);
|
||||||
|
|
||||||
|
|
||||||
/* Title form element */
|
/* Title form element */
|
||||||
$title = new Zend_Form_Element_Text('his_file_title');
|
$title = new Zend_Form_Element_Text('his_file_title');
|
||||||
|
@ -52,7 +57,7 @@ class Application_Form_EditHistoryFile extends Zend_Form
|
||||||
// Add the submit button
|
// Add the submit button
|
||||||
$this->addElement('button', 'his_file_save', array(
|
$this->addElement('button', 'his_file_save', array(
|
||||||
'ignore' => true,
|
'ignore' => true,
|
||||||
'class' => 'btn',
|
'class' => 'btn his_file_save',
|
||||||
'label' => _('Save'),
|
'label' => _('Save'),
|
||||||
'decorators' => array(
|
'decorators' => array(
|
||||||
'ViewHelper'
|
'ViewHelper'
|
||||||
|
@ -62,7 +67,7 @@ class Application_Form_EditHistoryFile extends Zend_Form
|
||||||
// Add the cancel button
|
// Add the cancel button
|
||||||
$this->addElement('button', 'his_file_cancel', array(
|
$this->addElement('button', 'his_file_cancel', array(
|
||||||
'ignore' => true,
|
'ignore' => true,
|
||||||
'class' => 'btn',
|
'class' => 'btn his_file_cancel',
|
||||||
'label' => _('Cancel'),
|
'label' => _('Cancel'),
|
||||||
'decorators' => array(
|
'decorators' => array(
|
||||||
'ViewHelper'
|
'ViewHelper'
|
||||||
|
|
|
@ -58,6 +58,14 @@ class Application_Model_Datatables
|
||||||
public static function findEntries($con, $displayColumns, $fromTable,
|
public static function findEntries($con, $displayColumns, $fromTable,
|
||||||
$data, $dataProp = "aaData")
|
$data, $dataProp = "aaData")
|
||||||
{
|
{
|
||||||
|
|
||||||
|
$where = array();
|
||||||
|
/* Holds the parameters for binding after the statement has been
|
||||||
|
prepared */
|
||||||
|
$params = array();
|
||||||
|
|
||||||
|
if (isset($data['advSearch']) && $data['advSearch'] === 'true') {
|
||||||
|
|
||||||
$librarySetting =
|
$librarySetting =
|
||||||
Application_Model_Preference::getCurrentLibraryTableColumnMap();
|
Application_Model_Preference::getCurrentLibraryTableColumnMap();
|
||||||
//$displayColumns[] = 'owner';
|
//$displayColumns[] = 'owner';
|
||||||
|
@ -96,12 +104,6 @@ class Application_Model_Datatables
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$where = array();
|
|
||||||
/* Holds the parameters for binding after the statement has been
|
|
||||||
prepared */
|
|
||||||
$params = array();
|
|
||||||
|
|
||||||
if (isset($data['advSearch']) && $data['advSearch'] === 'true') {
|
|
||||||
$advancedWhere = self::buildWhereClauseForAdvancedSearch($dbname2searchTerm);
|
$advancedWhere = self::buildWhereClauseForAdvancedSearch($dbname2searchTerm);
|
||||||
if (!empty($advancedWhere['clause'])) {
|
if (!empty($advancedWhere['clause'])) {
|
||||||
$where[] = join(" AND ", $advancedWhere['clause']);
|
$where[] = join(" AND ", $advancedWhere['clause']);
|
||||||
|
@ -119,7 +121,6 @@ class Application_Model_Datatables
|
||||||
$sql = $selectorCount." FROM ".$fromTable;
|
$sql = $selectorCount." FROM ".$fromTable;
|
||||||
$sqlTotalRows = $sql;
|
$sqlTotalRows = $sql;
|
||||||
|
|
||||||
|
|
||||||
if (isset($searchTerms)) {
|
if (isset($searchTerms)) {
|
||||||
$searchCols = array();
|
$searchCols = array();
|
||||||
for ($i = 0; $i < $data["iColumns"]; $i++) {
|
for ($i = 0; $i < $data["iColumns"]; $i++) {
|
||||||
|
@ -164,57 +165,47 @@ class Application_Model_Datatables
|
||||||
|
|
||||||
$sql = $selectorRows." FROM ".$fromTable." WHERE ".$where." ORDER BY ".$orderby;
|
$sql = $selectorRows." FROM ".$fromTable." WHERE ".$where." ORDER BY ".$orderby;
|
||||||
|
|
||||||
//limit the results returned.
|
|
||||||
if ($displayLength !== -1) {
|
|
||||||
$sql .= " OFFSET ".$data["iDisplayStart"]." LIMIT ".$displayLength;
|
|
||||||
}
|
}
|
||||||
} else {
|
else {
|
||||||
$sql = $selectorRows." FROM ".$fromTable." ORDER BY ".$orderby;
|
$sql = $selectorRows." FROM ".$fromTable." ORDER BY ".$orderby;
|
||||||
|
}
|
||||||
|
|
||||||
//limit the results returned.
|
//limit the results returned.
|
||||||
if ($displayLength !== -1) {
|
if ($displayLength !== -1) {
|
||||||
$sql .= " OFFSET ".$data["iDisplayStart"]." LIMIT ".$displayLength;
|
$sql .= " OFFSET ".$data["iDisplayStart"]." LIMIT ".$displayLength;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
|
Logging::info($sqlTotalRows);
|
||||||
|
|
||||||
$r = $con->query($sqlTotalRows);
|
$r = $con->query($sqlTotalRows);
|
||||||
$totalRows = $r->fetchColumn(0);
|
$totalRows = $r->fetchColumn(0);
|
||||||
|
|
||||||
if (isset($sqlTotalDisplayRows)) {
|
if (isset($sqlTotalDisplayRows)) {
|
||||||
|
Logging::info("sql is set");
|
||||||
|
Logging::info($sqlTotalDisplayRows);
|
||||||
$totalDisplayRows = Application_Common_Database::prepareAndExecute($sqlTotalDisplayRows, $params, 'column');
|
$totalDisplayRows = Application_Common_Database::prepareAndExecute($sqlTotalDisplayRows, $params, 'column');
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
|
Logging::info("sql is not set.");
|
||||||
$totalDisplayRows = $totalRows;
|
$totalDisplayRows = $totalRows;
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO
|
//TODO
|
||||||
if ($needToBind) {
|
if ($needToBind) {
|
||||||
$results = Application_Common_Database::prepareAndExecute($sql, $params);
|
$results = Application_Common_Database::prepareAndExecute($sql, $params);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
$stmt = $con->query($sql);
|
$stmt = $con->query($sql);
|
||||||
$stmt->setFetchMode(PDO::FETCH_ASSOC);
|
$stmt->setFetchMode(PDO::FETCH_ASSOC);
|
||||||
$results = $stmt->fetchAll();
|
$results = $stmt->fetchAll();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
catch (Exception $e) {
|
||||||
|
Logging::info($e->getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
// we need to go over all items and fix length for playlist
|
|
||||||
// in case the playlist contains dynamic block
|
|
||||||
foreach ($results as &$r) {
|
|
||||||
//this function is also called for Manage Users so in
|
|
||||||
//this case there will be no 'ftype'
|
|
||||||
if (isset($r['ftype'])) {
|
|
||||||
if ($r['ftype'] == 'playlist') {
|
|
||||||
$pl = new Application_Model_Playlist($r['id']);
|
|
||||||
$r['length'] = $pl->getLength();
|
|
||||||
} elseif ($r['ftype'] == "block") {
|
|
||||||
$bl = new Application_Model_Block($r['id']);
|
|
||||||
$r['bl_type'] = $bl->isStatic() ? 'static' : 'dynamic';
|
|
||||||
$r['length'] = $bl->getLength();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (Exception $e) {
|
|
||||||
Logging::debug($e->getMessage());
|
|
||||||
}
|
|
||||||
return array(
|
return array(
|
||||||
"sEcho" => intval($data["sEcho"]),
|
"sEcho" => intval($data["sEcho"]),
|
||||||
"iTotalDisplayRecords" => intval($totalDisplayRows),
|
"iTotalDisplayRecords" => intval($totalDisplayRows),
|
||||||
|
|
|
@ -778,6 +778,18 @@ SQL;
|
||||||
foreach ($results['aaData'] as &$row) {
|
foreach ($results['aaData'] as &$row) {
|
||||||
$row['id'] = intval($row['id']);
|
$row['id'] = intval($row['id']);
|
||||||
|
|
||||||
|
//taken from Datatables.php, needs to be cleaned up there.
|
||||||
|
if (isset($r['ftype'])) {
|
||||||
|
if ($r['ftype'] == 'playlist') {
|
||||||
|
$pl = new Application_Model_Playlist($r['id']);
|
||||||
|
$r['length'] = $pl->getLength();
|
||||||
|
} elseif ($r['ftype'] == "block") {
|
||||||
|
$bl = new Application_Model_Block($r['id']);
|
||||||
|
$r['bl_type'] = $bl->isStatic() ? 'static' : 'dynamic';
|
||||||
|
$r['length'] = $bl->getLength();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ($row['ftype'] === "audioclip") {
|
if ($row['ftype'] === "audioclip") {
|
||||||
|
|
||||||
$cuein_formatter = new LengthFormatter($row["cuein"]);
|
$cuein_formatter = new LengthFormatter($row["cuein"]);
|
||||||
|
|
|
@ -14,6 +14,8 @@ class Application_Service_HistoryService
|
||||||
"length" => "length",
|
"length" => "length",
|
||||||
"composer" => "composer",
|
"composer" => "composer",
|
||||||
"copyright" => "copyright",
|
"copyright" => "copyright",
|
||||||
|
"starts" => "starts",
|
||||||
|
"ends" => "ends"
|
||||||
);
|
);
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
|
@ -35,6 +37,34 @@ class Application_Service_HistoryService
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getListView($startDT, $endDT, $opts)
|
||||||
|
{
|
||||||
|
$this->translateColumns($opts);
|
||||||
|
|
||||||
|
$select = array (
|
||||||
|
"file.track_title as title",
|
||||||
|
"file.artist_name as artist",
|
||||||
|
"playout.starts",
|
||||||
|
"playout.ends",
|
||||||
|
"playout.history_id"
|
||||||
|
);
|
||||||
|
|
||||||
|
$start = $startDT->format("Y-m-d H:i:s");
|
||||||
|
$end = $endDT->format("Y-m-d H:i:s");
|
||||||
|
|
||||||
|
$historyTable = "(
|
||||||
|
select history.starts as starts, history.ends as ends,
|
||||||
|
history.id as history_id, history.file_id as file_id
|
||||||
|
from cc_playout_history as history
|
||||||
|
where history.starts >= '{$start}' and history.starts < '{$end}'
|
||||||
|
) AS playout
|
||||||
|
left join cc_files as file on (file.id = playout.file_id)";
|
||||||
|
|
||||||
|
$results = Application_Model_Datatables::findEntries($this->con, $select, $historyTable, $opts, "history");
|
||||||
|
|
||||||
|
return $results;
|
||||||
|
}
|
||||||
|
|
||||||
public function getAggregateView($startDT, $endDT, $opts)
|
public function getAggregateView($startDT, $endDT, $opts)
|
||||||
{
|
{
|
||||||
$this->translateColumns($opts);
|
$this->translateColumns($opts);
|
||||||
|
@ -42,11 +72,11 @@ class Application_Service_HistoryService
|
||||||
$select = array (
|
$select = array (
|
||||||
"file.track_title as title",
|
"file.track_title as title",
|
||||||
"file.artist_name as artist",
|
"file.artist_name as artist",
|
||||||
"playout.played",
|
"playout.played as played",
|
||||||
"playout.file_id",
|
"playout.file_id",
|
||||||
"file.composer",
|
"file.composer as composer",
|
||||||
"file.copyright",
|
"file.copyright as copyright",
|
||||||
"file.length"
|
"file.length as length"
|
||||||
);
|
);
|
||||||
|
|
||||||
$start = $startDT->format("Y-m-d H:i:s");
|
$start = $startDT->format("Y-m-d H:i:s");
|
||||||
|
@ -120,16 +150,34 @@ class Application_Service_HistoryService
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function makeHistoryItemForm() {
|
/* id is an id in cc_playout_history */
|
||||||
|
public function makeHistoryItemForm($id) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* id is an id in cc_files */
|
||||||
public function makeHistoryFileForm($id) {
|
public function makeHistoryFileForm($id) {
|
||||||
|
|
||||||
|
try {
|
||||||
$form = new Application_Form_EditHistoryFile();
|
$form = new Application_Form_EditHistoryFile();
|
||||||
|
|
||||||
|
$file = Application_Model_StoredFile::RecallById($id, $this->con);
|
||||||
|
$md = $file->getDbColMetadata();
|
||||||
|
|
||||||
|
$form->populate(array(
|
||||||
|
'his_file_id' => $id,
|
||||||
|
'his_file_title' => $md[MDATA_KEY_TITLE],
|
||||||
|
'his_file_creator' => $md[MDATA_KEY_CREATOR],
|
||||||
|
'his_file_composer' => $md[MDATA_KEY_COMPOSER],
|
||||||
|
'his_file_copyright' => $md[MDATA_KEY_COPYRIGHT]
|
||||||
|
));
|
||||||
|
|
||||||
return $form;
|
return $form;
|
||||||
}
|
}
|
||||||
|
catch (Exception $e) {
|
||||||
|
Logging::debug($e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* id is an id in cc_playout_history */
|
/* id is an id in cc_playout_history */
|
||||||
public function editPlayedItem($id) {
|
public function editPlayedItem($id) {
|
||||||
|
@ -137,8 +185,29 @@ class Application_Service_HistoryService
|
||||||
}
|
}
|
||||||
|
|
||||||
/* id is an id in cc_files */
|
/* id is an id in cc_files */
|
||||||
public function editPlayedFile($id) {
|
public function editPlayedFile($data) {
|
||||||
|
|
||||||
|
$form = new Application_Form_EditHistoryFile();
|
||||||
|
|
||||||
|
$json = $form->processAjax($data);
|
||||||
|
Logging::info($json);
|
||||||
|
|
||||||
|
if ($form->isValid($data)) {
|
||||||
|
|
||||||
|
$id = $data["his_file_id"];
|
||||||
|
$file = Application_Model_StoredFile::RecallById($id, $this->con);
|
||||||
|
|
||||||
|
$md = array(
|
||||||
|
MDATA_KEY_TITLE => $data['his_file_title'],
|
||||||
|
MDATA_KEY_CREATOR => $data['his_file_creator'],
|
||||||
|
MDATA_KEY_COMPOSER => $data['his_file_composer'],
|
||||||
|
MDATA_KEY_COPYRIGHT => $data['his_file_copyright']
|
||||||
|
);
|
||||||
|
|
||||||
|
$file->setDbColMetadata($md);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $json;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,4 +1,18 @@
|
||||||
<div id="history_content" class="ui-widget ui-widget-content block-shadow alpha-block padded">
|
<div id="history_content" class="ui-widget ui-widget-content block-shadow alpha-block padded">
|
||||||
<?php echo $this->date_form; ?>
|
<?php echo $this->date_form; ?>
|
||||||
<table id="history_table" cellpadding="0" cellspacing="0" class="datatable"></table>
|
|
||||||
|
|
||||||
|
<div id="his-tabs">
|
||||||
|
<ul>
|
||||||
|
<li><a href="#his-tabs-1"><?php echo _("Aggregate"); ?></a></li>
|
||||||
|
<li><a href="#his-tabs-2"><?php echo _("List"); ?></a></li>
|
||||||
|
</ul>
|
||||||
|
<div id="his-tabs-1">
|
||||||
|
<table id="history_table_aggregate" cellpadding="0" cellspacing="0" class="datatable"></table>
|
||||||
|
</div>
|
||||||
|
<div id="his-tabs-2">
|
||||||
|
<table id="history_table_list" cellpadding="0" cellspacing="0" class="datatable"></table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
|
@ -1,3 +1,44 @@
|
||||||
|
var AIRTIME = (function(AIRTIME) {
|
||||||
|
var mod;
|
||||||
|
|
||||||
|
if (AIRTIME.history === undefined) {
|
||||||
|
AIRTIME.history = {};
|
||||||
|
}
|
||||||
|
mod = AIRTIME.history;
|
||||||
|
|
||||||
|
var $historyContentDiv;
|
||||||
|
|
||||||
|
var oTableTools = {
|
||||||
|
"sSwfPath": baseUrl+"js/datatables/plugin/TableTools/swf/copy_cvs_xls_pdf.swf",
|
||||||
|
"aButtons": [
|
||||||
|
{
|
||||||
|
"sExtends": "copy",
|
||||||
|
"fnComplete": function(nButton, oConfig, oFlash, text) {
|
||||||
|
var lines = text.split('\n').length,
|
||||||
|
len = this.s.dt.nTFoot === null ? lines-1 : lines-2,
|
||||||
|
plural = (len==1) ? "" : "s";
|
||||||
|
alert(sprintf($.i18n._('Copied %s row%s to the clipboard'), len, plural));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"sExtends": "csv",
|
||||||
|
"fnClick": setFlashFileName
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"sExtends": "pdf",
|
||||||
|
"fnClick": setFlashFileName
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"sExtends": "print",
|
||||||
|
"sInfo" : sprintf($.i18n._("%sPrint view%sPlease use your browser's print function to print this table. Press escape when finished."), "<h6>", "</h6><p>")
|
||||||
|
}
|
||||||
|
]
|
||||||
|
};
|
||||||
|
|
||||||
|
var lengthMenu = [[50, 100, 500, -1], [50, 100, 500, $.i18n._("All")]];
|
||||||
|
|
||||||
|
var sDom = 'lf<"dt-process-rel"r><"H"T><"dataTables_scrolling"t><"F"ip>';
|
||||||
|
|
||||||
function getFileName(ext){
|
function getFileName(ext){
|
||||||
var filename = $("#his_date_start").val()+"_"+$("#his_time_start").val()+"m--"+$("#his_date_end").val()+"_"+$("#his_time_end").val()+"m";
|
var filename = $("#his_date_start").val()+"_"+$("#his_time_start").val()+"m--"+$("#his_date_end").val()+"_"+$("#his_time_end").val()+"m";
|
||||||
filename = filename.replace(/:/g,"h");
|
filename = filename.replace(/:/g,"h");
|
||||||
|
@ -30,22 +71,8 @@ function setFlashFileName( nButton, oConfig, oFlash ) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var AIRTIME = (function(AIRTIME) {
|
/* This callback can be used for all history tables */
|
||||||
var mod;
|
function fnServerData( sSource, aoData, fnCallback ) {
|
||||||
|
|
||||||
if (AIRTIME.history === undefined) {
|
|
||||||
AIRTIME.history = {};
|
|
||||||
}
|
|
||||||
mod = AIRTIME.history;
|
|
||||||
|
|
||||||
mod.historyTable = function() {
|
|
||||||
var oTable,
|
|
||||||
historyContentDiv = $("#history_content"),
|
|
||||||
historyTableDiv = historyContentDiv.find("#history_table"),
|
|
||||||
tableHeight = historyContentDiv.height() - 200,
|
|
||||||
fnServerData;
|
|
||||||
|
|
||||||
fnServerData = function ( sSource, aoData, fnCallback ) {
|
|
||||||
|
|
||||||
if (fnServerData.hasOwnProperty("start")) {
|
if (fnServerData.hasOwnProperty("start")) {
|
||||||
aoData.push( { name: "start", value: fnServerData.start} );
|
aoData.push( { name: "start", value: fnServerData.start} );
|
||||||
|
@ -63,7 +90,12 @@ var AIRTIME = (function(AIRTIME) {
|
||||||
"data": aoData,
|
"data": aoData,
|
||||||
"success": fnCallback
|
"success": fnCallback
|
||||||
} );
|
} );
|
||||||
},
|
}
|
||||||
|
|
||||||
|
function aggregateHistoryTable() {
|
||||||
|
var oTable,
|
||||||
|
$historyTableDiv = $historyContentDiv.find("#history_table_aggregate"),
|
||||||
|
fnRowCallback;
|
||||||
|
|
||||||
fnRowCallback = function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
|
fnRowCallback = function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
|
||||||
var url = baseUrl+"Playouthistory/edit-aggregate-item/format/json/id/"+aData.file_id,
|
var url = baseUrl+"Playouthistory/edit-aggregate-item/format/json/id/"+aData.file_id,
|
||||||
|
@ -75,7 +107,7 @@ var AIRTIME = (function(AIRTIME) {
|
||||||
$('td.his_edit', nRow).html($link);
|
$('td.his_edit', nRow).html($link);
|
||||||
};
|
};
|
||||||
|
|
||||||
oTable = historyTableDiv.dataTable( {
|
oTable = $historyTableDiv.dataTable( {
|
||||||
|
|
||||||
"aoColumns": [
|
"aoColumns": [
|
||||||
{"sTitle": $.i18n._("Title"), "mDataProp": "title", "sClass": "his_title"}, /* Title */
|
{"sTitle": $.i18n._("Title"), "mDataProp": "title", "sClass": "his_title"}, /* Title */
|
||||||
|
@ -89,66 +121,72 @@ var AIRTIME = (function(AIRTIME) {
|
||||||
|
|
||||||
"bProcessing": true,
|
"bProcessing": true,
|
||||||
"bServerSide": true,
|
"bServerSide": true,
|
||||||
"sAjaxSource": baseUrl+"Playouthistory/playout-history-feed",
|
"sAjaxSource": baseUrl+"playouthistory/aggregate-history-feed",
|
||||||
"sAjaxDataProp": "history",
|
"sAjaxDataProp": "history",
|
||||||
|
|
||||||
"fnServerData": fnServerData,
|
"fnServerData": fnServerData,
|
||||||
|
|
||||||
"fnRowCallback": fnRowCallback,
|
"fnRowCallback": fnRowCallback,
|
||||||
|
|
||||||
"oLanguage": datatables_dict,
|
"oLanguage": datatables_dict,
|
||||||
|
"aLengthMenu": lengthMenu,
|
||||||
"aLengthMenu": [[50, 100, 500, -1], [50, 100, 500, $.i18n._("All")]],
|
|
||||||
"iDisplayLength": 50,
|
"iDisplayLength": 50,
|
||||||
|
|
||||||
"sPaginationType": "full_numbers",
|
"sPaginationType": "full_numbers",
|
||||||
"bJQueryUI": true,
|
"bJQueryUI": true,
|
||||||
"bAutoWidth": true,
|
"bAutoWidth": true,
|
||||||
|
"sDom": sDom,
|
||||||
"sDom": 'lf<"dt-process-rel"r><"H"T><"dataTables_scrolling"t><"F"ip>',
|
"oTableTools": oTableTools
|
||||||
|
|
||||||
"oTableTools": {
|
|
||||||
"sSwfPath": baseUrl+"js/datatables/plugin/TableTools/swf/copy_cvs_xls_pdf.swf",
|
|
||||||
"aButtons": [
|
|
||||||
{
|
|
||||||
"sExtends": "copy",
|
|
||||||
"fnComplete": function(nButton, oConfig, oFlash, text) {
|
|
||||||
var lines = text.split('\n').length,
|
|
||||||
len = this.s.dt.nTFoot === null ? lines-1 : lines-2,
|
|
||||||
plural = (len==1) ? "" : "s";
|
|
||||||
alert(sprintf($.i18n._('Copied %s row%s to the clipboard'), len, plural));
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"sExtends": "csv",
|
|
||||||
"fnClick": setFlashFileName
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"sExtends": "pdf",
|
|
||||||
"fnClick": setFlashFileName
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"sExtends": "print",
|
|
||||||
"sInfo" : sprintf($.i18n._("%sPrint view%sPlease use your browser's print function to print this table. Press escape when finished."), "<h6>", "</h6><p>")
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
oTable.fnSetFilteringDelay(350);
|
oTable.fnSetFilteringDelay(350);
|
||||||
|
|
||||||
historyContentDiv.find(".dataTables_scrolling").css("max-height", tableHeight);
|
|
||||||
|
|
||||||
return oTable;
|
return oTable;
|
||||||
|
}
|
||||||
|
|
||||||
|
function itemHistoryTable() {
|
||||||
|
var oTable,
|
||||||
|
$historyTableDiv = $historyContentDiv.find("#history_table_list"),
|
||||||
|
fnRowCallback;
|
||||||
|
|
||||||
|
fnRowCallback = function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
|
||||||
|
var url = baseUrl+"playouthistory/edit-list-item/format/json/id/"+aData.history_id,
|
||||||
|
$link = $("<a/>", {
|
||||||
|
"href": url,
|
||||||
|
"text": $.i18n._("Edit")
|
||||||
|
});
|
||||||
|
|
||||||
|
$('td.his_edit', nRow).html($link);
|
||||||
};
|
};
|
||||||
|
|
||||||
return AIRTIME;
|
oTable = $historyTableDiv.dataTable( {
|
||||||
|
|
||||||
}(AIRTIME || {}));
|
"aoColumns": [
|
||||||
|
{"sTitle": $.i18n._("Start"), "mDataProp": "starts", "sClass": "his_starts"}, /* Starts */
|
||||||
|
{"sTitle": $.i18n._("End"), "mDataProp": "ends", "sClass": "his_ends"}, /* Ends */
|
||||||
|
{"sTitle": $.i18n._("Title"), "mDataProp": "title", "sClass": "his_title"}, /* Title */
|
||||||
|
{"sTitle": $.i18n._("Creator"), "mDataProp": "artist", "sClass": "his_artist"}, /* Creator */
|
||||||
|
{"sTitle" : $.i18n._("Admin"), "mDataProp": "history_id", "bSearchable" : false, "sClass": "his_edit"}, /* id of history item */
|
||||||
|
],
|
||||||
|
|
||||||
$(document).ready(function(){
|
"bProcessing": true,
|
||||||
|
"bServerSide": true,
|
||||||
|
"sAjaxSource": baseUrl+"playouthistory/item-history-feed",
|
||||||
|
"sAjaxDataProp": "history",
|
||||||
|
"fnServerData": fnServerData,
|
||||||
|
"fnRowCallback": fnRowCallback,
|
||||||
|
"oLanguage": datatables_dict,
|
||||||
|
"aLengthMenu": lengthMenu,
|
||||||
|
"iDisplayLength": 50,
|
||||||
|
"sPaginationType": "full_numbers",
|
||||||
|
"bJQueryUI": true,
|
||||||
|
"bAutoWidth": true,
|
||||||
|
"sDom": sDom,
|
||||||
|
"oTableTools": oTableTools
|
||||||
|
});
|
||||||
|
oTable.fnSetFilteringDelay(350);
|
||||||
|
|
||||||
|
return oTable;
|
||||||
|
}
|
||||||
|
|
||||||
|
mod.onReady = function() {
|
||||||
|
|
||||||
var viewport = AIRTIME.utilities.findViewportDimensions(),
|
var viewport = AIRTIME.utilities.findViewportDimensions(),
|
||||||
history_content = $("#history_content"),
|
|
||||||
widgetHeight = viewport.height - 185,
|
widgetHeight = viewport.height - 185,
|
||||||
screenWidth = Math.floor(viewport.width - 110),
|
screenWidth = Math.floor(viewport.width - 110),
|
||||||
oBaseDatePickerSettings,
|
oBaseDatePickerSettings,
|
||||||
|
@ -157,19 +195,39 @@ $(document).ready(function(){
|
||||||
dateStartId = "#his_date_start",
|
dateStartId = "#his_date_start",
|
||||||
timeStartId = "#his_time_start",
|
timeStartId = "#his_time_start",
|
||||||
dateEndId = "#his_date_end",
|
dateEndId = "#his_date_end",
|
||||||
timeEndId = "#his_time_end";
|
timeEndId = "#his_time_end",
|
||||||
|
$hisDialogEl;
|
||||||
|
|
||||||
|
$historyContentDiv = $("#history_content");
|
||||||
|
|
||||||
|
function removeHistoryDialog() {
|
||||||
|
$hisDialogEl.dialog("destroy");
|
||||||
|
$hisDialogEl.remove();
|
||||||
|
}
|
||||||
|
|
||||||
|
function makeHistoryDialog(html) {
|
||||||
|
$hisDialogEl = $(html);
|
||||||
|
|
||||||
|
$hisDialogEl.dialog({
|
||||||
|
title: $.i18n._("Edit History Record"),
|
||||||
|
modal: true,
|
||||||
|
close: function() {
|
||||||
|
removeHistoryDialog();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Icon hover states for search.
|
* Icon hover states for search.
|
||||||
*/
|
*/
|
||||||
history_content.on("mouseenter", ".his-timerange .ui-button", function(ev) {
|
$historyContentDiv.on("mouseenter", ".his-timerange .ui-button", function(ev) {
|
||||||
$(this).addClass("ui-state-hover");
|
$(this).addClass("ui-state-hover");
|
||||||
});
|
});
|
||||||
history_content.on("mouseleave", ".his-timerange .ui-button", function(ev) {
|
$historyContentDiv.on("mouseleave", ".his-timerange .ui-button", function(ev) {
|
||||||
$(this).removeClass("ui-state-hover");
|
$(this).removeClass("ui-state-hover");
|
||||||
});
|
});
|
||||||
|
|
||||||
history_content
|
$historyContentDiv
|
||||||
.height(widgetHeight)
|
.height(widgetHeight)
|
||||||
.width(screenWidth);
|
.width(screenWidth);
|
||||||
|
|
||||||
|
@ -193,36 +251,51 @@ $(document).ready(function(){
|
||||||
minuteText: $.i18n._("Minute")
|
minuteText: $.i18n._("Minute")
|
||||||
};
|
};
|
||||||
|
|
||||||
oTable = AIRTIME.history.historyTable();
|
oTable = aggregateHistoryTable();
|
||||||
|
itemHistoryTable();
|
||||||
|
|
||||||
history_content.find(dateStartId).datepicker(oBaseDatePickerSettings);
|
$historyContentDiv.find(dateStartId).datepicker(oBaseDatePickerSettings);
|
||||||
history_content.find(timeStartId).timepicker(oBaseTimePickerSettings);
|
$historyContentDiv.find(timeStartId).timepicker(oBaseTimePickerSettings);
|
||||||
history_content.find(dateEndId).datepicker(oBaseDatePickerSettings);
|
$historyContentDiv.find(dateEndId).datepicker(oBaseDatePickerSettings);
|
||||||
history_content.find(timeEndId).timepicker(oBaseTimePickerSettings);
|
$historyContentDiv.find(timeEndId).timepicker(oBaseTimePickerSettings);
|
||||||
|
|
||||||
history_content.on("click", "td.his_edit", function(e) {
|
$historyContentDiv.on("click", "td.his_edit", function(e) {
|
||||||
var url = e.target.href;
|
var url = e.target.href;
|
||||||
|
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
$.get(url, function(json) {
|
$.get(url, function(json) {
|
||||||
var dialog = $(json.dialog);
|
|
||||||
|
|
||||||
dialog.dialog({
|
makeHistoryDialog(json.dialog);
|
||||||
autoOpen: false,
|
|
||||||
title: $.i18n._("Edit History Record"),
|
|
||||||
//width: 460,
|
|
||||||
//height: 660,
|
|
||||||
modal: true
|
|
||||||
//close: closeDialogLibrary
|
|
||||||
});
|
|
||||||
|
|
||||||
dialog.dialog('open');
|
|
||||||
|
|
||||||
}, "json");
|
}, "json");
|
||||||
});
|
});
|
||||||
|
|
||||||
history_content.find("#his_submit").click(function(ev){
|
$('body').on("click", ".his_file_save", function(e) {
|
||||||
|
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
|
var $form = $(this).parents("form");
|
||||||
|
var data = $form.serializeArray();
|
||||||
|
|
||||||
|
var url = baseUrl+"Playouthistory/update-aggregate-item/format/json";
|
||||||
|
|
||||||
|
$.post(url, data, function(json) {
|
||||||
|
|
||||||
|
//TODO put errors on form.
|
||||||
|
if (json.data !== "true") {
|
||||||
|
//makeHistoryDialog(json.dialog);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
removeHistoryDialog();
|
||||||
|
oTable.fnDraw();
|
||||||
|
}
|
||||||
|
|
||||||
|
}, "json");
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
$historyContentDiv.find("#his_submit").click(function(ev){
|
||||||
var fn,
|
var fn,
|
||||||
oRange;
|
oRange;
|
||||||
|
|
||||||
|
@ -235,4 +308,12 @@ $(document).ready(function(){
|
||||||
oTable.fnDraw();
|
oTable.fnDraw();
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
$historyContentDiv.find("#his-tabs").tabs();
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
return AIRTIME;
|
||||||
|
|
||||||
|
}(AIRTIME || {}));
|
||||||
|
|
||||||
|
$(document).ready(AIRTIME.history.onReady);
|
Loading…
Add table
Add a link
Reference in a new issue