GraphViewer=function(parent,w,h){this.show_labels=true;this.font_size=10;if(!parent){this.wrapper=document.createElement('div') parent=this.wrapper} this.body=$a(parent,'div','gr_body');if(w&&h){$w(this.body,w+'px');$w(this.body,h+'px');} this._y_name=$a(parent,'div','gr_y_name');this._x_name=$a(parent,'div','gr_x_name');this._y_labels=$a(parent,'div','gr_y_labels');this._x_labels=$a(parent,'div','gr_x_labels');this.legend_area=$a(parent,'div','gr_legend_area');this.title_area=$a(parent,'div','gr_title_area');this.main_area=$a(parent,'div','gr_main_area');this.set_horizontal();} GraphViewer.prototype.clear=function(){this.series=[];this.xlabels=[];this.xtitle=null;this.ytitle=null;} GraphViewer.prototype.set_vertical=function(){this.k_barwidth='width';this.k_barstart='left';this.k_barlength='height';this.k_barbase='bottom';this.k_bartop='top';this.k_gridborder='borderTop';this.y_name=this._y_name;this.x_name=this._x_name;this.y_labels=this._y_labels;this.x_labels=this._x_labels;this.vertical=true;} GraphViewer.prototype.set_horizontal=function(){this.k_barwidth='height';this.k_barstart='top';this.k_barlength='width';this.k_barbase='left';this.k_bartop='right';this.k_gridborder='borderRight';this.y_name=this._x_name;this.x_name=this._y_name;this.y_labels=this._x_labels;this.x_labels=this._y_labels;this.vertical=false;} GraphViewer.prototype.set_title=function(t){this.title_area.innerHTML=t;} GraphViewer.prototype.add_series=function(label,color,values,borderColor){var s=new GraphViewer.GraphSeries(this,label);s.color=color;s.borderColor=borderColor;s.data=values;this.series[this.series.length]=s;} GraphViewer.prototype.refresh=function(){this.legend_area.innerHTML='';this.main_area.innerHTML='';this.x_labels.innerHTML='';this.y_labels.innerHTML='';this.x_name.innerHTML='';this.y_name.innerHTML='';var maxx=null;var legendheight=12;for(i=0;imaxx)maxx=series_max;var tmp=$a(this.legend_area,'div','gr_legend');tmp.style.backgroundColor=this.series[i].color;if(this.series[i].borderColor) tmp.style.border='1px solid '+this.series[i].borderColor;tmp.style.top=(i*(legendheight+2))+'px';tmp.style.height=legendheight+'px';var tmp1=$a(this.legend_area,'div','gr_legend');tmp1.style.top=(i*(legendheight+2))+'px';tmp1.style.left='30px';$w(tmp1,'80px');tmp1.innerHTML=this.series[i].name;} if(maxx==0)maxx=1;this.maxx=1.1*maxx;var xfn=fmt_money;if(maxx>1){var nchars=(cint(maxx)+'').length;var gstep=Math.pow(10,(nchars-1));while(flt(maxx/gstep)<4){gstep=gstep/2;}}else{var gstep=maxx/6;} var curstep=gstep;while(curstepm)m=this.data[t]} return m;} GraphViewer.GraphXUnit=function(graph,idx,label){this.body=$a(graph.main_area,'div','gr_xunit');this.body.style[graph.k_barstart]=(idx*graph.xunit_width)+'%';this.body.style[graph.k_barwidth]=graph.xunit_width+'%';this.body.style[graph.k_barlength]='100%';this.show(graph,label,idx);if(graph.show_labels){this.label=$a(graph.x_labels,'div','gr_label');this.label.style[graph.k_barstart]=(idx*graph.xunit_width)+'%';this.label.style[graph.k_barwidth]=graph.xunit_width+'%';if(graph.vertical){$y(this.label,{height:'100%',top:'10%'});this.label.innerHTML=label;}else{middletext(this.label,label);}}} GraphViewer.GraphXUnit.prototype.show=function(graph,l,idx){var bar_width=(100/(graph.series.length+1));start=(100-(graph.series.length*bar_width))/2 for(var i=0;iShow Query: ';this.show_query=$a_input(d,'checkbox');this.show_query.checked=false;this.dt=new _r.DataTable(this.dt_area,'');this.dt.finder=this;this.dt.make_query=function(){var report=me;if(me.current_loaded&&me.sc_dict[me.current_loaded]){var sc=get_local('Search Criteria',me.sc_dict[me.current_loaded]);} if(sc)me.dt.search_criteria=sc;else me.dt.search_criteria=null;if(sc&&sc.server_script)me.dt.server_script=sc.server_script;else me.dt.server_script=null;for(var i=0;i=';tmp1.bound='lower';var f2=copy_dict(f);f2.label='To '+f2.label;var tmp2=this.make_field_obj(f2,dt,my_div,is_custom);tmp2.sql_condition='<=';tmp2.bound='upper';} _r.ReportFilters.prototype.add_numeric_field=function(cell,f,dt,is_custom){var my_div=$a(cell,'div','',{});var f1=copy_dict(f);f1.label=f1.label+' >=';var tmp1=this.make_field_obj(f1,dt,my_div,is_custom);tmp1.sql_condition='>=';tmp1.bound='lower';var f2=copy_dict(f);f2.label=f2.label+' <=';var tmp2=this.make_field_obj(f2,dt,my_div,is_custom);tmp2.sql_condition='<=';tmp2.bound='upper';} _r.ReportFilters.prototype.make_field_obj=function(f,dt,parent,is_custom){var tmp=make_field(f,dt,parent,this.rb,false);tmp.not_in_form=1;tmp.in_filter=1;tmp.refresh();this.rb.filter_fields[this.rb.filter_fields.length]=tmp;this.rb.filter_fields_dict[f.parent+'\1'+f.label]=tmp;if(is_custom)tmp.is_custom=1;return tmp;} _r.ReportFilters.prototype.add_field=function(f,dt,in_primary,is_custom){var me=this;if(f.in_first_page)in_primary=true;var fparent=this.filter_fields_area;if(in_primary){fparent=this.first_page_filter;this.rb.has_primary_filters=1;} if(f.on_top){var cell=document.createElement('div');fparent.insertBefore(cell,fparent.firstChild);$y(cell,{width:'70%'});}else if(f.insert_before){var cell=document.createElement('div');fparent.insertBefore(cell,fparent[f.df.insert_before].filter_cell);$y(cell,{width:'70%'});} else var cell=$a(fparent,'div','',{width:'70%'});f.filter_cell=cell;if(f.fieldtype=='Date'){this.add_date_field(cell,f,dt);}else if(in_list(['Currency','Int','Float'],f.fieldtype)){this.add_numeric_field(cell,f,dt);}else if(!in_list(['Section Break','Column Break','Read Only','HTML','Table','Image','Button'],f.fieldtype)){var tmp=this.make_field_obj(f,dt,cell,is_custom);} if(f.fieldname!='docstatus') me.rb.orig_sort_list.push([f.label,'`tab'+f.parent+'`.`'+f.fieldname+'`']);if(f.def_filter) tmp.input.checked=true;} _r.ReportColumnPicker=function(rb){this.rb=rb;this.picker_area=$a(this.rb.mytabs.items['Select Columns'].body,'div','finder_picker_area');this.all_fields=[];this.sel_idx=0;this.make_body();} _r.ReportColumnPicker.prototype.make_body=function(){var t=make_table(this.picker_area,1,3,'100%',['35%','30%','35%'],{verticalAlign:'middle',textAlign:'center'});$a($td(t,0,0),'h3','',{marginBottom:'8px'}).innerHTML='Columns';this.unsel_fields=$a($td(t,0,0),'select','',{height:'200px',width:'100%',border:'1px solid #AAA'});this.unsel_fields.multiple=true;this.unsel_fields.onchange=function(){for(var i=0;iAdd >';this.add_btn.onclick=function(){me.move(me.unsel_fields,'add');} this.remove_btn=$a($a($td(t,0,1),'div'),'button','',{width:'110px'});this.remove_btn.innerHTML='< Remove';this.remove_btn.onclick=function(){me.move(me.sel_fields,'remove');} this.remove_all=$a($a($td(t,0,1),'div'),'button','',{width:'40px'});this.remove_all.innerHTML='<<';this.remove_all.onclick=function(){me.move(me.sel_fields,'remove',1);} this.dn_btn=$a($a($td(t,0,1),'div'),'button','',{width:'70px'});this.dn_btn.innerHTML='Down ↓';this.dn_btn.onclick=function(){me.move_down();} $a($td(t,0,2),'h3','',{marginBottom:'8px'}).innerHTML='Selected Columns';this.sel_fields=$a($td(t,0,2),'select','',{height:'200px',width:'100%',border:'1px solid #AAA'});this.sel_fields.multiple=true;this.sel_fields.onchange=function(){for(var i=0;i=0;i--){if(s.options[i].selected){this.get_by_sel_idx(s,i+1).sel_idx--;s.options[i].field.sel_idx++;}} this.refresh();} _r.ReportColumnPicker.prototype.move=function(s,type,all){for(var i=0;i
Please click on 'Export' to open in a spreadsheet");return;} _r.rb_con.cur_rb.mytabs.items['Result'].expand();} var me=this;this._get_query();if(this.set_data){this.show_result(this.set_data);this.set_data=null;return;} $ds(this.fetching_tag);if(isFF)this.clear_all();var args={'query':me.query,'report_name':'_r.DataTable','show_deleted':1,'sc_id':me.search_criteria?me.search_criteria.name:'','filter_values':me.filter_vals?docstring(me.filter_vals):'','roles':'["'+user_roles.join('","')+'"]'} if(this.is_simple)args.is_simple=1;page_body.set_status('Running Query...');$c('webnotes.widgets.query_builder.runquery',args,function(r,rt){$dh(me.fetching_tag);page_body.set_status('Done');me.show_result(r,rt);});} _r.DataTable.prototype.clear_all=function(){if(this.htab&&this.htab.parentNode){this.htab.parentNode.removeChild(this.htab);delete this.htab;} if(this.tab&&this.tab.parentNode){this.tab.parentNode.removeChild(this.tab);delete this.tab;} $dh(this.no_data_tag);} _r.DataTable.prototype.has_data=function(){if(this.htab&&this.htab.rows.length)return 1;else return 0;} _r.DataTable.prototype.show_result=function(r,rt){var me=this;this.clear_all();this.rset=eval(r.values);if(this.rset&&this.rset.length){if(this.has_headings){this.htab=$a(this.hwrapper,'table');$y(this.twrapper,{top:'25px',borderTop:'0px'});} this.tab=$a(this.twrapper,'table');this.colwidths=eval(r.colwidths);this.coltypes=eval(r.coltypes);this.coloptions=eval(r.coloptions);this.colnames=eval(r.colnames);$y(this.tab,{tableLayout:'fixed'});if(this.beforetableprint)this.beforetableprint(this);if(this.has_headings)this.make_head_tab(this.colnames);var start=this.start_rec;var rset_len=this.rset.length;if(rset_len>1000){msgprint("Showing only 1000 records out of "+rset_len+". Use 'Export' to see all records");rset_len=1000;} for(var vi=0;vi=this.page_len)this.has_next=true;if(r.style){for(var i=0;imaxv)maxv=v;if(v