pscript.queries_bg_dict={'Urgent':'RED','High':'ORANGE','Low':'BLUE','Closed':'GREEN','Pending Review':'YELLOW'} pscript.onload_Projects=function(){var d=$i('projects_div');new PageHeader(d,'Gantt Chart');new GanttChart($a(d,'div','',{margin:'16px'}));} GanttChart=function(parent){this.wrapper=$a(parent,'div');this.toolbar_area=$a(this.wrapper,'div','',{padding:'16px',border:'1px solid #AAF',});$bg(this.toolbar_area,'#EEF');$br(this.toolbar_area,'3px');this.toolbar_tab=make_table(this.toolbar_area,1,4,'100%',['25%','25%','25%','25%']);this.grid_area=$a(this.wrapper,'div','',{margin:'16px 0px'});this.no_task_message=$a(this.wrapper,'div','help_box',{textAign:'center',fontSize:'14px'},'Select your criteria and click on "Make" to show the Gantt Chart') this.get_init_data();} GanttChart.prototype.get_init_data=function(){var me=this;var callback=function(r,rt){me.pl=r.message.pl.sort();me.rl=r.message.rl.sort();me.make_toolbar();} $c_obj('Project Control','get_init_data','',callback);} GanttChart.prototype.make_filter=function(label,idx){var w=$a($td(this.toolbar_tab,0,idx),'div','',{marginBottom:'8px'});var l=$a(w,'div','',{fontSize:'11px'});l.innerHTML=label;return w;} GanttChart.prototype.make_select=function(label,options,idx){var w=this.make_filter(label,idx);var s=$a(w,'select','',{width:'100px'});add_sel_options(s,add_lists(['All'],options));return s;} GanttChart.prototype.make_date=function(label,idx){var w=this.make_filter(label,idx);var i=$a(w,'input');var user_fmt=locals['Control Panel']['Control Panel'].date_format;if(!this.user_fmt)this.user_fmt='dd-mm-yy';$(i).datepicker({dateFormat:user_fmt.replace('yyyy','yy'),altFormat:'yy-mm-dd',changeYear:true});return i;} GanttChart.prototype.make_toolbar=function(){this.r_sel=this.make_select('Resource',this.rl,0);this.p_sel=this.make_select('Project',this.pl,1);this.s_date=this.make_date('Start Date',2);this.s_date.value=date.str_to_user(date.month_start());this.e_date=this.make_date('End Date',3);this.e_date.value=date.str_to_user(date.month_end());var me=this;$btn(this.toolbar_area,'Make',function(){me.refresh();},null,'green',1);this.print_btn=$btn(this.toolbar_area,'Print',function(){me.print();},{display:'none'},null);} GanttChart.prototype.print=function(){$(this.grid_area).printElement();} GanttChart.prototype.get_data=function(){var me=this;var callback=function(r,rt){me.tasks=r.message;if(me.tasks.length){$dh(me.no_task_message);$ds(me.grid_area);me.show_tasks();$di(me.print_btn);}else{$dh(me.grid_area);$ds(me.no_task_message);$dh(me.print_btn);me.no_task_message.innerHTML='Nothing allocated for the above criteria'}} $c_obj('Project Control','get_tasks',[date.user_to_str(this.s_date.value),date.user_to_str(this.e_date.value),sel_val(this.p_sel),sel_val(this.r_sel)].join('~~~'),callback)} GanttChart.prototype.make_grid=function(){this.grid_area.innerHTML='';this.grid=new GanttGrid(this,this.s_date.value,this.e_date.value);} GanttChart.prototype.refresh=function(){this.get_data();} GanttChart.prototype.show_tasks=function(){this.make_grid();for(var i=0;i=100)x2=100;$y(this.body,{top:idx*40+14+'px',left:x1+'%',width:(x2-x1)+'%',zIndex:1,cursor:'pointer'}) if(idx){var d1=$a(grid.task_area,'div','',{borderBottom:'1px solid #AAA',position:'absolute',width:'100%',top:(idx*40)+'px'});var d2=$a(grid.y_labels,'div','',{borderBottom:'1px solid #AAA',position:'absolute',width:'100%',top:(idx*40)+'px'});} this.make_tooltip(data);} GanttTask.prototype.make_tooltip=function(d){var t='
';if(d[0])t+='Task: '+d[0];if(d[5])t+='
Priority: '+d[5];if(d[6])t+='
Status: '+d[6];if(d[1])t+='
Allocated To: '+d[1];if(d[2])t+='
Project: '+d[2];if(d[3])t+='
From: '+date.str_to_user(d[3]);if(d[4])t+='
To: '+date.str_to_user(d[4]);t+='
';$(this.body).qtip({content:t,position:{corner:{tooltip:'topMiddle',target:'bottomMiddle'}},style:{border:{width:5,radius:10},padding:10,tip:true,name:'green'}})}