2010-02-10 Miguel de Dios <miguel.dedios@artica.es>

* include/functions_gis.php: add in the function "getAgentMap" a new
	parameter "centerInAgent" (default true) for center the map in the last
	position of agent.
	
	* operation/agentes/ver_agente.php: clean source code.
	
	* godmode/agentes/agent_conf_gis.php: add page that you can change the
	position of agent.
	
	* godmode/agentes/configurar_agente.php: add the code to update the changed
	coords of agent, and show the tab to access the agent_conf_gis.php.



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@2337 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
mdtrooper 2010-02-10 13:08:33 +00:00
parent f5a8c6fb94
commit a41e8389ce
5 changed files with 162 additions and 3 deletions

View File

@ -1,3 +1,17 @@
2010-02-10 Miguel de Dios <miguel.dedios@artica.es>
* include/functions_gis.php: add in the function "getAgentMap" a new
parameter "centerInAgent" (default true) for center the map in the last
position of agent.
* operation/agentes/ver_agente.php: clean source code.
* godmode/agentes/agent_conf_gis.php: add page that you can change the
position of agent.
* godmode/agentes/configurar_agente.php: add the code to update the changed
coords of agent, and show the tab to access the agent_conf_gis.php.
2010-02-10 Miguel de Dios <miguel.dedios@artica.es>
* include/styles/pandora.css: add lost style for disable button.

View File

@ -0,0 +1,88 @@
<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2009 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation for version 2.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Load global vars
if (!isset ($id_agente)) {
die ("Not Authorized");
}
require_once ('include/functions_gis.php');
require_once ('include/functions_html.php');
require_javascript_file('openlayers.pandora');
echo "<h2>" . __('Agent configuration') . " &raquo; " . __('Configure GIS data') . "</h2>";
$agentData = get_db_row_sql('SELECT * FROM tagente WHERE id_agente = 8');
/* Map with the current position */
echo "<div id=\"".$agentData['nombre']."_agent_map\" style=\"border:1px solid black; width:98%; height: 30em;\"></div>";
echo getAgentMap($id_agente, "500px", "98%", false);
$table->width = '60%';
$table->data = array();
$table->colspan[0][0] = 2;
$table->data[0][0] = __('Agent coords:');
$table->data[1][0] = __('Longitude: ');
$table->data[1][1] = print_input_text ('longitude', $agentData['last_longitude'], '', 10, 10, true);
$table->data[2][0] = __('Latitude: ');
$table->data[2][1] = print_input_text ('latitude', $agentData['last_latitude'], '', 10, 10, true);
$table->data[3][0] = __('Altitude: ');
$table->data[3][1] = print_input_text ('altitude', $agentData['last_altitude'], '', 10, 10, true);
$table->data[4][0] = __('Ignore new GIS data:');
$table->data[4][1] = __('Disabled').' '.print_radio_button_extended ("update_gis_data", 0, '', $agentData['update_gis_data'], false, '', 'style="margin-right: 40px;"', true);
$table->data[4][1] .= __('Active').' '.print_radio_button_extended ("update_gis_data", 1, '', $agentData['update_gis_data'], false, '', 'style="margin-right: 40px;"', true);
$url = 'index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=gis&id_agente='.$id_agente;
echo "<form method='post' action='" . $url . "'>";
print_input_hidden('update_gis', 1);
print_table($table);
echo '<div class="action-buttons" style="clear: left; width: ' . $table->width . '; float: left;">';
print_submit_button (__('Update'), '', false, 'class="sub update"');
echo '</div>';
echo "</form>";
?>
<script type="text/javascript">
$(document).ready (
function () {
function changePositionAgent(e) {
var lonlat = map.getLonLatFromViewPortPx(e.xy);
var layer = map.getLayersByName("layer_for_agent_<?php echo $agentData['nombre']; ?>");
layer = layer[0];
feature = layer.features[0];
lonlat.transform(map.getProjectionObject(), map.displayProjection); //transform the lonlat in object proyection to "standar proyection"
$('input[name=latitude]').val(lonlat.lat);
$('input[name=longitude]').val(lonlat.lon);
$("#radiobtn0001").attr("checked","checked");
$("#radiobtn0002").removeAttr("checked");
//return to no-standar the proyection for to move
feature.move(lonlat.transform(map.displayProjection, map.getProjectionObject()));
}
js_activateEvents(changePositionAgent);
});
</script>

