var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; var Bizgaze; (function (Bizgaze) { let Apps; (function (Apps) { let Transact; (function (Transact) { let Controls; (function (Controls) { let Subscriptions; (function (Subscriptions) { class SubcribeUserRegistrations extends Unibase.Platform.Core.BaseComponent { cssFiles() { return ['apps/transact/controls/subscriptions/style.subscription.css']; } jsFiles() { return ["platform/bundle/index.subscriptions.components.min.js"]; } html(id, containerid) { var html = `

Registration

Please enter a valid email
Please enter a valid GSTIN
Bizgaze-Logo
`; return html; } load(id, containerid, callback) { var instance = this; Unibase.Platform.Helpers.FileCacheHelper.Instance().addCacheFiles(["apps/transact/controls/subscriptions/addons.component.js", "apps/transact/controls/subscriptions/registeremail.component.js"]); SubcribeUserRegistrations.Instance().autoComplete(); Bizgaze.Apps.Transact.Controls.Subscriptions.OrderDetails.Instance().getPlanItem_List(instance.PlanItemId, instance.Tenureid); $(`#${containerid}`).addClass("registration-modal bg-white bg-registration").removeClass('bg-light'); instance.isVerified = false; $('.biz-contact-form').find('input[type = "email"]').on("input", function () { var enteredEmail = $(this).val(); if (enteredEmail == "") { if ($('.emailValidText').hasClass('d-none') == false) { $('.emailValidText').addClass('d-none'); } } }); $('.biz-contact-form').find('input').on("input", function () { if ($(this).attr('id') == 'contactEmail') { var enteredEmail = $(this).val(); if (enteredEmail) { $('.emailValidText').addClass('d-none'); $(this).attr("style", ""); } } else { $(this).attr("style", ""); } }); $('.biz-contact-form').find('#txt_city').on("input", function () { $(this).parent().find('.select2-selection').removeClass('border-red'); }); function alphaOnly(event) { var key = event.keyCode; if (((key >= 65 && key <= 90) || key == 8) == false) { MessageHelper.Instance().showError("Please Enter valid GST Number", "div_errroMessage"); } else if ((key >= 65 && key <= 90) || key == 8) { if ($('#Bizgaze-messageInfo')) { $('#Bizgaze-messageInfo').click(); } } return ((key >= 65 && key <= 90) || key == 8); } ; function numericOnly(event) { var key = event.keyCode; if (((key >= 47 && key <= 58) || key == 8 || (key > 95 && key < 106)) == false) { MessageHelper.Instance().showError("Please Enter valid GST Number", "div_errroMessage"); } else if ((key >= 47 && key <= 58) || key == 8 || (key > 95 && key < 106)) { if ($('#Bizgaze-messageInfo')) { $('#Bizgaze-messageInfo').click(); } } return ((key > 47 && key < 58) || key == 8 || (key > 95 && key < 106)); } ; function alphaNumeric(event) { var key = event.keyCode; return ((key > 47 && key < 58) || key == 8 || (key >= 65 && key <= 90)); } ; $('#GSTIN').on('keydown', function () { $(this).addClass('text-uppercase'); var gst_val = $('#GSTIN').val().toString(); if (gst_val.length < 2) { return numericOnly(event); } else if ((gst_val.length >= 2) && (gst_val.length < 7)) { return alphaOnly(event); } else if ((gst_val.length >= 7) && (gst_val.length < 11)) { return numericOnly(event); } else if ((gst_val.length >= 11) && (gst_val.length < 12)) { return alphaOnly(event); } else if ((gst_val.length >= 12) && (gst_val.length < 13)) { return numericOnly(event); } else if ((gst_val.length >= 13) && (gst_val.length < 14)) { return alphaOnly(event); } else if ((gst_val.length >= 14) && (gst_val.length < 15)) { return alphaNumeric(event); } }); } init() { } saveDetails() { var companyName = $("#companyName").val(); var contactName = $("#contactName").val(); var contactEmail = $("#contactEmail").val(); var contactPhone = $("#contactPhone").val(); var AddressName = $("#AddressName").val(); var cityName = $("#txt_city").val(); var GSTIN = $("#GSTIN").val(); function validEmail(email) { var regex = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/; return regex.test(email); } function validGst(gstin) { var regex = /^[0-9]{2}[A-Z]{5}[0-9]{4}[A-Z]{1}[1-9A-Z]{1}Z[0-9A-Z]{1}$/; /^[0-9]{2}[A-Z]{5}[0-9]{4}[A-Z]{1}[1-9A-Z]{1}Z[0-9A-Z]{1}$/; return regex.test(gstin); } $('.biz-contact-form').find('input').on("input", function () { if ($(this).attr('id') == 'GSTIN') { var enteredGstin = $(this).val(); if (validGst(enteredGstin)) { $('.gstValidText').addClass('d-none'); } } }); $('#biz-contact-form input').each(function () { var val = $(this).val(); if (val == "") { var id = $(this).attr('id'); if (id != 'companyName' && id != 'GSTIN') { $(this).css("border-color", "red"); } } else { $(this).attr("style", ""); } }); if ($('#txt_city').val() == '') { $('#txt_city').parent().find('.select2-selection').addClass('border-red'); } else { $('#txt_city').parent().find('.select2-selection').removeClass('border-red'); } if (contactName == "" || contactPhone == "" || contactEmail == "" || AddressName == "" || cityName == "") { MessageHelper.Instance().showError("Mandatory fields are missing", "error_message"); $('.emailValidText').addClass('d-none'); } else { if (validEmail(contactEmail) == false) { $('.emailValidText').removeClass('d-none'); $('#contactEmail').css("border-color", "red"); return; } if (GSTIN != '') { if (validGst(GSTIN.toString().toUpperCase()) == false) { MessageHelper.Instance().showError("Please enter valid GSTIN", "error_message"); return; } } if (this.isVerified == false) { $('#Bizgaze-messageInfo').click(); if ($('.emailValidText').hasClass('d-none') == false) { $('.emailValidText').addClass('d-none'); } var obj = {}; obj = { UserName: contactName.toString().trim(), Email: contactEmail, ContactNumber: contactPhone, Organigationname: companyName.toString().trim(), }; this.fileCacheHelper.loadJsFile('apps/transact/managers/subscriptions/subscriptionmanager.js', function () { Bizgaze.Apps.Transact.Managers.Subscriptions.SubscriptionManager.Instance().SubscriptionsUserValidationInfo(obj).then(function (response) { var res = response.result; if (response.result == null) { MessageHelper.Instance().showError(response.message, "error_message"); } else { Bizgaze.Apps.Transact.Controls.Subscriptions.SubcribeUserRegistrations.Instance().sendOtp(); } }); }); } } } autoComplete() { Bizgaze.Apps.Transact.Managers.Subscriptions.SubscriptionManager.Instance().getCityName().then(function (res) { return __awaiter(this, void 0, void 0, function* () { let response = res.result, data = []; response.forEach(function (item, index) { data.push({ id: item.cityid, text: item.cityname }); }); $('#txt_city').select2({ placeholder: "Select City*", allowClear: true, data: data }); }); }); } subcribeUserRegistration(planid, tenureid) { Unibase.Platform.Helpers.NavigationHelper.Instance().hideLoading(); SubcribeUserRegistrations.instance.PlanItemId = Number(planid); SubcribeUserRegistrations.instance.Tenureid = Number(tenureid); var instance = this; instance.navigationHelper.popup(0, "", Bizgaze.Apps.Transact.Controls.Subscriptions.SubcribeUserRegistrations.Instance(), null, Unibase.Platform.Helpers.Size.ExtraLarge); } proceedToPay() { this.saveDetails(); } sendOtp() { var instance = this; var ContactText = $("#contactPhone").val().toString(); let Ismail = ContactText.includes("@"); if (ContactText != "") { if (Ismail == false) { if (ContactText.length == 10) { var token = "123456"; SubcribeUserRegistrations.instance.isMail = Ismail; instance.fileCacheHelper.loadJsFile("apps/crm/contacts/managers/contactmanager.js", function () { Bizgaze.Apps.Transact.Managers.Subscriptions.SubscriptionManager.Instance().getUserInfoByContactNo(ContactText).then(function (response) { var data = response.result; Bizgaze.Apps.Transact.Managers.Subscriptions.SubscriptionManager.Instance().getContactnumuberdetails(ContactText).then(function (res) { var info = res.result; if (data != null && data != "" || info != null && info != "") { MessageHelper.Instance().showError("Contact Number Alredy Exist", "error_message"); } else { Bizgaze.Apps.Transact.Controls.Subscriptions.SubcribeUserRegistrations.Instance().otpVerificationModal(); Bizgaze.Apps.Transact.Controls.Subscriptions.SubcribeUserRegistrations.Instance().sendEmail(ContactText, Ismail); } }); }); }); } else { $('#contactPhone').css("border-color", "red"); MessageHelper.Instance().showError("Please Enter Valid Mobile Number!", "error_message"); } } if (Ismail == true) { SubcribeUserRegistrations.instance.isMail = Ismail; var token = "123456"; Bizgaze.Apps.Transact.Controls.Subscriptions.SubcribeUserRegistrations.Instance().otpVerificationModal(); Bizgaze.Apps.Transact.Controls.Subscriptions.SubcribeUserRegistrations.Instance().sendEmail(ContactText, Ismail); } } else { MessageHelper.Instance().showError("Please Enter Valid Input Details!", "error_message"); } } otpVerificationModal() { const html = ``; const containerId = Unibase.Platform.Helpers.NavigationHelper.ModalContainerIds[Unibase.Platform.Helpers.NavigationHelper.ModalContainerIds.length - 1]; $('.otp-verification-modal').remove(); $(`#${containerId}`).append(html); const otpModalEl = $('#otpVerificationModal'); otpModalEl.addClass('show d-block'); $('.otp-input').first().focus(); $('#otpModalCloseBtn').click(function () { otpModalEl.removeClass('show d-block'); }); $('.otp-input-group .otp-input').on('input', function (e) { const inputEl = this; inputEl.value = inputEl.value.replace(/[^0-9]/g, ''); }); } sendEmail(email, Ismail) { this.fileCacheHelper.loadJsFile('apps/transact/managers/subscriptions/subscriptionmanager.js', function () { Bizgaze.Apps.Transact.Managers.Subscriptions.SubscriptionManager.Instance().sendRegistrationMail(email, Ismail).then(function (response) { var resinfo = response.result; var res = response.message; if (resinfo == null || resinfo == "") { MessageHelper.Instance().showError('OTP sending failed', 'otpErrMsg'); } else { SubcribeUserRegistrations.instance.registertoken = response.result; MessageHelper.Instance().showSuccess('OTP Send Succefully', 'otpErrMsg'); } }); }); } otpInputTabChange(val) { const ele = $('.otp-input'); if (ele[val - 1].value != '') { if (ele[val]) ele[val].focus(); } else if (ele[val - 1].value == '') { if (ele[val - 2]) ele[val - 2].focus(); } } otpSubmitHandler() { var instance = this; let enteredOtp = ''; $('.otp-input').each(function () { enteredOtp += $(this).val(); }); if (enteredOtp != '' || enteredOtp != "") { let otpId = SubcribeUserRegistrations.instance.registertoken; this.fileCacheHelper.loadJsFile('apps/transact/managers/subscriptions/subscriptionmanager.js', function () { Bizgaze.Apps.Transact.Managers.Subscriptions.SubscriptionManager.Instance().VerifyOtp(otpId, enteredOtp).then(function (response) { var res = response.result; if (res != null && res == true) { $('#otpVerificationModal').removeClass('show d-block'); instance.isVerified = true; $('.registration-proceed-btn').removeClass('d-none'); MessageHelper.Instance().showSuccess('Mobile Number verified Successfully', ''); Bizgaze.Apps.Transact.Controls.Subscriptions.SubcribeUserRegistrations.Instance().SaveSubcriptionUserInfo(); } else { MessageHelper.Instance().showError('Invalid OTP!', 'otpErrMsg'); } }); }); } else { MessageHelper.Instance().showError('Please Enter OTP!', 'otpErrMsg'); } } SaveSubcriptionUserInfo() { var companyName = $("#companyName").val(); var contactName = $("#contactName").val(); var contactEmail = $("#contactEmail").val(); var contactPhone = $("#contactPhone").val(); var AddressName = $("#AddressName").val(); var cityName = $("#txt_city").val(); var GSTIN = $("#GSTIN").val(); var tenurePeriod = $('#select_period').val(); if (tenurePeriod == 'select' || tenurePeriod == "" || tenurePeriod == null) { tenurePeriod = 0; } if (contactName == "") { MessageHelper.Instance().showError("Mandatory fields are missing", "error_message"); } else { var instance = this; instance.navigationHelper.showLoading(); var jsFiles = ["apps/transact/enums/enum.js", "apps/transact/managers/orders/ordermanager.js", "apps/transact/managers/subscriptions/subscriptionmanager.js"]; instance.fileCacheHelper.loadJsFiles(jsFiles, function () { Subscriptions.OrderDetails.instance.OrderData = []; Subscriptions.OrderDetails.instance.ItemData = []; for (var i = 0; i < Subscriptions.OrderDetails.instance.CartItems.length; ++i) { var addonQuantity = Subscriptions.OrderDetails.instance.CartItems[i].addonQuantity; var addonSku = Subscriptions.OrderDetails.instance.CartItems[i].addonSku; var addonItemId = Subscriptions.OrderDetails.instance.CartItems[i].addonItemId; var unitPrice = Subscriptions.OrderDetails.instance.CartItems[i].unitPrice; var discountPercent = Subscriptions.OrderDetails.instance.CartItems[i].discountPercent; var discountValue = Subscriptions.OrderDetails.instance.CartItems[i].discountValue; var refItemId = Number($(this).find("#hf_refItemId").val()); Subscriptions.OrderDetails.instance.ItemData.push({ SKU: addonSku, Quantity: addonQuantity, ItemId: addonItemId, UnitPrice: unitPrice, DiscountPercent: isNaN(discountPercent) ? 0 : discountPercent, DiscountValue: isNaN(discountValue) ? 0 : discountValue, RefItemId: isNaN(refItemId) ? 0 : refItemId }); } instance.ItemObj = JSON.stringify(Subscriptions.OrderDetails.instance.ItemData); var PlanId = SubcribeUserRegistrations.instance.PlanItemId; var TenureId = SubcribeUserRegistrations.instance.Tenureid; SubcribeUserRegistrations.instance.contactNumber = contactPhone; SubcribeUserRegistrations.instance.contactEmail = contactEmail; var obj = {}; obj = { UserName: contactName.toString().trim(), Email: contactEmail, ContactNumber: contactPhone, Organigationname: companyName.toString().trim(), PlanId: PlanId, TenureId: TenureId, GSTNO: GSTIN, City: cityName, AddressLine1: AddressName.toString().trim(), TenurePeriod: Number(tenurePeriod), OrderObject: instance.ItemObj }; Bizgaze.Apps.Transact.Managers.Subscriptions.SubscriptionManager.Instance().SaveSubscriptionsUserInfo(obj).then(function (response) { var res = response.result; if (response.result == null) { instance.navigationHelper.hideLoading(); MessageHelper.Instance().showError(response.message, "error_message"); } else { var customerUserId = res.SubscriptionsUserId; var PaymentStatus = true; var TotalAmt = Subscriptions.OrderDetails.instance.NetTotal; Bizgaze.Apps.Transact.Controls.Subscriptions.SubcribeUserRegistrations.Instance().paymentgateway(TotalAmt, customerUserId, PaymentStatus); } }); }); } } paymentgateway(invoiceamount, customerUserId, PaymentStatus) { var customerdetails = {}; var subcribeuserobj = {}; SubcribeUserRegistrations.instance.data = []; var customerUserId = customerUserId; if (isNaN(customerUserId)) { customerUserId = customerUserId; } var custContactNumber = SubcribeUserRegistrations.instance.contactNumber; var custEmailAdress = SubcribeUserRegistrations.instance.contactEmail; var instance = this; instance.fileCacheHelper.loadJsFiles(['apps/transact/managers/subscriptions/subscriptionmanager.js', 'settings/settings.js', 'platform/core/infos/status.js'], function () { var retunrUrl = window.location.origin + '/#/paymentorder/order_id={order_id}/order_token={order_token}'; var dt = new Date(); dt.setDate(dt.getDate() + 5); customerdetails = { CustomerId: String(customerUserId), CustomerEmail: custEmailAdress, CustomerPhone: custContactNumber, }; SubcribeUserRegistrations.instance.data.push({ OrderAmount: invoiceamount, OrderCurrency: "INR", customer_details: customerdetails, order_meta: { "ReturnUrl": retunrUrl }, OrderExpiryTime: dt }); Bizgaze.Apps.Transact.Managers.Subscriptions.SubscriptionManager.Instance().createGateWayOrder(instance.data[0]).then(function (response) { var res = response.result; if (response.status === Unibase.Data.Status.Error) { instance.navigationHelper.hideLoading(); MessageHelper.Instance().showError(response.message, "error_message"); } if (response.result != null) { var res = response.result; var url = res.payment_link; subcribeuserobj = { SubscriptionsUserId: customerUserId, OrderId: res.order_id, OrderToken: res.order_token, TotalAmount: invoiceamount }; var paymentDetails = {}; paymentDetails = { OrderId: res.order_id, OrderToken: res.order_token, TenureId: Number(SubcribeUserRegistrations.instance.Tenureid), TotalAmount: invoiceamount, }; var obj = {}; if (PaymentStatus == true) { obj = { SubscriptionsUserId: customerUserId, PaymentDetails: paymentDetails }; } instance.fileCacheHelper.loadJsFile('apps/transact/managers/subscriptions/subscriptionmanager.js', function () { if (PaymentStatus == true) { Bizgaze.Apps.Transact.Managers.Subscriptions.SubscriptionManager.Instance().SaveSubscriptionsUserInfo(subcribeuserobj).then(function (response) { var savinfo = response.result; instance.navigationHelper.hideLoading(); window.open(url, "_self"); }); } }); } }); }); } retryPayement(invoiceamount, customerUserId, PaymentStatus, Cust_Email, custContactNumber) { var customerdetails = {}; var subcribeuserobj = {}; SubcribeUserRegistrations.instance.data = []; var customerUserId = customerUserId; if (isNaN(customerUserId)) { customerUserId = customerUserId; } var custContactNumber = custContactNumber; var custEmailAdress = Cust_Email; var instance = this; instance.fileCacheHelper.loadJsFiles(['apps/transact/managers/subscriptions/subscriptionmanager.js', 'settings/settings.js', 'platform/core/infos/status.js'], function () { var retunrUrl = window.location.origin + '/#/paymentorder/order_id ={order_id}/order_token={order_token}'; var dt = new Date(); dt.setDate(dt.getDate() + 5); customerdetails = { CustomerId: String(customerUserId), CustomerEmail: custEmailAdress, CustomerPhone: custContactNumber, }; SubcribeUserRegistrations.instance.data.push({ OrderAmount: invoiceamount, OrderCurrency: "INR", customer_details: customerdetails, order_meta: { "ReturnUrl": retunrUrl }, OrderExpiryTime: dt }); Bizgaze.Apps.Transact.Managers.Subscriptions.SubscriptionManager.Instance().createGateWayOrder(instance.data[0]).then(function (response) { var res = response.result; if (res.status === Unibase.Data.Status.Error) { instance.navigationHelper.hideLoading(); MessageHelper.Instance().showError(res.message, "error_message"); } if (response.result != null) { var res = response.result; var url = res.payment_link; subcribeuserobj = { SubscriptionsUserId: customerUserId, OrderId: res.order_id, OrderToken: res.order_token, TotalAmount: invoiceamount }; var paymentDetails = {}; paymentDetails = { OrderId: res.order_id, OrderToken: res.order_token, TenureId: Number(SubcribeUserRegistrations.instance.Tenureid), TotalAmount: invoiceamount, }; var obj = {}; if (PaymentStatus == true) { obj = { SubscriptionsUserId: customerUserId, PaymentDetails: paymentDetails }; } instance.fileCacheHelper.loadJsFile('apps/transact/managers/subscriptions/subscriptionmanager.js', function () { if (PaymentStatus == true) { Bizgaze.Apps.Transact.Managers.Subscriptions.SubscriptionManager.Instance().SaveSubscriptionsUserInfo(subcribeuserobj).then(function (response) { var savinfo = response.result; instance.navigationHelper.hideLoading(); window.open(url, "_self"); }); } }); } }); }); } static Instance() { if (this.instance === undefined) { this.instance = new SubcribeUserRegistrations(); } return this.instance; } } Subscriptions.SubcribeUserRegistrations = SubcribeUserRegistrations; })(Subscriptions = Controls.Subscriptions || (Controls.Subscriptions = {})); })(Controls = Transact.Controls || (Transact.Controls = {})); })(Transact = Apps.Transact || (Apps.Transact = {})); })(Apps = Bizgaze.Apps || (Bizgaze.Apps = {})); })(Bizgaze || (Bizgaze = {}));