From 5dff4cd13ad67daff0e9512ee35c762915b1ef3f Mon Sep 17 00:00:00 2001 From: mdtrooper Date: Mon, 7 Mar 2011 18:24:15 +0000 Subject: [PATCH] 2011-03-07 Miguel de Dios * include/functions_reporting.php: added the SQL query with correct date operations for PostgreSQL. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4065 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 5 +++++ pandora_console/include/functions_reporting.php | 15 ++++++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index e057884c1a..7e511e98b6 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,8 @@ +2011-03-07 Miguel de Dios + + * include/functions_reporting.php: added the SQL query with correct + date operations for PostgreSQL. + 2011-03-07 Miguel de Dios * include/functions_db.php, godmode/admin_access_logs.php: changes for the diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index 4a0562a815..938662befe 100644 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -586,9 +586,18 @@ function get_group_stats ($id_group = 0) { foreach ($id_group as $group){ - $data["agents_unknown"] += get_db_sql ("SELECT COUNT(*) - FROM tagente - WHERE id_grupo = $group AND disabled = 0 AND ultimo_contacto < NOW() - (intervalo * 2)"); + switch ($config["dbtype"]) { + case "mysql": + $data["agents_unknown"] += get_db_sql ("SELECT COUNT(*) + FROM tagente + WHERE id_grupo = $group AND disabled = 0 AND ultimo_contacto < NOW() - (intervalo * 2)"); + break; + case "postgresql": + $data["agents_unknown"] += get_db_sql ("SELECT COUNT(*) + FROM tagente + WHERE id_grupo = $group AND disabled = 0 AND ceil(date_part('epoch', ultimo_contacto)) < ceil(date_part('epoch', NOW())) - (intervalo * 2)"); + break; + } $data["total_agents"] += get_db_sql ("SELECT COUNT(*) FROM tagente WHERE id_grupo = $group AND disabled = 0");