1 var perms = [ 'RUN_REPORTS', 'SHARE_REPORT_FOLDER', 'VIEW_REPORT_OUTPUT' ];
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 && PERMS.VIEW_REPORT_OUTPUT == -1 ) {
20 unHideMe(DOM.oils_rpt_permission_denied);
21 hideMe(DOM.oils_rpt_tree_loading);
26 dojo.require('dojo.cookie');
27 oilsRptCurrentOrg = USER.ws_ou();
28 dojo.cookie(COOKIE_SES, SESSION, { 'path' : '/', 'secure' : true});
29 dojo.cookie('ws_ou', USER.ws_ou(), { 'path' : '/', 'secure' : true});
31 // set the search form to submit-on-enter
32 DOM.template_search_query.onkeyup = function(evt) {
33 if (evt.keyCode == 13 &&
34 DOM.template_search_query.value) {
35 DOM.template_search_submit_button.onclick();
43 hideMe(DOM.oils_rpt_tree_loading);
44 unHideMe(DOM.oils_rpt_folder_table);
45 unHideMe(DOM.template_search_form_wrapper);
53 function oilsRtpInitFolders() {
54 oilsRptCurrentFolderManager =
55 new oilsRptFolderManager(DOM.oils_rpt_folder_tree_div);
56 oilsRptCurrentFolderManager.draw(SESSION);
59 function oilsCleanupReports() {
60 try {oilsRptDebugWindow.close();} catch(e) {}
62 oilsRptObjectCache = null;
63 oilsRptObject.objectCache = null;
69 /* ---------------------------------------------------------------------
70 Define the report object
71 --------------------------------------------------------------------- */
72 function oilsReport(templateObj, reportObj) {
83 this.reportObject = reportObj;
85 if(templateObj) this.setTemplate(templateObj);
88 this.params = JSON2js(reportObj.data());
89 if(!this.params) this.params = {};
93 oilsReport.prototype.setTemplate = function(template) {
94 this.def = JSON2js(template.data());
95 this.name = template.name();
96 this.templateObject = template;
99 oilsReport.prototype.toString = function() {
100 return formatJSON(js2JSON(this));
103 oilsReport.prototype.toHTMLString = function() {
104 return formatJSONHTML(js2JSON(this));
107 oilsReport.prototype.gatherParams = function() {
108 //if(oilsRptObjectKeys(this.params).length == 0) return;
109 _debug("we have params: " + js2JSON(this.params));
112 this._gatherParams(params, this.def.where, 'where', 'condition');
113 this._gatherParams(params, this.def.having, 'having', 'condition');
117 oilsReport.prototype._gatherParams = function(params, arr, type, field) {
119 for( var i = 0; i < arr.length; i++ ) {
126 /* add select transform support */
128 if( typeof node == 'string' ) {
129 key = node.match(/::.*/);
131 op = oilsRptObjectKeys(node)[0];
132 key = (node[op] +'').match(/::.*/);
136 key = key[0].replace(/::/,'');
137 _debug("key = "+key+", param = " + this.params[key]);
142 value : this.params[key],
146 relation : obj.relation,
148 field_doc : obj.field_doc
155 oilsReport.prototype.gatherTemplateParams = function() {
156 var arr = this.__gatherTemplateParams(this.def.where, 'where');
157 arr.concat(this.__gatherTemplateParams(this.def.having, 'having'));
158 _debug("template params: " + js2JSON(arr));
162 oilsReport.prototype.__gatherTemplateParams = function(arr, type) {
167 for( var i = 0; i < arr.length; i++ ) {
170 var node = obj.condition;
171 var op = oilsRptObjectKeys(node)[0];
174 /** if this is a dynamic param, skip it */
175 if( key && (key+'').match(/::.*/) ) continue;
177 _debug("template params: op = " + op + ", value = " + js2JSON(key));
180 key : key, /* key == value, since this is not a dynamic param */
186 relation : obj.relation,