Iniit
This commit is contained in:
@@ -0,0 +1,125 @@
|
||||
var Bizgaze;
|
||||
(function (Bizgaze) {
|
||||
let Apps;
|
||||
(function (Apps) {
|
||||
let Hrms;
|
||||
(function (Hrms) {
|
||||
let Controls;
|
||||
(function (Controls) {
|
||||
class geofencingmap extends Unibase.Platform.Core.BaseComponent {
|
||||
init(formpropertyid, prop, callback) {
|
||||
var _id = $(".formValidate:visible").attr("id");
|
||||
var slt = _id.split('_');
|
||||
var map11 = $('#locationcontrol_' + formpropertyid);
|
||||
map11.geocomplete({ details: "form.form_" + slt[1] });
|
||||
var instance = this;
|
||||
instance.loadControlSettings(prop.ControlJsonText, prop.FormPropertyId);
|
||||
instance.loadPropertySettings(prop.PropertySettings, prop.FormPropertyId);
|
||||
}
|
||||
loadControl(containerid, prop) {
|
||||
var html = '<div id="GeofencingMap" class="text-center b-a" style="height: 250px"></div>' +
|
||||
'<div class="coordinates"><span id="lbl_coordinates"></span></div><input type="hidden" id="hfLattitude" name="lat" value="">' +
|
||||
'<input type ="hidden" id = "hfLongitude" name = "lng" value = "" >';
|
||||
$("#" + containerid).html(html);
|
||||
var latd = 0;
|
||||
var lgtd = 0;
|
||||
$('#hfLattitude').val(latd);
|
||||
$('#hfLongitude').val(lgtd);
|
||||
$("#lbl_coordinates").html("latd : " + latd + ", lgtd : " + lgtd);
|
||||
Bizgaze.Apps.Hrms.Controls.geofencingmap.Instance().loadMap(latd, lgtd, prop.FormPropertyId);
|
||||
}
|
||||
loadMap(latd, lgtd, formpropertyid) {
|
||||
var instance = this;
|
||||
var myLatlng = new google.maps.LatLng(latd, lgtd);
|
||||
var mapOptions = {
|
||||
zoom: 15,
|
||||
center: myLatlng,
|
||||
draggable: true,
|
||||
};
|
||||
let radius = Number($("#div_radius").find(".number_radius").val());
|
||||
var myCity = new google.maps.Circle({
|
||||
center: myLatlng,
|
||||
radius: radius,
|
||||
strokeColor: "#87C1FF",
|
||||
strokeOpacity: 0.8,
|
||||
strokeWeight: 2,
|
||||
fillColor: "#87C1FF",
|
||||
fillOpacity: 0.4
|
||||
});
|
||||
var map = new google.maps.Map(document.getElementById("GeofencingMap"), mapOptions);
|
||||
myCity.setMap(map);
|
||||
var marker = new google.maps.Marker({
|
||||
position: myLatlng,
|
||||
title: "",
|
||||
});
|
||||
marker.setMap(map);
|
||||
var url = "https://maps.googleapis.com/maps/api/geocode/json?latlng=" + latd + "," + lgtd + "&key=" + _mapsettings.key() + "&sensor=false";
|
||||
var xhr = Bizgaze.Apps.Hrms.Controls.geofencingmap.Instance().createCORSRequest2('Get', url);
|
||||
if (!xhr) {
|
||||
bootbox.alert('CORS not supported');
|
||||
return;
|
||||
}
|
||||
xhr.onload = function () {
|
||||
var text = xhr.responseText;
|
||||
var json = JSON.parse(text);
|
||||
instance.addressData = [];
|
||||
instance.addressData = json.results;
|
||||
$("#locationcontrol_" + formpropertyid).val(json.results[0].formatted_address);
|
||||
};
|
||||
xhr.onerror = function () {
|
||||
bootbox.alert('Woops, there was an error making the request.');
|
||||
};
|
||||
}
|
||||
getLocation(formpropertyid) {
|
||||
var ContactAddressId = Number($("#hf_AutocompleteId").val());
|
||||
var latitude = 0;
|
||||
var longitude = 0;
|
||||
this.fileCacheHelper.addCacheFiles(["apps/crm/contacts/managers/contactmanager.js"]);
|
||||
Bizgaze.Apps.Crm.Contacts.Managers.ContactManager.Instance().getAddressById(ContactAddressId).then(function (response) {
|
||||
latitude = response.result.AddrLatd;
|
||||
longitude = response.result.AddrLgtd;
|
||||
if (latitude == 0 || longitude == 0 || latitude == null || longitude == null) {
|
||||
MessageHelper.Instance().showError("You are Selected Branch Geo Tagging is not Enabled longitude : " + longitude + " , latitude : " + latitude, 'div_ErrorMessage_' + $('#' + Unibase.Platform.Helpers.NavigationHelper.Instance().getLastContainerId()).find('#hf_FormId').val());
|
||||
}
|
||||
$("#div_latitude").find(".number_latitude").val(+latitude);
|
||||
$("#div_longitude").find(".number_longitude").val(+longitude);
|
||||
$("#lbl_coordinates").html("latd : " + latitude + ", lgtd : " + longitude);
|
||||
Bizgaze.Apps.Hrms.Controls.geofencingmap.Instance().loadMap(latitude, longitude, formpropertyid);
|
||||
});
|
||||
}
|
||||
createCORSRequest2(method, url) {
|
||||
let XDomainRequest;
|
||||
var xhr = new XMLHttpRequest();
|
||||
if ("withCredentials" in xhr) {
|
||||
xhr.open(method, url, true);
|
||||
}
|
||||
else if (typeof XDomainRequest != "undefined") {
|
||||
xhr = new XDomainRequest();
|
||||
xhr.open(method, url);
|
||||
}
|
||||
else {
|
||||
xhr = null;
|
||||
}
|
||||
return xhr;
|
||||
}
|
||||
loadControlSettings(controlsettingjson, formpropertyid) {
|
||||
return null;
|
||||
}
|
||||
loadPropertySettings(propertysettings, formpropertyid) {
|
||||
return null;
|
||||
}
|
||||
bindEditFormDetails(formpropertyid, propval, DocPropertyName) {
|
||||
return null;
|
||||
}
|
||||
static Instance() {
|
||||
if (this.instance === undefined) {
|
||||
this.instance = new geofencingmap();
|
||||
}
|
||||
return this.instance;
|
||||
}
|
||||
}
|
||||
Controls.geofencingmap = geofencingmap;
|
||||
})(Controls = Hrms.Controls || (Hrms.Controls = {}));
|
||||
})(Hrms = Apps.Hrms || (Apps.Hrms = {}));
|
||||
})(Apps = Bizgaze.Apps || (Bizgaze.Apps = {}));
|
||||
})(Bizgaze || (Bizgaze = {}));
|
||||
@@ -0,0 +1,39 @@
|
||||
var Bizgaze;
|
||||
(function (Bizgaze) {
|
||||
let Apps;
|
||||
(function (Apps) {
|
||||
let Hrms;
|
||||
(function (Hrms) {
|
||||
let Controls;
|
||||
(function (Controls) {
|
||||
class GeofencingMap_Settings {
|
||||
loadSettingHtml() {
|
||||
return ``;
|
||||
}
|
||||
bindControlData(controldatajson) {
|
||||
return "";
|
||||
}
|
||||
SaveControlData(controldatajson) {
|
||||
return "";
|
||||
}
|
||||
loadControlPropertiesHtml(Container) {
|
||||
return "";
|
||||
}
|
||||
bindPropertySettings(prop) {
|
||||
return "";
|
||||
}
|
||||
savePropertySettings(prop) {
|
||||
return "";
|
||||
}
|
||||
static Instance() {
|
||||
if (this.instance === undefined) {
|
||||
this.instance = new GeofencingMap_Settings();
|
||||
}
|
||||
return this.instance;
|
||||
}
|
||||
}
|
||||
Controls.GeofencingMap_Settings = GeofencingMap_Settings;
|
||||
})(Controls = Hrms.Controls || (Hrms.Controls = {}));
|
||||
})(Hrms = Apps.Hrms || (Apps.Hrms = {}));
|
||||
})(Apps = Bizgaze.Apps || (Bizgaze.Apps = {}));
|
||||
})(Bizgaze || (Bizgaze = {}));
|
||||
Reference in New Issue
Block a user