2
0
forked from Wavyzz/dolibarr

Look and feel v11

Enhance the progress bar of tasks
This commit is contained in:
Laurent Destailleur
2019-11-01 15:53:57 +01:00
parent e3b5be7475
commit 135e65c4aa
14 changed files with 223 additions and 239 deletions

View File

@@ -8093,19 +8093,18 @@ function roundUpToNextMultiple($n, $x = 5)
function dolGetBadge($label, $html = '', $type = 'primary', $mode = '', $url = '', $params = array())
{
$attr=array(
'class'=>'badge badge-status'.(!empty($mode)?' badge-'.$mode:'').(!empty($type)?' badge-'.$type:'')
'class'=>'badge badge-status'.(!empty($mode)?' badge-'.$mode:'').(!empty($type)?' badge-'.$type:'').(empty($params['css'])?'':' '.$params['css'])
);
if(empty($html)){
if (empty($html)) {
$html = $label;
}
if(!empty($url)){
if (!empty($url)) {
$attr['href'] = $url;
}
if($mode==='dot')
{
if ($mode==='dot') {
$attr['class'].= ' classfortooltip';
$attr['title'] = $html;
$attr['aria-label'] = $label;
@@ -8113,8 +8112,8 @@ function dolGetBadge($label, $html = '', $type = 'primary', $mode = '', $url = '
}
// Override attr
if(!empty($params['attr']) && is_array($params['attr'])){
foreach($params['attr']as $key => $value){
if (!empty($params['attr']) && is_array($params['attr'])) {
foreach($params['attr']as $key => $value) {
$attr[$key] = $value;
}
}
@@ -8125,7 +8124,7 @@ function dolGetBadge($label, $html = '', $type = 'primary', $mode = '', $url = '
$attr = array_map('dol_escape_htmltag', $attr);
$TCompiledAttr = array();
foreach($attr as $key => $value){
foreach($attr as $key => $value) {
$TCompiledAttr[] = $key.'="'.$value.'"';
}
@@ -8168,13 +8167,13 @@ function dolGetStatus($statusLabel = '', $statusLabelShort = '', $html = '', $st
elseif ($displayMode == 1) {
$return = !empty($html)?$html:(!empty($statusLabelShort)?$statusLabelShort:$statusLabel);
}
// use status with images
elseif (empty($conf->global->MAIN_STATUS_USES_CSS)) {
// Use status with images (for backward compatibility)
elseif (! empty($conf->global->MAIN_STATUS_USES_IMAGES)) {
$return = '';
$htmlLabel = (in_array($displayMode, array(1,2,5))?'<span class="hideonsmartphone">':'').(!empty($html)?$html:$statusLabel).(in_array($displayMode, array(1,2,5))?'</span>':'');
$htmlLabelShort = (in_array($displayMode, array(1,2,5))?'<span class="hideonsmartphone">':'').(!empty($html)?$html:(!empty($statusLabelShort)?$statusLabelShort:$statusLabel)).(in_array($displayMode, array(1,2,5))?'</span>':'');
// For small screen, we use the short label instead of long label.
// For small screen, we always use the short label instead of long label.
if (! empty($conf->dol_optimize_smallscreen))
{
if ($displayMode == 0) $displayMode = 1;
@@ -8212,7 +8211,6 @@ function dolGetStatus($statusLabel = '', $statusLabelShort = '', $html = '', $st
$return = $htmlImg .' '. $htmlLabel;
}
elseif ($displayMode === 5) {
// Add here a span class="hideonsmartphone ?
$return = $htmlLabelShort .' '. $htmlImg;
}
else { // $displayMode >= 6
@@ -8220,7 +8218,7 @@ function dolGetStatus($statusLabel = '', $statusLabelShort = '', $html = '', $st
}
}
// Use new badge
elseif (!empty($conf->global->MAIN_STATUS_USES_CSS) && !empty($displayMode)) {
elseif (empty($conf->global->MAIN_STATUS_USES_IMAGES) && !empty($displayMode)) {
$statusLabelShort = !empty($statusLabelShort)?$statusLabelShort:$statusLabel;
if ($displayMode == 3) {

View File

@@ -2023,23 +2023,23 @@ function getTaskProgressView($task, $label = true, $progressNumber = true, $hide
// 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;
$diffTitle = '<br/>'.$langs->trans('ProgressDeclared').' : '.$task->progress.'%';
$diffTitle.= '<br/>'.$langs->trans('ProgressCalculated').' : '.$progressCalculated.'%';
$diffTitle = '<br/>'.$langs->trans('ProgressDeclared').' : '.$task->progress.($task->progress ? '%' : '');
$diffTitle.= '<br/>'.$langs->trans('ProgressCalculated').' : '.$progressCalculated.($progressCalculated ? '%' : '');
if($progressCalculated > doubleval($task->progress)){
if($progressCalculated > doubleval($task->progress)) {
$progressBarClass = 'progress-bar-danger';
$title = $langs->trans('TheReportedProgressIsLessThanTheCalculatedProgressionByX', abs($task->progress-$progressCalculated).'%');
$diff = '<span class="text-danger classfortooltip"" title="'.dol_htmlentities($title.$diffTitle).'" ><i class="fa fa-caret-down"></i> '.($task->progress-$progressCalculated).'%</span>';
$title = $langs->trans('TheReportedProgressIsLessThanTheCalculatedProgressionByX', abs($task->progress-$progressCalculated).' '.$langs->trans("point"));
$diff = '<span class="text-danger classfortooltip paddingrightonly" title="'.dol_htmlentities($title.$diffTitle).'" ><i class="fa fa-caret-down"></i> '.($task->progress-$progressCalculated).'%</span>';
}
elseif($progressCalculated * $warningRatio >= doubleval($task->progress)){ // warning if close at 1%
elseif($progressCalculated * $warningRatio >= doubleval($task->progress)) { // warning if close at 1%
$progressBarClass = 'progress-bar-warning';
$title = $langs->trans('TheReportedProgressIsLessThanTheCalculatedProgressionByX', abs($task->progress-$progressCalculated).'%');
$diff = '<span class="text-warning classfortooltip" title="'.dol_htmlentities($title.$diffTitle).'" ><i class="fa fa-caret-left"></i> '.($task->progress-$progressCalculated).'%</span>';
$title = $langs->trans('TheReportedProgressIsLessThanTheCalculatedProgressionByX', abs($task->progress-$progressCalculated).' '.$langs->trans("point"));
$diff = '<span class="text-warning classfortooltip paddingrightonly" title="'.dol_htmlentities($title.$diffTitle).'" ><i class="fa fa-caret-left"></i> '.($task->progress-$progressCalculated).'%</span>';
}
else{
$progressBarClass = 'progress-bar-success';
$title = $langs->trans('TheReportedProgressIsMoreThanTheCalculatedProgressionByX', ($task->progress-$progressCalculated).'%');
$diff = '<span class="text-success classfortooltip" title="'.dol_htmlentities($title.$diffTitle).'" ><i class="fa fa-caret-up"></i> '.($task->progress-$progressCalculated).'%</span>';
$title = $langs->trans('TheReportedProgressIsMoreThanTheCalculatedProgressionByX', ($task->progress-$progressCalculated).' '.$langs->trans("point"));
$diff = '<span class="text-success classfortooltip paddingrightonly" title="'.dol_htmlentities($title.$diffTitle).'" ><i class="fa fa-caret-up"></i> '.($task->progress-$progressCalculated).'%</span>';
}
}
@@ -2062,7 +2062,7 @@ function getTaskProgressView($task, $label = true, $progressNumber = true, $hide
if($progressNumber !== false)
{
$out.= ' <span class="progress-number">';
if($progressNumber!==true){
if ($progressNumber!==true) {
$out.= $progressNumber; // replace label by param
}
else{
@@ -2087,8 +2087,21 @@ function getTaskProgressView($task, $label = true, $progressNumber = true, $hide
$out.= '</span>';
$out.= ' <div class="progress sm '.$spaced.'" title="'.doubleval($task->progress).'%" >';
$out.= ' <div class="progress-bar '.$progressBarClass.'" style="width: '.doubleval($task->progress).'%"></div>';
$out.= ' <div class="progress sm '.$spaced.'">';
$diffval = doubleval($task->progress) - doubleval($progressCalculated);
if ($diffval >= 0) {
// good
$out.= ' <div class="progress-bar '.$progressBarClass.'" style="width: '.doubleval($task->progress).'%" title="'.doubleval($task->progress).'%">';
$out.= ' <div class="progress-bar progress-bar-consumed" style="width: '.doubleval($progressCalculated / $task->progress * 100).'%" title="'.doubleval($progressCalculated).'%"></div>';
$out.= ' </div>';
}
else
{
// bad
$out.= ' <div class="progress-bar progress-bar-consumed" style="width: '.doubleval($progressCalculated).'%" title="'.doubleval($progressCalculated).'%">';
$out.= ' <div class="progress-bar '.$progressBarClass.'" style="width: '.($task->progress ? doubleval($task->progress / $progressCalculated * 100).'%' : '1px').'" title="'.doubleval($task->progress).'%"></div>';
$out.= ' </div>';
}
$out.= ' </div>';
$out.= '</div>';