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 if( cgi.param('dbg') ) oilsRptDebugEnabled = true;
18 fetchHighestPermOrgs(SESSION, USER.id(), perms);
19 if( PERMS.RUN_REPORTS == -1 ) {
20 unHideMe(DOM.oils_rpt_permission_denied);
21 hideMe(DOM.oils_rpt_tree_loading);
26 oilsRptCookie = new HTTP.Cookies();
27 oilsRptCurrentOrg = USER.ws_ou();
28 cookieManager.write(COOKIE_SES, SESSION, -1, '/');
29 cookieManager.write('ws_ou', USER.ws_ou(), -1, '/');
35 hideMe(DOM.oils_rpt_tree_loading);
36 unHideMe(DOM.oils_rpt_folder_table);
44 function oilsRtpInitFolders() {
45 oilsRptCurrentFolderManager =
46 new oilsRptFolderManager(DOM.oils_rpt_folder_tree_div);
47 oilsRptCurrentFolderManager.draw(SESSION);
50 function oilsCleanupReports() {
51 try {oilsRptDebugWindow.close();} catch(e) {}
53 oilsRptObjectCache = null;
54 oilsRptObject.objectCache = null;
60 /* ---------------------------------------------------------------------
61 Define the report object
62 --------------------------------------------------------------------- */
63 function oilsReport(templateObj, reportObj) {
74 this.reportObject = reportObj;
76 if(templateObj) this.setTemplate(templateObj);
79 this.params = JSON2js(reportObj.data());
80 if(!this.params) this.params = {};
84 oilsReport.prototype.setTemplate = function(template) {
85 this.def = JSON2js(template.data());
86 this.name = template.name();
87 this.templateObject = template;
90 oilsReport.prototype.toString = function() {
91 return formatJSON(js2JSON(this));
94 oilsReport.prototype.toHTMLString = function() {
95 return formatJSONHTML(js2JSON(this));
98 oilsReport.prototype.gatherParams = function() {
99 //if(oilsRptObjectKeys(this.params).length == 0) return;
100 _debug("we have params: " + js2JSON(this.params));
103 this._gatherParams(params, this.def.where, 'where', 'condition');
104 this._gatherParams(params, this.def.having, 'having', 'condition');
108 oilsReport.prototype._gatherParams = function(params, arr, type, field) {
110 for( var i = 0; i < arr.length; i++ ) {
117 /* add select transform support */
119 if( typeof node == 'string' ) {
120 key = node.match(/::.*/);
122 op = oilsRptObjectKeys(node)[0];
123 key = (node[op] +'').match(/::.*/);
127 key = key[0].replace(/::/,'');
128 _debug("key = "+key+", param = " + this.params[key]);
133 value : this.params[key],
137 relation : obj.relation,
145 oilsReport.prototype.gatherTemplateParams = function() {
146 var arr = this.__gatherTemplateParams(this.def.where, 'where');
147 arr.concat(this.__gatherTemplateParams(this.def.having, 'having'));
148 _debug("template params: " + js2JSON(arr));
152 oilsReport.prototype.__gatherTemplateParams = function(arr, type) {
157 for( var i = 0; i < arr.length; i++ ) {
160 var node = obj.condition;
161 var op = oilsRptObjectKeys(node)[0];
164 /** if this is a dynamic param, skip it */
165 if( key && key.match(/::.*/) ) continue;
167 _debug("template params: op = " + op + ", value = " + js2JSON(key));
170 key : key, /* key == value, since this is not a dynamic param */
176 relation : obj.relation,