2015-10-21 23:34:35 +00:00
|
|
|
|
2022-05-24 21:11:12 +00:00
|
|
|
module.exports = new Class({
|
2015-10-21 23:34:35 +00:00
|
|
|
Extends: Vn.Object
|
|
|
|
|
2022-11-16 01:46:44 +00:00
|
|
|
,initialize(moduleInfo, gui) {
|
2015-11-17 10:34:33 +00:00
|
|
|
this.info = moduleInfo;
|
|
|
|
this.gui = gui;
|
|
|
|
this.conn = gui.conn;
|
2022-06-06 16:02:17 +00:00
|
|
|
Vn.Object.prototype.initialize.call(this);
|
2015-11-17 10:34:33 +00:00
|
|
|
}
|
|
|
|
|
2022-11-16 01:46:44 +00:00
|
|
|
,open(lot) {
|
2022-05-30 01:30:33 +00:00
|
|
|
this.lot = lot;
|
2022-05-24 21:11:12 +00:00
|
|
|
this.createWindow();
|
2015-11-17 10:34:33 +00:00
|
|
|
}
|
2015-10-21 23:34:35 +00:00
|
|
|
|
2022-11-16 01:46:44 +00:00
|
|
|
,print() {
|
2022-05-24 21:11:12 +00:00
|
|
|
this.window.print();
|
2015-10-21 23:34:35 +00:00
|
|
|
}
|
|
|
|
|
2022-11-16 01:46:44 +00:00
|
|
|
,includeCss(path) {
|
2015-10-21 23:34:35 +00:00
|
|
|
var basePath = location.protocol +'//'+ location.host;
|
|
|
|
basePath += location.port ? ':'+ location.port : '';
|
2022-05-24 21:11:12 +00:00
|
|
|
basePath += location.pathname.substring(0,
|
|
|
|
location.pathname.lastIndexOf('/'));
|
2015-10-21 23:34:35 +00:00
|
|
|
|
2022-05-24 21:11:12 +00:00
|
|
|
var link = this.doc.createElement('link');
|
2015-10-21 23:34:35 +00:00
|
|
|
link.rel = 'stylesheet';
|
|
|
|
link.type = 'text/css';
|
2022-05-24 21:11:12 +00:00
|
|
|
link.href = basePath +'/'+ path + Vn.getVersion();
|
2015-10-21 23:34:35 +00:00
|
|
|
|
2022-05-24 21:11:12 +00:00
|
|
|
var head = this.doc.getElementsByTagName('head')[0];
|
|
|
|
head.appendChild(link);
|
2015-10-21 23:34:35 +00:00
|
|
|
}
|
|
|
|
|
2022-11-16 01:46:44 +00:00
|
|
|
,createWindow() {
|
2022-05-24 21:11:12 +00:00
|
|
|
var reportWindow = window.open(
|
2015-11-19 13:57:23 +00:00
|
|
|
'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
|
|
|
|
2022-05-24 21:11:12 +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
|
|
|
}
|
|
|
|
|
2022-05-24 21:11:12 +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;
|
|
|
|
}
|
|
|
|
|
2022-11-16 01:46:44 +00:00
|
|
|
,_onWindowLoad() {
|
2015-11-19 13:57:23 +00:00
|
|
|
this.doc = this.window.document
|
|
|
|
|
2022-05-24 21:11:12 +00:00
|
|
|
this.includeCss('reports/'+ this.info.path +'/style.css');
|
2015-11-19 13:57:23 +00:00
|
|
|
|
2022-05-24 21:11:12 +00:00
|
|
|
var printButton = this.doc.getElementById('print');
|
|
|
|
printButton.addEventListener('click', this.print.bind(this));
|
|
|
|
Vn.Node.setText(printButton, _('Print'));
|
2015-11-19 13:57:23 +00:00
|
|
|
|
2022-05-24 21:11:12 +00:00
|
|
|
this.onWindowCreate();
|
2015-11-19 13:57:23 +00:00
|
|
|
}
|
|
|
|
|
2022-11-16 01:46:44 +00:00
|
|
|
,onWindowCreate() {
|
2022-05-24 21:11:12 +00:00
|
|
|
var builder = new Vn.Builder();
|
|
|
|
builder.compileFile('reports/'+ this.info.path +'/ui.xml');
|
2015-11-19 13:57:23 +00:00
|
|
|
|
2022-05-24 21:11:12 +00:00
|
|
|
var scope = this.scope = builder.load(this.doc, this);
|
2022-06-18 21:04:34 +00:00
|
|
|
scope.link({
|
2022-05-30 01:30:33 +00:00
|
|
|
lot: this.lot,
|
2022-05-24 21:11:12 +00:00
|
|
|
conn: this.conn
|
|
|
|
});
|
2022-05-28 01:18:06 +00:00
|
|
|
this.$ = scope.$;
|
2015-11-19 13:57:23 +00:00
|
|
|
|
2022-05-28 01:18:06 +00:00
|
|
|
this.doc.body.appendChild(scope.$.report);
|
2015-10-21 23:34:35 +00:00
|
|
|
}
|
2022-11-19 00:28:24 +00:00
|
|
|
|
|
|
|
,_destroy() {
|
|
|
|
if (this.scope) this.scope._destroy();
|
|
|
|
Vn.Object.prototype._destroy.call(this);
|
|
|
|
}
|
2015-10-21 23:34:35 +00:00
|
|
|
});
|
|
|
|
|