From a41e8389ce30daf894a1253dad66cb7ccedb2a22 Mon Sep 17 00:00:00 2001 From: mdtrooper Date: Wed, 10 Feb 2010 13:08:33 +0000 Subject: [PATCH] 2010-02-10 Miguel de Dios * 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 --- pandora_console/ChangeLog | 14 +++ .../godmode/agentes/agent_conf_gis.php | 88 +++++++++++++++++++ .../godmode/agentes/configurar_agente.php | 43 +++++++++ pandora_console/include/functions_gis.php | 17 +++- .../operation/agentes/ver_agente.php | 3 +- 5 files changed, 162 insertions(+), 3 deletions(-) create mode 100644 pandora_console/godmode/agentes/agent_conf_gis.php diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index b02ee05f1d..3d15301545 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,17 @@ +2010-02-10 Miguel de Dios + + * 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 * include/styles/pandora.css: add lost style for disable button. diff --git a/pandora_console/godmode/agentes/agent_conf_gis.php b/pandora_console/godmode/agentes/agent_conf_gis.php new file mode 100644 index 0000000000..085745d4d2 --- /dev/null +++ b/pandora_console/godmode/agentes/agent_conf_gis.php @@ -0,0 +1,88 @@ +" . __('Agent configuration') . " » " . __('Configure GIS data') . ""; + +$agentData = get_db_row_sql('SELECT * FROM tagente WHERE id_agente = 8'); + +/* Map with the current position */ +echo "
"; +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 "
"; +print_input_hidden('update_gis', 1); +print_table($table); + +echo '
'; +print_submit_button (__('Update'), '', false, 'class="sub update"'); +echo '
'; +echo "
"; +?> + \ No newline at end of file diff --git a/pandora_console/godmode/agentes/configurar_agente.php b/pandora_console/godmode/agentes/configurar_agente.php index 051270d71f..c275c11ff2 100644 --- a/pandora_console/godmode/agentes/configurar_agente.php +++ b/pandora_console/godmode/agentes/configurar_agente.php @@ -228,6 +228,18 @@ if ($id_agente) { echo ''; echo " "; + // GIS tab + if ($config['activate_gis']) { + if ($tab == "gis") { + echo "
  • "; + } + else { + echo "
  • "; + } + echo " "; + echo "
  • "; + } + echo ""; // 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 diff --git a/pandora_console/include/functions_gis.php b/pandora_console/include/functions_gis.php index c3a8397416..9d442b83cc 100644 --- a/pandora_console/include/functions_gis.php +++ b/pandora_console/include/functions_gis.php @@ -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) { + ?> + + "; - } else { + } + else { echo "
  • "; } echo " ";