mirror of
https://github.com/Combodo/iTop.git
synced 2026-05-20 15:52:24 +02:00
N°1588 - Count on Managed Brick sometimes wrong
This commit is contained in:
@@ -35,6 +35,7 @@ use Combodo\iTop\Portal\Helper\ApplicationHelper;
|
||||
use DBObject;
|
||||
use DBObjectSet;
|
||||
use DBSearch;
|
||||
use DBUnionSearch;
|
||||
use Dict;
|
||||
use Exception;
|
||||
use FieldExpression;
|
||||
@@ -343,11 +344,13 @@ class ManageBrickController extends BrickController
|
||||
// Otherwise we create the tabs from the SQL expressions
|
||||
else
|
||||
{
|
||||
$aConditionQueryGrouping = array();
|
||||
foreach ($aGroupingTabs['groups'] as $aGroup)
|
||||
{
|
||||
$oConditionQuery = $oQuery->Intersect(DBSearch::FromOQL($aGroup['condition']));
|
||||
$oDBSearch = DBSearch::FromOQL($aGroup['condition']);
|
||||
$oConditionQuery = $oQuery->Intersect($oDBSearch);
|
||||
// - Restricting query to scope
|
||||
|
||||
array_push($aConditionQueryGrouping,$oDBSearch);
|
||||
$bHasScope = $oScopeValidator->AddScopeToQuery($oConditionQuery, $oConditionQuery->GetClass());
|
||||
if ($bHasScope)
|
||||
{
|
||||
@@ -368,7 +371,26 @@ class ManageBrickController extends BrickController
|
||||
'condition' => $oConditionQuery,
|
||||
'count' => $iGroupCount,
|
||||
);
|
||||
$iCount += $iGroupCount;
|
||||
}
|
||||
try
|
||||
{
|
||||
$oConditionQuery = $oQuery->Intersect(new DBUnionSearch($aConditionQueryGrouping));
|
||||
$bHasScope = $oScopeValidator->AddScopeToQuery($oConditionQuery, $oConditionQuery->GetClass());
|
||||
if ($bHasScope)
|
||||
{
|
||||
// - Building ObjectSet
|
||||
$oConditionSet = new DBObjectSet($oConditionQuery);
|
||||
$iCount = $oConditionSet->Count();
|
||||
}
|
||||
else
|
||||
{
|
||||
$oConditionSet = null;
|
||||
$iCount = 0;
|
||||
}
|
||||
}
|
||||
catch (Exception $e){
|
||||
$oConditionSet = null;
|
||||
$iCount = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{# itop-portal-base/portal/templates/bricks/manage/layout.html.twig #}
|
||||
{% extends 'itop-portal-base/portal/templates/bricks/layout.html.twig' %}
|
||||
|
||||
{% block pMainHeaderTitle %}{{ oBrick.GetTitle()|dict_s }} ({{ iCount }}) {% endblock %}
|
||||
{% block pMainHeaderTitle %}{{ oBrick.GetTitle()|dict_s }} {% if iCount >= 0 %} ({{ iCount }}){% endif %} {% endblock %}
|
||||
|
||||
{% block pMainHeaderActions %}
|
||||
{% if oBrick.GetAvailablesDisplayModes|length > 1 %}
|
||||
|
||||
Reference in New Issue
Block a user