return $e->event unless $e->allowed('RUN_REPORTS');
my $hint = $$args{hint};
+ my $org_col = $$args{org_column};
+ my $orgs = $$args{org};
# Find the class the iplements the given hint
my ($class) = grep {
$class =~ s/Fieldmapper:://og;
$class =~ s/::/_/og;
- my $method = "retrieve_all_$class";
+
+ my $method;
+ my $margs;
+
+ if( $org_col ) {
+ $method = "search_$class";
+ $margs = { $org_col => $orgs };
+ } else {
+ $method = "retrieve_all_$class";
+ }
$logger->info("reporter.magic_fetch => $method");
- return $e->$method();
+ return $e->$method($margs);
}
}
oilsRptRemoteWidget.prototype.draw = function() {
- var req = new Request(OILS_RPT_MAGIC_FETCH, SESSION, {hint:this.class});
+ var orgcol;
+ iterate(oilsIDL[this.class].fields,
+ function(i) {
+ if(i.type == 'link' && i.class == 'aou')
+ orgcol = i.name;
+ }
+ );
+
+ if(orgcol) _debug("found org column for remote widget: " + orgcol);
+
+ var orgs = [];
+ iterate(oilsRptMyOrgs,function(i){orgs.push(i.id());});
+ var req = new Request(OILS_RPT_MAGIC_FETCH, SESSION, {
+ hint:this.class,
+ org_column : orgcol,
+ org : orgs
+ });
+
var obj = this;
this.node.appendChild(this.source);
req.callback(function(r){obj.render(r.getResultObject())});
}
oilsRptRemoteWidget.prototype.render = function(objs) {
- _debug("rendering objects " + formatJSON(js2JSON(objs)));
for( var i = 0; i < objs.length; i++ ) {
var obj = objs[i];
var label = obj[this.field.selector]();
}
oilsRptMyOrgsWidget.prototype.draw = function() {
- var req = new Request(OILS_RPT_FETCH_ORG_FULL_PATH, this.orgid);
- var obj = this;
- req.callback(
- function(r) { obj.drawWidget(r.getResultObject()); }
- );
- req.send();
+ if(!oilsRptMyOrgs) {
+ var req = new Request(OILS_RPT_FETCH_ORG_FULL_PATH, this.orgid);
+ var obj = this;
+ req.callback(
+ function(r) { obj.drawWidget(r.getResultObject()); }
+ );
+ req.send();
+ } else {
+ this.drawWidget(oilsRptMyOrgs);
+ }
}
oilsRptMyOrgsWidget.prototype.drawWidget = function(orglist) {
var sel = this.node;
var started = false;
+ oilsRptMyOrgs = orglist;
for( var i = 0; i < orglist.length; i++ ) {
var org = orglist[i];
var opt = insertSelectorVal( this.node, -1,