1 var perms = [ 'RUN_REPORTS', 'SHARE_REPORT_FOLDER' ];
3 function oilsInitReports() {
6 /* tell FF to capture mouse movements */
7 document.captureEvents(Event.MOUSEMOVE);
8 document.onmousemove = setMousePos;
13 fetchUser(cgi.param('ses'));
14 DOM.oils_rpt_user.appendChild(text(USER.usrname()));
16 fetchHighestPermOrgs(SESSION, USER.id(), perms);
17 if( PERMS.RUN_REPORTS == -1 ) {
18 unHideMe(DOM.oils_rpt_permission_denied);
19 hideMe(DOM.oils_rpt_tree_loading);
24 oilsRptCookie = new HTTP.Cookies();
25 oilsRptCurrentOrg = USER.ws_ou();
26 cookieManager.write(COOKIE_SES, SESSION, -1, '/');
27 cookieManager.write('ws_ou', USER.ws_ou(), -1, '/');
33 hideMe(DOM.oils_rpt_tree_loading);
34 unHideMe(DOM.oils_rpt_folder_table);
42 function oilsRtpInitFolders() {
43 oilsRptCurrentFolderManager =
44 new oilsRptFolderManager(DOM.oils_rpt_folder_tree_div);
45 oilsRptCurrentFolderManager.draw(SESSION);
48 function oilsCleanupReports() {
49 try {oilsRptDebugWindow.close();} catch(e) {}
51 oilsRptObjectCache = null;
52 oilsRptObject.objectCache = null;
58 /* ---------------------------------------------------------------------
59 Define the report object
60 --------------------------------------------------------------------- */
61 function oilsReport(templateObj, reportObj) {
72 this.reportObject = reportObj;
74 if(templateObj) this.setTemplate(templateObj);
77 this.params = JSON2js(reportObj.data());
78 if(!this.params) this.params = {};
82 oilsReport.prototype.setTemplate = function(template) {
83 this.def = JSON2js(template.data());
84 this.name = template.name();
85 this.templateObject = template;
88 oilsReport.prototype.toString = function() {
89 return formatJSON(js2JSON(this));
92 oilsReport.prototype.toHTMLString = function() {
93 return formatJSONHTML(js2JSON(this));
96 oilsReport.prototype.gatherParams = function() {
97 //if(oilsRptObjectKeys(this.params).length == 0) return;
98 _debug("we have params: " + js2JSON(this.params));
101 this._gatherParams(params, this.def.where, 'where', 'condition');
102 this._gatherParams(params, this.def.having, 'having', 'condition');
106 oilsReport.prototype._gatherParams = function(params, arr, type, field) {
108 for( var i = 0; i < arr.length; i++ ) {
115 /* add select transform support */
117 if( typeof node == 'string' ) {
118 key = node.match(/::.*/);
120 op = oilsRptObjectKeys(node)[0];
121 key = (node[op] +'').match(/::.*/);
125 key = key[0].replace(/::/,'');
126 _debug("key = "+key+", param = " + this.params[key]);
131 value : this.params[key],
135 relation : obj.relation,