3 require_once('jpgraph/jpgraph.php');
4 require_once('jpgraph/jpgraph_gantt.php');
5 require_once('common/pm/ProjectTaskFactory.class');
7 $ptf = new ProjectTaskFactory($pg);
8 if (!$ptf || !is_object($ptf)) {
9 exit_error('Error','Could Not Get ProjectTaskFactory');
10 } elseif ($ptf->isError()) {
11 exit_error('Error',$ptf->getErrorMessage());
14 $ptf->setup($offset,$_order,$max_rows,$set,$_assigned_to,$_status,$_category_id);
15 if ($ptf->isError()) {
16 exit_error('Error',$ptf->getErrorMessage());
19 $pt_arr =& $ptf->getTasks();
20 if ($ptf->isError()) {
21 exit_error('Error',$ptf->getErrorMessage());
25 $graph = new GanttGraph (640,480, "auto");
26 } elseif ($_size==1024) {
27 $graph = new GanttGraph (1024,768, "auto");
28 } elseif ($_size==1600) {
29 $graph = new GanttGraph (1600,1200, "auto");
31 $graph = new GanttGraph (800,600, "auto");
35 // Add title and subtitle
36 $graph->title-> Set($pg->getName());
37 //$graph->title-> SetFont( FF_ARIAL, FS_BOLD, 12);
38 $graph->subtitle-> Set("(Draft version)");
40 // Show day, week and month scale
41 if ($_resolution == 'Days') {
42 $graph->ShowHeaders( GANTT_HDAY | GANTT_HWEEK | GANTT_HMONTH);
43 } elseif ($_resolution == 'Weeks') {
44 $graph->ShowHeaders( GANTT_HWEEK | GANTT_HMONTH);
46 $graph->ShowHeaders( GANTT_HMONTH);
49 // Instead of week number show the date for the first day in the week
51 $graph->scale->week->SetStyle(WEEKSTYLE_FIRSTDAY);
53 // Make the week scale font smaller than the default
54 $graph->scale->week->SetFont(FF_FONT0 );
56 // Use the short name of the month together with a 2 digit year
58 $graph->scale->month->SetStyle( MONTHSTYLE_SHORTNAMEYEAR2);
62 for ($i=0; $i<$rows; $i++) {
63 // Format the bar for the first activity
64 // ($row,$title,$startdate,$enddate)
65 $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()));
67 // Yellow diagonal line pattern on a red background
68 $activity[$i]->SetPattern(BAND_RDIAG, "yellow");
69 $activity[$i]->SetFillColor ("red");
70 $activity[$i]->progress->Set( (( $pt_arr[$i]->getPercentComplete() ) ? (1/$pt_arr[$i]->getPercentComplete()) : 0));
71 $activity[$i]->progress->SetPattern(BAND_RDIAG, "blue");
72 // Finally add the bar to the graph
73 $graph->Add( $activity[$i] );
78 // Display the Gantt chart