height: 100%; position: relative; } </style> </head> <body> <?php $relatorio = new Relatorio(); $array = $relatorio::listGantt(); function calculeHours($inicio, $final) { return date("d", strtotime($inicio) - strtotime($final)) * 24; } $max = array(); $tasks = $projects = array(); $gantt = Gantt::factory('targetGanttChartControl'); foreach ($array as $key => $value) { if (!isset($max[$value['ID_ASSUNTO']])) { $max[$value['ID_ASSUNTO']] = '2099-01-01'; } if ($max[$value['ID_ASSUNTO']] > $value['DT_DOCUMENTO']) { $max[$value['ID_ASSUNTO']] = $value['DT_DOCUMENTO']; } $hours = calculeHours($value['DT_PRAZO'], $value['DT_DOCUMENTO']); $tasks[$value['ID_ASSUNTO']][] = Task::factory($value['SQ_PRAZO'], $value['DIGITAL'] . ' - ' . $value['INTERESSADO'], $value['DT_DOCUMENTO'], $hours, $value['DT_RESPOSTA'] ? 100 : 0, ''); $projects[$value['ID_ASSUNTO']] = Project::factory($value['ID_ASSUNTO'], $value['ID_ASSUNTO'] . ' - ' . $value['NM_ASSUNTO'], $max[$value['ID_ASSUNTO']]); } foreach ($projects as $key => $project) { foreach ($tasks[$key] as $index => $task) { $project->addTask($task); }
function display() { extract($_REQUEST); $fields = array(); $fields["period"] = "monthly"; $fields["start_day"] = "01"; $fields["start_month"] = date("m"); $fields["start_year"] = date("Y"); $fields["end_day"] = date("d"); $fields["end_month"] = date("m"); $fields["end_year"] = date("Y"); extract($fields, EXTR_SKIP); $gantt = new Gantt($project_id); $period_fields = array("daily" => "Daily", "weekly" => "Weekly", "monthly" => "Monthly"); $period_sel = "<select name='period' onchange='javascript:document.form.submit()'>"; foreach ($period_fields as $key => $value) { if ($period == $key) { $sel = "selected"; } else { $sel = ""; } $period_sel .= "<option value='{$key}' {$sel}>{$value}</option>"; } $period_sel .= "</select>"; $start_epoch = mktime(0, 0, 0, $start_month, $start_day, $start_year); $end_epoch = mktime(0, 0, 0, $end_month, $end_day, $end_year); if ($period == "monthly") { $gantt_out = $gantt->generate_monthly($start_epoch, $end_epoch); } elseif ($period == "daily") { $gantt_out = $gantt->generate_daily($start_epoch, $end_epoch); } elseif ($period == "weekly") { $gantt_out = $gantt->generate_weekly($start_epoch, $end_epoch); } $OUTPUT = "<center>\n\t<h3>Gantt Chart</h3>\n\t<form method='post' action='" . SELF . "' name='form'>\n\t<input type='hidden' name='key' value='display' />\n\t<input type='hidden' name='project_id' value='{$project_id}' />\n\t<table " . TMPL_tblDflts . ">\n\t\t<tr>\n\t\t\t<th colspan='4'>Date Range</th>\n\t\t</tr>\n\t\t<tr class='" . bg_class() . "'>\n\t\t\t<td>" . mkDateSelect("start", $start_year, $start_month, $start_day) . "</td>\n\t\t\t<td><b>To</b></td>\n\t\t\t<td>" . mkDateSelect("end", $end_year, $end_month, $end_day) . "</td>\n\t\t\t<td><input type='submit' value='Select »' /></td>\n\t\t<tr>\n\t\t\t<th colspan='4'>Display</th>\n\t\t</tr>\n\t\t<tr class='" . bg_class() . "'>\n\t\t\t<td colspan='4' align='center'>{$period_sel}</td>\n\t\t</tr>\n\t</table>\n\t<p></p>\n\t<table cellpadding='3' cellspacing='0'>\n\t{$gantt_out}\n\t</table>\n\t</center>"; return $OUTPUT; return $OUTPUT; }
.targetGanttChartControl{ width: 100%; height: 670px; position: relative; } </style> </head> <body> <?php $project1 = Project::factory(1, 'Violencia', '2013-01-14'); $project1->addTask(Task::factory('11', '1.1', '2013-01-15', '24', 10, '')->addTask(Task::factory('111', '1.1.1', '2013-01-15', '12', 100, ''))->addTask(Task::factory('112', '1.1.2', '2013-01-15', '11', 65, '')->addTask(Task::factory('1121', '1.1.2.1', '2013-01-16', '1', 45, ''))))->addTask(Task::factory('12', '1.2', '2013-01-19', '48', 55, ''))->addTask(Task::factory('13', '1.3', '2013-01-25', '72', 65, '112')); $project2 = Project::factory(2, 'Sociedade', '2013-05-12'); $project2->addTask(Task::factory('21', '2.1', '2013-05-12', '48', 22, '')); $project3 = Project::factory(3, 'League of Legends', '2013-03-01'); $project3->addTask(Task::factory('31', '3.1', '2013-03-02', '12', 75, ''))->addTask(Task::factory('32', 'Mobilizacao Social', '2013-03-04', '24', 0, '31')); Gantt::factory('targetGanttChartControl')->addProject($project1)->addProject($project2)->addProject($project3)->render(); ?> </body> </html> <?php /** * @author Michael F. Rodrigues <*****@*****.**> */ class Gantt { /** * @var integer */ private $_id = 0; /**
<?php require "gantt.inc.php"; $gant = new Gantt(); print $gant->generate_monthly(1154689997, 1254789997); ?>