diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php index ca958dd4a3..381ec23d9c 100644 --- a/pandora_console/include/functions.php +++ b/pandora_console/include/functions.php @@ -6217,3 +6217,31 @@ function notify_reporting_console_node() return $return; } + + +/** + * Auxiliar Ordenation function + * + * @param string $sort Direction of sort. + * @param string $sortField Field for perform the sorting. + * + * @return mixed + */ +function arrayOutputSorting($sort, $sortField) +{ + return function ($a, $b) use ($sort, $sortField) { + if ($sort === 'up') { + if (is_string($a[$sortField]) === true) { + return strcasecmp($a[$sortField], $b[$sortField]); + } else { + return ($a[$sortField] - $b[$sortField]); + } + } else { + if (is_string($a[$sortField]) === true) { + return strcasecmp($b[$sortField], $a[$sortField]); + } else { + return ($a[$sortField] + $b[$sortField]); + } + } + }; +} diff --git a/pandora_console/operation/agentes/status_monitor.php b/pandora_console/operation/agentes/status_monitor.php index 7f78680d9a..320282e403 100644 --- a/pandora_console/operation/agentes/status_monitor.php +++ b/pandora_console/operation/agentes/status_monitor.php @@ -899,6 +899,7 @@ $order = null; switch ($sortField) { case 'agent_alias': + $fieldForSorting = 'agent_alias'; switch ($sort) { case 'up': $selectAgentNameUp = $selected; @@ -919,6 +920,7 @@ switch ($sortField) { break; case 'type': + $fieldForSorting = 'module_type'; switch ($sort) { case 'up': $selectDataTypeUp = $selected; @@ -939,6 +941,7 @@ switch ($sortField) { break; case 'moduletype': + $fieldForSorting = 'module_type'; switch ($sort) { case 'up': $selectTypeUp = $selected; @@ -959,6 +962,7 @@ switch ($sortField) { break; case 'module_name': + $fieldForSorting = 'module_name'; switch ($sort) { case 'up': $selectModuleNameUp = $selected; @@ -979,6 +983,7 @@ switch ($sortField) { break; case 'interval': + $fieldForSorting = 'module_interval'; switch ($sort) { case 'up': $selectIntervalUp = $selected; @@ -999,6 +1004,7 @@ switch ($sortField) { break; case 'status': + $fieldForSorting = 'estado'; switch ($sort) { case 'up': $selectStatusUp = $selected; @@ -1019,6 +1025,7 @@ switch ($sortField) { break; case 'last_status_change': + $fieldForSorting = 'last_status_change'; switch ($sort) { case 'up': $selectStatusUp = $selected; @@ -1039,6 +1046,7 @@ switch ($sortField) { break; case 'timestamp': + $fieldForSorting = 'utimestamp'; switch ($sort) { case 'up': $selectTimestampUp = $selected; @@ -1059,6 +1067,7 @@ switch ($sortField) { break; case 'data': + $fieldForSorting = 'datos'; switch ($sort) { case 'up': $selectDataUp = $selected; @@ -1079,6 +1088,7 @@ switch ($sortField) { break; default: + $fieldForSorting = 'agent_alias'; $selectAgentNameUp = $selected; $selectAgentNameDown = false; $selectDataTypeUp = false; @@ -1102,6 +1112,7 @@ switch ($sortField) { break; } + $sql = 'SELECT (SELECT GROUP_CONCAT(ttag.name SEPARATOR \',\') FROM ttag @@ -1216,6 +1227,8 @@ if ($autosearch) { $result = array_merge($result, $result_server); } + usort($result, arrayOutputSorting($sort, $fieldForSorting)); + metaconsole_restore_db(); }