From a16f0e43560a0b0289dc49c330c3a7fabc763b96 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 20 Oct 2017 04:04:16 +0200 Subject: [PATCH] NEW The gantt diagram is now sensitive to hours NEW Add a group task line for tasks on same level on gantt diagram --- htdocs/includes/jsgantt/jsgantt.js | 2 +- htdocs/langs/en_US/projects.lang | 2 + htdocs/projet/activity/perday.php | 4 +- htdocs/projet/activity/perweek.php | 4 +- htdocs/projet/ganttchart.inc.php | 87 +++++++++++++++++++++------ htdocs/projet/ganttview.php | 65 ++++++++++++-------- htdocs/projet/jsgantt_language.js.php | 7 ++- htdocs/theme/eldy/style.css.php | 20 +++++- 8 files changed, 140 insertions(+), 51 deletions(-) diff --git a/htdocs/includes/jsgantt/jsgantt.js b/htdocs/includes/jsgantt/jsgantt.js index 7d73ecfb519..7a26eecb9fc 100644 --- a/htdocs/includes/jsgantt/jsgantt.js +++ b/htdocs/includes/jsgantt/jsgantt.js @@ -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()); } diff --git a/htdocs/langs/en_US/projects.lang b/htdocs/langs/en_US/projects.lang index 1a46cfef5f8..20c528a944d 100644 --- a/htdocs/langs/en_US/projects.lang +++ b/htdocs/langs/en_US/projects.lang @@ -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 diff --git a/htdocs/projet/activity/perday.php b/htdocs/projet/activity/perday.php index 5cea39bc59e..7b49ba28c45 100644 --- a/htdocs/projet/activity/perday.php +++ b/htdocs/projet/activity/perday.php @@ -396,8 +396,8 @@ dol_fiche_end(); print '
'.$nav.'
'; // We move this before the assign to components so, the default submit button is not the assign to. print '
'; -$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 '
'; $formproject->selectTasks($socid?$socid:-1, $taskid, 'taskid', 32, 0, 1, 1); print '
'; diff --git a/htdocs/projet/activity/perweek.php b/htdocs/projet/activity/perweek.php index f44a03b0cd9..421db33a8e7 100644 --- a/htdocs/projet/activity/perweek.php +++ b/htdocs/projet/activity/perweek.php @@ -399,8 +399,8 @@ dol_fiche_end(); print '
'.$nav.'
'; // We move this before the assign to components so, the default submit button is not the assign to. print '
'; -$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 '
'; $formproject->selectTasks($socid?$socid:-1, $taskid, 'taskid', 32, 0, 1, 1); print '
'; diff --git a/htdocs/projet/ganttchart.inc.php b/htdocs/projet/ganttchart.inc.php index a0abaf6bb59..58d212db7bd 100644 --- a/htdocs/projet/ganttchart.inc.php +++ b/htdocs/projet/ganttchart.inc.php @@ -111,11 +111,27 @@ if (g.getDivId() != null) 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=''.$task['task_name'].''; @@ -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); } } } diff --git a/htdocs/projet/ganttview.php b/htdocs/projet/ganttview.php index 499de954e57..d63f2d2bb62 100644 --- a/htdocs/projet/ganttview.php +++ b/htdocs/projet/ganttview.php @@ -195,28 +195,36 @@ if ($id > 0 || ! empty($ref)) * Buttons actions */ -print '
'; - -if ($user->rights->projet->all->creer || $user->rights->projet->creer) +if ($id > 0) { - if ($object->public || $userWrite > 0) - { - print ''.$langs->trans('AddTask').''; - } - else - { - print ''.$langs->trans('AddTask').''; - } + + print '
'; + + if ($user->rights->projet->all->creer || $user->rights->projet->creer) + { + if ($object->public || $userWrite > 0) + { + print ''.$langs->trans('AddTask').''; + } + else + { + print ''.$langs->trans('AddTask').''; + } + } + else + { + print ''.$langs->trans('AddTask').''; + } + + print '
'; + + print '
'; } else { - print ''.$langs->trans('AddTask').''; + print_fiche_titre($langs->trans("GanttView")); } -print '
'; - -print '
'; - // 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 '
'; diff --git a/htdocs/projet/jsgantt_language.js.php b/htdocs/projet/jsgantt_language.js.php index 98a0035ed30..a702432998e 100644 --- a/htdocs/projet/jsgantt_language.js.php +++ b/htdocs/projet/jsgantt_language.js.php @@ -38,16 +38,17 @@ require_once __DIR__.'/../main.inc.php'; top_httphead('text/javascript'); global $langs; +$langs->load("projects"); ?> var vLangs={'getDefaultLang(1);?>': { - 'format':'','hour':'"transnoentities('Hour'); ?>','day':'transnoentities('Day'); ?>', + 'format':'transnoentities('Period');?>','hour':'"transnoentities('Hour'); ?>','day':'transnoentities('Day'); ?>', 'week':'transnoentities('Week'); ?>','month':'transnoentities('Month'); ?>','quarter':'transnoentities('Quadri'); ?>', 'hours':'transnoentities('Hours'); ?>','days':'transnoentities('Days'); ?>','weeks':'transnoentities('Weeks');?>', 'months':'transnoentities('Months'); ?>','quarters':'transnoentities('Quadri'); ?>','hr':'Hr','dy':'transnoentities('Day'); ?>','wk':'transnoentities('Week'); ?>','mth':'transnoentities('Month'); ?>','qtr':'transnoentities('Quadri'); ?>','hrs':'transnoentities('Hours'); ?>', - 'dys':'transnoentities('Days'); ?>','wks':'transnoentities('Weeks'); ?>','mths':'transnoentities('Months'); ?>','qtrs':'transnoentities('Quadri'); ?>','resource':'transnoentities('Resources')); ?>','duration':'transnoentities('Duration')); ?>','comp':'% transnoentities('Total')); ?>', - 'completion':'transnoentities('Total'); ?>','startdate':'transnoentities('DateStart'); ?>','enddate':'transnoentities('DateEnd'); ?>','moreinfo':'transnoentities('MoreInformation')); ?>', + 'dys':'transnoentities('Days'); ?>','wks':'transnoentities('Weeks'); ?>','mths':'transnoentities('Months'); ?>','qtrs':'transnoentities('Quadri'); ?>','resource':'transnoentities('Resource')); ?>','duration':'transnoentities('Duration')); ?>','comp':'%', + 'completion':'transnoentities('Total'); ?>','startdate':'transnoentities('DateStart'); ?>','enddate':'transnoentities('DateEnd'); ?>','moreinfo':'transnoentities('ShowTask')); ?>', 'notes':'transnoentities('NotePublic'); ?>', 'january':'transnoentities('January'); ?>','february':'transnoentities('February'); ?>','march':'transnoentities('March'); ?>','april':'transnoentities('April'); ?>','maylong':'transnoentities('May'); ?>','june':'transnoentities('June'); ?>','july':'transnoentities('July'); ?>', 'august':'transnoentities('August'); ?>','september':'transnoentities('September'); ?>','october':'transnoentities('October'); ?>','november':'transnoentities('November'); ?>','december':'transnoentities('December'); ?>', diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index c6769c7996d..fbdb612e398 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -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; +} /* ============================================================================== */