`;
$("#" + containerid).html(html);
}
loadControlSettings(controlsettingjson, formpropertyid) {
return null;
}
loadPropertySettings(propertysettings, formpropertyid) {
return null;
}
bindEditFormDetails(formpropertyid, propval, DocPropertyName) {
var ewaybillid = Number(propval);
var instance = this;
}
load() {
Bizgaze.Apps.Integrations.EWayBill.Components.irnwithewaybill.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.irnwithewaybill.Instance().GetDistanceByPinCode();
});
}
getAddressById() {
let AutoComplete_branchid = Number($(".txtAutoComplete_branchid").val());
Bizgaze.Apps.Crm.Contacts.Managers.ContactManager.Instance().getAddressById(AutoComplete_branchid).then(function (response) {
if (response.result != null) {
$(".txt_frompincode").val(response.result.ZipCode);
$(".labelSection_FromGSTIN").html("
From GSTIN : " + response.result.GSTNO + "");
Bizgaze.Apps.Integrations.EWayBill.Components.irnwithewaybill.Instance().getDistance();
}
});
}
getdcewaydetails() {
let VisibleContainerId = Unibase.Platform.Helpers.NavigationHelper.ModalContainerIds[Unibase.Platform.Helpers.NavigationHelper.ModalContainerIds.length - 1];
let dcid = Number($(".txtAutoComplete_dcid").val());
Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("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);
$(".txt_topincode").val(response.result.ShipToZipCode);
let branchid = Number(response.result.BranchId);
$(".labelSection_ToGSTIN").html("
To GSTIN : " + response.result.GSTInNo + "");
$(".labelSection_FromGSTIN").html("
From GSTIN : " + response.result.GSTInNo + "");
$(".hfAutoCompleteId_invoiceid").val(response.result.InvoiceId);
$(".hdn_refid").val($(".txtAutoComplete_dcid").val());
Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/crm/companies/managers/companymanager.js", function () {
Bizgaze.Apps.CRM.Companies.Managers.CompanyManager.Instance().getBranch(branchid).then(function (response) {
if (response.result != null) {
let BranchName = response.result.BranchName;
let branch = new Option(BranchName, branchid.toString(), true);
$("#" + VisibleContainerId).find(".txtAutoComplete_branchid").append(branch).val(branchid).trigger("change");
}
});
});
Bizgaze.Apps.Integrations.EWayBill.Components.irnwithewaybill.Instance().getDistance();
}
});
});
}
getdc() {
var InstalledAppId = Unibase.Themes.Providers.DetailHelper.installedAppId;
var recordid = Number(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + InstalledAppId + "_recordid").Value);
var dcid = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + InstalledAppId + "_dcid").Value;
Bizgaze.Apps.Transact.Managers.DCManager.Instance().getdc(dcid).then(function (response) {
if (response.result != null) {
$(".txt_frompincode").val(response.result.BillFromZipCode);
$(".txt_topincode").val(response.result.BillToZipCode);
$(".labelSection_ToGSTIN").html("
To GSTIN : " + response.result.GSTNo + "");
}
});
}
getinvoiceewaydetails() {
let VisibleContainerId = Unibase.Platform.Helpers.NavigationHelper.ModalContainerIds[Unibase.Platform.Helpers.NavigationHelper.ModalContainerIds.length - 1];
let Autocomplete_invoiceid = Number($(".txtAutoComplete_invoiceid").val());
Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/transact/managers/invoicemanager.js", function () {
Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().getInvoiceDetails(Autocomplete_invoiceid).then(function (response) {
if (response.result != null) {
$(".txt_frompincode").val(response.result.BillFromZipCode);
$(".txt_topincode").val(response.result.BillToZipCode);
let branchid = Number(response.result.BranchId);
$(".labelSection_ToGSTIN").html("
To GSTIN : " + response.result.GSTNo + "");
$(".labelSection_FromGSTIN").html("
From GSTIN : " + response.result.GSTNo + "");
$(".hfAutoCompleteId_dcid").val(response.result.DcId);
$(".hdn_refid").val($(".txtAutoComplete_invoiceid").val());
Bizgaze.Apps.Integrations.EWayBill.Components.irnwithewaybill.Instance().getDistance();
Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/crm/companies/managers/companymanager.js", function () {
Bizgaze.Apps.CRM.Companies.Managers.CompanyManager.Instance().getBranch(branchid).then(function (response) {
if (response.result != null) {
let BranchName = response.result.BranchName;
let branch = new Option(BranchName, branchid.toString(), true);
$("#" + VisibleContainerId).find(".txtAutoComplete_branchid").append(branch).val(branchid).trigger("change");
}
});
});
}
});
});
}
getInvoiceDetails() {
var InstalledAppId = Unibase.Themes.Providers.DetailHelper.installedAppId;
var recordid = Number(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + InstalledAppId + "_recordid").Value);
var invoiceid = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + InstalledAppId + "_invoiceid").Value;
Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().getInvoiceDetails(invoiceid).then(function (response) {
if (response.result != null) {
$(".txt_frompincode").val(response.result.BillFromZipCode);
$(".txt_topincode").val(response.result.BillToZipCode);
$(".labelSection_ToGSTIN").html("
To GSTIN : " + response.result.GSTNo + "");
}
});
}
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;
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);
}
}
}
Checkout() {
let instance = this;
$(".modal-body").scrollTop(0);
let cont_id = $("._bizgaze_popup_container:visible").attr("id");
$("#" + cont_id).find("#btnDynamicSave").css("cursor", "pointer");
$(".modal-body").scrollTop(0);
$(".btn_Save_Form, .section_Default,.section_Part-B").removeClass("hidden");
$("#btn_CloseForm_" + $("#hf_FormId").val()).removeClass('hidden');
$(".CheckOutButton,.btn_back ").addClass('hidden');
}
backtoDetails() {
$(".btn_Save_Form, .section_Default").removeClass('hidden');
$(".section_Part-B,.CheckOutButton,.btn_back").addClass('hidden');
$("#btn_CloseForm_" + $("#hf_FormId").val()).removeClass('hidden');
}
ShowPrintButton() {
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 + `
`);
$(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('
');
$(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 {
$(detailContainer).find('.li_DetailSetting_' + InstalledAppId + '_E-WayBill').removeClass('hidden');
}
}
getEwayForm(Pk_Value) {
let instance = Bizgaze.Apps.Integrations.EWayBill.Components.irnwithewaybill.Instance();
instance.fileCacheHelper.loadJsFiles(['platform/forms/managers/formmanager.js', 'platform/apps/managers/appmanager.js'], function () {
var FormUniqueId = 'Bizgaze_Extension_Transact_E-WayBill_App_E-WayBill_OrderDetails__CreateForm';
Unibase.Platform.Forms.Managers.FormManager.Instance().getFormbyUniqueId(FormUniqueId).then(function (response) {
var onLoadCallBack = {
CallBack: function () {
instance.bindewaydata(Pk_Value);
},
Parameters: null,
};
var formviewerObj = {
FormId: response.result.FormId,
AppConfigurationId: 0,
Pk_Value: 0,
PortletWidgetId: 0,
OnSuccess: null,
OnFail: null,
OnLoad: onLoadCallBack,
};
Unibase.Platform.Forms.Components.FormViewer.Instance().init(formviewerObj);
instance.navigationHelper.hideLoading();
});
});
}
bindewaydata(Pk_Value) {
let instance = Bizgaze.Apps.Integrations.EWayBill.Components.irnwithewaybill.Instance();
let VisibleContainerId = Unibase.Platform.Helpers.NavigationHelper.ModalContainerIds[Unibase.Platform.Helpers.NavigationHelper.ModalContainerIds.length - 1];
let _ewaybillid = Pk_Value;
instance.fileCacheHelper.loadJsFiles(["apps/transact/managers/ewaybill/ewaybillmanager.js"], function () {
Bizgaze.Apps.Transact.Managers.EWayBillManager.Instance().getewaybillpayload(_ewaybillid).then(function (res) {
if (res.result != null) {
$('input[type=text]').parent().addClass("floating-label-form-group-with-value");
$(".txt_cessvalue").val(res.result.cessValue);
$(".txt_cessvalue").attr("readonly", "readonly");
$(".txt_cgstvalue").val(res.result.cgstValue);
$(".txt_cgstvalue").attr("readonly", "readonly");
$(".txt_transporterdocno").val(res.result.docNo);
$(".txt_transporterdocno").attr("readonly", "readonly");
$(".txt_dispatchfromgstin").val(res.result.fromGstin);
$(".txt_dispatchfromgstin").attr("readonly", "readonly");
$(".txt_fromaddr1").val(res.result.fromAddr1);
$(".txt_fromaddr1").attr("readonly", "readonly");
$(".txt_fromaddr2").val(res.result.fromAddr2);
$(".txt_fromaddr2").attr("readonly", "readonly");
$(".txt_frompincode").val(res.result.fromPincode);
$(".txt_frompincode").attr("readonly", "readonly");
$(".txt_fromplace").val(res.result.fromPlace);
$(".txt_fromplace").attr("readonly", "readonly");
$(".txt_fromstatecode").val(res.result.fromStateCode);
$(".txt_fromstatecode").attr("readonly", "readonly");
$(".txt_dispatchfromgstin").val(res.result.dispatchFromGSTIN);
$(".txt_dispatchfromgstin").attr("readonly", "readonly");
$(".txt_dispatchfromtradename").val(res.result.dispatchFromTradeName);
$(".txt_dispatchfromtradename").attr("readonly", "readonly");
$(".txt_igstvalue").val(res.result.igstValue);
$(".txt_igstvalue").attr("readonly", "readonly");
$(".txt_sgstvalue").val(res.result.sgstValue);
$(".txt_sgstvalue").attr("readonly", "readonly");
$(".txt_shiptogstin").val(res.result.shipToGSTIN);
$(".txt_shiptogstin").attr("readonly", "readonly");
$(".txt_shiptotradename").val(res.result.shipToTradeName);
$(".txt_transportername").attr("readonly", "readonly");
$(".txt_toaddr1").val(res.result.toAddr1);
$(".txt_toaddr1").attr("readonly", "readonly");
$(".txt_toaddr2").val(res.result.toAddr2);
$(".txt_toaddr2").attr("readonly", "readonly");
$(".txt_toplace").val(res.result.toPlace);
$(".txt_toplace").attr("readonly", "readonly");
$(".txt_tostatecode").val(res.result.toStateCode);
$(".txt_tostatecode").attr("readonly", "readonly");
$(".txt_toplace").attr("readonly", "readonly");
$(".txt_topincode").val(res.result.toPincode);
$(".txt_topincode").attr("readonly", "readonly");
$(".txt_vehicleno").val(res.result.vehicleNo);
$(".dropdown_vehicletype").val(res.result.vehicleType).prop("disabled", true);
$(".dropdown_transmode").val(res.result.transMode).prop("disabled", true);
$(".date_transporterdocdate").val(res.result.transDocDate).prop("disabled", true);
$(".txt_vehicleno").attr("readonly", "readonly");
$(".txt_totalvalue").val(res.result.totalValue);
$(".txt_totalvalue").attr("readonly", "readonly");
$(".txt_totinvvalue").val(res.result.totInvValue);
$(".number_approxdistance").val(res.result.transDistance);
$(".txt_totinvvalue").attr("readonly", "readonly");
var dt = res.result;
var itemlists = dt.itemList;
for (var i = 0; i < itemlists.length; i++) {
var data = itemlists[i];
var html = '
' +
'' + data.productName + ' | ' +
'' + data.productDesc + ' | ' +
'' + data.quantity + ' | ' +
'' + data.hsnCode + ' | ' +
'' + data.qtyUnit + ' | ' +
'' + data.cgstRate + ' | ' +
'' + data.sgstRate + ' | ' +
'' + data.taxableAmount + ' | ' +
'
';
$("#tblgetewaybilliitems").append(html);
}
instance.fileCacheHelper.loadJsFile("apps/transact/managers/ewaybill/ewaybillmanager.js", function () {
Bizgaze.Apps.Transact.Managers.EWayBillManager.Instance().getEwayBill(_ewaybillid).then(function (ewaybillresponse) {
if (ewaybillresponse.result != null) {
let SupplyTypeid = Number(ewaybillresponse.result.SupplyTypeId);
let SupplyTypename = ewaybillresponse.result.SupplyTypeName;
let supplytype = new Option(SupplyTypename, SupplyTypeid.toString(), true);
$("#" + VisibleContainerId).find(".txtAutoComplete_supplytypeid").append(supplytype).prop("disabled", true);
$("#" + VisibleContainerId).find(".hfAutoCompleteId_supplytypeid").val(ewaybillresponse.result.SupplyTypeId);
let SubSupplyTypeid = Number(ewaybillresponse.result.SubSupplyTypeId);
let SubSupplyTypeName = ewaybillresponse.result.SubSupplyType;
let SubSupplyType = new Option(SubSupplyTypeName, SubSupplyTypeid.toString(), true);
$("#" + VisibleContainerId).find(".ddl_cascading_subsupplytypeid").append(SubSupplyType).prop("disabled", true);
$("#" + VisibleContainerId).find(".hfAutoCompleteId_subsupplytypeid").val(ewaybillresponse.result.SubSupplyTypeId);
let DocTypeid = Number(ewaybillresponse.result.DocTypeId);
let DocTypeName = ewaybillresponse.result.DocTypeName;
let DocType = new Option(DocTypeName, DocTypeid.toString(), true);
$("#" + VisibleContainerId).find(".ddl_cascading_doctypeid").append(DocType).prop("disabled", true);
$("#" + VisibleContainerId).find(".hfAutoCompleteId_doctypeid").val(ewaybillresponse.result.DocTypeId);
$(".hdn_ewaybillid").val(ewaybillresponse.result.EwayBillId);
$(".hdn_ewaybilldate").val(ewaybillresponse.result.ewaybilldate);
$(".hdn_ewaybillno").val(ewaybillresponse.result.ewaybillno);
$(".hdn_validupto").val(ewaybillresponse.result.validupto);
$(".hdn_refid").val(ewaybillresponse.result.validupto);
let Invoiceid = Number(ewaybillresponse.result.RefId);
instance.fileCacheHelper.loadJsFile("apps/transact/managers/invoicemanager.js", function () {
Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().getInvoiceDetails(Invoiceid).then(function (response) {
if (response.result != null) {
let Invoiceno = response.result.InvoiceNo;
let invoice = new Option(Invoiceno, Invoiceid.toString(), true);
$("#" + VisibleContainerId).find(".txtAutoComplete_invoiceid").append(invoice).prop("disabled", true);
}
});
});
}
});
});
}
});
});
}
getewaybillsavedata(Ewaybillid) {
let instance = this;
let EwayItemList = new Array();
for (let i = 0; i < instance.g_EwaybillItems.length; i++) {
let EwaybillItem = instance.g_EwaybillItems[i];
EwayItemList.push({
ProductName: EwaybillItem.productName,
Ewaybillid: Ewaybillid,
ProductDesc: EwaybillItem.productDesc,
hsnCode: EwaybillItem.hsnCode,
Quantity: EwaybillItem.quantity,
QtyUnit: EwaybillItem.qtyUnit,
cgstRate: EwaybillItem.cgstRate,
igstRate: EwaybillItem.sgstRate,
taxableAmount: EwaybillItem.taxableAmount,
});
}
return EwayItemList;
}
static Instance() {
if (this.instance === undefined) {
this.instance = new irnwithewaybill();
}
return this.instance;
}
}
Components.irnwithewaybill = irnwithewaybill;
})(Components = EWayBill.Components || (EWayBill.Components = {}));
})(EWayBill = Integrations.EWayBill || (Integrations.EWayBill = {}));
})(Integrations = Apps.Integrations || (Apps.Integrations = {}));
})(Apps = Bizgaze.Apps || (Bizgaze.Apps = {}));
})(Bizgaze || (Bizgaze = {}));