diff --git a/pandora_console/godmode/gis_maps/configure_gis_map.php b/pandora_console/godmode/gis_maps/configure_gis_map.php index c716cca43f..5b68afaf37 100644 --- a/pandora_console/godmode/gis_maps/configure_gis_map.php +++ b/pandora_console/godmode/gis_maps/configure_gis_map.php @@ -44,7 +44,7 @@ $sec2 = safe_url_extraclean($sec2); $sec = get_parameter_get('sec'); $sec = safe_url_extraclean($sec); -// Layers +// Layers. $layer_ids = get_parameter('layer_ids', []); $layers = get_parameter('layers', []); $layer_list = []; @@ -84,9 +84,10 @@ switch ($action) { $map_default_latitude = get_parameter('map_default_latitude'); $map_default_altitude = get_parameter('map_default_altitude'); $map_group_id = get_parameter('map_group_id'); - $map_levels_zoom = get_parameter('map_levels_zoom'); + $map_levels_zoom = get_parameter('map_levels_zoom', 16); $map_connection_list_temp = explode(',', get_parameter('map_connection_list')); + $listConnectionTemp = db_get_all_rows_sql('SELECT id_tmap_connection, conection_name, group_id FROM tgis_map_connection'); foreach ($map_connection_list_temp as $index => $value) { @@ -99,14 +100,14 @@ switch ($action) { $map_connection_default = get_parameter('map_connection_default'); $map_connection_list = []; - foreach ($map_connection_list_temp as $idMapConnection) { + foreach ($listConnectionTemp as $idMapConnection) { $default = 0; - if ($map_connection_default == $idMapConnection) { + if ($map_connection_default == $idMapConnection['id_tmap_connection']) { $default = 1; } $map_connection_list[] = [ - 'id_conection' => $idMapConnection, + 'id_conection' => $idMapConnection['id_tmap_connection'], 'default' => $default, ]; } @@ -124,7 +125,7 @@ switch ($action) { $map_levels_zoom ); - if (empty($invalidFields) && get_parameter('map_connection_list') != '') { + if (empty($invalidFields)) { $idMap = gis_save_map( $map_name, $map_initial_longitude, @@ -139,8 +140,13 @@ switch ($action) { $map_connection_list, $layer_list ); - $mapCreatedOk = true; - $next_action = 'update_saved'; + if ($idMap) { + $mapCreatedOk = true; + $next_action = 'update_saved'; + } else { + $next_action = 'save_new'; + $mapCreatedOk = false; + } } else { $next_action = 'save_new'; $mapCreatedOk = false; @@ -168,7 +174,7 @@ switch ($action) { $map_group_id = ''; $map_connection_list = []; $layer_list = []; - $map_levels_zoom = 0; + $map_levels_zoom = 16; break; case 'edit_map': @@ -188,9 +194,12 @@ switch ($action) { $map_default_latitude = get_parameter('map_default_latitude'); $map_default_altitude = get_parameter('map_default_altitude'); $map_group_id = get_parameter('map_group_id'); - $map_levels_zoom = get_parameter('map_levels_zoom'); + $map_levels_zoom = get_parameter('map_levels_zoom', 16); $map_connection_list_temp = explode(',', get_parameter('map_connection_list')); + + $listConnectionTemp = db_get_all_rows_sql('SELECT id_tmap_connection, conection_name, group_id FROM tgis_map_connection'); + foreach ($map_connection_list_temp as $index => $value) { $cleanValue = trim($value); if ($cleanValue == '') { @@ -201,14 +210,14 @@ switch ($action) { $map_connection_default = get_parameter('map_connection_default'); $map_connection_list = []; - foreach ($map_connection_list_temp as $idMapConnection) { + foreach ($listConnectionTemp as $idMapConnection) { $default = 0; - if ($map_connection_default == $idMapConnection) { + if ($map_connection_default == $idMapConnection['id_tmap_connection']) { $default = 1; } $map_connection_list[] = [ - 'id_conection' => $idMapConnection, + 'id_conection' => $idMapConnection['id_tmap_connection'], 'default' => $default, ]; } @@ -226,7 +235,7 @@ switch ($action) { $map_levels_zoom ); - if (empty($invalidFields) && get_parameter('map_connection_list') != '') { + if (empty($invalidFields)) { // TODO gis_update_map( $idMap, @@ -263,7 +272,7 @@ switch ($action) { $url = 'index.php?sec='.$sec.'&sec2='.$sec2.'&map_id='.$idMap.'&action='.$next_action; $buttons['gis_maps_list'] = [ - 'active' => true, + 'active' => false, 'text' => ''.html_print_image( 'images/list.png', true, @@ -275,7 +284,7 @@ $buttons['gis_maps_list'] = [ ]; if ($idMap) { $buttons['view_gis'] = [ - 'active' => true, + 'active' => false, 'text' => ''.html_print_image( 'images/op_gis.png', true, @@ -457,7 +466,7 @@ $table->data[1][0] = __('Add Map connection').$iconError; $table->data[1][1] = "'; -// Group items +// Group items. $group_select = html_print_select_groups($config['id_user'], 'AR', false, 'layer_group_id', '', '', '', 0, true); $params = []; $params['return'] = true; @@ -597,8 +613,10 @@ $params['input_name'] = 'agent_alias_for_data'; $params['value'] = ''; $params['javascript_function_action_after_select'] = 'toggleAddGroupBtn'; $params['selectbox_group'] = 'layer_group_id'; -// Filter by group -$params['disabled_javascript_on_blur_function'] = true; +$params['javascript_is_function_select'] = true; + +// Filter by group. +$params['disabled_javascript_on_blur_function'] = false; $agent_for_group_input = ui_print_agent_autocomplete_input($params); $add_group_btn = html_print_button(__('Add'), 'add_group', true, '', 'class="sub add"', true); diff --git a/pandora_console/godmode/setup/gis_step_2.php b/pandora_console/godmode/setup/gis_step_2.php index ff1b110b1c..2ec5deb0d9 100644 --- a/pandora_console/godmode/setup/gis_step_2.php +++ b/pandora_console/godmode/setup/gis_step_2.php @@ -278,26 +278,26 @@ if ($mapConnectionData != null) { } } -// Open Street Map Connection. -$optionsConnectionOSMTable = '
- ".html_print_select($listConnection, 'map_connection', '', '', '', '0', true)." + ".html_print_select($listConnection, 'map_connection_list', '', '', '', '0', true)." ".html_print_image( @@ -504,7 +513,11 @@ $table->data[2][1] = html_print_select_groups( ); $table->data[3][0] = __('Default zoom'); -$table->data[3][1] = html_print_input_text('map_zoom_level', $map_zoom_level, '', 2, 4, true).html_print_input_hidden('map_levels_zoom', $map_levels_zoom, true); +$table->data[3][1] = html_print_input_text('map_zoom_level', $map_zoom_level, '', 2, 4, true).html_print_input_hidden( + 'map_levels_zoom', + $map_levels_zoom, + true +); $table->data[4][0] = __('Center Latitude').':'; $table->data[4][1] = html_print_input_text('map_initial_latitude', $map_initial_latitude, '', 8, 8, true); @@ -571,6 +584,9 @@ $params['hidden_input_idagent_name'] = 'agent_id'; $params['input_name'] = 'agent_alias'; $params['value'] = ''; $params['javascript_function_action_after_select'] = 'active_button_add_agent'; +$params['javascript_is_function_select'] = true; +$params['disabled_javascript_on_blur_function'] = false; + $table->data[1][1] .= ui_print_agent_autocomplete_input($params); @@ -585,7 +601,7 @@ $table->data[1][1] .= '
'.''.''.''.''.'
'.htmlentities( - __('Tile Server URL'), - ENT_QUOTES, - 'UTF-8' -).':'.html_print_input_text( - 'url', - $mapConnectionDataUrl, - '', - 45, - 90, - true -).'
'; + // Open Street Map Connection. + $optionsConnectionOSMTable = '
'.htmlentities( + __('Tile Server URL'), + ENT_QUOTES, + 'UTF-8' + ).':'.html_print_input_text( + 'url', + $mapConnectionDataUrl, + '', + 45, + 90, + true + ).'
'; // Google Maps Connection. $gmaps_types['G_PHYSICAL_MAP'] = __('Google Physical'); $gmaps_types['G_HYBRID_MAP'] = __('Google Hybrid'); $gmaps_types['G_SATELITE_MAP'] = __('Google Satelite'); // TODO: Use label tags for the forms. - $optionsConnectionGmapTable = ''.''.''.'
'.__('Google Map Type').':'.trim( + $optionsConnectionGmapTable = '
'.__('Google Map Type').':'.trim( html_print_select( $gmaps_types, 'gmap_type', @@ -305,181 +305,223 @@ $optionsConnectionOSMTable = ''.''.''.''.''.''.''.''.'
'.__('Google Maps Key').':
'.html_print_input_text( + ).'
'.__('Google Maps Key').':
'.html_print_input_text( 'gmap_key', $gmap_key, '', 90, 128, true - ).'
'; + ).'
'; // Image Map Connection. - $optionsConnectionImageTable = ''.''.''.'
'.__('Image URL').':'.html_print_input_text( + $optionsConnectionImageTable = ''.''.''.''.''.''.''.''.''.''.''.''.''.''.''.''.''.''.''.''.''.''.''.''.''.''.'
'.__('Image URL').':'.html_print_input_text( 'url', $mapConnectionDataUrl, '', 45, 90, true - ).'
'.__('Corners of the area of the image').':
'.__('Left').':'.html_print_input_text( + ).'
'.__('Corners of the area of the image').':
'.__('Left').':'.html_print_input_text( 'bb_left', $bb_left, '', 25, 25, true - ).''.__('Bottom').':'.html_print_input_text( + ).''.__('Bottom').':'.html_print_input_text( 'bb_bottom', $bb_bottom, '', 25, 25, true - ).'
'.__('Right').':'.html_print_input_text( + ).'
'.__('Right').':'.html_print_input_text( 'bb_right', $bb_right, '', 25, 25, true - ).''.__('Top').':'.html_print_input_text( + ).''.__('Top').':'.html_print_input_text( 'bb_top', $bb_top, '', 25, 25, true - ).'
'.__('Image Size').':
'.__('Width').':'.html_print_input_text('image_width', $image_width, '', 25, 25, true).''.__('Height').':'.html_print_input_text('image_height', $image_height, '', 25, 25, true).'
'; + ).'
'.__('Image Size').':
'.__('Width').':'.html_print_input_text( + 'image_width', + $image_width, + '', + 25, + 25, + true + ).''.__('Height').':'.html_print_input_text( + 'image_height', + $image_height, + '', + 25, + 25, + true + ).'
'; - // WMS Server Connection. - $optionsConnectionWMSTable = ''.''.''.''.''.''.''.''.''.'
'.__('WMS Server URL').''.''.html_print_input_text('url', $mapConnectionDataUrl, '', 90, 255, true).'
'.__('Layers').''.html_print_input_text('layers', $layers, '', 90, 255, true).'
'; + // WMS Server Connection. + $optionsConnectionWMSTable = '
'.__('WMS Server URL').''.html_print_input_text( + 'url', + $mapConnectionDataUrl, + '', + 90, + 255, + true + ).'
'.__('Layers').''.html_print_input_text( + 'layers', + $layers, + '', + 90, + 255, + true + ).'
'; - if ($mapConnectionData != null) { - switch ($mapConnection_type) { - case 'OSM': - $optionsConnectionTypeTable = $optionsConnectionOSMTable; - break; + if ($mapConnectionData != null) { + switch ($mapConnection_type) { + case 'OSM': + $optionsConnectionTypeTable = $optionsConnectionOSMTable; + break; - case 'Gmap': - $optionsConnectionTypeTable = $optionsConnectionGmapTable; - break; + case 'Gmap': + $optionsConnectionTypeTable = $optionsConnectionGmapTable; + break; - case 'Static_Image': - $optionsConnectionTypeTable = $optionsConnectionImageTable; - break; + case 'Static_Image': + $optionsConnectionTypeTable = $optionsConnectionImageTable; + break; - case 'WMS': - $optionsConnectionTypeTable = $optionsConnectionWMSTable; - break; + case 'WMS': + $optionsConnectionTypeTable = $optionsConnectionWMSTable; + break; - default: - // Default. - break; + default: + // Default. + break; + } } - } - echo "
".$optionsConnectionTypeTable.'
'; + echo "
".$optionsConnectionTypeTable.'
'; - echo '

