From f9e13f960f46ed6715da3e23ed3f86890efb7253 Mon Sep 17 00:00:00 2001 From: zarzuelo Date: Wed, 6 Oct 2010 12:16:24 +0000 Subject: [PATCH] 2010-10-06 Sergio Martin * include/fgraph.php operation/incidents/incident_statistics.php: Fixed the incident statistics for bug 3078118 git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@3350 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 6 +++ pandora_console/include/fgraph.php | 53 ++++++++++++++----- .../incidents/incident_statistics.php | 6 +-- 3 files changed, 48 insertions(+), 17 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 74dfc1a6de..712259e692 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,9 @@ +2010-10-06 Sergio Martin + + * include/fgraph.php + operation/incidents/incident_statistics.php: Fixed the incident + statistics for bug 3078118 + 2010-10-06 Dario Rodriguez *operation/agentes/estado_agente.php, ver_agente.php: Fixed some problems diff --git a/pandora_console/include/fgraph.php b/pandora_console/include/fgraph.php index ace3f40f39..6e851200a2 100644 --- a/pandora_console/include/fgraph.php +++ b/pandora_console/include/fgraph.php @@ -688,15 +688,19 @@ function grafico_incidente_prioridad () { global $graphic_type; $data_tmp = array (0, 0, 0, 0, 0, 0); - $sql = 'SELECT COUNT(id_incidencia), prioridad + $sql = 'SELECT COUNT(id_incidencia) n_incidents, prioridad FROM tincidencia GROUP BY prioridad ORDER BY 2 DESC'; $incidents = get_db_all_rows_sql ($sql); + + if($incidents == false) { + $incidents = array(); + } foreach ($incidents as $incident) { if ($incident['prioridad'] < 5) - $data_tmp[$incident[1]] = $incident[0]; + $data_tmp[$incident['prioridad']] = $incident['n_incidents']; else - $data_tmp[5] += $incident[0]; + $data_tmp[5] += $incident['n_incidents']; } $data = array (__('Informative') => $data_tmp[0], __('Low') => $data_tmp[1], @@ -721,15 +725,18 @@ function graphic_incident_group () { $data = array (); $max_items = 5; - $sql = sprintf ('SELECT COUNT(id_incidencia), nombre + $sql = sprintf ('SELECT COUNT(id_incidencia) n_incidents, nombre FROM tincidencia,tgrupo WHERE tgrupo.id_grupo = tincidencia.id_grupo GROUP BY tgrupo.id_grupo ORDER BY 1 DESC LIMIT %d', $max_items); $incidents = get_db_all_rows_sql ($sql); - foreach ($incidents as $incident) { - $name = $incident[1].' ('.$incident[0].')'; - $data[$name] = $incident[0]; + + if($incidents == false) { + $incidents = array(); + } + foreach ($incidents as $incident) { + $data[$incident['nombre']] = $incident['n_incidents']; } if (! $graphic_type) { @@ -753,13 +760,23 @@ function graphic_incident_user () { $data = array (); $max_items = 5; - $sql = sprintf ('SELECT COUNT(id_incidencia), id_usuario + $sql = sprintf ('SELECT COUNT(id_incidencia) n_incidents, id_usuario FROM tincidencia GROUP BY id_usuario ORDER BY 1 DESC LIMIT %d', $max_items); $incidents = get_db_all_rows_sql ($sql); + + if($incidents == false) { + $incidents = array(); + } foreach ($incidents as $incident) { - $name = $incident[1].' ('.$incident[0].')'; - $data[$name] = $incident[0]; + if($incident['id_usuario'] == false) { + $name = __('System'); + } + else { + $name = $incident['id_usuario']; + } + + $data[$name] = $incident['n_incidents']; } if (! $graphic_type) { @@ -782,12 +799,16 @@ function graphic_user_activity ($width = 350, $height = 230) { $data = array (); $max_items = 5; - $sql = sprintf ('SELECT COUNT(id_usuario), id_usuario + $sql = sprintf ('SELECT COUNT(id_usuario) n_incidents, id_usuario FROM tsesion GROUP BY id_usuario ORDER BY 1 DESC LIMIT %d', $max_items); $logins = get_db_all_rows_sql ($sql); + + if($logins == false) { + $logins = array(); + } foreach ($logins as $login) { - $data[$login[1]] = $login[0]; + $data[$login['id_usuario']] = $login['n_incidents']; } if (! $graphic_type) { @@ -809,12 +830,16 @@ function graphic_incident_source ($width = 320, $height = 200) { $data = array (); $max_items = 5; - $sql = sprintf ('SELECT COUNT(id_incidencia), origen + $sql = sprintf ('SELECT COUNT(id_incidencia) n_incident, origen FROM tincidencia GROUP BY `origen` ORDER BY 1 DESC LIMIT %d', $max_items); $origins = get_db_all_rows_sql ($sql); + + if($origins == false) { + $origins = array(); + } foreach ($origins as $origin) { - $data[$origin[1]] = $origin[0]; + $data[$origin['origen']] = $origin['n_incident']; } if (! $graphic_type) { diff --git a/pandora_console/operation/incidents/incident_statistics.php b/pandora_console/operation/incidents/incident_statistics.php index 1be46b0b32..97e079c5a1 100644 --- a/pandora_console/operation/incidents/incident_statistics.php +++ b/pandora_console/operation/incidents/incident_statistics.php @@ -42,19 +42,19 @@ if ($config['flash_charts']) { } echo '

'.__('Incidents by group').'

'; if ($config['flash_charts']) { - echo grafico_incidente_prioridad (); + echo graphic_incident_group (); } else { echo ''; } echo '

'.__('Incidents by user').'

'; if ($config['flash_charts']) { - echo grafico_incidente_prioridad (); + echo graphic_incident_user (); } else { echo ''; } echo '

'.__('Incidents by source').'

'; if ($config['flash_charts']) { - echo grafico_incidente_prioridad (); + echo graphic_incident_source (); } else { echo ''; }