OG Event Gant

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 Gant Diagramm.

To do this we have made a copy of our og_calendar Folder to og_gant. This will be our Gant 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 Gant....

Dependencies

It may be possible to build the Gant 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 Gant Diagramm in your Case Tracker Nodes ...

help please

ebru4486 - May 21, 2008 - 09:44

Hi ,
We are trying to add a gant chart to our drupal website. We used your advises above but we had some problems and we need a little bit help. We applied all the steps except the last one.
we haven't found where to paste this code :
$output .= '';
$output .= ''. t('Gant').'';
$output .= '';
#print_r($project);
$output .= sbw_og_gant_page($project->nid);
$output .= '';
$output .= '';

we tried to paste it to the themes/template.php file but when we make this like that we are getting an error and the page could not open.We would be very happy if you could help us
thanks ...

 
 

Drupal is a registered trademark of Dries Buytaert.