mirror of
https://github.com/Combodo/iTop.git
synced 2026-05-18 23:08:46 +02:00
N°3823 - Error on "Header with statistics dashlet" with autorefresh and filter on organization
This commit is contained in:
@@ -608,18 +608,17 @@ HTML;
|
||||
foreach($aTemp as $sTemp)
|
||||
{
|
||||
$aMatches = array();
|
||||
if (preg_match('/^([+-])?(.+)$/', $sTemp, $aMatches))
|
||||
{
|
||||
if (preg_match('/^([+-])?(.+)$/', $sTemp, $aMatches)) {
|
||||
$bAscending = true;
|
||||
if ($aMatches[1] == '-')
|
||||
{
|
||||
$bAscending = false;
|
||||
if ($aMatches[1] == '-') {
|
||||
$bAscending = false;
|
||||
}
|
||||
$aOrderBy[$aMatches[2]] = $bAscending;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$aExtraParams['query_params'] = $this->m_oFilter->GetInternalParams();
|
||||
$this->m_oSet = new CMDBObjectSet($this->m_oFilter, $aOrderBy, $aQueryParams);
|
||||
}
|
||||
$this->m_oSet->SetShowObsoleteData($this->m_bShowObsoleteData);
|
||||
@@ -1167,8 +1166,9 @@ JS
|
||||
);
|
||||
$sFormat = isset($aExtraParams['format']) ? $aExtraParams['format'] : 'UI:Pagination:HeaderNoSelection';
|
||||
$sTitle = Dict::Format($sFormat, $iTotalCount);
|
||||
$oBlock = DataTableUIBlockFactory::MakeForStaticData($sTitle, $aAttribs, $aData, null, $aExtraParams,
|
||||
$this->m_oFilter->ToOQL());
|
||||
|
||||
$aExtraParams['query_params'] = $this->m_oFilter->GetInternalParams();
|
||||
$oBlock = DataTableUIBlockFactory::MakeForStaticData($sTitle, $aAttribs, $aData, null, $aExtraParams, $this->m_oFilter->ToOQL());
|
||||
|
||||
} else {
|
||||
// Simply count the number of elements in the set
|
||||
|
||||
@@ -102,7 +102,11 @@ try
|
||||
$oPage->SetContentType('text/html');
|
||||
$sExtraParams = utils::ReadParam('extra_params', '', false, 'raw_data');
|
||||
$aExtraParams = json_decode($sExtraParams, true);
|
||||
$oFilter = DBObjectSearch::FromOQL($sFilter);
|
||||
$aQueryParams = [];
|
||||
if (isset($aExtraParams['query_params'])) {
|
||||
$aQueryParams = $aExtraParams['query_params'];
|
||||
}
|
||||
$oFilter = DBObjectSearch::FromOQL($sFilter, $aQueryParams);
|
||||
$oFilter->SetShowObsoleteData(utils::ShowObsoleteData());
|
||||
$oSet = new CMDBObjectSet($oFilter, [], $aExtraParams);
|
||||
$oBlock = new displayblock($oFilter, 'summary', false, [], $oSet);
|
||||
|
||||
@@ -428,28 +428,25 @@ class AjaxRenderController
|
||||
}
|
||||
}
|
||||
|
||||
$aGroupBy = array();
|
||||
$aGroupBy = [];
|
||||
$aGroupBy['grouped_by_1'] = $oGroupByExp;
|
||||
$aQueryParams = array();
|
||||
if (isset($aExtraParams['query_params'])) {
|
||||
$aQueryParams = $aExtraParams['query_params'];
|
||||
}
|
||||
$aFunctions = array();
|
||||
|
||||
$aFunctions = [];
|
||||
$sFctVar = '_itop_count_';
|
||||
if (isset($aExtraParams['aggregation_function']) && !empty($aExtraParams['aggregation_attribute'])) {
|
||||
$sAggregationFunction = $aExtraParams['aggregation_function'];
|
||||
$sAggregationAttr = $aExtraParams['aggregation_attribute'];
|
||||
$oAttrExpr = Expression::FromOQL('`'.$sAlias.'`.`'.$sAggregationAttr.'`');
|
||||
$oFctExpr = new FunctionExpression(strtoupper($sAggregationFunction), array($oAttrExpr));
|
||||
$oFctExpr = new FunctionExpression(strtoupper($sAggregationFunction), [$oAttrExpr]);
|
||||
$sFctVar = '_itop_'.$sAggregationFunction.'_';
|
||||
$aFunctions = array($sFctVar => $oFctExpr);
|
||||
$aFunctions = [$sFctVar => $oFctExpr];
|
||||
}
|
||||
|
||||
$iLimit = 0;
|
||||
if (isset($aExtraParams['limit'])) {
|
||||
$iLimit = intval($aExtraParams['limit']);
|
||||
}
|
||||
$aOrderBy = array();
|
||||
$aOrderBy = [];
|
||||
if (isset($aExtraParams['order_direction']) && isset($aExtraParams['order_by'])) {
|
||||
switch ($aExtraParams['order_by']) {
|
||||
case 'attribute':
|
||||
@@ -460,7 +457,10 @@ class AjaxRenderController
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$aQueryParams = [];
|
||||
if (isset($aExtraParams['query_params'])) {
|
||||
$aQueryParams = $aExtraParams['query_params'];
|
||||
}
|
||||
$sSql = $oFilter->MakeGroupByQuery($aQueryParams, $aGroupBy, true, $aFunctions, $aOrderBy, $iLimit);
|
||||
|
||||
$aRes = CMDBSource::QueryToArray($sSql);
|
||||
@@ -505,8 +505,11 @@ class AjaxRenderController
|
||||
if (isset($aExtraParams['order_direction']) && isset($aExtraParams['order_by'])) {
|
||||
$aOrderBy = ['order_by' => $aExtraParams['order_by'], 'order_direction' => $aExtraParams['order_direction']];
|
||||
}
|
||||
|
||||
$oSet = new CMDBObjectSet($oFilter, $aOrderBy, $aExtraParams);
|
||||
$aQueryParams = [];
|
||||
if (isset($aExtraParams['query_params'])) {
|
||||
$aQueryParams = $aExtraParams['query_params'];
|
||||
}
|
||||
$oSet = new CMDBObjectSet($oFilter, $aOrderBy, $aQueryParams);
|
||||
$iCount = $oSet->Count();
|
||||
$sFormat = 'UI:CountOfObjects';
|
||||
if (isset($aExtraParams['format'])) {
|
||||
@@ -533,8 +536,11 @@ class AjaxRenderController
|
||||
$aExtraParams = utils::ReadParam('extra_params', '', false, 'raw_data');
|
||||
$oFilter = DBObjectSearch::FromOQL($sFilter);
|
||||
$oFilter->SetShowObsoleteData(utils::ShowObsoleteData());
|
||||
|
||||
$oSet = new CMDBObjectSet($oFilter, [], $aExtraParams);
|
||||
$aQueryParams = array();
|
||||
if (isset($aExtraParams['query_params'])) {
|
||||
$aQueryParams = $aExtraParams['query_params'];
|
||||
}
|
||||
$oSet = new CMDBObjectSet($oFilter, [], $aQueryParams);
|
||||
$iCount = $oSet->Count();
|
||||
$aResult = ['count' => $iCount];
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
/**
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2021 Combodo SARL
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
*/
|
||||
@@ -50,8 +50,8 @@ class BlockList extends UIContentBlock
|
||||
public function GetJSRefresh(): string
|
||||
{
|
||||
return '$("#'.$this->sId.'").block();
|
||||
$.post("ajax.render.php?style=list",
|
||||
{ operation: "refreshDashletList", filter: "'.$this->sFilter.'", extra_params: '.json_encode($this->aExtraParams).' },
|
||||
$.post("ajax.render.php?operation=refreshDashletList",
|
||||
{ style: "list", filter: "'.$this->sFilter.'", extra_params: '.json_encode($this->aExtraParams).' },
|
||||
function(data){
|
||||
$("#'.$this->sId.'")
|
||||
.empty()
|
||||
|
||||
Reference in New Issue
Block a user