123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136 |
- var Bizgaze;
- (function (Bizgaze) {
- let Apps;
- (function (Apps) {
- let Transact;
- (function (Transact) {
- let Controls;
- (function (Controls) {
- class Logistics extends Unibase.Platform.Core.BaseComponent {
- init(formpropertyid, prop, callback) {
- var instance = this;
- var companyId = 0;
- if (Unibase.Platform.Membership.Infos.Identity.getCurrentUser().settings != null) {
- var companySetting = Unibase.Platform.Membership.Infos.Identity.getCurrentUser().settings.find(x => x.settingName == "companyid");
- if (companySetting != null) {
- companyId = companySetting.settingValue;
- var Parameters = [{ "ColumnName": "companyid", "Value": companyId, }];
- Unibase.Forms.Controls.AutoComplete.Instance().LoadAutoComplete($(".txtAutoComplete_fromaddressid"), Parameters);
- }
- else {
- $(".txtAutoComplete_leadid").attr("disabled", "disabled");
- Unibase.Platform.Forms.Components.FormViewer.Instance().showError("Please Configure Default Branch");
- }
- }
- else {
- $(".txtAutoComplete_leadid").attr("disabled", "disabled");
- Unibase.Platform.Forms.Components.FormViewer.Instance().showError("Please Configure Default Branch");
- }
- var Parameters = [{ "ColumnName": "contactid", "Value": Number($(".txtAutoComplete_leadid option:selected").val()), }];
- Unibase.Forms.Controls.AutoComplete.Instance().LoadAutoComplete($(".txtAutoComplete_toaddressid"), Parameters);
- $(".txtAutoComplete_leadid").change(function () {
- var Parameters = [{ "ColumnName": "contactid", "Value": Number($(".txtAutoComplete_leadid option:selected").val()), }];
- Unibase.Forms.Controls.AutoComplete.Instance().LoadAutoComplete($(".txtAutoComplete_toaddressid"), Parameters);
- setTimeout(function () {
- var Number = $('.txtAutoComplete_leadid').attr("data-addldata");
- if (Number != undefined) {
- $(".txt_contactnumber").val(Number);
- }
- }, 200);
- });
- Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFiles(["apps/transact/controls/pricelist/managers/pricelistmanager.js", "apps/transact/managers/inventory/itemmanager.js"], function () {
- $(".txtAutoComplete_itemid").change(function () {
- Bizgaze.Apps.Transact.Managers.PriceListManager.Instance().getPriceValue(Number($(".txtAutoComplete_itemid option:selected").val())).then(function (response) {
- if (response.result != null) {
- $(".txt_unitprice").val(response.result.ListPrice);
- }
- });
- Bizgaze.Apps.Transact.Managers.ItemManager.Instance().getItem(Number($(".txtAutoComplete_itemid option:selected").val())).then(function (response) {
- if (response.result != null) {
- $(".txt_height").val(response.result.ItemHeight);
- $(".txt_length").val(response.result.ItemLength);
- $(".txt_width").val(response.result.ItemWidth);
- $(".txt_weight").val(response.result.ItemWeight);
- $(".txt_weight").attr("disabled", "disabled");
- }
- });
- });
- $(".txtAutoComplete_fromaddressid").change(function () {
- instance.getDistance();
- });
- $(".txtAutoComplete_toaddressid").change(function () {
- setTimeout(function () {
- instance.getDistance();
- }, 200);
- });
- });
- }
- getDistance() {
- var fromplace = Number($('.txtAutoComplete_fromaddressid').attr("data-addldata"));
- var apikey = 'AIzaSyBGmahAAg3EVzAUJvttDZsjdZiJenJxGt8';
- if (apikey == undefined) {
- }
- var toplace = Number($('.txtAutoComplete_toaddressid').attr("data-addldata"));
- if (toplace == 0) {
- $('.txt_distance').val(0);
- }
- else {
- $.ajax({
- url: "https://maps.googleapis.com/maps/api/geocode/json?address=" + fromplace + "%20%22&key=" + apikey + "&sensor=false",
- method: "POST",
- success: function (data) {
- let latitude, longitude, flatitude, flongitude;
- flatitude = data.results[0].geometry.location.lat;
- flongitude = data.results[0].geometry.location.lng;
- $.ajax({
- url: "https://maps.googleapis.com/maps/api/geocode/json?address=" + toplace + "%20%22&key=" + apikey + "&sensor=false",
- method: "POST",
- success: function (_data) {
- latitude = _data.results[0].geometry.location.lat;
- longitude = _data.results[0].geometry.location.lng;
- var dd = getDistanceFromLatLonInKm(flatitude, flongitude, latitude, longitude);
- $('.txt_distance').val(Math.round(dd));
- }
- });
- }
- });
- function getDistanceFromLatLonInKm(lat1, lon1, lat2, lon2) {
- var R = 6371;
- var dLat = deg2rad(lat2 - lat1);
- var dLon = deg2rad(lon2 - lon1);
- var a = Math.sin(dLat / 2) * Math.sin(dLat / 2) +
- Math.cos(deg2rad(lat1)) * Math.cos(deg2rad(lat2)) *
- Math.sin(dLon / 2) * Math.sin(dLon / 2);
- var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
- var d = R * c;
- return d;
- }
- function deg2rad(deg) {
- return deg * (Math.PI / 180);
- }
- }
- }
- loadControl(containerid, prop) {
- return "";
- }
- loadControlSettings(controlsettingjson, formpropertyid) {
- return "";
- }
- loadPropertySettings(propertysettings, formpropertyid, DocPropertyName) {
- return "";
- }
- bindEditFormDetails(formpropertyid, propval, DocPropertyName) {
- return "";
- }
- static Instance() {
- if (this.instance === undefined) {
- this.instance = new Logistics();
- }
- return this.instance;
- }
- }
- Controls.Logistics = Logistics;
- })(Controls = Transact.Controls || (Transact.Controls = {}));
- })(Transact = Apps.Transact || (Apps.Transact = {}));
- })(Apps = Bizgaze.Apps || (Bizgaze.Apps = {}));
- })(Bizgaze || (Bizgaze = {}));
|