mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
NEW The gantt diagram is now sensitive to hours
NEW Add a group task line for tasks on same level on gantt diagram
This commit is contained in:
parent
daa7847ab3
commit
a16f0e4356
|
|
@ -820,7 +820,7 @@ JSGantt.GanttChart=function(pDiv, pFormat)
|
|||
vTmpCell=this.newNode(vTmpRow, 'td', null, 'gresource');
|
||||
/*vTmpDiv=this.newNode(vTmpCell, 'div', null, null, vTaskList[i].getResource());*/
|
||||
var vTmpNode=this.newNode(vTmpCell, 'div', null, '');
|
||||
vTmpNode=this.newNode(vTmpNode, 'a', null, '', vLangs[vLang]['moreinfo']);
|
||||
vTmpNode=this.newNode(vTmpNode, 'a', null, '', (vTaskList[i].getLink() != '' ? vLangs[vLang]['moreinfo'] : ''));
|
||||
vTmpNode.setAttribute('href',vTaskList[i].getLink());
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ OpenedTasks=Open tasks
|
|||
OpportunitiesStatusForOpenedProjects=Opportunities amount of open projects by status
|
||||
OpportunitiesStatusForProjects=Opportunities amount of projects by status
|
||||
ShowProject=Show project
|
||||
ShowTask=Show task
|
||||
SetProject=Set project
|
||||
NoProject=No project defined or owned
|
||||
NbOfProjects=Nb of projects
|
||||
|
|
@ -75,6 +76,7 @@ Time=Time
|
|||
ListOfTasks=List of tasks
|
||||
GoToListOfTimeConsumed=Go to list of time consumed
|
||||
GoToListOfTasks=Go to list of tasks
|
||||
GanttView=Gantt View
|
||||
ListProposalsAssociatedProject=List of the commercial proposals associated with the project
|
||||
ListOrdersAssociatedProject=List of customer orders associated with the project
|
||||
ListInvoicesAssociatedProject=List of customer invoices associated with the project
|
||||
|
|
|
|||
|
|
@ -396,8 +396,8 @@ dol_fiche_end();
|
|||
print '<div class="floatright right'.($conf->dol_optimize_smallscreen?' centpercent':'').'">'.$nav.'</div>'; // We move this before the assign to components so, the default submit button is not the assign to.
|
||||
|
||||
print '<div class="float valignmiddle">';
|
||||
$titleassigntask = $langs->trans("AssignTaskToMe");
|
||||
if ($usertoprocess->id != $user->id) $titleassigntask = $langs->trans("AssignTaskToUser", $usertoprocess->getFullName($langs));
|
||||
$titleassigntask = $langs->transnoentities("AssignTaskToMe");
|
||||
if ($usertoprocess->id != $user->id) $titleassigntask = $langs->transnoentities("AssignTaskToUser", $usertoprocess->getFullName($langs));
|
||||
print '<div class="taskiddiv inline-block">';
|
||||
$formproject->selectTasks($socid?$socid:-1, $taskid, 'taskid', 32, 0, 1, 1);
|
||||
print '</div>';
|
||||
|
|
|
|||
|
|
@ -399,8 +399,8 @@ dol_fiche_end();
|
|||
print '<div class="floatright right'.($conf->dol_optimize_smallscreen?' centpercent':'').'">'.$nav.'</div>'; // We move this before the assign to components so, the default submit button is not the assign to.
|
||||
|
||||
print '<div class="float valignmiddle">';
|
||||
$titleassigntask = $langs->trans("AssignTaskToMe");
|
||||
if ($usertoprocess->id != $user->id) $titleassigntask = $langs->trans("AssignTaskToUser", $usertoprocess->getFullName($langs));
|
||||
$titleassigntask = $langs->transnoentities("AssignTaskToMe");
|
||||
if ($usertoprocess->id != $user->id) $titleassigntask = $langs->transnoentities("AssignTaskToUser", $usertoprocess->getFullName($langs));
|
||||
print '<div class="taskiddiv inline-block">';
|
||||
$formproject->selectTasks($socid?$socid:-1, $taskid, 'taskid', 32, 0, 1, 1);
|
||||
print '</div>';
|
||||
|
|
|
|||
|
|
@ -111,11 +111,27 @@ if (g.getDivId() != null)
|
|||
<?php
|
||||
$level=0;
|
||||
$tnums = count($tasks);
|
||||
for ($tcursor=0; $tcursor < $tnums; $tcursor++) {
|
||||
$old_project_id = 0;
|
||||
for ($tcursor=0; $tcursor < $tnums; $tcursor++)
|
||||
{
|
||||
$t = $tasks[$tcursor];
|
||||
if ($t["task_parent"] == 0) {
|
||||
constructGanttLine($tasks,$t,$project_dependencies,$level,$project_id);
|
||||
findChildGanttLine($tasks,$t["task_id"],$project_dependencies,$level+1);
|
||||
|
||||
if (empty($old_project_id) || $old_project_id != $t['task_project_id'])
|
||||
{
|
||||
// Break on project, create a fictive task for project id $t['task_project_id']
|
||||
$projecttmp=new Project($db);
|
||||
$projecttmp->fetch($t['task_project_id']);
|
||||
$tmpt = array(
|
||||
'task_id'=> '-'.$t['task_project_id'], 'task_name'=>$projecttmp->ref.' '.$projecttmp->title, 'task_resources'=>'', 'task_start_date'=>'', 'task_end_date'=>'',
|
||||
'task_is_group'=>1, 'task_css'=>'ggroupblack', 'task_milestone'=> 0, 'task_parent'=>0, 'task_notes'=>'');
|
||||
constructGanttLine($tasks, $tmpt, array(), 0, $t['task_project_id']);
|
||||
$old_project_id = $t['task_project_id'];
|
||||
}
|
||||
|
||||
if ($t["task_parent"] <= 0)
|
||||
{
|
||||
constructGanttLine($tasks, $t, $task_dependencies, $level, $t['task_project_id']);
|
||||
findChildGanttLine($tasks, $t["task_id"], $task_dependencies, $level+1);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
@ -138,12 +154,12 @@ else
|
|||
*
|
||||
* @param array $tarr Array of all tasks
|
||||
* @param array $task Array with properties of one task
|
||||
* @param Project $project_dependencies Project object
|
||||
* @param array $task_dependencies Task dependencies (array(array(0=>idtask,1=>idtasktofinishfisrt))
|
||||
* @param int $level Level
|
||||
* @param int $project_id Id of project
|
||||
* @return void
|
||||
*/
|
||||
function constructGanttLine($tarr,$task,$project_dependencies,$level=0,$project_id=null)
|
||||
function constructGanttLine($tarr, $task, $task_dependencies, $level=0, $project_id=null)
|
||||
{
|
||||
global $dateformatinput2;
|
||||
|
||||
|
|
@ -157,23 +173,35 @@ function constructGanttLine($tarr,$task,$project_dependencies,$level=0,$project_
|
|||
// Define depend (ex: "", "4,13", ...)
|
||||
$depend = '';
|
||||
$count = 0;
|
||||
foreach ($project_dependencies as $value) {
|
||||
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 .= "\"";
|
||||
// $depend .= "\"";
|
||||
// Define parent
|
||||
if ($project_id && $level < 0)
|
||||
$parent = 'p'.$project_id;
|
||||
{
|
||||
$parent = '-'.$project_id;
|
||||
}
|
||||
else
|
||||
$parent = $task["task_parent"];
|
||||
{
|
||||
$parent = $task["task_parent"];
|
||||
}
|
||||
// Define percent
|
||||
$percent = $task['task_percent_complete']?$task['task_percent_complete']:0;
|
||||
// Link (more information)
|
||||
$link=DOL_URL_ROOT.'/projet/tasks/contact.php?withproject=1&id='.$task["task_id"];
|
||||
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='<a href="'.DOL_URL_ROOT.'/projet/task/tasks.php?id='.$task['task_id'].'">'.$task['task_name'].'</a>';
|
||||
|
|
@ -211,9 +239,19 @@ function constructGanttLine($tarr,$task,$project_dependencies,$level=0,$project_
|
|||
//$note="";
|
||||
|
||||
$s = "\n// Add taks id=".$task["task_id"]." level = ".$level."\n";
|
||||
// $s.= "g.AddTaskItem(new JSGantt.TaskItem(".$task['task_id'].",'".dol_escape_js($name)."','".$start_date."', '".$end_date."', '".$task['task_color']."', '".$link."', ".$task['task_milestone'].", '".$resources."', ".($percent >= 0 ? $percent : 0).", ".($task["task_is_group"]>0?1:0).", '".$parent."', 1, '".($depend?$depend:"")."', '".$note."'));";
|
||||
|
||||
//$task["task_is_group"]=1; // When task_is_group is 1, content will be autocalculated from sum of all low tasks
|
||||
|
||||
// For JSGanttImproved
|
||||
$s.= "g.AddTaskItem(new JSGantt.TaskItem(".$task['task_id'].",'".dol_escape_js(trim($name))."','".$start_date."', '".$end_date."', '".$task['task_css']."', '".$link."', ".$task['task_milestone'].", '".dol_escape_js($resources)."', ".($percent >= 0 ? $percent : 0).", ".($task["task_is_group"]).", ".$parent.", 1, '".($depend?$depend:$parent."SS")."', '".($percent >= 0 ? $percent.'%' : '0%')."','".dol_escape_js($task['note'])."', g));";
|
||||
$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;
|
||||
|
||||
$s.= "g.AddTaskItem(new JSGantt.TaskItem('".$task['task_id']."', '".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($task['note'])."', g));";
|
||||
echo $s;
|
||||
|
||||
|
||||
|
|
@ -224,19 +262,34 @@ function constructGanttLine($tarr,$task,$project_dependencies,$level=0,$project_
|
|||
*
|
||||
* @param array $tarr tarr
|
||||
* @param int $parent Parent
|
||||
* @param Project $project_dependencies Project object
|
||||
* @param array $task_dependencies Task dependencies
|
||||
* @param int $level Level
|
||||
* @return void
|
||||
*/
|
||||
function findChildGanttLine($tarr,$parent,$project_dependencies,$level)
|
||||
function findChildGanttLine($tarr, $parent, $task_dependencies, $level)
|
||||
{
|
||||
$n=count($tarr);
|
||||
|
||||
echo "\n";
|
||||
echo "/* g.AddTaskItem(new JSGantt.TaskItem(task_id, 'label', 'start_date', 'end_date', 'css', 'link', milestone, 'Resources', Compl%, Group, Parent, 1, 'Dependency', 'label','note', g)); */\n";
|
||||
|
||||
$old_parent_id = 0;
|
||||
for ($x=0; $x < $n; $x++)
|
||||
{
|
||||
if($tarr[$x]["task_parent"] == $parent && $tarr[$x]["task_parent"] != $tarr[$x]["task_id"])
|
||||
{
|
||||
constructGanttLine($tarr,$tarr[$x],$project_dependencies,$level,null);
|
||||
findChildGanttLine($tarr,$tarr[$x]["task_id"],$project_dependencies,$level+1);
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -195,28 +195,36 @@ if ($id > 0 || ! empty($ref))
|
|||
* Buttons actions
|
||||
*/
|
||||
|
||||
print '<div class="tabsAction">';
|
||||
|
||||
if ($user->rights->projet->all->creer || $user->rights->projet->creer)
|
||||
if ($id > 0)
|
||||
{
|
||||
if ($object->public || $userWrite > 0)
|
||||
{
|
||||
print '<a class="butAction" href="'.DOL_URL_ROOT.'/projet/tasks.php?id='.$object->id.'&action=create'.$param.'&tab=gantt&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$object->id).'">'.$langs->trans('AddTask').'</a>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<a class="butActionRefused" href="#" title="'.$langs->trans("NotOwnerOfProject").'">'.$langs->trans('AddTask').'</a>';
|
||||
}
|
||||
|
||||
print '<div class="tabsAction">';
|
||||
|
||||
if ($user->rights->projet->all->creer || $user->rights->projet->creer)
|
||||
{
|
||||
if ($object->public || $userWrite > 0)
|
||||
{
|
||||
print '<a class="butAction" href="'.DOL_URL_ROOT.'/projet/tasks.php?id='.$object->id.'&action=create'.$param.'&tab=gantt&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$object->id).'">'.$langs->trans('AddTask').'</a>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<a class="butActionRefused" href="#" title="'.$langs->trans("NotOwnerOfProject").'">'.$langs->trans('AddTask').'</a>';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<a class="butActionRefused" href="#" title="'.$langs->trans("NotEnoughPermissions").'">'.$langs->trans('AddTask').'</a>';
|
||||
}
|
||||
|
||||
print '</div>';
|
||||
|
||||
print '<br>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<a class="butActionRefused" href="#" title="'.$langs->trans("NotEnoughPermissions").'">'.$langs->trans('AddTask').'</a>';
|
||||
print_fiche_titre($langs->trans("GanttView"));
|
||||
}
|
||||
|
||||
print '</div>';
|
||||
|
||||
print '<br>';
|
||||
|
||||
|
||||
// Get list of tasks in tasksarray and taskarrayfiltered
|
||||
// We need all tasks (even not limited to a user because a task to user
|
||||
|
|
@ -237,24 +245,28 @@ if (count($tasksarray)>0)
|
|||
$datehourformat=$langs->trans("FormatDateShortJQuery").' '.$langs->trans("FormatHourShortJQuery"); // Used by include ganttchart.inc.php later
|
||||
$array_contacts=array();
|
||||
$tasks=array();
|
||||
$project_dependencies=array();
|
||||
$task_dependencies=array();
|
||||
$taskcursor=0;
|
||||
foreach($tasksarray as $key => $val)
|
||||
{
|
||||
$task->fetch($val->id);
|
||||
|
||||
$tasks[$taskcursor]['task_id']=$val->id;
|
||||
$tasks[$taskcursor]['task_parent']=$val->fk_parent;
|
||||
$tasks[$taskcursor]['task_project_id']=$val->fk_project;
|
||||
$tasks[$taskcursor]['task_parent']=($val->fk_parent ? $val->fk_parent : '-'.$val->fk_project);
|
||||
$tasks[$taskcursor]['task_is_group'] = 0;
|
||||
$tasks[$taskcursor]['task_css'] = 'gtaskblue';
|
||||
|
||||
if($val->fk_parent > 0 && $task->hasChildren()> 0){
|
||||
if ($val->fk_parent != 0 && $task->hasChildren()> 0){
|
||||
$tasks[$taskcursor]['task_is_group']=1;
|
||||
$tasks[$taskcursor]['task_css'] = 'gtaskred';
|
||||
$tasks[$taskcursor]['task_css']='ggroupblack';
|
||||
//$tasks[$taskcursor]['task_css'] = 'gtaskblue';
|
||||
}
|
||||
elseif($task->hasChildren()> 0) {
|
||||
elseif ($task->hasChildren()> 0) {
|
||||
$tasks[$taskcursor]['task_is_group'] = 1;
|
||||
$tasks[$taskcursor]['task_css'] = 'gtaskgreen';
|
||||
//$tasks[$taskcursor]['task_is_group'] = 0;
|
||||
$tasks[$taskcursor]['task_css'] = 'ggroupblack';
|
||||
//$tasks[$taskcursor]['task_css'] = 'gtaskblue';
|
||||
}
|
||||
$tasks[$taskcursor]['task_milestone']='0';
|
||||
$tasks[$taskcursor]['task_percent_complete']=$val->progress;
|
||||
|
|
@ -315,9 +327,12 @@ if (count($tasksarray)>0)
|
|||
if (! empty($conf->use_javascript_ajax))
|
||||
{
|
||||
//var_dump($_SESSION);
|
||||
$dateformatinput='mm/dd/yyyy'; // How the date for data are formated
|
||||
$dateformatinput2="%m/%d/%Y"; // How the date for data are formated
|
||||
//var_dump($dateformatinput);
|
||||
|
||||
// How the date for data are formated (format used bu jsgantt)
|
||||
$dateformatinput='yyyy-mm-dd';
|
||||
// How the date for data are formated (format used by dol_print_date)
|
||||
$dateformatinput2='standard';
|
||||
//var_dump($dateformatinput);
|
||||
//var_dump($dateformatinput2);
|
||||
|
||||
print '<div class="div-table-responsive">';
|
||||
|
|
|
|||
|
|
@ -38,16 +38,17 @@ require_once __DIR__.'/../main.inc.php';
|
|||
top_httphead('text/javascript');
|
||||
|
||||
global $langs;
|
||||
$langs->load("projects");
|
||||
?>
|
||||
|
||||
var vLangs={'<?php print $langs->getDefaultLang(1);?>':
|
||||
{
|
||||
'format':'<?php print '-';?>','hour':'"<?php print $langs->transnoentities('Hour'); ?>','day':'<?php print $langs->transnoentities('Day'); ?>',
|
||||
'format':'<?php print $langs->transnoentities('Period');?>','hour':'"<?php print $langs->transnoentities('Hour'); ?>','day':'<?php print $langs->transnoentities('Day'); ?>',
|
||||
'week':'<?php print $langs->transnoentities('Week'); ?>','month':'<?php print $langs->transnoentities('Month'); ?>','quarter':'<?php print $langs->transnoentities('Quadri'); ?>',
|
||||
'hours':'<?php print $langs->transnoentities('Hours'); ?>','days':'<?php print $langs->transnoentities('Days'); ?>','weeks':'<?php print $langs->transnoentities('Weeks');?>',
|
||||
'months':'<?php print $langs->transnoentities('Months'); ?>','quarters':'<?php print $langs->transnoentities('Quadri'); ?>','hr':'Hr','dy':'<?php print $langs->transnoentities('Day'); ?>','wk':'<?php print $langs->transnoentities('Week'); ?>','mth':'<?php print $langs->transnoentities('Month'); ?>','qtr':'<?php print $langs->transnoentities('Quadri'); ?>','hrs':'<?php print $langs->transnoentities('Hours'); ?>',
|
||||
'dys':'<?php print $langs->transnoentities('Days'); ?>','wks':'<?php print $langs->transnoentities('Weeks'); ?>','mths':'<?php print $langs->transnoentities('Months'); ?>','qtrs':'<?php print $langs->transnoentities('Quadri'); ?>','resource':'<?php print dol_escape_js($langs->transnoentities('Resources')); ?>','duration':'<?php print dol_escape_js($langs->transnoentities('Duration')); ?>','comp':'% <?php print dol_escape_js($langs->transnoentities('Total')); ?>',
|
||||
'completion':'<?php print $langs->transnoentities('Total'); ?>','startdate':'<?php print $langs->transnoentities('DateStart'); ?>','enddate':'<?php print $langs->transnoentities('DateEnd'); ?>','moreinfo':'<?php print dol_escape_js($langs->transnoentities('MoreInformation')); ?>',
|
||||
'dys':'<?php print $langs->transnoentities('Days'); ?>','wks':'<?php print $langs->transnoentities('Weeks'); ?>','mths':'<?php print $langs->transnoentities('Months'); ?>','qtrs':'<?php print $langs->transnoentities('Quadri'); ?>','resource':'<?php print dol_escape_js($langs->transnoentities('Resource')); ?>','duration':'<?php print dol_escape_js($langs->transnoentities('Duration')); ?>','comp':'%',
|
||||
'completion':'<?php print $langs->transnoentities('Total'); ?>','startdate':'<?php print $langs->transnoentities('DateStart'); ?>','enddate':'<?php print $langs->transnoentities('DateEnd'); ?>','moreinfo':'<?php print dol_escape_js($langs->transnoentities('ShowTask')); ?>',
|
||||
'notes':'<?php print $langs->transnoentities('NotePublic'); ?>',
|
||||
'january':'<?php print $langs->transnoentities('January'); ?>','february':'<?php print $langs->transnoentities('February'); ?>','march':'<?php print $langs->transnoentities('March'); ?>','april':'<?php print $langs->transnoentities('April'); ?>','maylong':'<?php print $langs->transnoentities('May'); ?>','june':'<?php print $langs->transnoentities('June'); ?>','july':'<?php print $langs->transnoentities('July'); ?>',
|
||||
'august':'<?php print $langs->transnoentities('August'); ?>','september':'<?php print $langs->transnoentities('September'); ?>','october':'<?php print $langs->transnoentities('October'); ?>','november':'<?php print $langs->transnoentities('November'); ?>','december':'<?php print $langs->transnoentities('December'); ?>',
|
||||
|
|
|
|||
|
|
@ -3922,11 +3922,29 @@ div.gTaskInfo {
|
|||
.gtaskblue {
|
||||
background: rgb(108,152,185) !important;
|
||||
}
|
||||
.gtaskgreen {
|
||||
background: rgb(160,173,58) !important;
|
||||
}
|
||||
td.gtaskname {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
td.gminorheadingwkend {
|
||||
color: #888 !important;
|
||||
}
|
||||
td.gminorheading {
|
||||
color: #666 !important;
|
||||
}
|
||||
.gtaskname div, .gtaskname {
|
||||
min-width: 200px !important;
|
||||
max-width: 200px !important;
|
||||
width: 200px !important;
|
||||
}
|
||||
.gpccomplete div, .gpccomplete {
|
||||
min-width: 40px !important;
|
||||
max-width: 40px !important;
|
||||
width: 40px !important;
|
||||
}
|
||||
|
||||
|
||||
/* ============================================================================== */
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user