2012-06-20 22:47:11 +02:00
|
|
|
function getFileName(ext){
|
2013-07-09 00:00:02 +02:00
|
|
|
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");
|
|
|
|
|
|
|
|
if (ext == "pdf"){
|
|
|
|
filename = filename+".pdf";
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
filename = filename+".csv";
|
2012-06-20 22:47:11 +02:00
|
|
|
}
|
2012-06-20 22:35:34 +02:00
|
|
|
return filename;
|
|
|
|
}
|
|
|
|
|
|
|
|
function setFlashFileName( nButton, oConfig, oFlash ) {
|
2013-07-09 00:00:02 +02:00
|
|
|
var filename = getFileName(oConfig.sExtends);
|
2012-06-20 22:35:34 +02:00
|
|
|
oFlash.setFileName( filename );
|
2013-07-09 00:00:02 +02:00
|
|
|
|
|
|
|
if (oConfig.sExtends == "pdf") {
|
2012-06-20 22:47:11 +02:00
|
|
|
this.fnSetText( oFlash,
|
|
|
|
"title:"+ this.fnGetTitle(oConfig) +"\n"+
|
|
|
|
"message:"+ oConfig.sPdfMessage +"\n"+
|
|
|
|
"colWidth:"+ this.fnCalcColRatios(oConfig) +"\n"+
|
|
|
|
"orientation:"+ oConfig.sPdfOrientation +"\n"+
|
|
|
|
"size:"+ oConfig.sPdfSize +"\n"+
|
|
|
|
"--/TableToolsOpts--\n" +
|
|
|
|
this.fnGetTableData(oConfig));
|
2013-07-09 00:00:02 +02:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
this.fnSetText(oFlash, this.fnGetTableData(oConfig));
|
2012-06-20 22:47:11 +02:00
|
|
|
}
|
2012-06-20 22:35:34 +02:00
|
|
|
}
|
|
|
|
|
2012-03-08 18:30:56 +01:00
|
|
|
var AIRTIME = (function(AIRTIME) {
|
|
|
|
var mod;
|
|
|
|
|
|
|
|
if (AIRTIME.history === undefined) {
|
|
|
|
AIRTIME.history = {};
|
|
|
|
}
|
|
|
|
mod = AIRTIME.history;
|
|
|
|
|
|
|
|
mod.historyTable = function() {
|
|
|
|
var oTable,
|
|
|
|
historyContentDiv = $("#history_content"),
|
2012-03-12 11:47:25 +01:00
|
|
|
historyTableDiv = historyContentDiv.find("#history_table"),
|
2012-03-13 16:41:06 +01:00
|
|
|
tableHeight = historyContentDiv.height() - 200,
|
2012-03-12 11:47:25 +01:00
|
|
|
fnServerData;
|
|
|
|
|
|
|
|
fnServerData = function ( sSource, aoData, fnCallback ) {
|
|
|
|
|
|
|
|
if (fnServerData.hasOwnProperty("start")) {
|
|
|
|
aoData.push( { name: "start", value: fnServerData.start} );
|
|
|
|
}
|
|
|
|
if (fnServerData.hasOwnProperty("end")) {
|
|
|
|
aoData.push( { name: "end", value: fnServerData.end} );
|
|
|
|
}
|
|
|
|
|
|
|
|
aoData.push( { name: "format", value: "json"} );
|
|
|
|
|
|
|
|
$.ajax( {
|
|
|
|
"dataType": 'json',
|
|
|
|
"type": "GET",
|
|
|
|
"url": sSource,
|
|
|
|
"data": aoData,
|
|
|
|
"success": fnCallback
|
|
|
|
} );
|
2013-07-09 00:00:02 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
fnRowCallback = function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
|
|
|
|
var url = baseUrl+"Playouthistory/edit-aggregate-item/format/json/id/"+aData.file_id,
|
|
|
|
$link = $("<a/>", {
|
|
|
|
"href": url,
|
|
|
|
"text": $.i18n._("Edit")
|
|
|
|
});
|
|
|
|
|
|
|
|
$('td.his_edit', nRow).html($link);
|
2012-03-12 11:47:25 +01:00
|
|
|
};
|
2012-03-08 18:30:56 +01:00
|
|
|
|
|
|
|
oTable = historyTableDiv.dataTable( {
|
|
|
|
|
|
|
|
"aoColumns": [
|
2012-11-20 17:16:10 +01:00
|
|
|
{"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 */
|
2013-07-09 00:00:02 +02:00
|
|
|
{"sTitle": $.i18n._("Copyright"), "mDataProp": "copyright", "sClass": "his_copyright"}, /* Copyright */
|
|
|
|
{"sTitle" : $.i18n._("Admin"), "mDataProp": "file_id", "bSearchable" : false, "sClass": "his_edit"}, /* id of history item */
|
2012-03-08 18:30:56 +01:00
|
|
|
],
|
|
|
|
|
|
|
|
"bProcessing": true,
|
|
|
|
"bServerSide": true,
|
2013-01-14 22:00:38 +01:00
|
|
|
"sAjaxSource": baseUrl+"Playouthistory/playout-history-feed",
|
2012-03-08 18:30:56 +01:00
|
|
|
"sAjaxDataProp": "history",
|
|
|
|
|
2012-03-12 11:47:25 +01:00
|
|
|
"fnServerData": fnServerData,
|
2012-03-08 18:30:56 +01:00
|
|
|
|
2013-07-09 00:00:02 +02:00
|
|
|
"fnRowCallback": fnRowCallback,
|
|
|
|
|
2012-11-27 18:17:59 +01:00
|
|
|
"oLanguage": datatables_dict,
|
2012-03-08 18:30:56 +01:00
|
|
|
|
2012-11-27 18:23:16 +01:00
|
|
|
"aLengthMenu": [[50, 100, 500, -1], [50, 100, 500, $.i18n._("All")]],
|
2012-03-12 11:47:25 +01:00
|
|
|
"iDisplayLength": 50,
|
|
|
|
|
2012-03-08 18:30:56 +01:00
|
|
|
"sPaginationType": "full_numbers",
|
|
|
|
"bJQueryUI": true,
|
2012-03-12 11:47:25 +01:00
|
|
|
"bAutoWidth": true,
|
2012-03-08 18:30:56 +01:00
|
|
|
|
2012-05-18 16:00:36 +02:00
|
|
|
"sDom": 'lf<"dt-process-rel"r><"H"T><"dataTables_scrolling"t><"F"ip>',
|
2012-03-09 13:39:12 +01:00
|
|
|
|
|
|
|
"oTableTools": {
|
2013-01-14 22:00:38 +01:00
|
|
|
"sSwfPath": baseUrl+"js/datatables/plugin/TableTools/swf/copy_cvs_xls_pdf.swf",
|
2012-06-20 22:35:34 +02:00
|
|
|
"aButtons": [
|
2013-01-02 22:04:19 +01:00
|
|
|
{
|
|
|
|
"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
|
|
|
|
},
|
2013-01-14 23:01:50 +01:00
|
|
|
{
|
|
|
|
"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>")
|
|
|
|
}
|
2013-01-02 22:04:19 +01:00
|
|
|
]
|
2012-03-09 13:39:12 +01:00
|
|
|
}
|
2012-03-08 18:30:56 +01:00
|
|
|
});
|
2012-03-09 11:13:32 +01:00
|
|
|
oTable.fnSetFilteringDelay(350);
|
2012-03-12 11:47:25 +01:00
|
|
|
|
2012-03-13 16:41:06 +01:00
|
|
|
historyContentDiv.find(".dataTables_scrolling").css("max-height", tableHeight);
|
|
|
|
|
2012-03-12 11:47:25 +01:00
|
|
|
return oTable;
|
2012-03-08 18:30:56 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
return AIRTIME;
|
|
|
|
|
|
|
|
}(AIRTIME || {}));
|
|
|
|
|
|
|
|
$(document).ready(function(){
|
|
|
|
|
|
|
|
var viewport = AIRTIME.utilities.findViewportDimensions(),
|
|
|
|
history_content = $("#history_content"),
|
|
|
|
widgetHeight = viewport.height - 185,
|
2012-03-12 11:47:25 +01:00
|
|
|
screenWidth = Math.floor(viewport.width - 110),
|
|
|
|
oBaseDatePickerSettings,
|
|
|
|
oBaseTimePickerSettings,
|
|
|
|
oTable,
|
|
|
|
dateStartId = "#his_date_start",
|
|
|
|
timeStartId = "#his_time_start",
|
|
|
|
dateEndId = "#his_date_end",
|
|
|
|
timeEndId = "#his_time_end";
|
2012-03-08 18:30:56 +01:00
|
|
|
|
2012-05-18 15:40:22 +02:00
|
|
|
/*
|
|
|
|
* Icon hover states for search.
|
|
|
|
*/
|
|
|
|
history_content.on("mouseenter", ".his-timerange .ui-button", function(ev) {
|
|
|
|
$(this).addClass("ui-state-hover");
|
|
|
|
});
|
|
|
|
history_content.on("mouseleave", ".his-timerange .ui-button", function(ev) {
|
|
|
|
$(this).removeClass("ui-state-hover");
|
|
|
|
});
|
|
|
|
|
2012-03-08 18:30:56 +01:00
|
|
|
history_content
|
|
|
|
.height(widgetHeight)
|
|
|
|
.width(screenWidth);
|
|
|
|
|
2012-03-12 11:47:25 +01:00
|
|
|
oBaseDatePickerSettings = {
|
|
|
|
dateFormat: 'yy-mm-dd',
|
2012-11-22 23:32:24 +01:00
|
|
|
//i18n_months, i18n_days_short are in common.js
|
|
|
|
monthNames: i18n_months,
|
|
|
|
dayNamesMin: i18n_days_short,
|
2012-03-12 11:47:25 +01:00
|
|
|
onSelect: function(sDate, oDatePicker) {
|
|
|
|
$(this).datepicker( "setDate", sDate );
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
oBaseTimePickerSettings = {
|
|
|
|
showPeriodLabels: false,
|
|
|
|
showCloseButton: true,
|
2012-11-23 22:39:41 +01:00
|
|
|
closeButtonText: $.i18n._("Done"),
|
2012-03-12 11:47:25 +01:00
|
|
|
showLeadingZero: false,
|
2012-11-22 23:32:24 +01:00
|
|
|
defaultTime: '0:00',
|
|
|
|
hourText: $.i18n._("Hour"),
|
|
|
|
minuteText: $.i18n._("Minute")
|
2012-03-12 11:47:25 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
oTable = AIRTIME.history.historyTable();
|
|
|
|
|
|
|
|
history_content.find(dateStartId).datepicker(oBaseDatePickerSettings);
|
|
|
|
history_content.find(timeStartId).timepicker(oBaseTimePickerSettings);
|
|
|
|
history_content.find(dateEndId).datepicker(oBaseDatePickerSettings);
|
|
|
|
history_content.find(timeEndId).timepicker(oBaseTimePickerSettings);
|
|
|
|
|
2013-07-09 00:00:02 +02:00
|
|
|
history_content.on("click", "td.his_edit", function(e) {
|
|
|
|
var url = e.target.href;
|
|
|
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
|
|
|
$.get(url, function(json) {
|
|
|
|
var dialog = $(json.dialog);
|
|
|
|
|
|
|
|
dialog.dialog({
|
|
|
|
autoOpen: false,
|
|
|
|
title: $.i18n._("Edit History Record"),
|
|
|
|
//width: 460,
|
|
|
|
//height: 660,
|
|
|
|
modal: true
|
|
|
|
//close: closeDialogLibrary
|
|
|
|
});
|
|
|
|
|
|
|
|
dialog.dialog('open');
|
|
|
|
|
|
|
|
}, "json");
|
|
|
|
});
|
2012-03-12 11:47:25 +01:00
|
|
|
|
|
|
|
history_content.find("#his_submit").click(function(ev){
|
|
|
|
var fn,
|
|
|
|
oRange;
|
|
|
|
|
|
|
|
oRange = AIRTIME.utilities.fnGetScheduleRange(dateStartId, timeStartId, dateEndId, timeEndId);
|
|
|
|
|
|
|
|
fn = oTable.fnSettings().fnServerData;
|
|
|
|
fn.start = oRange.start;
|
|
|
|
fn.end = oRange.end;
|
|
|
|
|
|
|
|
oTable.fnDraw();
|
|
|
|
});
|
2012-03-08 18:30:56 +01:00
|
|
|
|
2012-10-19 17:09:34 +02:00
|
|
|
});
|