diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 45794559d3..f09782e751 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,14 @@ +2010-02-18 Miguel de Dios + + * include/functions_gis.php: check in the function "addPath" if the agent + haven't history data. And clean source code. + + * operation/agentes/gis_view.php: change to use new tables, and show + messages when the agent haven't data GIS. + + * godmode/agentes/agent_conf_gis.php: change the message for agent without + data GIS. + 2010-02-18 Miguel de Dios * include/functions_html.php: hightlight that the parameter $script in diff --git a/pandora_console/godmode/agentes/agent_conf_gis.php b/pandora_console/godmode/agentes/agent_conf_gis.php index 509af2026b..bd14250f50 100644 --- a/pandora_console/godmode/agentes/agent_conf_gis.php +++ b/pandora_console/godmode/agentes/agent_conf_gis.php @@ -36,7 +36,7 @@ echo getAgentMap($id_agente, "500px", "98%", false); if ($agentData === false) { - echo "

" . __("There aren't any GIS data of agent, then it's positioned in default position of map.") . "

"; + echo "

" . __("There is no GIS data for this agent, so it's positioned in default position of map.") . "

"; } echo "

" . __("Warning: When you change the position the agent automatily enabled ignore GIS Data") . "

"; diff --git a/pandora_console/include/functions_gis.php b/pandora_console/include/functions_gis.php index 8f0e35ca5d..7e7a43834c 100644 --- a/pandora_console/include/functions_gis.php +++ b/pandora_console/include/functions_gis.php @@ -448,7 +448,12 @@ function get_agent_icon_map($idAgent, $state = false) { function addPath($layerName, $idAgent) { - $listPoints = get_db_all_rows_sql('SELECT * FROM tgis_data WHERE tagente_id_agente = ' . $idAgent . ' ORDER BY end_timestamp ASC'); + $listPoints = get_db_all_rows_sql('SELECT * FROM tgis_data_history WHERE tagente_id_agente = ' . $idAgent . ' ORDER BY end_timestamp ASC'); + + //If the agent is empty the history + if ($listPoints === false) { + return; + } $avaliableColors = array("#ff0000", "#00ff00", "#0000ff", "#000000"); @@ -769,11 +774,13 @@ function getAgentMap($agent_id, $heigth, $width, $show_history = false, $centerI makeLayer("layer_for_agent_".$agent_name); $agent_icon = get_agent_icon_map($agent_id); - /* If show_history is true, show the path of the agent */ + + /* If show_history is true, show the path of the agent */ if ($show_history) { /* TODO: only show the last history_time part of the path */ addPath("layer_for_agent_".$agent_name,$agent_id); } + addPoint("layer_for_agent_".$agent_name, $agent_name, $agentPositionLatitude, $agentPositionLongitude, $agent_icon, 20, 20, $agent_id, 'point_agent_info'); if ($centerInAgent) { diff --git a/pandora_console/operation/agentes/gis_view.php b/pandora_console/operation/agentes/gis_view.php index aee18500b6..394ae9d578 100644 --- a/pandora_console/operation/agentes/gis_view.php +++ b/pandora_console/operation/agentes/gis_view.php @@ -33,6 +33,7 @@ require_javascript_file('openlayers.pandora'); $period = get_parameter ("period", 86400); $agentId = get_parameter('id_agente'); $agent_name = get_agent_name($agentId); +$agentData = getDataLastPositionAgent($id_agente); echo "

".__('Received data from')." ". $agent_name . "

"; echo "

" . __("Map with the last position/s") . " " . human_time_description ($period) ."

"; @@ -41,13 +42,17 @@ echo "

" . __("Map with the last position/s") . " " . human_time_description echo "
"; echo getAgentMap($agentId, "500px", "98%", true); +if ($agentData === false) { + echo "

" . __("There is no GIS data for this agent, so it's positioned in default position of map.") . "

"; +} + echo "

" . __("Positional data from the last") . " " . human_time_description ($period) ."

"; /* Get the total number of Elements for the pagination */ -$sqlCount = sprintf ("SELECT COUNT(*) FROM tgis_data WHERE tagente_id_agente = %d AND end_timestamp > %d ORDER BY end_timestamp DESC", $agentId, get_system_time () - $period); +$sqlCount = sprintf ("SELECT COUNT(*) FROM tgis_data_history WHERE tagente_id_agente = %d AND end_timestamp > %d ORDER BY end_timestamp DESC", $agentId, get_system_time () - $period); $countData = get_db_value_sql($sqlCount); /* Get the elements to present in this page */ $sql = sprintf ("SELECT longitude, latitude, altitude, start_timestamp, end_timestamp, description, number_of_packages, manual_placement - FROM tgis_data + FROM tgis_data_history WHERE tagente_id_agente = %d AND end_timestamp > %d ORDER BY end_timestamp DESC LIMIT %d OFFSET %d", $agentId, get_system_time () - $period, $config['block_size'], get_parameter ('offset')); @@ -55,7 +60,7 @@ $result = get_db_all_rows_sql ($sql, true); if ($result === false) { - echo '

'.__('There was a problem locating the positional data').'

'; + echo '

'.__('There was a problem locating the positional data or empty history.').'

'; } else { pagination ($countData, false) ;