diff --git a/htdocs/core/boxes/box_task.php b/htdocs/core/boxes/box_task.php index 3a0b2c67af9..cf1d5241753 100644 --- a/htdocs/core/boxes/box_task.php +++ b/htdocs/core/boxes/box_task.php @@ -156,6 +156,8 @@ class box_task extends ModeleBoxes $sql.= " pt.entity = ".$conf->entity; $sql.= " AND p.fk_statut = ".Project::STATUS_VALIDATED; $sql.= " AND (pt.progress < 100 OR pt.progress IS NULL ) "; // 100% is done and not displayed + $sql.= " AND p.usage_task = 1 "; + $sql.= " ORDER BY pt.datee ASC, pt.dateo ASC"; $sql.= $db->plimit($max, 0); diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index 19d89c6799b..d37c7d5f960 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -565,7 +565,9 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t // resume print ''; - print getTaskProgressView($taskstatic, false, false); + if ($lines[$i]->progress != '' && $lines[$i]->duration) { + print getTaskProgressView($taskstatic, false, false); + } print ''; if ($showbilltime) @@ -664,12 +666,48 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t print convertSecondToTime($total_projectlinesa_spent, 'allhourmin'); if ($projectidfortotallink > 0) print ''; print ''; + + if ($total_projectlinesa_planned) { + $totalAverageDeclaredProgress = round(100 * $total_projectlinesa_declared_if_planned / $total_projectlinesa_planned, 2); + $totalCalculatedProgress = round(100 * $total_projectlinesa_spent / $total_projectlinesa_planned, 2); + // this conf is actually hidden, by default we use 1% for "be carefull or warning" + $warningRatio = !empty($conf->global->PROJECT_TIME_SPEND_WARNING_PERCENT) ? (1 + $conf->global->PROJECT_TIME_SPEND_WARNING_PERCENT / 100) : 1.01; + + // define progress color according to time spend vs workload + $progressBarClass = 'progress-bar-info'; + $badgeClass = 'badge '; + + if ($totalCalculatedProgress > $totalAverageDeclaredProgress) { + $progressBarClass = 'progress-bar-danger'; + $badgeClass.= 'badge-danger'; + } elseif ($totalCalculatedProgress * $warningRatio >= $totalAverageDeclaredProgress) { // warning if close at 1% + $progressBarClass = 'progress-bar-warning'; + $badgeClass.= 'badge-warning'; + } else { + $progressBarClass = 'progress-bar-success'; + $badgeClass.= 'badge-success'; + } + } + print ''; - if ($total_projectlinesa_planned) print round(100 * $total_projectlinesa_spent / $total_projectlinesa_planned, 2).' %'; + if ($total_projectlinesa_planned) print $totalCalculatedProgress.' %'; print ''; print ''; - if ($total_projectlinesa_planned) print round(100 * $total_projectlinesa_declared_if_planned / $total_projectlinesa_planned, 2).' %'; + if ($total_projectlinesa_planned) print ''.$totalAverageDeclaredProgress.' %'; print ''; + + + // resume + print ''; + if ($total_projectlinesa_planned){ + print ''; + print '
'; + print '
'; + print '
'; + print ''; + } + print ''; + if ($showbilltime) { print ''; diff --git a/htdocs/projet/tasks/list.php b/htdocs/projet/tasks/list.php index 7b74e3a743a..ebe506c15d6 100644 --- a/htdocs/projet/tasks/list.php +++ b/htdocs/projet/tasks/list.php @@ -121,6 +121,7 @@ $arrayfields=array( 't.duration_effective'=>array('label'=>$langs->trans("TimeSpent"), 'checked'=>1, 'position'=>103), 't.progress_calculated'=>array('label'=>$langs->trans("ProgressCalculated"), 'checked'=>1, 'position'=>104), 't.progress'=>array('label'=>$langs->trans("ProgressDeclared"), 'checked'=>1, 'position'=>105), + 't.progress_summary'=>array('label'=>$langs->trans("TaskProgressSummary"), 'checked'=>1, 'position'=>106), 't.tobill'=>array('label'=>$langs->trans("TimeToBill"), 'checked'=>0, 'position'=>110), 't.billed'=>array('label'=>$langs->trans("TimeBilled"), 'checked'=>0, 'position'=>111), 't.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500), @@ -570,6 +571,7 @@ if (! empty($arrayfields['t.planned_workload']['checked'])) print ''; if (! empty($arrayfields['t.progress_calculated']['checked'])) print ''; if (! empty($arrayfields['t.progress']['checked'])) print ''; +if (! empty($arrayfields['t.progress_summary']['checked'])) print ''; if (! empty($arrayfields['t.tobill']['checked'])) print ''; if (! empty($arrayfields['t.billed']['checked'])) print ''; // Extra fields @@ -610,6 +612,7 @@ if (! empty($arrayfields['t.planned_workload']['checked'])) print_liste_ if (! empty($arrayfields['t.duration_effective']['checked'])) print_liste_field_titre($arrayfields['t.duration_effective']['label'], $_SERVER["PHP_SELF"], "t.duration_effective", "", $param, '', $sortfield, $sortorder, 'center '); if (! empty($arrayfields['t.progress_calculated']['checked'])) print_liste_field_titre($arrayfields['t.progress_calculated']['label'], $_SERVER["PHP_SELF"], "", "", $param, '', '', '', 'center '); if (! empty($arrayfields['t.progress']['checked'])) print_liste_field_titre($arrayfields['t.progress']['label'], $_SERVER["PHP_SELF"], "t.progress", "", $param, '', $sortfield, $sortorder, 'center '); +if (! empty($arrayfields['t.progress_summary']['checked'])) print_liste_field_titre($arrayfields['t.progress_summary']['label'], $_SERVER["PHP_SELF"], "t.progress", "", $param, '', $sortfield, $sortorder, 'center '); if (! empty($arrayfields['t.tobill']['checked'])) print_liste_field_titre($arrayfields['t.tobill']['label'], $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'center '); if (! empty($arrayfields['t.billed']['checked'])) print_liste_field_titre($arrayfields['t.billed']['label'], $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'center '); // Extra fields @@ -642,6 +645,9 @@ while ($i < min($num, $limit)) $object->progress = $obj->progress; $object->datee = $db->jdate($obj->date_end); // deprecated $object->date_end = $db->jdate($obj->date_end); + $object->planned_workload= $obj->planned_workload; + $object->duration_effective= $obj->duration_effective; + $projectstatic->id = $obj->projectid; $projectstatic->ref = $obj->projectref; @@ -784,12 +790,23 @@ while ($i < min($num, $limit)) print ''; if ($obj->progress != '') { - print $obj->progress.' %'; + print getTaskProgressBadge($object); } print ''; if (! $i) $totalarray['nbfield']++; if (! $i) $totalarray['totalprogress_declaredfield']=$totalarray['nbfield']; $totalarray['totaldurationdeclared'] += $obj->planned_workload * $obj->progress / 100; + } + // Progress summary + if (! empty($arrayfields['t.progress_summary']['checked'])) + { + print ''; + if($obj->progress != '' && $obj->duration_effective){ + print getTaskProgressView($object, false, false); + } + print ''; + if (! $i) $totalarray['nbfield']++; + if (! $i) $totalarray['totalprogress_summary']=$totalarray['nbfield']; } // Time not billed if (! empty($arrayfields['t.tobill']['checked'])) @@ -891,7 +908,7 @@ if (isset($totalarray['totaldurationeffectivefield']) || isset($totalarray['tota elseif ($totalarray['totalprogress_declaredfield'] == $i) print ''.($totalarray['totalplannedworkload'] > 0 ? round(100 * $totalarray['totaldurationdeclared'] / $totalarray['totalplannedworkload'], 2).' %' : '').''; elseif ($totalarray['totaltobillfield'] == $i) print ''.convertSecondToTime($totalarray['totaltobill'], $plannedworkloadoutputformat).''; elseif ($totalarray['totalbilledfield'] == $i) print ''.convertSecondToTime($totalarray['totalbilled'], $plannedworkloadoutputformat).''; - else print ''; + else print ''; } print ''; }