2015-10-21 23:34:35 +00:00
|
|
|
|
2016-09-26 09:28:47 +00:00
|
|
|
module.exports = new Class
|
2015-10-21 23:34:35 +00:00
|
|
|
({
|
|
|
|
Extends: Vn.Object
|
|
|
|
|
2015-11-17 10:34:33 +00:00
|
|
|
,initialize: function (moduleInfo, gui)
|
|
|
|
{
|
|
|
|
this.info = moduleInfo;
|
|
|
|
this.gui = gui;
|
|
|
|
this.conn = gui.conn;
|
|
|
|
this.parent (null);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets an object from the builder associated to this report.
|
|
|
|
*
|
|
|
|
* @param {string} objectId The object identifier
|
|
|
|
* @return {Object} The object, or %null if not found
|
2016-12-20 09:32:17 +00:00
|
|
|
*/
|
2015-11-17 10:34:33 +00:00
|
|
|
,$: function (objectId)
|
|
|
|
{
|
|
|
|
if (this.builderResult)
|
|
|
|
return this.builderResult.getById (objectId);
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
,open: function (batch)
|
|
|
|
{
|
|
|
|
this.batch = batch;
|
2015-11-19 13:57:23 +00:00
|
|
|
this.createWindow ();
|
2015-11-17 10:34:33 +00:00
|
|
|
}
|
2015-10-21 23:34:35 +00:00
|
|
|
|
|
|
|
,print: function ()
|
|
|
|
{
|
|
|
|
this.window.print ();
|
|
|
|
}
|
|
|
|
|
|
|
|
,includeCss: function (path)
|
|
|
|
{
|
|
|
|
var basePath = location.protocol +'//'+ location.host;
|
|
|
|
basePath += location.port ? ':'+ location.port : '';
|
|
|
|
basePath += location.pathname.substring (0,
|
|
|
|
location.pathname.lastIndexOf ('/'));
|
|
|
|
|
|
|
|
var link = this.doc.createElement ('link');
|
|
|
|
link.rel = 'stylesheet';
|
|
|
|
link.type = 'text/css';
|
|
|
|
link.href = basePath +'/'+ path + Vn.getVersion ();
|
|
|
|
|
|
|
|
var head = this.doc.getElementsByTagName ('head')[0];
|
|
|
|
head.appendChild (link);
|
|
|
|
}
|
|
|
|
|
2015-11-19 13:57:23 +00:00
|
|
|
,createWindow: function ()
|
2015-08-17 18:02:14 +00:00
|
|
|
{
|
2015-11-19 13:57:23 +00:00
|
|
|
var reportWindow = window.open (
|
|
|
|
'js/hedera/report.html', '_blank',
|
2015-11-26 12:30:04 +00:00
|
|
|
'height=650, width=950, resizable=yes, fullscreen=no,'+
|
2015-11-19 13:57:23 +00:00
|
|
|
'titlebar=no, menubar=no, toolbar=no, location=no, scrollbars=yes'
|
|
|
|
);
|
2015-10-21 23:34:35 +00:00
|
|
|
|
|
|
|
if (!reportWindow)
|
|
|
|
{
|
|
|
|
Htk.Toast.showError (
|
2015-10-27 18:02:03 +00:00
|
|
|
_('Please unlock popups and try again'));
|
2015-11-19 13:57:23 +00:00
|
|
|
return false;
|
2015-10-21 23:42:52 +00:00
|
|
|
}
|
|
|
|
|
2015-11-19 13:57:23 +00:00
|
|
|
reportWindow.addEventListener ('load',
|
|
|
|
this._onWindowLoad.bind (this));
|
2015-10-21 23:42:52 +00:00
|
|
|
this.window = reportWindow;
|
2015-11-19 13:57:23 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
,_onWindowLoad: function ()
|
|
|
|
{
|
|
|
|
this.doc = this.window.document
|
|
|
|
|
|
|
|
this.includeCss ('reports/'+ this.info.path +'/style.css');
|
|
|
|
|
2015-11-26 12:30:04 +00:00
|
|
|
var printButton = this.doc.getElementById ('print');
|
2015-11-19 13:57:23 +00:00
|
|
|
printButton.addEventListener ('click', this.print.bind (this));
|
2015-11-26 12:30:04 +00:00
|
|
|
Vn.Node.setText (printButton, _('Print'));
|
2015-11-19 13:57:23 +00:00
|
|
|
|
|
|
|
this.onWindowCreate ();
|
|
|
|
}
|
|
|
|
|
|
|
|
,onWindowCreate: function ()
|
|
|
|
{
|
|
|
|
var builder = new Vn.Builder ();
|
|
|
|
builder.signalData = this;
|
|
|
|
builder.add ('batch', this.batch);
|
|
|
|
builder.add ('conn', this.conn);
|
|
|
|
builder.loadXml ('reports/'+ this.info.path +'/ui.xml');
|
|
|
|
|
|
|
|
var res = this.builderResult = builder.load ();
|
|
|
|
res.link ();
|
|
|
|
|
|
|
|
this.doc.body.appendChild (res.$('report'));
|
2015-10-21 23:34:35 +00:00
|
|
|
}
|
|
|
|
});
|