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

* include/functions_html.php: hightlight that the parameter $script in
	function print_input_text_extended isn't in use.
	
	* include/functions_gis.php: create function "getDataLastPositionAgent"
	that return row of position and other data for id agent.
	
	* godmode/agentes/agent_conf_gis.php: add the validate fields and adapt
	to new tables.
	
	* godmode/agentes/configurar_agente.php: adapt to new tables.



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@2375 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
mdtrooper 2010-02-18 13:29:36 +00:00
parent fc6c4c678a
commit 3a7cfb3b3f
5 changed files with 158 additions and 28 deletions

View File

@ -1,3 +1,16 @@
2010-02-18 Miguel de Dios <miguel.dedios@artica.es>
* include/functions_html.php: hightlight that the parameter $script in
function print_input_text_extended isn't in use.
* include/functions_gis.php: create function "getDataLastPositionAgent"
that return row of position and other data for id agent.
* godmode/agentes/agent_conf_gis.php: add the validate fields and adapt
to new tables.
* godmode/agentes/configurar_agente.php: adapt to new tables.
2010-02-17 Pablo de la Concepción <pablo.concepcion@artica.es>
* pandoradb.sql, extras/pandoradb_migrate_v3.0_to_v3.1.sql: Modified data

View File

@ -25,12 +25,22 @@ 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');
$agentData = getDataLastPositionAgent($id_agente);
$updateGisData = get_db_value('update_gis_data','tagente', 'id_agente', $id_agente);
$agent_name = get_agent_name($id_agente);
/* Map with the current position */
echo "<div id=\"".$agentData['nombre']."_agent_map\" style=\"border:1px solid black; width:98%; height: 30em;\"></div>";
echo "<div id=\"" . $agent_name . "_agent_map\" style=\"border:1px solid black; width:98%; height: 30em;\"></div>";
echo getAgentMap($id_agente, "500px", "98%", false);
if ($agentData === false) {
echo "<p>" . __("There aren't any GIS data of agent, then it's positioned in default position of map.") . "</p>";
}
echo "<h4>" . __("Warning: When you change the position the agent automatily enabled ignore GIS Data") . "</h4>";
$table->width = '60%';
$table->data = array();
@ -39,20 +49,23 @@ $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[1][1] = print_input_text_extended ('longitude', $agentData['stored_longitude'], 'text-longitude', '', 10, 10, false, '',
array('onchange' => "setIgnoreGISDataEnabled()", 'onkeyup' => "setIgnoreGISDataEnabled()"), true);
$table->data[2][0] = __('Latitude: ');
$table->data[2][1] = print_input_text ('latitude', $agentData['last_latitude'], '', 10, 10, true);
$table->data[2][1] = print_input_text_extended ('latitude', $agentData['stored_latitude'], 'text-latitude', '', 10, 10, false, '',
array('onchange' => "setIgnoreGISDataEnabled()", 'onkeyup' => "setIgnoreGISDataEnabled()"), true);
$table->data[3][0] = __('Altitude: ');
$table->data[3][1] = print_input_text ('altitude', $agentData['last_altitude'], '', 10, 10, true);
$table->data[3][1] = print_input_text_extended ('altitude', $agentData['stored_altitude'], 'text-altitude', '', 10, 10, false, '',
array('onchange' => "setIgnoreGISDataEnabled()", 'onkeyup' => "setIgnoreGISDataEnabled()"), 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);
$table->data[4][1] = __('Disabled').' '.print_radio_button_extended ("update_gis_data", 1, '', $updateGisData, false, '', 'style="margin-right: 40px;"', true);
$table->data[4][1] .= __('Active').' '.print_radio_button_extended ("update_gis_data", 0, '', $updateGisData, 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 . "'>";
echo "<form method='post' action='" . $url . "' onsubmit ='return validateFormFields();'>";
print_input_hidden('update_gis', 1);
print_table($table);
@ -62,11 +75,54 @@ echo '</div>';
echo "</form>";
?>
<script type="text/javascript">
function setIgnoreGISDataEnabled() {
$("#radiobtn0001").removeAttr("checked");
$("#radiobtn0002").attr("checked","checked");
}
function validateFormFields() {
longitude = $('input[name=longitude]').val();
latitude = $('input[name=latitude]').val();
altitude = $('input[name=altitude]').val();
valid = true;
$('input[name=longitude]').css('background', '#ffffff');
$('input[name=latitude]').css('background', '#ffffff');
$('input[name=altitude]').css('background', '#ffffff');
//Validate longitude
if ((jQuery.trim(longitude).length == 0) ||
isNaN(parseFloat(longitude))) {
$('input[name=longitude]').css('background', '#cc0000');
valid = false;
}
//Validate latitude
if ((jQuery.trim(latitude).length == 0) ||
isNaN(parseFloat(latitude))) {
$('input[name=latitude]').css('background', '#cc0000');
valid = false;
}
//Validate altitude
if ((jQuery.trim(altitude).length == 0) ||
isNaN(parseFloat(altitude))) {
$('input[name=altitude]').css('background', '#cc0000');
valid = false;
}
if (valid) return true;
else return false;
}
$(document).ready (
function () {
function changePositionAgent(e) {
var lonlat = map.getLonLatFromViewPortPx(e.xy);
var layer = map.getLayersByName("layer_for_agent_<?php echo $agentData['nombre']; ?>");
var layer = map.getLayersByName("layer_for_agent_<?php echo $agent_name ?>");
layer = layer[0];
feature = layer.features[0];
@ -76,8 +132,10 @@ $(document).ready (
$('input[name=latitude]').val(lonlat.lat);
$('input[name=longitude]').val(lonlat.lon);
$("#radiobtn0001").attr("checked","checked");
$("#radiobtn0002").removeAttr("checked");
if ($('input[name=altitude]').val().length == 0)
$('input[name=altitude]').val(0)
setIgnoreGISDataEnabled();
//return to no-standar the proyection for to move
feature.move(lonlat.transform(map.displayProjection, map.getProjectionObject()));

View File

@ -673,27 +673,58 @@ if (isset ($_GET["delete_module"])){ // DELETE agent module !
// ==========
$updateGIS = get_parameter('update_gis', 0);
if ($updateGIS) {
$updateGisData = get_parameter("update_gis");
$updateGisData = get_parameter("update_gis_data");
$lastLatitude = get_parameter("latitude");
$lastLongitude = get_parameter("longitude");
$lastAltitude = get_parameter("altitude");
$idAgente = get_parameter("id_agente");
$previusAgentGISData = get_db_row_sql("SELECT *
FROM tgis_data_status WHERE tagente_id_agente = " . $idAgente);
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_update('tagente', array('update_gis_data' => $updateGisData),
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
if ($previusAgentGISData !== false) {
process_sql_insert('tgis_data_history', array(
"longitude" => $previusAgentGISData['stored_longitude'],
"latitude" => $previusAgentGISData['stored_latitude'],
"altitude" => $previusAgentGISData['stored_altitude'],
"start_timestamp" => $previusAgentGISData['start_timestamp'],
"end_timestamp" => time(),
"description" => "Save by Pandora Console",
"manual_placement" => $previusAgentGISData['manual_placement'],
"number_of_packages" => $previusAgentGISData['number_of_packages'],
"tagente_id_agente" => $previusAgentGISData['tagente_id_agente']
));
process_sql_update('tgis_data_status', array(
"tagente_id_agente" => $idAgente,
"current_longitude" => $lastLongitude,
"current_latitude" => $lastLatitude,
"current_altitude" => $lastAltitude,
"stored_longitude" => $lastLongitude,
"stored_latitude" => $lastLatitude,
"stored_altitude" => $lastAltitude,
"start_timestamp" => time(),
"manual_placement" => 1,
"description" => "Update by Pandora Console"),
array("tagente_id_agente" => $idAgente));
}
else {
process_sql_insert('tgis_data_status', array(
"tagente_id_agente" => $idAgente,
"current_longitude" => $lastLongitude,
"current_latitude" => $lastLatitude,
"current_altitude" => $lastAltitude,
"stored_longitude" => $lastLongitude,
"stored_latitude" => $lastLatitude,
"stored_altitude" => $lastAltitude,
"manual_placement" => 1,
"description" => "Insert by Pandora Console"
));
}
process_sql_commit();
}

View File

@ -12,6 +12,23 @@
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
/**
* Return the data of last position of agent from tgis_data_status.
*
* @param integer $idAgent The id of agent.
* @param boolean $returnEmptyArrayInFail The set return a empty array when fail and true.
* @return Array The row of agent in tgis_data_status, and it's a associative array.
*/
function getDataLastPositionAgent($idAgent, $returnEmptyArrayInFail = false) {
$returnVar = get_db_row('tgis_data_status', 'tagente_id_agente', $idAgent);
if (($returnVar === false) && ($returnEmptyArrayInFail)) {
return array();
}
return $returnVar;
}
function printMap($idDiv, $iniZoom, $numLevelZooms, $latCenter, $lonCenter, $baselayers, $controls = null) {
$controls = (array)$controls;
@ -725,8 +742,19 @@ function getAgentMap($agent_id, $heigth, $width, $show_history = false, $centerI
AND t3.id_tmap_connection = t2.tgis_map_connection_id_tmap_connection");
$defaultMap = $defaultMap[0];
$agent_position = get_agent_last_coords($agent_id);
$agent_name = $agent_position['nombre'];
$agent_position = getDataLastPositionAgent($agent_id);
if ($agent_position === false) {
$agentPositionLongitude = $defaultMap['default_longitude'];
$agentPositionLatitude = $defaultMap['default_latitude'];
$agentPositionAltitude = $defaultMap['default_altitude'];
}
else {
$agentPositionLongitude = $agent_position['stored_longitude'];
$agentPositionLatitude = $agent_position['stored_latitude'];
$agentPositionAltitude = $agent_position['stored_altitude'];
}
$agent_name = get_agent_name($agent_id);
$conectionData = json_decode($defaultMap['conection_data'], true);
$baselayers[0]['url'] = $conectionData['url'];
@ -746,14 +774,14 @@ function getAgentMap($agent_id, $heigth, $width, $show_history = false, $centerI
/* 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, $agent_position['last_latitude'], $agent_position['last_longitude'], $agent_icon, 20, 20, $agent_id, 'point_agent_info');
addPoint("layer_for_agent_".$agent_name, $agent_name, $agentPositionLatitude, $agentPositionLongitude, $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']; ?>)
var lonlat = new OpenLayers.LonLat(<?php echo $agentPositionLongitude; ?>, <?php echo $agentPositionLatitude; ?>)
.transform(map.displayProjection, map.getProjectionObject());
map.setCenter(lonlat, <?php echo $defaultMap['zoom_level']; ?>, false, false);
});

View File

@ -314,7 +314,7 @@ function print_extended_select_for_time ($fields, $name, $selected = '', $script
* @param int $size Size of the input.
* @param int $maxlength Maximum length allowed.
* @param bool $disabled Disable the button (optional, button enabled by default).
* @param string $script JavaScript to attach to this
* @param string $script JavaScript to attach to this . (TODO This parameter don't use...and I don't know reason)
* @param mixed $attributes Attributes to add to this tag. Should be an array for correction.
* @param bool $return Whether to return an output string or echo now (optional, echo by default).
* @param bool $password Whether it is a password input or not. Not password by default.