We are using Organic Group and Event to build our Project Management System (still in alpha ;).
Using OG Calendar we provides each group with a calendar showing only the group's events, but we wish to add relationsships between nodes and show it as Gantt Diagram.

To do this we have made a copy of our og_calendar Folder to og_gant. This will be our Gantt View of the Group Events.
Remember we are also using Case Tracker for detailled case management. This should be also included in our solution. Every Case Tracker Node is an Organic Group wich accept Events as cases used for Gantt....

Dependencies

It may be possible to build the Gantt functions but we are lazy and rely on the fab work of JpGraph.
JpGraph is a Object-Oriented Graph creating library for PHP >= 4.3.1 The library is completely written in PHP and ready to be used in any PHP scripts (both CGI/APXS/CLI versions of PHP are supported). Supports advanced Gantt-charts (ex1, ex2)

How To .. sample

In our og_gant folder we are going to make some changes in the source:

  • rename all og_calendar functions to og_gant
  • include jpgraph in our newly created module

    // Also load required integration for jpgraph modules
    $path = drupal_get_path('module', 'sbw_og_gant') . '/jpgraph/src';
    $files = drupal_system_listing('jpgraph.php', $path, 'name', 0);
    foreach($files as $file) {
        require_once("./$file->filename");
    }
    $files = drupal_system_listing('jpgraph_gantt.php', $path, 'name', 0);
    foreach($files as $file) {
        require_once("./$file->filename");
    }
    
  • replace the output code of og_gant_page to fill in your JpGraph data array

    	  $gantData = array();
    	  $i = 0;
    	  $range = array();
    	  $range[0] = 80; #heigth of gant image
    	  $range[1] = 750; #width of gant image
          foreach($nodes as $node) {
    		$range[0] += 20;
    		$row = array($i,
    					  check_plain($node->title),
    			          format_date($node->event_start, 'custom', 'Y/m/d H:i:s', $node->start_offset),
    			          format_date($node->event_end, 'custom', 'Y/m/d H:i:s', $node->end_offset),
    			          FF_FONT1,FS_BOLD,8
    					 );
    		array_push($gantData,$row);
    		$i++;
    	  }
    	  $output .= _og_gant_event_gant($gantData,$range); 
    
            
  • add your modified output function to output

    $output .= _og_gant_event_gant($gantData,$range);
    function _og_gant_event_gant($data,$range) {
    	$graph = new GanttGraph($range[1],$range[0],"auto");
    	
    	$graph->title->Set("Group Gant");
    	
    	// Setup some "very" nonstandard colors
    	$graph->SetMarginColor('lightblue@0.8');
    	$graph->SetBox(true,'yellow:0.6',2);
    	$graph->SetFrame(true,'darkred',4);
    	$graph->scale->divider->SetColor('yellow:0.6');
    	$graph->scale->dividerh->SetColor('yellow:0.6');
    	
    	// Display month and year scale with the gridlines
    	$graph->ShowHeaders(GANTT_HMONTH | GANTT_HYEAR);
    	$graph->scale->month->grid->SetColor('gray');
    	$graph->scale->month->grid->Show(true);
    	$graph->scale->year->grid->SetColor('gray');
    	$graph->scale->year->grid->Show(true);
    	
    	// Create the bars and add them to the gantt chart
    	for($i=0; $i<count($data); ++$i) {
    		$bar = new GanttBar($data[$i][0],$data[$i][1],$data[$i][2],$data[$i][3],"[50%]",10);
    		if( count($data[$i])>4 )
    			$bar->title->SetFont($data[$i][4],$data[$i][5],$data[$i][6]);
    		$bar->SetPattern(BAND_RDIAG,"yellow");
    		$bar->SetFillColor("red");
    		$bar->progress->Set(0.5);
    		$bar->progress->SetPattern(GANTT_SOLID,"darkgreen");
    		$graph->Add($bar);
    	}
    	
    	// Output the chart
    	$destination="files/gants/".$gid.".gant.png";
    	$graph->Stroke($destination);
    	$text_html="<img src=\"$destination\" border=\"0\" >";
            return $text_html; 	
    }
        
  • adapt your case tracker output to include the gant
    phptemplate_casetracker_project_summary($project) in your template.php
      $output .= '<fieldset id="casetracker-node-cases-table" class=" collapsible collapsible">';
      $output .= '<legend>'. t('Gant').'</legend>';
      $output .= '<div class="description">';
      #print_r($project);
      $output .= sbw_og_gant_page($project->nid);
      $output .= '</div>';
      $output .= '</fieldset>';
    

Now you can access your Organic Group Events (Group Calendar) as Gantt Diagram in your Case Tracker Nodes .

Comments

foxfabi’s picture

the described method add an output method in the og_gant module:
sbw_og_gant_page($project->nid);
now we can use it in our template.tlp.php. it may also be possible to add it as view..
in the example we adapt the phptemplate_casetracker_project_summary($project) function found in the
case tracker module using phptemplate theming method.
-- ease your mind ...

-- every day is a new day to explore, discover and understand

claymanz’s picture

leave a bookmark!

jmary’s picture

Is that working in D6 ?

--
Julien MARY

Dane Powell’s picture

FYI, I've written a Gantt chart Views style plugin that integrates with jsGantt, if anyone's interested.
http://drupal.org/project/views_jsgantt

carlo-nois3lab’s picture

subscribing: is it working on d6?