'.__('Preview to select the center of the map and the default position of an agent without gis data').'


'; - html_print_button(__('Load preview map'), 'button_refresh', false, 'refreshMapView();', 'class="sub"'); - echo '

'; - echo "
"; + echo '

'.__('Preview to select the center of the map and the default position of an agent without gis data').'


'; + html_print_button(__('Load preview map'), 'button_refresh', false, 'refreshMapView();', 'class="sub next"'); + echo '

'; + echo "
"; - $table->width = '60%'; - $table->data = []; + $table->width = '60%'; + $table->data = []; - // $table->colspan[0][3] = 3; - $table->data[0][0] = ''; - $table->data[0][1] = __('Map Center'); - $table->data[0][2] = __('Default position for agents without GIS data'); + // $table->colspan[0][3] = 3; + $table->data[0][0] = ''; + $table->data[0][1] = __('Map Center'); + $table->data[0][2] = __('Default position for agents without GIS data'); - $table->data[1][0] = __('Change in the map'); - $table->data[1][1] = html_print_radio_button_extended( - 'radio_button', - 1, - '', - 1, - false, - 'changeSetManualPosition(true, false)', - '', - true - ); - $table->data[1][2] = html_print_radio_button_extended( - 'radio_button', - 2, - '', - 0, - false, - 'changeSetManualPosition(false, true)', - '', - true - ); + $table->data[1][0] = __('Change in the map'); + $table->data[1][1] = html_print_radio_button_extended( + 'radio_button', + 1, + '', + 1, + false, + 'changeSetManualPosition(true, false)', + '', + true + ); + $table->data[1][2] = html_print_radio_button_extended( + 'radio_button', + 2, + '', + 0, + false, + 'changeSetManualPosition(false, true)', + '', + true + ); - $table->data[2][0] = __('Latitude'); - $table->data[2][1] = html_print_input_text( - 'center_latitude', - $mapConnection_centerLatitude, - '', - 10, - 10, - true - ); - $table->data[2][2] = html_print_input_text( - 'default_latitude', - $mapConnection_defaultLatitude, - '', - 10, - 10, - true - ); + $table->data[2][0] = __('Latitude'); + $table->data[2][1] = html_print_input_text( + 'center_latitude', + $mapConnection_centerLatitude, + '', + 10, + 10, + true + ); + $table->data[2][2] = html_print_input_text( + 'default_latitude', + $mapConnection_defaultLatitude, + '', + 10, + 10, + true + ); - $table->data[3][0] = __('Longitude'); - $table->data[3][1] = html_print_input_text( - 'center_longitude', - $mapConnection_centerLongitude, - '', - 10, - 10, - true - ); - $table->data[3][2] = html_print_input_text( - 'default_longitude', - $mapConnection_defaultLongitude, - '', - 10, - 10, - true - ); + $table->data[3][0] = __('Longitude'); + $table->data[3][1] = html_print_input_text( + 'center_longitude', + $mapConnection_centerLongitude, + '', + 10, + 10, + true + ); + $table->data[3][2] = html_print_input_text( + 'default_longitude', + $mapConnection_defaultLongitude, + '', + 10, + 10, + true + ); - $table->data[4][0] = __('Altitude'); - $table->data[4][1] = html_print_input_text( - 'center_altitude', - $mapConnection_centerAltitude, - '', - 10, - 10, - true - ); - $table->data[4][2] = html_print_input_text( - 'default_altitude', - $mapConnection_defaultAltitude, - '', - 10, - 10, - true - ); - html_print_table($table); + $table->data[4][0] = __('Altitude'); + $table->data[4][1] = html_print_input_text( + 'center_altitude', + $mapConnection_centerAltitude, + '', + 10, + 10, + true + ); + $table->data[4][2] = html_print_input_text( + 'default_altitude', + $mapConnection_defaultAltitude, + '', + 10, + 10, + true + ); + html_print_table($table); - echo '
'; - html_print_submit_button(__('Save'), '', false, 'class="sub save wand"'); - echo '
'; - echo ''; + echo '
'; + html_print_submit_button(__('Save'), '', false, 'class="sub save wand"'); + echo '
'; + echo ''; - ui_require_javascript_file('OpenLayers/OpenLayers'); - ui_require_javascript_file('openlayers.pandora'); - ?> + ui_require_javascript_file('OpenLayers/OpenLayers'); + ui_require_javascript_file('openlayers.pandora'); + ?>