3 if (!file_exists($sys_path_to_jpgraph.'jpgraph.php')) {
4 exit_error('Error', 'Package JPGraph not installed');
7 require_once($sys_path_to_jpgraph.'jpgraph.php');
8 require_once($sys_path_to_jpgraph.'jpgraph_gantt.php');
9 require_once('common/pm/ProjectTaskFactory.class');
12 * settitlefont() - Set font setting for GanttGraph object
14 * @param GanttGraph Target GanttGraph object
15 * @param string Font family
16 * @param string Font style
17 * @param integer Font size
19 function settitlefont($graph, $sys_font_family, $sys_font_style, $sys_font_size) {
20 if ($sys_font_family != "" &&
21 $sys_font_style != "" &&
22 $sys_font_size != "") {
24 eval() is a nasty security hole
26 eval("\$font_family=$sys_font_family;");
27 eval("\$font_style=$sys_font_style;");
28 eval("\$font_size=$sys_font_size;");
29 $graph->title->SetFont($font_family,$font_style,$font_size);
34 $ptf = new ProjectTaskFactory($pg);
35 if (!$ptf || !is_object($ptf)) {
36 exit_error('Error','Could Not Get ProjectTaskFactory');
37 } elseif ($ptf->isError()) {
38 exit_error('Error',$ptf->getErrorMessage());
41 $ptf->setup($offset,$_order,$max_rows,'custom',$_assigned_to,$_status,$_category_id);
42 if ($ptf->isError()) {
43 exit_error('Error',$ptf->getErrorMessage());
46 $pt_arr =& $ptf->getTasks();
47 if ($ptf->isError()) {
48 exit_error('Error',$ptf->getErrorMessage());
52 $graph = new GanttGraph (640,480, "auto");
53 } elseif ($_size==1024) {
54 $graph = new GanttGraph (1024,768, "auto");
55 } elseif ($_size==1600) {
56 $graph = new GanttGraph (1600,1200, "auto");
58 $graph = new GanttGraph (800,600, "auto");
60 //$graph->SetShadow();
61 $graph->SetMargin(10,10,25,10);
63 // Add title and subtitle
64 $graph->title-> Set($pg->getName());
65 //global $sys_gantt_title_font_family,$sys_gantt_title_font_style,$sys_gantt_title_font_size;
66 //settitlefont($graph,$sys_gantt_title_font_family,$sys_gantt_title_font_style,$sys_gantt_title_font_size);
67 //$graph->subtitle-> Set("(Draft version)");
69 // Show day, week and month scale
70 if ($_resolution == 'Days') {
71 $graph->ShowHeaders( GANTT_HDAY | GANTT_HWEEK | GANTT_HMONTH);
72 } elseif ($_resolution == 'Weeks') {
73 $graph->ShowHeaders( GANTT_HWEEK | GANTT_HMONTH);
75 $graph->ShowHeaders( GANTT_HMONTH);
78 // Instead of week number show the date for the first day in the week
80 $graph->scale->week->SetStyle(WEEKSTYLE_FIRSTDAY);
82 // Make the week scale font smaller than the default
83 $graph->scale->week->SetFont(FF_FONT0 );
85 // Use the short name of the month together with a 2 digit year
87 $graph->scale->month->SetStyle( MONTHSTYLE_SHORTNAMEYEAR2);
91 for ($i=0; $i<$rows; $i++) {
92 // Format the bar for the first activity
93 // ($row,$title,$startdate,$enddate)
94 $activity[$i] = new GanttBar ($i, $pt_arr[$i]->getSummary(), date('Y-m-d',$pt_arr[$i]->getStartDate()), date('Y-m-d',$pt_arr[$i]->getEndDate()-86400));
96 // Yellow diagonal line pattern on a red background
97 $activity[$i]->SetPattern(BAND_RDIAG, "yellow");
98 $activity[$i]->SetFillColor ("red");
99 $activity[$i]->progress->Set( (( $pt_arr[$i]->getPercentComplete() ) ? ($pt_arr[$i]->getPercentComplete()/100) : 0));
100 $activity[$i]->progress->SetPattern(BAND_RDIAG, "blue");
102 // global $sys_gantt_task_font_family,$sys_gantt_task_font_style,$sys_gantt_task_font_size;
103 // settitlefont($activity[$i],$sys_gantt_title_font_family,$sys_gantt_title_font_style,$sys_gantt_title_font_size);
104 // Finally add the bar to the graph
105 $graph->Add( $activity[$i] );
109 $todayline = new GanttVLine(date('Y-m-d',time()),"Today");
110 $todayline ->SetDayOffset (0.5);
111 $graph->Add( $todayline);
113 // Display the Gantt chart