*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
/**
* \file htdocs/projet/ganttchart.inc.php
* \ingroup projet
* \brief Gantt diagram of a project
*/
?>
idtask,1=>idtasktofinishfisrt))
* @param int $level Level
* @param int $project_id Id of project
* @return void
*/
function constructGanttLine($tarr, $task, $task_dependencies, $level = 0, $project_id = null)
{
global $langs;
global $dateformatinput2;
$start_date = $task["task_start_date"];
$end_date = $task["task_end_date"];
if (!$end_date) {
$end_date = $start_date;
}
$start_date = dol_print_date($start_date, $dateformatinput2);
$end_date = dol_print_date($end_date, $dateformatinput2);
// Resources
$resources = $task["task_resources"];
// Define depend (ex: "", "4,13", ...)
$depend = '';
$count = 0;
foreach ($task_dependencies as $value) {
// Not yet used project_dependencies = array(array(0=>idtask,1=>idtasktofinishfisrt))
if ($value[0] == $task['task_id']) {
$depend .= ($count > 0 ? "," : "").$value[1];
$count++;
}
}
// $depend .= "\"";
// Define parent
if ($project_id && $level < 0) {
$parent = '-'.$project_id;
} else {
$parent = $task["task_parent_alternate_id"];
//$parent = $task["task_parent"];
}
// Define percent
$percent = empty($task['task_percent_complete']) ? 0 : $task['task_percent_complete'];
// Link (more information)
if ($task["task_id"] < 0) {
//$link=DOL_URL_ROOT.'/projet/tasks.php?withproject=1&id='.abs($task["task_id"]);
$link = '';
} else {
$link = DOL_URL_ROOT.'/projet/tasks/contact.php?withproject=1&id='.$task["task_id"];
}
// Name
//$name=''.$task['task_name'].'';
$name = $task['task_name'];
/*for($i=0; $i < $level; $i++) {
$name=' - '.$name;
}*/
// Add line to gantt
/*
g.AddTaskItem(new JSGantt.TaskItem(1, 'Define Chart API','', '', 'ggroupblack','', 0, 'Brian', 0, 1,0,1,'','','Some Notes text',g));
g.AddTaskItem(new JSGantt.TaskItem(11,'Chart Object', '2014-02-20','2014-02-20','gmilestone', '', 1, 'Shlomy',100,0,1,1,'','','',g));
Method definition:
TaskItem(pID, pName, pStart, pEnd, pColor, pLink, pMile, pRes, pComp, pGroup, pParent, pOpen, pDepend, pCaption, pNotes, pGantt)
- pID
- (required) a unique numeric ID used to identify each row
- pName
- (required) the task Label
- pStart
- (required) the task start date, can enter empty date ('') for groups. You can also enter specific time (2014-02-20 12:00) for additional precision.
- pEnd
- (required) the task end date, can enter empty date ('') for groups
- pClass
- (required) the css class for this task
- pLink
- (optional) any http link to be displayed in tool tip as the "More information" link.
- pMile
- (optional) indicates whether this is a milestone task - Numeric; 1 = milestone, 0 = not milestone
- press
- (optional) resource name
- pComp
- (required) completion percent, numeric
- pGroup
- (optional) indicates whether this is a group task (parent) - Numeric; 0 = normal task, 1 = standard group task, 2 = combined group task
- pParent
- (required) identifies a parent pID, this causes this task to be a child of identified task. Numeric, top level tasks should have pParent set to 0
- pOpen
- (required) indicates whether a standard group task is open when chart is first drawn. Value must be set for all items but is only used by standard group tasks. Numeric, 1 = open, 0 = closed
- pDepend
- (optional) comma separated list of id's this task is dependent on. A line will be drawn from each listed task to this item
Each id can optionally be followed by a dependency type suffix. Valid values are:'FS' - Finish to Start (default if suffix is omitted)
'SF' - Start to Finish
'SS' - Start to Start
'FF' - Finish to Finish
If present the suffix must be added directly to the id e.g. '123SS'
- pCaption
- (optional) caption that will be added after task bar if CaptionType set to "Caption"
- pNotes
- (optional) Detailed task information that will be displayed in tool tip for this task
- pGantt
- (required) javascript JSGantt.GanttChart object from which to take settings. Defaults to "g" for backwards compatibility
*/
//$note="";
$s = "\n// Add task level = ".$level." id=".$task["task_id"]." parent_id=".$task["task_parent"]." aternate_id=".$task["task_alternate_id"]." parent_aternate_id=".$task["task_parent_alternate_id"]."\n";
//$task["task_is_group"]=1; // When task_is_group is 1, content will be autocalculated from sum of all low tasks
// For JSGanttImproved
$css = $task['task_css'];
$line_is_auto_group = $task["task_is_group"];
//$line_is_auto_group=0;
//if ($line_is_auto_group) $css = 'ggroupblack';
//$dependency = ($depend?$depend:$parent."SS");
$dependency = '';
//$name = str_repeat("..", $level).$name;
$taskid = $task["task_alternate_id"];
//$taskid = $task['task_id'];
$note = empty($task['note']) ? '' : $task['note'];
$note = dol_concatdesc($note, $langs->trans("Workload").' : '.(empty($task['task_planned_workload']) ? '' : convertSecondToTime($task['task_planned_workload'], 'allhourmin')));
$s .= "g.AddTaskItem(new JSGantt.TaskItem('".$taskid."', '".dol_escape_js(trim($name))."', '".$start_date."', '".$end_date."', '".$css."', '".$link."', ".$task['task_milestone'].", '".dol_escape_js($resources)."', ".($percent >= 0 ? $percent : 0).", ".$line_is_auto_group.", '".$parent."', 1, '".$dependency."', '".(empty($task["task_is_group"]) ? (($percent >= 0 && $percent != '') ? $percent.'%' : '') : '')."', '".dol_escape_js($note)."', g));";
echo $s;
}
/**
* Find child Gantt line
*
* @param array $tarr tarr
* @param int $parent Parent
* @param array $task_dependencies Task dependencies
* @param int $level Level
* @return void
*/
function findChildGanttLine($tarr, $parent, $task_dependencies, $level)
{
$n = count($tarr);
$old_parent_id = 0;
for ($x = 0; $x < $n; $x++) {
if ($tarr[$x]["task_parent"] == $parent && $tarr[$x]["task_parent"] != $tarr[$x]["task_id"]) {
// Create a grouping parent task for the new level
/*if (empty($old_parent_id) || $old_parent_id != $tarr[$x]['task_project_id'])
{
$tmpt = array(
'task_id'=> -98, 'task_name'=>'Level '.$level, 'task_resources'=>'', 'task_start_date'=>'', 'task_end_date'=>'',
'task_is_group'=>1, 'task_css'=>'ggroupblack', 'task_milestone'=> 0, 'task_parent'=>$tarr[$x]["task_parent"], 'task_notes'=>'');
constructGanttLine($tasks, $tmpt, array(), 0, $tarr[$x]['task_project_id']);
$old_parent_id = $tarr[$x]['task_project_id'];
}*/
constructGanttLine($tarr, $tarr[$x], $task_dependencies, $level, null);
findChildGanttLine($tarr, $tarr[$x]["task_id"], $task_dependencies, $level + 1);
}
}
}