var Bizgaze; (function (Bizgaze) { let Apps; (function (Apps) { let Integrations; (function (Integrations) { let EWayBill; (function (EWayBill_1) { let Components; (function (Components) { class EWayBill extends Unibase.Platform.Core.BaseComponent { jsFiles() { return []; } cssFiles() { return []; } html() { return null; } load() { Bizgaze.Apps.Integrations.EWayBill.Components.EWayBill.Instance().getInvoiceDetails(); $(".txt_vehicleno").keyup(function () { $(".txt_vehicleno").val($(".txt_vehicleno").val().toString().toUpperCase()); }); $(".txt_topincode,.txt_frompincode").on("click", function () { Bizgaze.Apps.Integrations.EWayBill.Components.EWayBill.Instance().GetDistanceByPinCode(); }); } getAddressById(id) { let AutoComplete_branchid = Number($(".txtAutoComplete_branchid").val()); if (id != 0) AutoComplete_branchid = id; Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/crm/contacts/managers/contactmanager.js", function () { Bizgaze.Apps.Crm.Contacts.Managers.ContactManager.Instance().getAddressById(AutoComplete_branchid).then(function (response) { if (response.result != null) { $(".txt_frompincode").val(response.result.ZipCode).parent().addClass("floating-label-form-group-with-value"); ; $(".labelSection_FromGSTIN").html("From GSTIN : " + response.result.GSTNO + ""); Bizgaze.Apps.Integrations.EWayBill.Components.EWayBill.Instance().getDistance(); $(".hdn_fromplace").val(response.result.AliasName); $(".hdn_fromstatecode").val(response.result.StateCode); if (Number($(".txtAutoComplete_branchid").val()) == 0) { let supplytype = new Option(response.result.AliasName, AutoComplete_branchid.toString(), true); $(".txtAutoComplete_branchid").append(supplytype); $(".hfAutoCompleteId_branchid").val(AutoComplete_branchid); } } }); }); } getInvoiceDetails() { var InstalledAppId = Unibase.Themes.Providers.DetailHelper.installedAppId; if (Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + InstalledAppId + "_invoiceid") != undefined) { var invoiceid = Number(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + InstalledAppId + "_invoiceid").Value); if (invoiceid != 0) { Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFiles(["apps/transact/managers/invoicemanager.js"], function () { Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().getInvoiceDetails(invoiceid).then(function (response) { if (response.result != null) { $(".txt_frompincode").val(response.result.BillFromZipCode).parent().addClass("floating-label-form-group-with-value"); $(".txt_topincode").val(response.result.BillToZipCode).parent().addClass("floating-label-form-group-with-value"); $(".labelSection_ToGSTIN").html("To GSTIN : " + response.result.GSTNo + ""); $(".hdn_refid").val(invoiceid); $(".hdn_dcid").val(response.result.DcId); $(".hdn_invoiceid").val(invoiceid); $(".hdn_refinstalledappid").val(response.result.InstalledAppId); let supplytype = new Option("Outward", "1", true); $(".txtAutoComplete_supplytypeid").append(supplytype).val(1).trigger("change"); Bizgaze.Apps.Integrations.EWayBill.Components.EWayBill.Instance().getAddressById(response.result.BillFromAddressId); } }); }); } } else { if (Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + InstalledAppId + "_dcid") != undefined) { var dcid = Number(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + InstalledAppId + "_dcid").Value); if (dcid != 0) { Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFiles(["apps/transact/managers/inventory/dcmanager.js"], function () { Bizgaze.Apps.Transact.Managers.DCManager.Instance().getdc(dcid).then(function (response) { if (response.result != null) { $(".txt_frompincode").val(response.result.ShipFromZipCode).addClass("floating-label-form-group-with-value"); ; $(".txt_topincode").val(response.result.ShipToZipCode).addClass("floating-label-form-group-with-value"); ; $(".labelSection_ToGSTIN").html("To GSTIN : " + response.result.GSTInNo + ""); $(".hdn_isdc").val("true"); $(".hdn_refid").val(dcid); $(".hdn_invoiceid").val(response.result.InvoiceId); $(".hdn_dcid").val(dcid); $(".hdn_refinstalledappid").val(response.result.DcInstallAppId); let supplytype = new Option("Inward", "2", true); $(".txtAutoComplete_supplytypeid").append(supplytype).val(2).trigger("change"); ; Bizgaze.Apps.Integrations.EWayBill.Components.EWayBill.Instance().getAddressById(0); } }); }); } } } } getDistance() { var fromplace = Number($('.txt_frompincode').val()); var apikey = 'AIzaSyBGmahAAg3EVzAUJvttDZsjdZiJenJxGt8'; if (apikey == undefined) { } var toplace = Number($('.txt_topincode').val()); if (toplace == 0) { $('.number_approxdistance').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; if (data.results.length > 0) { 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); $('.number_approxdistance').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); } } } ShowPrintButton() { debugger; let instance = this; let InstalledAppId = Unibase.Themes.Providers.DetailHelper.installedAppId; let EWaybillId = Number(Unibase.Themes.Providers.DetailHelper.recordId); let detailContainer = "#" + Unibase.Platform.Helpers.NavigationHelper.ModalContainerIds[Unibase.Platform.Helpers.NavigationHelper.ModalContainerIds.length - 1]; $(detailContainer).find(".DetailSetting_" + InstalledAppId + "_Print").removeClass("btn-undefined").addClass("btn-warning"); $(".btn-undefined").addClass("btn-success").removeClass("btn-undefined"); instance.fileCacheHelper.loadJsFile("apps/transact/managers/ewaybill/ewaybillmanager.js", function (response) { Bizgaze.Apps.Transact.Managers.EWayBillManager.Instance().getEwayBill(EWaybillId).then(function (ewaybillresponse) { if (ewaybillresponse.result.Notes != null && ewaybillresponse.result.Notes != undefined && ewaybillresponse.result.Notes != "") { $(detailContainer).find(".li_DetailSetting_" + InstalledAppId + "_ApprovalError").remove(); $(detailContainer).find('#div_App_DefaultWidgetSettings').append(`
` + ewaybillresponse.result.Notes + `