2015-11-25 08:39:18 +01:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Pandora FMS- http://pandorafms.com
|
|
|
|
* ==================================================
|
|
|
|
* Copyright (c) 2005-2009 Artica Soluciones Tecnologicas
|
2019-01-30 16:18:44 +01:00
|
|
|
*
|
2015-11-25 08:39:18 +01:00
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
// Login check
|
2019-01-30 16:18:44 +01:00
|
|
|
check_login();
|
2015-11-25 08:39:18 +01:00
|
|
|
|
|
|
|
// Load global vars
|
|
|
|
global $config;
|
|
|
|
|
2019-01-30 16:18:44 +01:00
|
|
|
require_once 'include/functions_gis.php';
|
|
|
|
|
|
|
|
// ui_require_javascript_file('openlayers.pandora');
|
|
|
|
$buttons['gis_maps_list'] = [
|
|
|
|
'active' => true,
|
|
|
|
'text' => '<a href="index.php?sec=godgismaps&sec2=operation/gis_maps/gis_map">'.html_print_image(
|
|
|
|
'images/list.png',
|
|
|
|
true,
|
|
|
|
['title' => __('GIS Maps list')]
|
|
|
|
).'</a>',
|
|
|
|
];
|
|
|
|
|
|
|
|
ui_print_page_header(
|
|
|
|
__('GIS Maps'),
|
|
|
|
'images/op_gis.png',
|
|
|
|
false,
|
2020-05-29 11:37:06 +02:00
|
|
|
'',
|
2019-01-30 16:18:44 +01:00
|
|
|
false,
|
|
|
|
$buttons
|
|
|
|
);
|
2016-01-19 13:16:38 +01:00
|
|
|
|
|
|
|
$own_info = get_user_info($config['id_user']);
|
2019-01-30 16:18:44 +01:00
|
|
|
if ($own_info['is_admin'] || check_acl($config['id_user'], 0, 'MM')) {
|
|
|
|
$display_default_column = true;
|
|
|
|
} else {
|
|
|
|
$display_default_column = false;
|
|
|
|
}
|
2016-01-19 13:16:38 +01:00
|
|
|
|
|
|
|
$edit_gis_maps = false;
|
2019-01-30 16:18:44 +01:00
|
|
|
if (check_acl($config['id_user'], 0, 'MW') || check_acl($config['id_user'], 0, 'MM')) {
|
|
|
|
$edit_gis_maps = true;
|
2016-01-19 13:16:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-01-30 16:18:44 +01:00
|
|
|
if (is_ajax()) {
|
|
|
|
$action = get_parameter('action');
|
|
|
|
$id_map = get_parameter('id_map');
|
|
|
|
|
|
|
|
// Set to not default the actual default map
|
|
|
|
$returnOperationDB = db_process_sql_update('tgis_map', ['default_map' => 0], ['default_map' => 1]);
|
|
|
|
|
|
|
|
// Set default the new default map
|
|
|
|
$returnOperationDB = db_process_sql_update('tgis_map', ['default_map' => 1], ['id_tgis_map' => $id_map]);
|
|
|
|
|
|
|
|
if ($returnOperationDB === false) {
|
|
|
|
$data['correct'] = false;
|
|
|
|
} else {
|
|
|
|
$data['correct'] = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
echo json_encode($data);
|
|
|
|
|
|
|
|
return;
|
2016-01-19 13:16:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
$action = get_parameter('action');
|
|
|
|
switch ($action) {
|
2019-01-30 16:18:44 +01:00
|
|
|
case 'delete_map':
|
|
|
|
$idMap = get_parameter('map_id');
|
|
|
|
$result = gis_delete_map($idMap);
|
|
|
|
|
|
|
|
ui_print_result_message(
|
|
|
|
$result,
|
|
|
|
__('Successfully deleted'),
|
|
|
|
__('Could not be deleted')
|
|
|
|
);
|
|
|
|
|
|
|
|
break;
|
2016-01-19 13:16:38 +01:00
|
|
|
}
|
|
|
|
|
2015-11-25 08:39:18 +01:00
|
|
|
|
|
|
|
$maps = gis_get_maps();
|
|
|
|
|
2016-01-19 13:16:38 +01:00
|
|
|
|
2015-11-25 08:39:18 +01:00
|
|
|
$table = new stdClass();
|
2019-01-30 16:18:44 +01:00
|
|
|
$table->width = '100%';
|
2019-03-29 11:05:52 +01:00
|
|
|
$table->class = 'info_table';
|
2016-01-19 13:16:38 +01:00
|
|
|
|
2019-01-30 16:18:44 +01:00
|
|
|
$table->head = [];
|
2016-01-19 13:16:38 +01:00
|
|
|
$table->head['name'] = __('Name');
|
|
|
|
$table->head['group'] = __('Group');
|
|
|
|
if ($edit_gis_maps) {
|
2019-01-30 16:18:44 +01:00
|
|
|
if ($display_default_column) {
|
|
|
|
$table->head['default'] = __('Default');
|
|
|
|
}
|
|
|
|
|
|
|
|
$table->head['op'] = '<span title="Operations">'.__('Op.').'</span>';
|
2016-01-19 13:16:38 +01:00
|
|
|
}
|
|
|
|
|
2019-01-30 16:18:44 +01:00
|
|
|
$table->headstyle = [];
|
2016-01-19 13:16:38 +01:00
|
|
|
$table->headstyle['name'] = 'text-align: left;';
|
|
|
|
$table->headstyle['group'] = 'text-align: center;';
|
|
|
|
if ($edit_gis_maps) {
|
2019-01-30 16:18:44 +01:00
|
|
|
if ($display_default_column) {
|
|
|
|
$table->headstyle['default'] = 'text-align: center;';
|
|
|
|
}
|
|
|
|
|
|
|
|
$table->headstyle['op'] = 'text-align: center;';
|
2016-01-19 13:16:38 +01:00
|
|
|
}
|
|
|
|
|
2019-01-30 16:18:44 +01:00
|
|
|
$table->size = [];
|
|
|
|
$table->size['name'] = '80%';
|
|
|
|
$table->size['group'] = '30';
|
2016-01-19 13:16:38 +01:00
|
|
|
if ($edit_gis_maps) {
|
2019-01-30 16:18:44 +01:00
|
|
|
if ($display_default_column) {
|
|
|
|
$table->size['default'] = '30';
|
|
|
|
}
|
|
|
|
|
|
|
|
$table->size['op'] = '60';
|
2016-01-19 13:16:38 +01:00
|
|
|
}
|
|
|
|
|
2019-01-30 16:18:44 +01:00
|
|
|
$table->align = [];
|
2016-01-19 13:16:38 +01:00
|
|
|
$table->align['name'] = 'left';
|
|
|
|
$table->align['group'] = 'center';
|
|
|
|
if ($edit_gis_maps) {
|
2019-01-30 16:18:44 +01:00
|
|
|
if ($display_default_column) {
|
|
|
|
$table->align['default'] = 'center';
|
|
|
|
}
|
|
|
|
|
|
|
|
$table->align['op'] = 'center';
|
2016-01-19 13:16:38 +01:00
|
|
|
}
|
|
|
|
|
2019-01-30 16:18:44 +01:00
|
|
|
$table->data = [];
|
2015-11-25 08:39:18 +01:00
|
|
|
|
|
|
|
$rowPair = true;
|
|
|
|
$iterator = 0;
|
|
|
|
|
|
|
|
if ($maps !== false) {
|
2019-01-30 16:18:44 +01:00
|
|
|
foreach ($maps as $map) {
|
|
|
|
if (!check_acl($config['id_user'], $map['group_id'], 'MR')
|
|
|
|
&& !check_acl($config['id_user'], $map['group_id'], 'MW')
|
|
|
|
&& !check_acl($config['id_user'], $map['group_id'], 'MM')
|
|
|
|
) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($rowPair) {
|
|
|
|
$table->rowclass[$iterator] = 'rowPair';
|
|
|
|
} else {
|
|
|
|
$table->rowclass[$iterator] = 'rowOdd';
|
|
|
|
}
|
|
|
|
|
|
|
|
$rowPair = !$rowPair;
|
|
|
|
$iterator++;
|
|
|
|
|
|
|
|
$data = [];
|
|
|
|
|
|
|
|
$data['name'] = '<a href="index.php?sec=gismaps&sec2=operation/gis_maps/render_view&map_id='.$map['id_tgis_map'].'">'.$map['map_name'].'</a> ';
|
|
|
|
$data['group'] = ui_print_group_icon($map['group_id'], true);
|
|
|
|
|
|
|
|
if ($edit_gis_maps) {
|
|
|
|
if ($display_default_column) {
|
|
|
|
$checked = false;
|
|
|
|
if ($map['default_map']) {
|
|
|
|
$checked = true;
|
|
|
|
$defaultMapId = $map['id_tgis_map'];
|
|
|
|
}
|
|
|
|
|
|
|
|
$data['default'] = html_print_radio_button_extended('default_map', $map['id_tgis_map'], '', $checked, false, 'setDefault('.$map['id_tgis_map'].');', '', true);
|
|
|
|
}
|
|
|
|
|
2019-04-02 13:42:30 +02:00
|
|
|
$table->cellclass[]['op'] = 'action_buttons';
|
|
|
|
$data['op'] = '<a href="index.php?sec=godgismaps&sec2=godmode/gis_maps/configure_gis_map&map_id='.$map['id_tgis_map'].'&action=edit_map">'.html_print_image('images/config.png', true, ['title' => __('Edit')]).'</a>'.'<a href="index.php?sec=godgismaps&sec2=operation/gis_maps/gis_map&map_id='.$map['id_tgis_map'].'&action=delete_map" onclick="return confirmDelete();">'.html_print_image('images/cross.png', true, ['title' => __('Delete')]).'</a>';
|
2019-01-30 16:18:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
array_push($table->data, $data);
|
|
|
|
}
|
2015-11-25 08:39:18 +01:00
|
|
|
}
|
|
|
|
|
2019-01-30 16:18:44 +01:00
|
|
|
if (!empty($table->data)) {
|
|
|
|
html_print_table($table);
|
|
|
|
} else {
|
|
|
|
echo '<div class="nf">'.__('No maps found').'</div>';
|
2015-11-25 08:39:18 +01:00
|
|
|
}
|
2016-01-19 13:16:38 +01:00
|
|
|
|
|
|
|
if ($edit_gis_maps) {
|
2019-01-30 16:18:44 +01:00
|
|
|
echo '<div class="action-buttons" style="width: '.$table->width.'">';
|
|
|
|
echo '<form action="index.php?sec=godgismaps&sec2=godmode/gis_maps/configure_gis_map" method="post">';
|
|
|
|
html_print_input_hidden('action', 'new_map');
|
|
|
|
html_print_submit_button(__('Create'), '', false, 'class="sub next"');
|
|
|
|
echo '</form>';
|
|
|
|
echo '</div>';
|
2016-01-19 13:16:38 +01:00
|
|
|
}
|
|
|
|
|
2019-01-30 16:18:44 +01:00
|
|
|
unset($table);
|
2015-11-25 08:39:18 +01:00
|
|
|
?>
|
2016-01-19 13:16:38 +01:00
|
|
|
|
|
|
|
<script type="text/javascript">
|
2019-01-30 16:18:44 +01:00
|
|
|
var defaultMapId = "<?php echo $defaultMapId; ?>";
|
|
|
|
|
|
|
|
function confirmDelete() {
|
|
|
|
if (confirm('<?php echo __('Caution: Do you want delete the map?'); ?>'))
|
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
function setDefault(id_tgis_map) {
|
|
|
|
if (confirm('<?php echo __('Do you want to set default the map?'); ?>')) {
|
|
|
|
jQuery.ajax ({
|
|
|
|
data: "page=operation/gis_maps/gis_map&action=set_default&id_map=" + id_tgis_map,
|
|
|
|
type: "POST",
|
|
|
|
dataType: 'json',
|
|
|
|
url: "ajax.php",
|
|
|
|
success: function (data) {
|
|
|
|
if (data.correct == 0) {
|
2019-05-14 11:11:27 +02:00
|
|
|
alert("<?php echo __('There was error on setup the default map.'); ?>");
|
2019-01-30 16:18:44 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
jQuery.each($("input[name=default_map]"), function() {
|
|
|
|
if ($(this).val() == defaultMapId) {
|
|
|
|
$(this).attr("checked", "checked");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$(this).removeAttr("checked");
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
2016-01-19 13:16:38 +01:00
|
|
|
</script>
|