From a1b2130247cef3920d3195235c6fb9ee950eb5a5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 1 Nov 2019 16:09:31 +0100 Subject: [PATCH] Enhance the progress bar of tasks --- htdocs/core/lib/project.lib.php | 18 ++++++++++-------- htdocs/theme/eldy/progress.inc.php | 2 +- htdocs/theme/eldy/theme_vars.inc.php | 2 +- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index ecadec1b5a8..06cd96ab995 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -670,8 +670,9 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t 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; + + // this conf is actually hidden, by default we use 10% for "be carefull or warning" + $warningRatio = !empty($conf->global->PROJECT_TIME_SPEND_WARNING_PERCENT) ? (1 + $conf->global->PROJECT_TIME_SPEND_WARNING_PERCENT / 100) : 1.10; // define progress color according to time spend vs workload $progressBarClass = 'progress-bar-info'; @@ -2020,18 +2021,19 @@ function getTaskProgressView($task, $label = true, $progressNumber = true, $hide if ($task->planned_workload){ $progressCalculated = round(100 * doubleval($task->duration_effective) / doubleval($task->planned_workload), 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; + // this conf is actually hidden, by default we use 10% for "be carefull or warning" + $warningRatio = !empty($conf->global->PROJECT_TIME_SPEND_WARNING_PERCENT) ? (1 + $conf->global->PROJECT_TIME_SPEND_WARNING_PERCENT / 100) : 1.10; $diffTitle = '
'.$langs->trans('ProgressDeclared').' : '.$task->progress.($task->progress ? '%' : ''); $diffTitle.= '
'.$langs->trans('ProgressCalculated').' : '.$progressCalculated.($progressCalculated ? '%' : ''); - if($progressCalculated > doubleval($task->progress)) { + //var_dump($progressCalculated.' '.$warningRatio.' '.$task->progress.' '.doubleval($task->progress * $warningRatio)); + if (doubleval($progressCalculated) > doubleval($task->progress * $warningRatio)) { $progressBarClass = 'progress-bar-danger'; $title = $langs->trans('TheReportedProgressIsLessThanTheCalculatedProgressionByX', abs($task->progress-$progressCalculated).' '.$langs->trans("point")); $diff = ' '.($task->progress-$progressCalculated).'%'; } - elseif($progressCalculated * $warningRatio >= doubleval($task->progress)) { // warning if close at 1% + elseif (doubleval($progressCalculated) > doubleval($task->progress)) { // warning if close at 1% $progressBarClass = 'progress-bar-warning'; $title = $langs->trans('TheReportedProgressIsLessThanTheCalculatedProgressionByX', abs($task->progress-$progressCalculated).' '.$langs->trans("point")); $diff = ' '.($task->progress-$progressCalculated).'%'; @@ -2130,8 +2132,8 @@ function getTaskProgressBadge($task, $label = '', $tooltip = '') if ($task->planned_workload){ $progressCalculated = round(100 * doubleval($task->duration_effective) / doubleval($task->planned_workload), 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; + // this conf is actually hidden, by default we use 10% for "be carefull or warning" + $warningRatio = !empty($conf->global->PROJECT_TIME_SPEND_WARNING_PERCENT) ? (1 + $conf->global->PROJECT_TIME_SPEND_WARNING_PERCENT / 100) : 1.10; if($progressCalculated > doubleval($task->progress)){ $badgeClass.= 'badge-danger'; diff --git a/htdocs/theme/eldy/progress.inc.php b/htdocs/theme/eldy/progress.inc.php index c6b48205360..a211c40efb4 100644 --- a/htdocs/theme/eldy/progress.inc.php +++ b/htdocs/theme/eldy/progress.inc.php @@ -167,7 +167,7 @@ if (! defined('ISLOADEDBYSTEELSHEET')) die('Must be call by steelsheet'); ?> } .progress-bar-yellow, .progress-bar-warning { - background-color: #f39c12; + background-color: #bc9526; } .progress-striped .progress-bar-yellow, .progress-striped .progress-bar-warning { diff --git a/htdocs/theme/eldy/theme_vars.inc.php b/htdocs/theme/eldy/theme_vars.inc.php index 386a81f0afd..24e7e6f7d41 100644 --- a/htdocs/theme/eldy/theme_vars.inc.php +++ b/htdocs/theme/eldy/theme_vars.inc.php @@ -81,7 +81,7 @@ $toolTipFontColor='#333'; $textSuccess ='#28a745'; $colorblind_deuteranopes_textSuccess ='#37de5d'; $textDanger ='#dc3545'; -$textWarning ='#f39c12'; +$textWarning ='#bc9526'; $colorblind_deuteranopes_textWarning = $textWarning; // currently not tested with a color blind people so use default color