123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268 |
- 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("<span>From GSTIN : " + response.result.GSTNO + "</span>");
- 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("<span>To GSTIN : " + response.result.GSTNo + "</span>");
- $(".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("<span>To GSTIN : " + response.result.GSTInNo + "</span>");
- $(".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(`<div><div class="ActionsApprovalError mx-20 mb-2 rounded py-10 px-0 li_DetailSetting_` + InstalledAppId + `_ApprovalError" id="li_DetailSetting_` + InstalledAppId + `_ApprovalError" style="background-color:rgb(252 250 247);border-left: 3px solid #ff6060;padding:0.5rem 1rem 1rem;"> <p class="font-14 text-danger col-sm-12">` + ewaybillresponse.result.Notes + `</p> </div>`);
- $(detailContainer).find('#div_App_DefaultWidgetSettings').addClass('pb-0');
- }
- });
- });
- instance.Print();
- }
- Print() {
- let instance = this;
- let detailContainer = "#" + Unibase.Platform.Helpers.NavigationHelper.ModalContainerIds[Unibase.Platform.Helpers.NavigationHelper.ModalContainerIds.length - 1];
- if ($(".printsetting").length != 0) {
- let printhtml = $(".printsetting")[0].outerHTML;
- $(".printsetting").remove();
- $(detailContainer).find("#div_App_DefaultWidgetSettings").find(".row").append(printhtml);
- $(".printsetting").find(".pull-right").removeClass("pull-right");
- }
- $('.DetailSetting_' + Unibase.Themes.Providers.DetailHelper.installedAppId + '_Print').html('<span><i class=\"fa fa-print\"></i></span>');
- $(detailContainer).find('.DetailSetting_' + Unibase.Themes.Providers.DetailHelper.installedAppId + '_Print').click(function () {
- let EwaybillId = Unibase.Themes.Providers.DetailHelper.recordId;
- Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFiles(["apps/transact/managers/ewaybill/ewaybillmanager.js", "platform/core/helpers/printhelper/printhelper.js"], function () {
- Bizgaze.Apps.Transact.Managers.EWayBillManager.Instance().getPrintEWayBill(EwaybillId).then(function (response) {
- Unibase.Platform.Helpers.PrintHelper.Instance().printPopup(response.result.PrintHTML);
- });
- });
- });
- }
- GetDistanceByPinCode() {
- let instance = this;
- var FromPinCode = $(".txt_frompincode").val().toString();
- var ToPinCode = $(".txt_topincode").val().toString();
- if (FromPinCode.length == 6 && ToPinCode.length == 6) {
- instance.getDistance();
- }
- }
- ShoworHideEWayBillButton() {
- let instance = this;
- let InstalledAppId = Unibase.Themes.Providers.DetailHelper.installedAppId;
- let detailContainer = "#" + Unibase.Platform.Helpers.NavigationHelper.ModalContainerIds[Unibase.Platform.Helpers.NavigationHelper.ModalContainerIds.length - 1];
- let RefStatusId = Number(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + InstalledAppId + "_refstatusid").Value);
- if (RefStatusId == 1 || RefStatusId == 2 || RefStatusId == 6) {
- $(detailContainer).find('.li_DetailSetting_' + InstalledAppId + '_E-WayBill').addClass('hidden');
- }
- else {
- $('.DetailSetting_' + Unibase.Themes.Providers.DetailHelper.installedAppId + '_E-WayBill').addClass('hidden');
- let ewaybillid = Number(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_ewaybillid") == undefined ? 0 : Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_ewaybillid").Value);
- if (ewaybillid == 0)
- $('.DetailSetting_' + Unibase.Themes.Providers.DetailHelper.installedAppId + '_E-WayBill').removeClass('hidden');
- }
- }
- getdcdetails() {
- Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFiles(["apps/transact/managers/inventory/dcmanager.js"], function () {
- Bizgaze.Apps.Transact.Managers.DCManager.Instance().getdc($(".txtAutoComplete_dcid").val()).then(function (response) {
- if (response.result != null) {
- $(".hfAutoCompleteId_invoiceid").val(response.result.InvoiceId);
- $(".hdn_refid").val($(".txtAutoComplete_dcid").val());
- }
- });
- });
- }
- GetInvoice() {
- Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFiles(["apps/transact/managers/invoicemanager.js"], function () {
- Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().getInvoiceDetails($(".txtAutoComplete_invoiceid").val()).then(function (response) {
- if (response.result != null) {
- $(".hfAutoCompleteId_dcid").val(response.result.DcId);
- $(".hdn_refid").val($(".txtAutoComplete_invoiceid").val());
- }
- });
- });
- }
- checkstatus() {
- var installedAppId = Unibase.Themes.Providers.DetailHelper.installedAppId;
- var einvoiceid = String(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + installedAppId + "_ewaybillid").Value);
- var statusid = Number(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + installedAppId + "_statusid").Value);
- if (statusid != undefined) {
- if (statusid == 2) {
- $(".DetailSetting_" + installedAppId + "_Cancele-WayBill").addClass("hidden");
- $(".DetailSetting_" + installedAppId + "_UpdateVehicleNo").addClass("hidden");
- $(".DetailSetting_" + installedAppId + "_e-waybill").addClass("hidden");
- }
- else {
- $(".DetailSetting_" + installedAppId + "_Cancele-WayBill").removeClass("hidden");
- $(".DetailSetting_" + installedAppId + "_UpdateVehicleNo").removeClass("hidden");
- $(".DetailSetting_" + installedAppId + "_e-waybill").removeClass("hidden");
- }
- }
- }
- checkewaybillstatus() {
- var installedAppId = Unibase.Themes.Providers.DetailHelper.installedAppId;
- var ewaybillno = String(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + installedAppId + "_ewaybillno").Value);
- if (ewaybillno == " " || ewaybillno == "") {
- $(".DetailSetting_" + installedAppId + "_e-waybill").removeClass("hidden");
- }
- $(".DetailSetting_" + installedAppId + "_e-waybill").addClass("hidden");
- }
- static Instance() {
- if (this.instance === undefined) {
- this.instance = new EWayBill();
- }
- return this.instance;
- }
- }
- Components.EWayBill = EWayBill;
- })(Components = EWayBill_1.Components || (EWayBill_1.Components = {}));
- })(EWayBill = Integrations.EWayBill || (Integrations.EWayBill = {}));
- })(Integrations = Apps.Integrations || (Apps.Integrations = {}));
- })(Apps = Bizgaze.Apps || (Bizgaze.Apps = {}));
- })(Bizgaze || (Bizgaze = {}));
|