|
|
|
|
@ -286,7 +286,7 @@ class ExtraField extends Model |
|
|
|
|
$option = new ExtraFieldOption($this->type); |
|
|
|
|
if (!empty($extraFields)) { |
|
|
|
|
foreach ($extraFields as &$extraField) { |
|
|
|
|
$extraField['display_text'] = self::translateDisplayName( |
|
|
|
|
$extraField['display_text'] = $this->translateDisplayName( |
|
|
|
|
$extraField['variable'], |
|
|
|
|
$extraField['display_text'] |
|
|
|
|
); |
|
|
|
|
@ -317,7 +317,7 @@ class ExtraField extends Model |
|
|
|
|
if (Database::num_rows($result)) { |
|
|
|
|
$row = Database::fetch_array($result, 'ASSOC'); |
|
|
|
|
if ($row) { |
|
|
|
|
$row['display_text'] = self::translateDisplayName( |
|
|
|
|
$row['display_text'] = $this->translateDisplayName( |
|
|
|
|
$row['variable'], |
|
|
|
|
$row['display_text'] |
|
|
|
|
); |
|
|
|
|
@ -355,7 +355,7 @@ class ExtraField extends Model |
|
|
|
|
$result = Database::query($sql); |
|
|
|
|
if (Database::num_rows($result)) { |
|
|
|
|
$row = Database::fetch_array($result, 'ASSOC'); |
|
|
|
|
$row['display_text'] = self::translateDisplayName( |
|
|
|
|
$row['display_text'] = $this->translateDisplayName( |
|
|
|
|
$row['variable'], |
|
|
|
|
$row['display_text'] |
|
|
|
|
); |
|
|
|
|
@ -525,7 +525,7 @@ class ExtraField extends Model |
|
|
|
|
$form->addHidden('item_id', $itemId); |
|
|
|
|
$extraData = false; |
|
|
|
|
if (!empty($itemId)) { |
|
|
|
|
$extraData = self::get_handler_extra_data($itemId); |
|
|
|
|
$extraData = $this->get_handler_extra_data($itemId); |
|
|
|
|
if ($form) { |
|
|
|
|
if (!empty($showOnlyTheseFields)) { |
|
|
|
|
$setData = []; |
|
|
|
|
@ -594,7 +594,7 @@ class ExtraField extends Model |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$extra_data = []; |
|
|
|
|
$fields = self::get_all(); |
|
|
|
|
$fields = $this->get_all(); |
|
|
|
|
$field_values = new ExtraFieldValue($this->type); |
|
|
|
|
|
|
|
|
|
if (!empty($fields) > 0) { |
|
|
|
|
@ -630,10 +630,7 @@ class ExtraField extends Model |
|
|
|
|
break; |
|
|
|
|
case self::FIELD_TYPE_DOUBLE_SELECT: |
|
|
|
|
case self::FIELD_TYPE_SELECT_WITH_TEXT_FIELD: |
|
|
|
|
$selected_options = explode( |
|
|
|
|
'::', |
|
|
|
|
$field_value |
|
|
|
|
); |
|
|
|
|
$selected_options = explode('::', $field_value); |
|
|
|
|
$firstOption = isset($selected_options[0]) ? $selected_options[0] : ''; |
|
|
|
|
$secondOption = isset($selected_options[1]) ? $selected_options[1] : ''; |
|
|
|
|
$extra_data['extra_'.$field['variable']]['extra_'.$field['variable']] = $firstOption; |
|
|
|
|
@ -700,7 +697,7 @@ class ExtraField extends Model |
|
|
|
|
*/ |
|
|
|
|
public function get_field_types() |
|
|
|
|
{ |
|
|
|
|
return self::get_extra_fields_by_handler($this->type); |
|
|
|
|
return $this->get_extra_fields_by_handler($this->type); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
@ -708,7 +705,7 @@ class ExtraField extends Model |
|
|
|
|
*/ |
|
|
|
|
public function get_field_type_by_id($id) |
|
|
|
|
{ |
|
|
|
|
$types = self::get_field_types(); |
|
|
|
|
$types = $this->get_field_types(); |
|
|
|
|
if (isset($types[$id])) { |
|
|
|
|
return $types[$id]; |
|
|
|
|
} |
|
|
|
|
@ -1762,17 +1759,24 @@ class ExtraField extends Model |
|
|
|
|
$form->freeze('extra_'.$field_details['variable']); |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
case self::FIELD_TYPE_GEOLOCALIZATION_COORDINATES: |
|
|
|
|
case self::FIELD_TYPE_GEOLOCALIZATION: |
|
|
|
|
$dataValue = isset($extraData['extra_'.$field_details['variable']]) |
|
|
|
|
? $extraData['extra_'.$field_details['variable']] |
|
|
|
|
: ''; |
|
|
|
|
$form->addElement( |
|
|
|
|
|
|
|
|
|
$form->addGeoLocationMapField( |
|
|
|
|
'extra_'.$field_details['variable'], |
|
|
|
|
$field_details['display_text'], |
|
|
|
|
$dataValue |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
/*$form->addElement( |
|
|
|
|
'text', |
|
|
|
|
'extra_'.$field_details['variable'], |
|
|
|
|
$field_details['display_text'], |
|
|
|
|
['id' => 'extra_'.$field_details['variable']] |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
$form->addHidden( |
|
|
|
|
'extra_'.$field_details['variable'].'_coordinates', |
|
|
|
|
'', |
|
|
|
|
@ -1780,348 +1784,21 @@ class ExtraField extends Model |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
$form->applyFilter('extra_'.$field_details['variable'], 'stripslashes'); |
|
|
|
|
$form->applyFilter('extra_'.$field_details['variable'], 'trim'); |
|
|
|
|
if ($freezeElement) { |
|
|
|
|
$form->freeze('extra_'.$field_details['variable']); |
|
|
|
|
} |
|
|
|
|
$form->applyFilter('extra_'.$field_details['variable'], 'trim');*/ |
|
|
|
|
|
|
|
|
|
$dataValue = addslashes($dataValue); |
|
|
|
|
|
|
|
|
|
$form->addHtml(" |
|
|
|
|
<script> |
|
|
|
|
$(function() { |
|
|
|
|
if (typeof google === 'object') { |
|
|
|
|
var address = '$dataValue'; |
|
|
|
|
initializeGeo{$field_details['variable']}(address, false); |
|
|
|
|
|
|
|
|
|
$('#geolocalization_extra_{$field_details['variable']}').on('click', function() { |
|
|
|
|
var address = $('#extra_{$field_details['variable']}').val(); |
|
|
|
|
initializeGeo{$field_details['variable']}(address, false); |
|
|
|
|
return false; |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
$('#myLocation_extra_{$field_details['variable']}').on('click', function() { |
|
|
|
|
myLocation{$field_details['variable']}(); |
|
|
|
|
return false; |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
$('#extra_{$field_details['variable']}').keypress(function(event) { |
|
|
|
|
if (event.which == 13) { |
|
|
|
|
$('#geolocalization_extra_{$field_details['variable']}').click(); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$('#map_extra_{$field_details['variable']}') |
|
|
|
|
.html('<div class=\"alert alert-info\">" |
|
|
|
|
.addslashes(get_lang('YouNeedToActivateTheGoogleMapsPluginInAdminPlatformToSeeTheMap')) |
|
|
|
|
."</div>'); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
function myLocation{$field_details['variable']}() { |
|
|
|
|
if (navigator.geolocation) { |
|
|
|
|
var geoPosition = function(position) { |
|
|
|
|
var lat = position.coords.latitude; |
|
|
|
|
var lng = position.coords.longitude; |
|
|
|
|
var latLng = new google.maps.LatLng(lat, lng); |
|
|
|
|
initializeGeo{$field_details['variable']}(false, latLng) |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
var geoError = function(error) { |
|
|
|
|
console.log(error); |
|
|
|
|
alert('Geocode ".get_lang('Error').": ' + error); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
var geoOptions = { |
|
|
|
|
enableHighAccuracy: true |
|
|
|
|
}; |
|
|
|
|
navigator.geolocation.getCurrentPosition(geoPosition, geoError, geoOptions); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function initializeGeo{$field_details['variable']}(address, latLng) { |
|
|
|
|
var geocoder = new google.maps.Geocoder(); |
|
|
|
|
var latlng = new google.maps.LatLng(-34.397, 150.644); |
|
|
|
|
var myOptions = { |
|
|
|
|
zoom: 15, |
|
|
|
|
center: latlng, |
|
|
|
|
mapTypeControl: true, |
|
|
|
|
mapTypeControlOptions: { |
|
|
|
|
style: google.maps.MapTypeControlStyle.DROPDOWN_MENU |
|
|
|
|
}, |
|
|
|
|
navigationControl: true, |
|
|
|
|
mapTypeId: google.maps.MapTypeId.ROADMAP |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
map_{$field_details['variable']} = new google.maps.Map( |
|
|
|
|
document.getElementById('map_extra_{$field_details['variable']}'), |
|
|
|
|
myOptions |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
var parameter = address ? {'address': address} : latLng ? {'latLng': latLng} : false; |
|
|
|
|
|
|
|
|
|
if (geocoder && parameter) { |
|
|
|
|
geocoder.geocode(parameter, function(results, status) { |
|
|
|
|
if (status == google.maps.GeocoderStatus.OK) { |
|
|
|
|
if (status != google.maps.GeocoderStatus.ZERO_RESULTS) { |
|
|
|
|
map_{$field_details['variable']}.setCenter(results[0].geometry.location); |
|
|
|
|
//if (!address) { |
|
|
|
|
$('#extra_{$field_details['variable']}').val(results[0].formatted_address); |
|
|
|
|
$('#extra_{$field_details['variable']}_coordinates').val( |
|
|
|
|
results[0].geometry.location.lat()+','+results[0].geometry.location.lng()); |
|
|
|
|
//} |
|
|
|
|
var infowindow = new google.maps.InfoWindow({ |
|
|
|
|
content: '<b>' + $('#extra_{$field_details['variable']}').val() + '</b>', |
|
|
|
|
size: new google.maps.Size(150, 50) |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
var marker = new google.maps.Marker({ |
|
|
|
|
position: results[0].geometry.location, |
|
|
|
|
map: map_{$field_details['variable']}, |
|
|
|
|
title: $('#extra_{$field_details['variable']}').val() |
|
|
|
|
}); |
|
|
|
|
google.maps.event.addListener(marker, 'click', function() { |
|
|
|
|
infowindow.open(map_{$field_details['variable']}, marker); |
|
|
|
|
}); |
|
|
|
|
} else { |
|
|
|
|
alert('".get_lang('NotFound')."'); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
alert('Geocode ".get_lang('Error').": ".get_lang("AddressField") |
|
|
|
|
." ".get_lang('NotFound')."'); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
</script> |
|
|
|
|
"); |
|
|
|
|
if ($hideGeoLocalizationDetails) { |
|
|
|
|
$form->addHtml('<div style="display:none">'); |
|
|
|
|
} |
|
|
|
|
$form->addHtml(' |
|
|
|
|
<div class="form-group"> |
|
|
|
|
<label for="geolocalization_extra_'.$field_details['variable'].'" |
|
|
|
|
class="col-sm-2 control-label"></label> |
|
|
|
|
<div class="col-sm-8"> |
|
|
|
|
<button class="btn btn-default" |
|
|
|
|
id="geolocalization_extra_'.$field_details['variable'].'" |
|
|
|
|
name="geolocalization_extra_'.$field_details['variable'].'" |
|
|
|
|
type="submit"> |
|
|
|
|
<em class="fa fa-map-marker"></em> '.get_lang('SearchGeolocalization').' |
|
|
|
|
</button> |
|
|
|
|
<button class="btn btn-default" id="myLocation_extra_'.$field_details['variable'].'" |
|
|
|
|
name="myLocation_extra_'.$field_details['variable'].'" |
|
|
|
|
type="submit"> |
|
|
|
|
<em class="fa fa-crosshairs"></em> '.get_lang('MyLocation').' |
|
|
|
|
</button> |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
'); |
|
|
|
|
|
|
|
|
|
$form->addHtml(' |
|
|
|
|
<div class="form-group"> |
|
|
|
|
<label for="map_extra_'.$field_details['variable'].'" class="col-sm-2 control-label"> |
|
|
|
|
'.$field_details['display_text'].' - '.get_lang('Map').' |
|
|
|
|
</label> |
|
|
|
|
<div class="col-sm-8"> |
|
|
|
|
<div name="map_extra_'.$field_details['variable'].'" |
|
|
|
|
id="map_extra_'.$field_details['variable'].'" style="width:100%; height:300px;"> |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
'); |
|
|
|
|
if ($hideGeoLocalizationDetails) { |
|
|
|
|
$form->addHtml('</div>'); |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
case self::FIELD_TYPE_GEOLOCALIZATION_COORDINATES: |
|
|
|
|
$dataValue = isset($extraData['extra_'.$field_details['variable']]) |
|
|
|
|
? $extraData['extra_'.$field_details['variable']] |
|
|
|
|
: ''; |
|
|
|
|
$form->addElement( |
|
|
|
|
'text', |
|
|
|
|
'extra_'.$field_details['variable'], |
|
|
|
|
$field_details['display_text'], |
|
|
|
|
['id' => 'extra_'.$field_details['variable']] |
|
|
|
|
); |
|
|
|
|
$form->applyFilter('extra_'.$field_details['variable'], 'stripslashes'); |
|
|
|
|
$form->applyFilter('extra_'.$field_details['variable'], 'trim'); |
|
|
|
|
if ($freezeElement) { |
|
|
|
|
$form->freeze('extra_'.$field_details['variable']); |
|
|
|
|
} |
|
|
|
|
$latLag = explode(",", $dataValue); |
|
|
|
|
|
|
|
|
|
// if no value, set default coordinates value |
|
|
|
|
if (empty($dataValue)) { |
|
|
|
|
$lat = '-34.397'; |
|
|
|
|
$lng = '150.644'; |
|
|
|
|
} else { |
|
|
|
|
$lat = $latLag[0]; |
|
|
|
|
$lng = $latLag[1]; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$form->addHtml(" |
|
|
|
|
<script> |
|
|
|
|
$(document).ready(function() { |
|
|
|
|
if (typeof google === 'object') { |
|
|
|
|
var lat = '$lat'; |
|
|
|
|
var lng = '$lng'; |
|
|
|
|
var latLng = new google.maps.LatLng(lat, lng); |
|
|
|
|
initializeGeo{$field_details['variable']}(false, latLng); |
|
|
|
|
|
|
|
|
|
$('#geolocalization_extra_{$field_details['variable']}').on('click', function() { |
|
|
|
|
var latLng = $('#extra_{$field_details['variable']}').val().split(','); |
|
|
|
|
var lat = latLng[0]; |
|
|
|
|
var lng = latLng[1]; |
|
|
|
|
var latLng = new google.maps.LatLng(lat, lng); |
|
|
|
|
initializeGeo{$field_details['variable']}(false, latLng); |
|
|
|
|
return false; |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
$('#myLocation_extra_{$field_details['variable']}').on('click', function() { |
|
|
|
|
myLocation{$field_details['variable']}(); |
|
|
|
|
return false; |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
$('#extra_{$field_details['variable']}').keypress(function (event) { |
|
|
|
|
if (event.which == 13) { |
|
|
|
|
$('#geolocalization_extra_{$field_details['variable']}').click(); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$('#map_extra_{$field_details['variable']}') |
|
|
|
|
.html('<div class=\"alert alert-info\">" |
|
|
|
|
.get_lang('YouNeedToActivateTheGoogleMapsPluginInAdminPlatformToSeeTheMap') |
|
|
|
|
."</div>'); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
function myLocation{$field_details['variable']}() { |
|
|
|
|
if (navigator.geolocation) { |
|
|
|
|
var geoPosition = function(position) { |
|
|
|
|
var lat = position.coords.latitude; |
|
|
|
|
var lng = position.coords.longitude; |
|
|
|
|
var latLng = new google.maps.LatLng(lat, lng); |
|
|
|
|
initializeGeo{$field_details['variable']}(false, latLng) |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
var geoError = function(error) { |
|
|
|
|
alert('Geocode ".get_lang('Error').": ' + error); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
var geoOptions = { |
|
|
|
|
enableHighAccuracy: true |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
navigator.geolocation.getCurrentPosition(geoPosition, geoError, geoOptions); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function initializeGeo{$field_details['variable']}(address, latLng) { |
|
|
|
|
var geocoder = new google.maps.Geocoder(); |
|
|
|
|
var latlng = new google.maps.LatLng(-34.397, 150.644); |
|
|
|
|
var myOptions = { |
|
|
|
|
zoom: 15, |
|
|
|
|
center: latlng, |
|
|
|
|
mapTypeControl: true, |
|
|
|
|
mapTypeControlOptions: { |
|
|
|
|
style: google.maps.MapTypeControlStyle.DROPDOWN_MENU |
|
|
|
|
}, |
|
|
|
|
navigationControl: true, |
|
|
|
|
mapTypeId: google.maps.MapTypeId.ROADMAP |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
map_{$field_details['variable']} = new google.maps.Map( |
|
|
|
|
document.getElementById('map_extra_{$field_details['variable']}'), |
|
|
|
|
myOptions |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
var parameter = address ? {'address': address} : latLng ? {'latLng': latLng} : false; |
|
|
|
|
|
|
|
|
|
if (geocoder && parameter) { |
|
|
|
|
geocoder.geocode(parameter, function(results, status) { |
|
|
|
|
if (status == google.maps.GeocoderStatus.OK) { |
|
|
|
|
if (status != google.maps.GeocoderStatus.ZERO_RESULTS) { |
|
|
|
|
map_{$field_details['variable']}.setCenter(results[0].geometry.location); |
|
|
|
|
|
|
|
|
|
$('#extra_{$field_details['variable']}') |
|
|
|
|
.val(results[0].geometry.location.lat() + ',' + results[0].geometry.location.lng()); |
|
|
|
|
|
|
|
|
|
var infowindow = new google.maps.InfoWindow({ |
|
|
|
|
content: '<b>' + $('#extra_{$field_details['variable']}').val() + '</b>', |
|
|
|
|
size: new google.maps.Size(150, 50) |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
var marker = new google.maps.Marker({ |
|
|
|
|
position: results[0].geometry.location, |
|
|
|
|
map: map_{$field_details['variable']}, |
|
|
|
|
title: $('#extra_{$field_details['variable']}').val() |
|
|
|
|
}); |
|
|
|
|
google.maps.event.addListener(marker, 'click', function() { |
|
|
|
|
infowindow.open(map_{$field_details['variable']}, marker); |
|
|
|
|
}); |
|
|
|
|
} else { |
|
|
|
|
alert('".get_lang("NotFound")."'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
alert('Geocode ".get_lang('Error').": ' + status); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
</script> |
|
|
|
|
"); |
|
|
|
|
$form->addHtml(' |
|
|
|
|
<div class="form-group"> |
|
|
|
|
<label for="geolocalization_extra_'.$field_details['variable'].'" |
|
|
|
|
class="col-sm-2 control-label"></label> |
|
|
|
|
<div class="col-sm-8"> |
|
|
|
|
<button class="null btn btn-default " |
|
|
|
|
id="geolocalization_extra_'.$field_details['variable'].'" |
|
|
|
|
name="geolocalization_extra_'.$field_details['variable'].'" |
|
|
|
|
type="submit"> |
|
|
|
|
<em class="fa fa-map-marker"></em> '.get_lang('Geolocalization').' |
|
|
|
|
</button> |
|
|
|
|
<button class="null btn btn-default" |
|
|
|
|
id="myLocation_extra_'.$field_details['variable'].'" |
|
|
|
|
name="myLocation_extra_'.$field_details['variable'].'" type="submit"> |
|
|
|
|
<em class="fa fa-crosshairs"></em> '.get_lang('MyLocation').' |
|
|
|
|
</button> |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
'); |
|
|
|
|
|
|
|
|
|
$form->addHtml(' |
|
|
|
|
<div class="form-group"> |
|
|
|
|
<label for="map_extra_'.$field_details['variable'].'" class="col-sm-2 control-label"> |
|
|
|
|
'.$field_details['display_text'].' - '.get_lang('Map').' |
|
|
|
|
</label> |
|
|
|
|
<div class="col-sm-8"> |
|
|
|
|
<div name="map_extra_'.$field_details['variable'].'" |
|
|
|
|
id="map_extra_'.$field_details['variable'].'" |
|
|
|
|
style="width:100%; height:300px;"> |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
'); |
|
|
|
|
break; |
|
|
|
|
case self::FIELD_TYPE_SELECT_WITH_TEXT_FIELD: |
|
|
|
|
$jquery_ready_content .= self::addSelectWithTextFieldElement( |
|
|
|
|
$jquery_ready_content .= $this->addSelectWithTextFieldElement( |
|
|
|
|
$form, |
|
|
|
|
$field_details, |
|
|
|
|
$freezeElement |
|
|
|
|
); |
|
|
|
|
break; |
|
|
|
|
case self::FIELD_TYPE_TRIPLE_SELECT: |
|
|
|
|
$jquery_ready_content .= self::addTripleSelectElement( |
|
|
|
|
$jquery_ready_content .= $this->addTripleSelectElement( |
|
|
|
|
$form, |
|
|
|
|
$field_details, |
|
|
|
|
is_array($extraData) ? $extraData : [], |
|
|
|
|
@ -3361,7 +3038,7 @@ JAVASCRIPT; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$options = self::extra_field_double_select_convert_array_to_ordered_array($fieldDetails['options']); |
|
|
|
|
$options = $this->extra_field_double_select_convert_array_to_ordered_array($fieldDetails['options']); |
|
|
|
|
$values = ['' => get_lang('Select')]; |
|
|
|
|
|
|
|
|
|
$second_values = []; |
|
|
|
|
@ -3436,7 +3113,7 @@ JAVASCRIPT; |
|
|
|
|
}); |
|
|
|
|
"; |
|
|
|
|
|
|
|
|
|
$options = self::extra_field_double_select_convert_array_to_ordered_array($fieldDetails['options']); |
|
|
|
|
$options = $this->extra_field_double_select_convert_array_to_ordered_array($fieldDetails['options']); |
|
|
|
|
$values = ['' => get_lang('Select')]; |
|
|
|
|
|
|
|
|
|
if (!empty($options)) { |
|
|
|
|
@ -3583,13 +3260,13 @@ JAVASCRIPT; |
|
|
|
|
? $extraData["extra_$variable"]["extra_{$variable}_second"] |
|
|
|
|
: ''; |
|
|
|
|
|
|
|
|
|
$options = self::tripleSelectConvertArrayToOrderedArray($fieldDetails['options']); |
|
|
|
|
$options = $this->tripleSelectConvertArrayToOrderedArray($fieldDetails['options']); |
|
|
|
|
$values1 = ['' => $langSelect]; |
|
|
|
|
$values2 = ['' => $langSelect]; |
|
|
|
|
$values3 = ['' => $langSelect]; |
|
|
|
|
$level1 = self::getOptionsFromTripleSelect($options['level1'], 0); |
|
|
|
|
$level2 = self::getOptionsFromTripleSelect($options['level2'], $firstId); |
|
|
|
|
$level3 = self::getOptionsFromTripleSelect($options['level3'], $secondId); |
|
|
|
|
$level1 = $this->getOptionsFromTripleSelect($options['level1'], 0); |
|
|
|
|
$level2 = $this->getOptionsFromTripleSelect($options['level2'], $firstId); |
|
|
|
|
$level3 = $this->getOptionsFromTripleSelect($options['level3'], $secondId); |
|
|
|
|
/** @var \HTML_QuickForm_select $slctFirst */ |
|
|
|
|
$slctFirst = $form->createElement('select', "extra_$variable", null, $values1, ['id' => $slctFirstId]); |
|
|
|
|
/** @var \HTML_QuickForm_select $slctFirst */ |
|
|
|
|
@ -3626,4 +3303,198 @@ JAVASCRIPT; |
|
|
|
|
|
|
|
|
|
return $js; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @param string $variable |
|
|
|
|
* @param string $dataValue |
|
|
|
|
* |
|
|
|
|
* @return string |
|
|
|
|
*/ |
|
|
|
|
public static function getLocalizationJavascript($variable, $dataValue) |
|
|
|
|
{ |
|
|
|
|
$dataValue = addslashes($dataValue); |
|
|
|
|
$html = "<script> |
|
|
|
|
$(function() { |
|
|
|
|
if (typeof google === 'object') { |
|
|
|
|
var address = '$dataValue'; |
|
|
|
|
initializeGeo{$variable}(address, false); |
|
|
|
|
|
|
|
|
|
$('#geolocalization_extra_{$variable}').on('click', function() { |
|
|
|
|
var address = $('#{$variable}').val(); |
|
|
|
|
initializeGeo{$variable}(address, false); |
|
|
|
|
return false; |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
$('#myLocation_extra_{$variable}').on('click', function() { |
|
|
|
|
myLocation{$variable}(); |
|
|
|
|
return false; |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
// When clicking enter |
|
|
|
|
$('#{$variable}').keypress(function(event) { |
|
|
|
|
if (event.which == 13) { |
|
|
|
|
$('#geolocalization_extra_{$variable}').click(); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
// On focus out update city |
|
|
|
|
$('#{$variable}').focusout(function() { |
|
|
|
|
$('#geolocalization_extra_{$variable}').click(); |
|
|
|
|
return false; |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$('#map_extra_{$variable}') |
|
|
|
|
.html('<div class=\"alert alert-info\">" |
|
|
|
|
.addslashes(get_lang('YouNeedToActivateTheGoogleMapsPluginInAdminPlatformToSeeTheMap')) |
|
|
|
|
."</div>'); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
function myLocation{$variable}() |
|
|
|
|
{ |
|
|
|
|
if (navigator.geolocation) { |
|
|
|
|
var geoPosition = function(position) { |
|
|
|
|
var lat = position.coords.latitude; |
|
|
|
|
var lng = position.coords.longitude; |
|
|
|
|
var latLng = new google.maps.LatLng(lat, lng); |
|
|
|
|
initializeGeo{$variable}(false, latLng); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
var geoError = function(error) { |
|
|
|
|
alert('Geocode ".get_lang('Error').": ' + error); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
var geoOptions = { |
|
|
|
|
enableHighAccuracy: true |
|
|
|
|
}; |
|
|
|
|
navigator.geolocation.getCurrentPosition(geoPosition, geoError, geoOptions); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function initializeGeo{$variable}(address, latLng) |
|
|
|
|
{ |
|
|
|
|
var geocoder = new google.maps.Geocoder(); |
|
|
|
|
var latlng = new google.maps.LatLng(-34.397, 150.644); |
|
|
|
|
var myOptions = { |
|
|
|
|
zoom: 15, |
|
|
|
|
center: latlng, |
|
|
|
|
mapTypeControl: true, |
|
|
|
|
mapTypeControlOptions: { |
|
|
|
|
style: google.maps.MapTypeControlStyle.DROPDOWN_MENU |
|
|
|
|
}, |
|
|
|
|
navigationControl: true, |
|
|
|
|
mapTypeId: google.maps.MapTypeId.ROADMAP |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
map_{$variable} = new google.maps.Map( |
|
|
|
|
document.getElementById('map_extra_{$variable}'), |
|
|
|
|
myOptions |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
var parameter = address ? {'address': address} : latLng ? {'latLng': latLng} : false; |
|
|
|
|
|
|
|
|
|
if (geocoder && parameter) { |
|
|
|
|
geocoder.geocode(parameter, function(results, status) { |
|
|
|
|
if (status == google.maps.GeocoderStatus.OK) { |
|
|
|
|
if (status != google.maps.GeocoderStatus.ZERO_RESULTS) { |
|
|
|
|
map_{$variable}.setCenter(results[0].geometry.location); |
|
|
|
|
|
|
|
|
|
// get city and country |
|
|
|
|
var defaultAddress = results[0].formatted_address; |
|
|
|
|
var city = ''; |
|
|
|
|
var country = ''; |
|
|
|
|
|
|
|
|
|
for (var i=0; i<results[0].address_components.length; i++) { |
|
|
|
|
if (results[0].address_components[i].types[0] == \"locality\") { |
|
|
|
|
//this is the object you are looking for City |
|
|
|
|
city = results[0].address_components[i]; |
|
|
|
|
} |
|
|
|
|
/*if (results[j].address_components[i].types[0] == \"administrative_area_level_1\") { |
|
|
|
|
//this is the object you are looking for State |
|
|
|
|
region = results[0].address_components[i]; |
|
|
|
|
}*/ |
|
|
|
|
if (results[0].address_components[i].types[0] == \"country\") { |
|
|
|
|
//this is the object you are looking for |
|
|
|
|
country = results[0].address_components[i]; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (city && city.long_name && country && country.long_name) { |
|
|
|
|
defaultAddress = city.long_name + ', ' + country.long_name; |
|
|
|
|
} |
|
|
|
|
$('#{$variable}').val(defaultAddress); |
|
|
|
|
$('#{$variable}_coordinates').val( |
|
|
|
|
results[0].geometry.location.lat()+','+results[0].geometry.location.lng() |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
var infowindow = new google.maps.InfoWindow({ |
|
|
|
|
content: '<b>' + $('#extra_{$variable}').val() + '</b>', |
|
|
|
|
size: new google.maps.Size(150, 50) |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
var marker = new google.maps.Marker({ |
|
|
|
|
position: results[0].geometry.location, |
|
|
|
|
map: map_{$variable}, |
|
|
|
|
title: $('#extra_{$variable}').val() |
|
|
|
|
}); |
|
|
|
|
google.maps.event.addListener(marker, 'click', function() { |
|
|
|
|
infowindow.open(map_{$variable}, marker); |
|
|
|
|
}); |
|
|
|
|
} else { |
|
|
|
|
alert('".get_lang('NotFound')."'); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
alert('Geocode ".get_lang('Error').": ".get_lang("AddressField")." ".get_lang('NotFound')."'); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
</script>"; |
|
|
|
|
|
|
|
|
|
return $html; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @param string $variable |
|
|
|
|
* @param string $text |
|
|
|
|
* |
|
|
|
|
* @return string |
|
|
|
|
*/ |
|
|
|
|
public static function getLocalizationInput($variable, $text) |
|
|
|
|
{ |
|
|
|
|
$html = ' |
|
|
|
|
<div class="form-group"> |
|
|
|
|
<label for="geolocalization_extra_'.$variable.'" |
|
|
|
|
class="col-sm-2 control-label"></label> |
|
|
|
|
<div class="col-sm-8"> |
|
|
|
|
<button class="btn btn-default" |
|
|
|
|
id="geolocalization_extra_'.$variable.'" |
|
|
|
|
name="geolocalization_extra_'.$variable.'" |
|
|
|
|
type="submit"> |
|
|
|
|
<em class="fa fa-map-marker"></em> '.get_lang('SearchGeolocalization').' |
|
|
|
|
</button> |
|
|
|
|
<button class="btn btn-default" id="myLocation_extra_'.$variable.'" |
|
|
|
|
name="myLocation_extra_'.$variable.'" |
|
|
|
|
type="submit"> |
|
|
|
|
<em class="fa fa-crosshairs"></em> '.get_lang('MyLocation').' |
|
|
|
|
</button> |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
<div class="form-group"> |
|
|
|
|
<label for="map_extra_'.$variable.'" class="col-sm-2 control-label"> |
|
|
|
|
'.$text.' - '.get_lang('Map').' |
|
|
|
|
</label> |
|
|
|
|
<div class="col-sm-8"> |
|
|
|
|
<div name="map_extra_'.$variable.'" |
|
|
|
|
id="map_extra_'.$variable.'" style="width:100%; height:300px;"> |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
'; |
|
|
|
|
|
|
|
|
|
return $html; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|