2010-02-22 Sancho Lerena <slerena@artica.es>

* 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.



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@2405 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
mdtrooper 2010-02-23 12:12:41 +00:00
parent b2c9b7320d
commit 3289ad7339
4 changed files with 89 additions and 47 deletions

View File

@ -1,3 +1,14 @@
2010-02-22 Sancho Lerena <slerena@artica.es>
* 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 <slerena@artica.es>
* include/functions_menu.php: Add calls for new enterprise ACL system.

View File

@ -215,6 +215,15 @@ function activateAjaxRefresh($layers = null, $lastTimeOfData = null) {
var refreshAjaxIntervalSeconds = 6000;
var idIntervalAjax = null;
<?php
if ($layers === null) {
echo "var agentView = 1;";
}
else {
echo "var agentView = 0;";
}
?>
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];
<?php
if ($layers === null) {
refreshAjaxLayer(layer);
?>
if (layer.isVector) {
refreshAjaxLayer(layer);
}
<?php
}
else {
foreach ($layers as $layer) {
@ -720,7 +736,7 @@ function getAgentMap($agent_id, $heigth, $width, $show_history = false, $centerI
makeLayer("layer_for_agent_".$agent_name);
$agent_icon = get_agent_icon_map($agent_id);
$agent_icon = get_agent_icon_map($agent_id, true);
/* If show_history is true, show the path of the agent */
if ($show_history) {

View File

@ -42,6 +42,11 @@ echo "<h3>" . __("Map with the last position/s") . " " . human_time_description
echo "<div id=\"".$agent_name."_agent_map\" style=\"border:1px solid black; width:98%; height: 30em;\"></div>";
echo getAgentMap($agentId, "500px", "98%", true);
$timestampLastOperation = get_db_value_sql("SELECT UNIX_TIMESTAMP()");
activateAjaxRefresh(null, $timestampLastOperation);
activateSelectControl();
if ($agentData === false) {
echo "<p>" . __("There is no GIS data for this agent, so it's positioned in default position of map.") . "</p>";
}

View File

@ -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') . ': <a style="font-weight: bolder;" href="?sec=estado&sec2=operation/agentes/ver_agente&id_agente=' . $row['id_agente'] . '">'.$row['nombre'].'</a><br />';
$returnJSON['content'] .= __('Position (Long, Lat, Alt)') . ': (' . $row['last_longitude'] . ', ' . $row['last_latitude'] . ', ' . $row['last_altitude'] . ') <br />';
$returnJSON['content'] .= __('Position (Long, Lat, Alt)') . ': (' . $agentDataGIS['stored_longitude'] . ', ' . $agentDataGIS['stored_latitude'] . ', ' . $agentDataGIS['stored_altitude'] . ') <br />';
$agent_ip_address = get_agent_address ($id_agente);
if ($agent_ip_address || $agent_ip_address != '') {
$returnJSON['content'] .= __('IP Address').': '.get_agent_address ($id_agente).'<br />';