diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 06bec333e2..c285fa201c 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,14 @@ +2010-02-22 Sancho Lerena + + * include/functions_gis.php: change the function "activateAjaxRefresh" for + refresh also the agent maps, and in the function "getAgentMap" show icon + with status the agent maps. + * operation/gis_maps/ajax.php: in the switch option "get_new_positions" + return GIS data for agent maps, in the "point_agent_info" and + "point_path_info" option change for new tables. + * operation/agentes/gis_view.php: add the ajax moving agent and click + bubble info. + 2010-02-22 Sancho Lerena * include/functions_menu.php: Add calls for new enterprise ACL system. diff --git a/pandora_console/include/functions_gis.php b/pandora_console/include/functions_gis.php index c5bd1d82e1..fefd736e3b 100644 --- a/pandora_console/include/functions_gis.php +++ b/pandora_console/include/functions_gis.php @@ -215,6 +215,15 @@ function activateAjaxRefresh($layers = null, $lastTimeOfData = null) { var refreshAjaxIntervalSeconds = 6000; var idIntervalAjax = null; + + function refreshAjaxLayer(layer) { var featureIdArray = Array(); @@ -222,14 +231,16 @@ function activateAjaxRefresh($layers = null, $lastTimeOfData = null) { feature = layer.features[featureIndex]; if (feature.data.type != 'point_path_info') { - featureIdArray.push(feature.data.id); + if (feature.geometry.CLASS_NAME == "OpenLayers.Geometry.Point") { + featureIdArray.push(feature.data.id); + } } } if (featureIdArray.length > 0) { jQuery.ajax ({ data: "page=operation/gis_maps/ajax&opt=get_new_positions&id_features=" + featureIdArray.toString() - + "&last_time_of_data=" + last_time_of_data + "&layer_id=" + layer.data.id, + + "&last_time_of_data=" + last_time_of_data + "&layer_id=" + layer.data.id + "&agent_view=" + agentView, type: "GET", dataType: 'json', url: "ajax.php", @@ -245,8 +256,9 @@ function activateAjaxRefresh($layers = null, $lastTimeOfData = null) { feature = searchPointAgentById(idAgent); layer.removeFeatures(feature); - console.log(feature); + delete feature; + feature = null js_addPointExtent(layer.name, agentDataGIS['name'], agentDataGIS['stored_longitude'], agentDataGIS['stored_latitude'], @@ -260,12 +272,16 @@ function activateAjaxRefresh($layers = null, $lastTimeOfData = null) { } } - function clock_ajax_refresh() { + function clock_ajax_refresh() { for (layerIndex = 0; layerIndex < map.getNumLayers(); layerIndex++) { layer = map.layers[layerIndex]; + if (layer.isVector) { + refreshAjaxLayer(layer); + } + " . __("Map with the last position/s") . " " . human_time_description echo "
"; echo getAgentMap($agentId, "500px", "98%", true); +$timestampLastOperation = get_db_value_sql("SELECT UNIX_TIMESTAMP()"); + +activateAjaxRefresh(null, $timestampLastOperation); +activateSelectControl(); + if ($agentData === false) { echo "

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

"; } diff --git a/pandora_console/operation/gis_maps/ajax.php b/pandora_console/operation/gis_maps/ajax.php index 8ccb836aef..f99d874582 100644 --- a/pandora_console/operation/gis_maps/ajax.php +++ b/pandora_console/operation/gis_maps/ajax.php @@ -38,57 +38,66 @@ switch ($opt) { $id_features = get_parameter('id_features', ''); $last_time_of_data = get_parameter('last_time_of_data'); $layerId = get_parameter('layer_id'); + $agentView = get_parameter('agent_view'); $returnJSON = array(); $returnJSON['correct'] = 1; - $flagGroupAll = get_db_all_rows_sql('SELECT tgrupo_id_grupo FROM tgis_map_layer WHERE id_tmap_layer = ' . $layerId . ' AND tgrupo_id_grupo = 1;'); //group 1 = all groups - - $defaultCoords = get_db_row_sql('SELECT default_longitude, default_latitude - FROM tgis_map - WHERE id_tgis_map IN (SELECT tgis_map_id_tgis_map FROM tgis_map_layer WHERE id_tmap_layer = ' . $layerId . ')'); - - if ($flagGroupAll === false) { - $idAgentsWithGISTemp = get_db_all_rows_sql('SELECT id_agente FROM tagente WHERE id_grupo IN - (SELECT tgrupo_id_grupo FROM tgis_map_layer WHERE id_tmap_layer = ' . $layerId . ') - OR id_agente IN - (SELECT tagente_id_agente FROM tgis_map_layer_has_tagente WHERE tgis_map_layer_id_tmap_layer = ' . $layerId . ');'); + if ($agentView == 0) { + $flagGroupAll = get_db_all_rows_sql('SELECT tgrupo_id_grupo FROM tgis_map_layer WHERE id_tmap_layer = ' . $layerId . ' AND tgrupo_id_grupo = 1;'); //group 1 = all groups + $defaultCoords = get_db_row_sql('SELECT default_longitude, default_latitude + FROM tgis_map + WHERE id_tgis_map IN (SELECT tgis_map_id_tgis_map FROM tgis_map_layer WHERE id_tmap_layer = ' . $layerId . ')'); + + if ($flagGroupAll === false) { + $idAgentsWithGISTemp = get_db_all_rows_sql('SELECT id_agente FROM tagente WHERE id_grupo IN + (SELECT tgrupo_id_grupo FROM tgis_map_layer WHERE id_tmap_layer = ' . $layerId . ') + OR id_agente IN + (SELECT tagente_id_agente FROM tgis_map_layer_has_tagente WHERE tgis_map_layer_id_tmap_layer = ' . $layerId . ');'); + + + $agentsGISStatus = get_db_all_rows_sql('SELECT tagente_id_agente, stored_longitude, stored_latitude + FROM tgis_data_status + WHERE tagente_id_agente IN + (SELECT id_agente FROM tagente WHERE id_grupo IN + (SELECT tgrupo_id_grupo FROM tgis_map_layer WHERE id_tmap_layer = ' . $layerId . ')) + OR tagente_id_agente IN + (SELECT tagente_id_agente FROM tgis_map_layer_has_tagente WHERE tgis_map_layer_id_tmap_layer = ' . $layerId . ');'); + + } + else { + //All groups, all agents + $idAgentsWithGISTemp = get_db_all_rows_sql('SELECT tagente_id_agente AS id_agente + FROM tgis_data_status + WHERE tagente_id_agente'); + + + $agentsGISStatus = get_db_all_rows_sql('SELECT tagente_id_agente, stored_longitude, stored_latitude + FROM tgis_data_status + WHERE tagente_id_agente'); + } + + foreach ($idAgentsWithGISTemp as $idAgent) { + $idAgentsWithGIS[] = $idAgent['id_agente']; + } $agentsGISStatus = get_db_all_rows_sql('SELECT tagente_id_agente, stored_longitude, stored_latitude - FROM tgis_data_status - WHERE tagente_id_agente IN - (SELECT id_agente FROM tagente WHERE id_grupo IN - (SELECT tgrupo_id_grupo FROM tgis_map_layer WHERE id_tmap_layer = ' . $layerId . ')) - OR tagente_id_agente IN - (SELECT tagente_id_agente FROM tgis_map_layer_has_tagente WHERE tgis_map_layer_id_tmap_layer = ' . $layerId . ');'); - + FROM tgis_data_status + WHERE tagente_id_agente IN (' . implode(',', $idAgentsWithGIS) . ') + UNION + SELECT id_agente AS tagente_id_agente, + ' . $defaultCoords['default_longitude'] . ' AS stored_longitude, ' . $defaultCoords['default_latitude'] . ' AS stored_latitude + FROM tagente + WHERE id_agente NOT IN (' . implode(',', $idAgentsWithGIS) . ')'); } else { - //All groups, all agents - $idAgentsWithGISTemp = get_db_all_rows_sql('SELECT tagente_id_agente AS id_agente - FROM tgis_data_status - WHERE tagente_id_agente'); - - + //agentView equal 1 $agentsGISStatus = get_db_all_rows_sql('SELECT tagente_id_agente, stored_longitude, stored_latitude - FROM tgis_data_status - WHERE tagente_id_agente'); + FROM tgis_data_status + WHERE tagente_id_agente = ' . $id_features); } - foreach ($idAgentsWithGISTemp as $idAgent) { - $idAgentsWithGIS[] = $idAgent['id_agente']; - } - - $agentsGISStatus = get_db_all_rows_sql('SELECT tagente_id_agente, stored_longitude, stored_latitude - FROM tgis_data_status - WHERE tagente_id_agente IN (' . implode(',', $idAgentsWithGIS) . ') - UNION - SELECT id_agente AS tagente_id_agente, - ' . $defaultCoords['default_longitude'] . ' AS stored_longitude, ' . $defaultCoords['default_latitude'] . ' AS stored_latitude - FROM tagente - WHERE id_agente NOT IN (' . implode(',', $idAgentsWithGIS) . ')'); - if ($agentsGISStatus === false) { $agentsGISStatus = array(); } @@ -109,7 +118,7 @@ switch ($opt) { break; case 'point_path_info': $id = get_parameter('id'); - $row = get_db_row_sql('SELECT * FROM tgis_data WHERE id_tgis_data = ' . $id); + $row = get_db_row_sql('SELECT * FROM tgis_data_history WHERE id_tgis_data = ' . $id); $returnJSON = array(); $returnJSON['correct'] = 1; @@ -126,11 +135,12 @@ switch ($opt) { case 'point_agent_info': $id = get_parameter('id'); $row = get_db_row_sql('SELECT * FROM tagente WHERE id_agente = ' . $id); + $agentDataGIS = getDataLastPositionAgent($row['id_agente']); $returnJSON = array(); $returnJSON['correct'] = 1; $returnJSON['content'] = __('Agent') . ': '.$row['nombre'].'
'; - $returnJSON['content'] .= __('Position (Long, Lat, Alt)') . ': (' . $row['last_longitude'] . ', ' . $row['last_latitude'] . ', ' . $row['last_altitude'] . ')
'; + $returnJSON['content'] .= __('Position (Long, Lat, Alt)') . ': (' . $agentDataGIS['stored_longitude'] . ', ' . $agentDataGIS['stored_latitude'] . ', ' . $agentDataGIS['stored_altitude'] . ')
'; $agent_ip_address = get_agent_address ($id_agente); if ($agent_ip_address || $agent_ip_address != '') { $returnJSON['content'] .= __('IP Address').': '.get_agent_address ($id_agente).'
';