2010-01-18 15:24:25 +01:00
|
|
|
<?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
|
|
|
|
require_once ("include/config.php");
|
|
|
|
|
|
|
|
check_login ();
|
|
|
|
|
|
|
|
require_once ('include/functions_gis.php');
|
|
|
|
|
2010-02-09 18:06:25 +01:00
|
|
|
require_javascript_file('openlayers.pandora');
|
|
|
|
|
2010-01-27 20:52:53 +01:00
|
|
|
$idMap = (int) get_parameter ('map_id');
|
|
|
|
$show_history = get_parameter ('show_history', 'n');
|
2010-01-18 15:24:25 +01:00
|
|
|
|
|
|
|
$map = get_db_row ('tgis_map', 'id_tgis_map', $idMap);
|
|
|
|
$confMap = getMapConf($idMap);
|
2010-01-27 20:52:53 +01:00
|
|
|
|
|
|
|
$num_baselayer=0;
|
2010-03-02 16:24:49 +01:00
|
|
|
// Initialy there is no Gmap base layer.
|
|
|
|
$gmap_layer = false;
|
2010-01-28 19:15:16 +01:00
|
|
|
if ($confMap !== false) {
|
|
|
|
foreach ($confMap as $mapC) {
|
|
|
|
$baselayers[$num_baselayer]['typeBaseLayer'] = $mapC['connection_type'];
|
|
|
|
$baselayers[$num_baselayer]['name'] = $mapC['conection_name'];
|
|
|
|
$decodeJSON = json_decode($mapC['conection_data'], true);
|
2010-02-24 14:42:01 +01:00
|
|
|
|
|
|
|
switch ($mapC['connection_type']) {
|
|
|
|
case 'OSM':
|
|
|
|
$baselayers[$num_baselayer]['url'] = $decodeJSON['url'];
|
|
|
|
break;
|
2010-03-02 16:24:49 +01:00
|
|
|
case 'Gmap':
|
|
|
|
$baselayers[$num_baselayer]['gmap_type'] = $decodeJSON['gmap_type'];
|
|
|
|
$baselayers[$num_baselayer]['gmap_key'] = $decodeJSON['gmap_key'];
|
|
|
|
$gmap_key = $decodeJSON['gmap_key'];
|
|
|
|
// Onece a Gmap base layer is found we mark it to import the API
|
|
|
|
$gmap_layer = true;
|
|
|
|
break;
|
2010-02-24 14:42:01 +01:00
|
|
|
case 'Static_Image':
|
|
|
|
$baselayers[$num_baselayer]['url'] = $decodeJSON['url'];
|
|
|
|
$baselayers[$num_baselayer]['bb_left'] = $decodeJSON['bb_left'];
|
|
|
|
$baselayers[$num_baselayer]['bb_right'] = $decodeJSON['bb_right'];
|
|
|
|
$baselayers[$num_baselayer]['bb_bottom'] = $decodeJSON['bb_bottom'];
|
|
|
|
$baselayers[$num_baselayer]['bb_top'] = $decodeJSON['bb_top'];
|
|
|
|
$baselayers[$num_baselayer]['image_width'] = $decodeJSON['image_width'];
|
|
|
|
$baselayers[$num_baselayer]['image_height'] = $decodeJSON['image_height'];
|
|
|
|
break;
|
|
|
|
}
|
2010-01-28 19:15:16 +01:00
|
|
|
$num_baselayer++;
|
|
|
|
if ($mapC['default_map_connection'] == 1) {
|
|
|
|
$numZoomLevels = $mapC['num_zoom_levels'];
|
|
|
|
}
|
2010-01-27 20:52:53 +01:00
|
|
|
}
|
|
|
|
}
|
2010-03-02 16:24:49 +01:00
|
|
|
if ($gmap_layer === true) {
|
|
|
|
?>
|
2010-03-03 11:34:35 +01:00
|
|
|
<script type="text/javascript" src="http://maps.google.com/maps?file=api&v=2&sensor=false&key=<?php echo $gmap_key ?>" ></script>
|
2010-03-02 16:24:49 +01:00
|
|
|
<?php
|
|
|
|
}
|
2010-01-27 20:52:53 +01:00
|
|
|
|
2010-02-24 11:58:07 +01:00
|
|
|
$controls = array('PanZoomBar', 'ScaleLine', 'Navigation', 'MousePosition', 'OverviewMap');
|
2010-01-18 15:24:25 +01:00
|
|
|
|
|
|
|
$layers = getLayers($idMap);
|
|
|
|
|
|
|
|
// Render map
|
2010-02-23 17:36:24 +01:00
|
|
|
|
|
|
|
$buttons = array();
|
2010-01-18 15:24:25 +01:00
|
|
|
|
|
|
|
if ($config["pure"] == 0) {
|
2010-02-23 17:36:24 +01:00
|
|
|
$buttons[] = '<a href="index.php?sec=visualc&sec2=operation/gis_maps/render_view&map_id='.$idMap.'&refr='.$config["refr"].'&pure=1">' .
|
|
|
|
print_image ("images/fullscreen.png", true, array ("title" => __('Full screen mode'))) . "</a>";
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$buttons[] = '<a href="index.php?sec=visualc&sec2=operation/gis_maps/render_view&map_id='.$idMap.'&refr='.$config["refr"].'">' .
|
|
|
|
print_image ("images/normalscreen.png", true, array ("title" => __('Back to normal mode'))) . "</a>";
|
2010-01-18 15:24:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (give_acl ($config["id_user"], $map['group_id'], "AW"))
|
2010-03-01 12:40:07 +01:00
|
|
|
$buttons [] = '<a href="index.php?sec=godgismaps&sec2=godmode/gis_maps/configure_gis_map&action=edit_map&map_id='. $idMap.'">'.print_image ("images/setup.png", true, array ("title" => __('Setup'))).'</a>';
|
2010-02-23 17:36:24 +01:00
|
|
|
|
|
|
|
$buttonsString = '<a href="index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=3"><img src="images/bricks.png" class="top" border="0"> Agent - test_gis1</a></li></ul></div><div id="menu_tab"><ul class="mn"><li class="nomn"><a href="index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&id_agente=3"><img src="images/setup.png" class="top" title="Manage" border="0" width="16"> </a></li><li class="nomn_high"><a href="index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=3"><img src="images/monitor.png" class="top" title="Main" border="0"> </a></li><li class="nomn"><a href="index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=3&tab=data"><img src="images/lightbulb.png" class="top" title="Data" border="0"> </a></li><li class="nomn"><a href="index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=3&tab=alert"><img src="images/bell.png" class="top" title="Alerts" border="0"> </a></li><li class="nomn"><a href="index.php?sec=estado&sec2=operation/agentes/ver_agente&tab=sla&id_agente=3"><img src="images/images.png" class="top" title="S.L.A." border="0"> </a></li><li class="nomn"><a href="index.php?sec=estado&sec2=operation/agentes/estado_agente&group_id=2"><img src="images/agents_group.png" class="top" title="Group" border="0"> </a></li><li class="nomn"><a href="index.php?sec=estado&sec2=operation/agentes/ver_agente&tab=inventory&id_agente=3"><img src="images/page_white_text.png" class="top" title="Inventory" border="0" width="16"> </a></li><li class="nomn"><a href="index.php?sec=estado&sec2=operation/agentes/ver_agente&tab=gis&id_agente=3"><img src="images/world.png" class="top" title="GIS data" border="0"> </a>';
|
|
|
|
|
|
|
|
$times = array(
|
|
|
|
5 => 5 . ' ' . __('seconds'),
|
|
|
|
10 => 10 . ' ' . __('seconds'),
|
|
|
|
30 => 30 . ' ' . __('seconds'),
|
|
|
|
60 => 1 . ' ' . __('minute'),
|
|
|
|
120 => 2 . ' ' . __('minutes'),
|
|
|
|
300 => 5 . ' ' . __('minutes'),
|
|
|
|
600 => 10 . ' ' . __('minutes'),
|
|
|
|
3600 => 1 . ' ' . __('hour'),
|
|
|
|
7200 => 2 . ' ' . __('hours')
|
|
|
|
);
|
|
|
|
|
2010-02-24 12:49:03 +01:00
|
|
|
$buttons[] = ' ' . __('Refresh: ') . print_select($times, 'refresh_time', 60, 'changeRefreshTime(this.value);', '', 0, true, false, false) . " ";
|
|
|
|
|
2010-03-03 11:34:35 +01:00
|
|
|
$buttons[] = '<a id="button_status_all" href="javascript: changeShowStatus(\'all\');" style="border: 1px black solid;">' .
|
|
|
|
__('All') . '</a>';
|
|
|
|
$buttons[] = '<a id="button_status_bad" href="javascript: changeShowStatus(\'bad\');"><div style="height: 18px;">' .
|
|
|
|
'<img src="images/status_sets/default/agent_critical_ball.png" title="' . __('Critical') . '"/></div></a>';
|
|
|
|
$buttons[] = '<a id="button_status_warning" href="javascript: changeShowStatus(\'warning\');"><div style="height: 18px;">' .
|
|
|
|
'<img src="images/status_sets/default/agent_warning_ball.png" title="' . __('Warning') . '"/></div></a>';
|
|
|
|
$buttons[] = '<a id="button_status_ok" href="javascript: changeShowStatus(\'ok\');"><div style="height: 18px;">' .
|
|
|
|
'<img src="images/status_sets/default/agent_ok_ball.png" title="' . __('Ok') . '"/></div></a>';
|
|
|
|
$buttons[] = '<a id="button_status_default" href="javascript: changeShowStatus(\'default\');"><div style="height: 18px;">' .
|
|
|
|
'<img src="images/status_sets/default/agent_no_monitors_ball.png" title="' . __('Other') . '"/></div></a>';
|
2010-02-24 12:49:03 +01:00
|
|
|
$buttons[] = __('Show agents in state: ');
|
2010-02-23 17:36:24 +01:00
|
|
|
|
|
|
|
|
2010-03-01 12:40:07 +01:00
|
|
|
print_page_header(__('Map') . " » " . __('Map') . " " . $map['map_name'], "", false, "", false, $buttons);
|
2010-01-18 15:24:25 +01:00
|
|
|
|
|
|
|
printMap('map', $map['zoom_level'], $numZoomLevels, $map['initial_latitude'],
|
2010-01-27 20:52:53 +01:00
|
|
|
$map['initial_longitude'], $baselayers, $controls);
|
2010-01-18 15:24:25 +01:00
|
|
|
|
|
|
|
if ($layers != false) {
|
|
|
|
foreach ($layers as $layer) {
|
2010-02-17 18:27:25 +01:00
|
|
|
makeLayer($layer['layer_name'], $layer['view_layer'], null, $layer['id_tmap_layer']);
|
2010-01-18 15:24:25 +01:00
|
|
|
|
2010-01-29 16:47:40 +01:00
|
|
|
// calling get_group_agents with none to obtain the names in the same case as they are in the DB.
|
2010-02-25 13:46:47 +01:00
|
|
|
$agentNamesByGroup = get_group_agents($layer['tgrupo_id_grupo'],false,'none', true);
|
|
|
|
$agentNamesByLayer = getAgentsLayer($layer['id_tmap_layer'], array('nombre'));
|
|
|
|
|
|
|
|
$agentNames = array_unique($agentNamesByGroup + $agentNamesByLayer);
|
|
|
|
|
2010-01-18 15:24:25 +01:00
|
|
|
foreach ($agentNames as $agentName) {
|
|
|
|
$idAgent = get_agent_id($agentName);
|
2010-02-18 18:32:14 +01:00
|
|
|
$coords = getDataLastPositionAgent($idAgent);
|
2010-01-18 15:24:25 +01:00
|
|
|
|
2010-02-22 17:13:12 +01:00
|
|
|
if ($coords === false) {
|
|
|
|
$coords['stored_latitude'] = $map['default_latitude'];
|
|
|
|
$coords['stored_longitude'] = $map['default_longitude'];
|
|
|
|
}
|
|
|
|
else {
|
2010-02-24 12:49:03 +01:00
|
|
|
if ($show_history == 'y') {
|
2010-03-03 11:34:35 +01:00
|
|
|
$lastPosition = array('longitude' => $coords['stored_longitude'], 'latitude' => $coords['stored_latitude']);
|
|
|
|
addPath($layer['layer_name'], $idAgent, $lastPosition);
|
2010-02-22 17:13:12 +01:00
|
|
|
}
|
|
|
|
}
|
2010-02-04 11:34:30 +01:00
|
|
|
$icon = get_agent_icon_map($idAgent, true);
|
2010-02-19 13:26:54 +01:00
|
|
|
$status = get_agent_status($idAgent);
|
2010-02-25 18:27:55 +01:00
|
|
|
$parent = get_db_value('id_parent', 'tagente', 'id_agente', $idAgent);
|
2010-02-04 11:34:30 +01:00
|
|
|
|
2010-02-25 18:27:55 +01:00
|
|
|
addAgentPoint($layer['layer_name'], $agentName, $coords['stored_latitude'],
|
|
|
|
$coords['stored_longitude'], $icon, 20, 20, $idAgent, $status, 'point_agent_info', $parent);
|
2010-01-18 15:24:25 +01:00
|
|
|
}
|
|
|
|
}
|
2010-03-02 13:00:57 +01:00
|
|
|
addParentLines();
|
2010-02-04 11:34:30 +01:00
|
|
|
|
|
|
|
$timestampLastOperation = get_db_value_sql("SELECT UNIX_TIMESTAMP()");
|
|
|
|
|
2010-01-21 18:08:58 +01:00
|
|
|
activateSelectControl();
|
2010-02-04 11:34:30 +01:00
|
|
|
activateAjaxRefresh($layers, $timestampLastOperation);
|
2010-01-18 15:24:25 +01:00
|
|
|
}
|
|
|
|
|
2010-01-27 20:52:53 +01:00
|
|
|
if ($config["pure"] == 0) {
|
2010-02-24 12:49:03 +01:00
|
|
|
echo "<div id='map' style='width: 99%; height: 500px; border: 1px solid black;' ></div>";
|
2010-01-27 20:52:53 +01:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
echo "<div id='map' style='position:absolute;top:40px; z-index:100; width: 98%; height:94%; border: 1px solid black;' ></div>";
|
2010-03-03 10:25:10 +01:00
|
|
|
}
|
|
|
|
?>
|