include "../includes/library.php"; include "../includes/jpgraph/jpgraph.php"; include "../includes/jpgraph/jpgraph_gantt.php"; $tmpquery = "WHERE tas.id = '" . $task . "'"; $taskDetail = new request(); $taskDetail->openTasks($tmpquery); $tmpquery = "WHERE pro.id = '" . $taskDetail->tas_project[0] . "'"; $projectDetail = new request(); $projectDetail->openProjects($tmpquery); $projectDetail->pro_created[0] = createDate($projectDetail->pro_created[0], $timezoneSession); $projectDetail->pro_name[0] = str_replace('"', '"', $projectDetail->pro_name[0]); $projectDetail->pro_name[0] = str_replace("'", "'", $projectDetail->pro_name[0]); $graph = new GanttGraph(); $graph->SetBox(); $graph->SetMarginColor("white"); $graph->SetColor("white"); $graph->title->Set($strings["task"] . " " . $taskDetail->tas_name[0]); $graph->subtitle->Set("(" . $strings["created"] . ": " . $taskDetail->tas_created[0] . ")"); $graph->title->SetFont(FF_FONT1); $graph->SetColor("white"); $graph->ShowHeaders(GANTT_HYEAR | GANTT_HMONTH | GANTT_HDAY | GANTT_HWEEK); $graph->scale->week->SetStyle(WEEKSTYLE_FIRSTDAY); $graph->scale->week->SetFont(FF_FONT0); $graph->scale->year->SetFont(FF_FONT1); $tmpquery = "WHERE subtas.task = '{$task}' AND subtas.start_date != '--' AND subtas.due_date != '--' AND tas.published != '1' ORDER BY subtas.due_date"; $listTasks = new request(); $listTasks->openSubtasks($tmpquery); $comptListTasks = count($listTasks->subtas_id); for ($i = 0; $i < $comptListTasks; $i++) { $listTasks->subtas_name[$i] = str_replace('"', '"', $listTasks->subtas_name[$i]); $listTasks->subtas_name[$i] = str_replace("'", "'", $listTasks->subtas_name[$i]);
function graph_schedule($data, $title, $show_day) { require_once "jpgraph/jpgraph.php"; require_once "jpgraph/jpgraph_gantt.php"; // Some sample Gantt data /* $data = array( array(0, " Bryce", "2009-08-28 11:00","2009-08-28 15:30"), array(1, " Kyla", "2009-08-28 08:00","2009-08-28 15:30"), array(2, " Nathan", "2009-08-28 08:00","2009-08-28 17:00") ); */ // Basic graph parameters $graph = new GanttGraph(700); $graph->SetMarginColor('darkgreen@0.8'); $graph->SetColor('white'); $graph->title->Set("{$title}'s Schedule"); $graph->title->SetColor('darkgray'); // We want to display day, hour and minute scales if ($show_day) { $graph->ShowHeaders(GANTT_HDAY | GANTT_HHOUR); } else { $graph->ShowHeaders(GANTT_HHOUR); } #$graph->ShowHeaders(GANTT_HDAY | GANTT_HHOUR); #$graph->ShowHeaders(GANTT_HHOUR); // Setup day format $graph->scale->day->SetBackgroundColor('lightyellow:1.5'); $graph->scale->day->SetStyle(DAYSTYLE_LONG); $graph->scale->day->SetFont(FF_FONT1, FS_NORMAL, 16); // Setup hour format $graph->scale->hour->SetIntervall(1); $graph->scale->hour->SetBackgroundColor('lightyellow:1.5'); $graph->scale->hour->SetStyle(HOURSTYLE_HAMPM); $graph->scale->hour->grid->SetColor('gray:0.8'); $graph->scale->hour->SetFont(FF_FONT1, FS_NORMAL, 13); for ($i = 0; $i < count($data); ++$i) { $bar = new GanttBar($data[$i][0], $data[$i][1], $data[$i][2], $data[$i][3], $data[$i][4]); $bar->SetPattern(BAND_RDIAG, "yellow"); $bar->SetFillColor("gray"); $graph->Add($bar); } // Draw graph $graph->Stroke(); }
/** *Make Gantt *@return image png & die */ function MakeGanttChart(){ // is logged ? if (!logged_user()->isProjectUser(active_project())) { die; } // if // is user can view this project ?? if (!ProjectFile::canView(logged_user(), active_project())) { die; } //if /* * Init gantt graph */ $width = 850; $graph = new GanttGraph($width); /* * here header must be set at end and during process catch all date to determine the difference max between start and end * to present HDAY or not depend on information volume */ //graph header $graph->ShowHeaders(GANTT_HYEAR | GANTT_HMONTH | GANTT_HWEEK | GANTT_HDAY); // Instead of week number show the date for the first day in the week // on the week scale $graph->scale->week->SetStyle(WEEKSTYLE_FIRSTDAY); $graph->SetMarginColor('blue:1.7'); $graph->SetColor('white'); $graph->SetBackgroundGradient('#60A2BA','white',GRAD_HOR,BGRAD_MARGIN); //$graph->SetBackgroundGradient('#A01010','white',GRAD_HOR,BGRAD_MARGIN); $graph->title->SetColor('white'); $graph->title->SetFont(FF_FONT2,FS_BOLD,18); //$graph->scale->actinfo->SetColTitles(array('Act','Duration','Start','Finish','Resp')); $graph->scale->actinfo->SetStyle(ACTINFO_3D); $graph->scale->actinfo->SetFont(FF_ARIAL,FS_NORMAL,10); $graph->scale->actinfo->vgrid->SetColor('gray'); $graph->scale->actinfo->SetColor('darkgray'); $locale_char_set = 'utf-8'; //For french support //Localization::instance()->getLocale(); //if (preg_match('/' . Localization::instance()->getLocale() . '/i', 'fr_fr')) $graph->scale->SetDateLocale("fr_FR.utf8"); /* * data jpgraph construction gantt type for project */ $project = active_project(); //Project title $project_name = $project->getName(); $graph->title->Set(lang('project') . ': ' . substr(utf8_decode($project_name),0,40) ); $rows = $this->displayProjectGantt($project, $graph, 0); $subprojects = $project->getSubprojects(); if (is_array($subprojects)) { foreach($subprojects as $subproject) { $rows = $this->displayProjectGantt($subproject, $graph, $rows++); } } //send data $type = "image/png"; $name = "projectpiergantt.png"; header("Content-Type: $type"); header("pragma: no-cache"); header("Content-Disposition: attachment; filename=\"$name\""); $graph->Stroke(); die(); //end process do not send other informations } //MakeGantt
<?php // Gantt hour + minute example include "../jpgraph.php"; include "../jpgraph_gantt.php"; // Some sample Gantt data $data = array(array(0, array("Group 1", "345 days", "2004-03-01", "2004-05-05"), "2001-11-27 10:00", "2001-11-27 14:00", FF_FONT2, FS_NORMAL, 0), array(1, array(" Label one", ' 122,5 days', ' 2004-03-01', ' 2003-05-05', 'MJ'), "2001-11-27 16:00", "2001-11-27 18:00"), array(2, " Label two", "2001-11-27", "2001-11-27 10:00"), array(3, " Label three", "2001-11-27", "2001-11-27 08:00")); // Basic graph parameters $graph = new GanttGraph(); $graph->SetMarginColor('darkgreen@0.8'); $graph->SetColor('white'); // We want to display day, hour and minute scales $graph->ShowHeaders(GANTT_HDAY | GANTT_HHOUR | GANTT_HMIN); // We want to have the following titles in our columns // describing each activity $graph->scale->actinfo->SetColTitles(array('Act', 'Duration', 'Start', 'Finish', 'Resp')); //,array(100,70,70,70)); // Uncomment the following line if you don't want the 3D look // in the columns headers //$graph->scale->actinfo->SetStyle(ACTINFO_2D); $graph->scale->actinfo->SetFont(FF_ARIAL, FS_NORMAL, 10); //These are the default values for use in the columns //$graph->scale->actinfo->SetFontColor('black'); //$graph->scale->actinfo->SetBackgroundColor('lightgray'); //$graph->scale->actinfo->vgrid->SetStyle('solid'); $graph->scale->actinfo->vgrid->SetColor('gray'); $graph->scale->actinfo->SetColor('darkgray'); // Setup day format $graph->scale->day->SetBackgroundColor('lightyellow:1.5'); $graph->scale->day->SetFont(FF_ARIAL); $graph->scale->day->SetStyle(DAYSTYLE_SHORTDAYDATE1);
function ganttPDF($reportName, $listTasks) { include "../includes/jpgraph/jpgraph.php"; include "../includes/jpgraph/jpgraph_gantt.php"; $graph = new GanttGraph(); $graph->SetBox(); $graph->SetMarginColor("white"); $graph->SetColor("white"); $graph->title->Set($strings["project"] . " " . $reportName); // $graph->subtitle->Set("(".$strings["created"].": "..")"); $graph->title->SetFont(FF_FONT1); $graph->SetColor("white"); $graph->ShowHeaders(GANTT_HYEAR | GANTT_HMONTH | GANTT_HDAY | GANTT_HWEEK); $graph->scale->week->SetStyle(WEEKSTYLE_FIRSTDAY); $graph->scale->week->SetFont(FF_FONT0); $graph->scale->year->SetFont(FF_FONT1); $comptListTasks = count($listTasks->tas_id); $posGantt = 0; for ($i = 0; $i < $comptListTasks; $i++) { $listTasks->tas_name[$i] = str_replace('"', '"', $listTasks->tas_name[$i]); $listTasks->tas_name[$i] = str_replace("'", "'", $listTasks->tas_name[$i]); $progress = round($listTasks->tas_completion[$i] / 10, 2); $printProgress = $listTasks->tas_completion[$i] * 10; $activity = new GanttBar($posGantt, $listTasks->tas_pro_name[$i] . " / " . $listTasks->tas_name[$i], $listTasks->tas_start_date[$i], $listTasks->tas_due_date[$i]); $activity->SetPattern(BAND_LDIAG, "yellow"); $activity->caption->Set($listTasks->tas_mem_login[$i] . " (" . $printProgress . "%)"); $activity->SetFillColor("gray"); if ($listTasks->tas_priority[$i] == "4" || $listTasks->tas_priority[$i] == "5") { $activity->progress->SetPattern(BAND_SOLID, "#BB0000"); } else { $activity->progress->SetPattern(BAND_SOLID, "#0000BB"); } $activity->progress->Set($progress); $graph->Add($activity); // begin if subtask $tmpquery = "WHERE task = " . $listTasks->tas_id[$i]; $listSubTasks = new request(); $listSubTasks->openSubtasks($tmpquery); $comptListSubTasks = count($listSubTasks->subtas_id); if ($comptListSubTasks >= 1) { // list subtasks for ($j = 0; $j < $comptListSubTasks; $j++) { $listSubTasks->subtas_name[$j] = str_replace('"', '"', $listSubTasks->subtas_name[$j]); $listSubTasks->subtas_name[$j] = str_replace("'", "'", $listSubTasks->subtas_name[$j]); $progress = round($listSubTasks->subtas_completion[$j] / 10, 2); $printProgress = $listSubTasks->subtas_completion[$j] * 10; $posGantt += 1; // $activity = new GanttBar($posGantt,$listTasks->tas_pro_name[$i]." / ".$listSubTasks->subtas_name[$j],$listSubTasks->subtas_start_date[$j],$listSubTasks->subtas_due_date[$j]); // change name of project for name of parent task $activity = new GanttBar($posGantt, $listSubTasks->subtas_tas_name[$j] . " / " . $listSubTasks->subtas_name[$j], $listSubTasks->subtas_start_date[$j], $listSubTasks->subtas_due_date[$j]); //$activity = new GanttBar($j,$strings["project"].": ".$listSubTasks->subtas_pro_name[$j]." / ".$strings["task"].": ".$listSubTasks->subtas_name[$j],$listSubTasks->subtas_start_date[$j],$listSubTasks->subtas_due_date[$j]); $activity->SetPattern(BAND_LDIAG, "yellow"); $activity->caption->Set($listSubTasks->subtas_mem_login[$j] . " (" . $printProgress . "%)"); $activity->SetFillColor("gray"); if ($listSubTasks->subtas_priority[$j] == "4" || $listSubTasks->subtas_priority[$j] == "5") { $activity->progress->SetPattern(BAND_SOLID, "#BB0000"); } else { $activity->progress->SetPattern(BAND_SOLID, "#0000BB"); } $activity->progress->Set($progress); $graph->Add($activity); } // end for comptListSubTasks } // end if subtask $posGantt += 1; } // end for complisttask $tmpGantt = "../files/" . md5(uniqid(rand())); $graph->Stroke($tmpGantt); return $tmpGantt; }