View File

@ -228,6 +228,18 @@ if ($id_agente) {
echo '<a href="index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&ag_group='.$group.'">';
echo "<img src='images/agents_group.png' class='top' title='".__('Group')."'>&nbsp;</a></li>";
// GIS tab
if ($config['activate_gis']) {
if ($tab == "gis") {
echo "<li class='nomn_high'>";
}
else {
echo "<li class='nomn'>";
}
echo "<a href='index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=gis&id_agente=$id_agente'><img src='images/world.png' class='top' border=0 title='".__('GIS data')."'>&nbsp;</a>";
echo "</li>";
}
echo "</ul></div></div>";
// Make some space between tabs and title
@ -618,6 +630,34 @@ if (isset ($_GET["delete_module"])){ // DELETE agent module !
}
}
// UPDATE GIS
// ==========
$updateGIS = get_parameter('update_gis', 0);
if ($updateGIS) {
$updateGisData = get_parameter("update_gis");
$lastLatitude = get_parameter("latitude");
$lastLongitude = get_parameter("longitude");
$lastAltitude = get_parameter("altitude");
$idAgente = get_parameter("id_agente");
process_sql_begin();
process_sql_update('tagente', array('update_gis_data' => $updateGisData,
'last_latitude' => $lastLatitude, 'last_longitude' => $lastLongitude,
'last_altitude' => $lastAltitude), array('id_agente' => $idAgente));
process_sql_insert('tgis_data', array('longitude' => $lastLongitude,
'latitude' => $lastLatitude,
'altitude' => $lastAltitude,
'description' => __('Added by user in Pandora Console'),
'manual_placement' => 1,
'number_of_packages' => 1,
'tagente_id_agente' => $idAgente
));
process_sql_commit();
}
// -----------------------------------
// Load page depending on tab selected
// -----------------------------------
@ -639,6 +679,9 @@ switch ($tab) {
case "template":
require ("agent_template.php");
break;
case "gis":
require("agent_conf_gis.php");
break;
default:
if (enterprise_hook ('switch_agent_tab', array ($tab)))
//This will make sure that blank pages will have at least some

View File

@ -605,11 +605,12 @@ function saveMap($map_name, $map_initial_longitude, $map_initial_latitude,
* @param $height: heigth in a string in css format
* @param $width: width in a string in css format
* @param $show_history: by default or when this parameter is false in the map the path with the
* @param $centerInAgent boolean Default is true, set the map center in the icon agent.
* @param $history_time: Number of seconds in the past to show from where to start the history path.
*
* @return A div tag with the map and the agent and the history path if asked.
*/
function getAgentMap($agent_id, $heigth, $width, $show_history = false, $history_time = 86400) {
function getAgentMap($agent_id, $heigth, $width, $show_history = false, $centerInAgent = true, $history_time = 86400) {
$defaultMap = get_db_all_rows_sql("
SELECT t1.*, t3.conection_name, t3.connection_type, t3.conection_data, t3.num_zoom_levels
FROM tgis_map AS t1,
@ -642,7 +643,19 @@ function getAgentMap($agent_id, $heigth, $width, $show_history = false, $history
addPath("layer_for_agent_".$agent_name,$agent_id);
}
addPoint("layer_for_agent_".$agent_name, $agent_name, $agent_position['last_latitude'], $agent_position['last_longitude'], $agent_icon, 20, 20, $agent_id, 'point_agent_info');
if ($centerInAgent) {
?>
<script type="text/javascript">
$(document).ready (
function () {
var lonlat = new OpenLayers.LonLat(<?php echo $agent_position['last_longitude']; ?>, <?php echo $agent_position['last_latitude']; ?>)
.transform(map.displayProjection, map.getProjectionObject());
map.setCenter(lonlat, <?php echo $defaultMap['zoom_level']; ?>, false, false);
});
</script>
<?php
}
}
/**

View File

@ -267,7 +267,8 @@ enterprise_hook ('inventory_tab');
if ($config['activate_gis']) {
if ($tab == "gis") {
echo "<li class='nomn_high'>";
} else {
}
else {
echo "<li class='nomn'>";
}
echo "<a href='index.php?sec=estado&sec2=operation/agentes/ver_agente&tab=gis&id_agente=$id_agente'><img src='images/world.png' class='top' border=0 title='".__('GIS data')."'>&nbsp;</a>";