diff --git a/application/audit.category.class.inc.php b/application/audit.category.class.inc.php
index 06f7df30f..e50c18ac8 100644
--- a/application/audit.category.class.inc.php
+++ b/application/audit.category.class.inc.php
@@ -48,13 +48,38 @@ class AuditCategory extends cmdbAbstractObject
MetaModel::Init_AddAttribute(new AttributeString("description", array("allowed_values"=>null, "sql"=>"description", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeOQL("definition_set", array("allowed_values"=>null, "sql"=>"definition_set", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeLinkedSet("rules_list", array("linked_class"=>"AuditRule", "ext_key_to_me"=>"category_id", "allowed_values"=>null, "count_min"=>0, "count_max"=>0, "depends_on"=>array(), "edit_mode" => LINKSET_EDITMODE_INPLACE, "tracking_level" => LINKSET_TRACKING_ALL)));
+ MetaModel::Init_AddAttribute(new AttributeInteger("ok_error_tolerance", array("allowed_values"=>null, "sql"=>"ok_error_tolerance", "default_value"=>5, "is_null_allowed"=>true, "depends_on"=>array())));
+ MetaModel::Init_AddAttribute(new AttributeInteger("warning_error_tolerance", array("allowed_values"=>null, "sql"=>"warning_error_tolerance", "default_value"=>25, "is_null_allowed"=>true, "depends_on"=>array())));
// Display lists
- MetaModel::Init_SetZListItems('details', array('name', 'description', 'definition_set', 'rules_list')); // Attributes to be displayed for the complete details
+ MetaModel::Init_SetZListItems('details', array('name', 'description', 'definition_set', 'ok_error_tolerance', 'warning_error_tolerance', 'rules_list')); // Attributes to be displayed for the complete details
MetaModel::Init_SetZListItems('list', array('description', )); // Attributes to be displayed for a list
// Search criteria
MetaModel::Init_SetZListItems('standard_search', array('description', 'definition_set')); // Criteria of the std search form
MetaModel::Init_SetZListItems('default_search', array('name', 'description')); // Criteria of the default search form
}
+
+ /**
+ * @param int $iTotal
+ * @param int $iErrors
+ *
+ * @return string A semantic color name (eg. red, green, orange, success, failure, ... {@see css/backoffice/utils/variables/colors/_semantic-palette.scss}) to use for this category depending on its error count and tolerance
+ * @throws \CoreException
+ *
+ * @since 3.1.0
+ */
+ public function GetReportColor($iTotal, $iErrors)
+ {
+ $sResult = 'red';
+ if ( ($iTotal == 0) || ($iErrors / $iTotal) <= ($this->Get('ok_error_tolerance') / 100) )
+ {
+ $sResult = 'green';
+ }
+ else if ( ($iErrors / $iTotal) <= ($this->Get('warning_error_tolerance') / 100) )
+ {
+ $sResult = 'orange';
+ }
+ return $sResult;
+ }
}
?>
diff --git a/dictionaries/de.dictionary.itop.ui.php b/dictionaries/de.dictionary.itop.ui.php
index ff71879d4..757764fe1 100644
--- a/dictionaries/de.dictionary.itop.ui.php
+++ b/dictionaries/de.dictionary.itop.ui.php
@@ -14,6 +14,10 @@ Dict::Add('DE DE', 'German', 'Deutsch', array(
'Class:AuditCategory/Attribute:definition_set+' => 'OQL-Ausdrücke, die den Umfang der zu auditierenden Objekte festlegen',
'Class:AuditCategory/Attribute:rules_list' => 'Audit-Regeln',
'Class:AuditCategory/Attribute:rules_list+' => 'Audit-Regeln für diese Kategorie',
+ 'Class:AuditCategory/Attribute:ok_error_tolerance' => 'Fehlertoleranz (OK)',
+ 'Class:AuditCategory/Attribute:ok_error_tolerance+' => 'Erlaubter prozentualer Anteil ungültiger Objekte, bei dem das Ergebnis noch als in Ordnung (grün) dargestellt wird',
+ 'Class:AuditCategory/Attribute:warning_error_tolerance' => 'Fehlertoleranz (Warnung)',
+ 'Class:AuditCategory/Attribute:warning_error_tolerance+' => 'Erlaubter prozentualer Anteil ungültiger Objekte, bei dem das Ergebnis noch als Warnung (orange) dargestellt wir.',
));
//
diff --git a/dictionaries/en.dictionary.itop.ui.php b/dictionaries/en.dictionary.itop.ui.php
index f40a2b438..6483e190c 100644
--- a/dictionaries/en.dictionary.itop.ui.php
+++ b/dictionaries/en.dictionary.itop.ui.php
@@ -30,6 +30,10 @@ Dict::Add('EN US', 'English', 'English', array(
'Class:AuditCategory/Attribute:definition_set+' => 'OQL expression defining the set of objects to audit',
'Class:AuditCategory/Attribute:rules_list' => 'Audit Rules',
'Class:AuditCategory/Attribute:rules_list+' => 'Audit rules for this category',
+ 'Class:AuditCategory/Attribute:ok_error_tolerance' => 'Error tolerance (OK)',
+ 'Class:AuditCategory/Attribute:ok_error_tolerance+' => 'Allowed percentage of invalid objects at which the result is still displayed as OK (green)',
+ 'Class:AuditCategory/Attribute:warning_error_tolerance' => 'Error tolerance (warning)',
+ 'Class:AuditCategory/Attribute:warning_error_tolerance+' => 'Allowed percentage of invalid objects at which the result is still displayed as a warning (orange)',
));
//
diff --git a/pages/audit.php b/pages/audit.php
index b75bfc2c9..e465b486a 100644
--- a/pages/audit.php
+++ b/pages/audit.php
@@ -139,20 +139,6 @@ function GetRuleResultFilter($iRuleId, $oDefinitionFilter, $oAppContext)
return $oFilter;
}
-function GetReportColor($iTotal, $iErrors)
-{
- $sResult = 'red';
- if ( ($iTotal == 0) || ($iErrors / $iTotal) <= 0.05 )
- {
- $sResult = 'green';
- }
- else if ( ($iErrors / $iTotal) <= 0.25 )
- {
- $sResult = 'orange';
- }
- return $sResult;
-}
-
try
{
require_once('../approot.inc.php');
@@ -306,6 +292,7 @@ try
$oCategoriesSet = new DBObjectSet($oAuditFilter);
$aAuditCategoryPanels = [];
+ /** @var AuditCategory $oAuditCategory */
while($oAuditCategory = $oCategoriesSet->fetch())
{
$oAuditCategoryPanelBlock = new Panel($oAuditCategory->GetName());
@@ -340,7 +327,7 @@ try
// nothing to check, really !
$aRow['nb_errors'] = "GetKey()."&rule=".$oAuditRule->GetKey()."\">0";
$aRow['percent_ok'] = '100.00';
- $aRow['class'] = GetReportColor($iCount, 0);
+ $aRow['class'] = $oAuditCategory->GetReportColor($iCount, 0);
}
else
{
@@ -355,7 +342,7 @@ try
}
$aRow['nb_errors'] = ($iErrorsCount == 0) ? '0' : "GetKey()."&rule=".$oAuditRule->GetKey()."&".$oAppContext->GetForLink()."\">$iErrorsCount GetKey()."&rule=".$oAuditRule->GetKey()."&".$oAppContext->GetForLink()."\">
";
$aRow['percent_ok'] = sprintf('%.2f', 100.0 * (($iCount - $iErrorsCount) / $iCount));
- $aRow['class'] = GetReportColor($iCount, $iErrorsCount);
+ $aRow['class'] = $oAuditCategory->GetReportColor($iCount, $iErrorsCount);
}
catch(Exception $e)
{
@@ -373,7 +360,7 @@ try
}
$iTotalErrors = count($aObjectsWithErrors);
$sOverallPercentOk = ($iCount == 0) ? '100.00' : sprintf('%.2f', 100.0 * (($iCount - $iTotalErrors) / $iCount));
- $sClass = GetReportColor($iCount, $iTotalErrors);
+ $sClass = $oAuditCategory->GetReportColor($iCount, $iTotalErrors);
$oTotalBlock->SetCount((int)$oTotalBlock->GetCount() + ($iCount));
$oErrorBlock->SetCount((int)$oErrorBlock->GetCount() + $iTotalErrors);