var Bizgaze; (function (Bizgaze) { let Apps; (function (Apps) { let PayBacks; (function (PayBacks) { let Components; (function (Components) { class Redemption extends Unibase.Platform.Core.BaseComponent { constructor() { super(); this._totalamount = 0; this._totalcount = 0; } cssFiles() { return ['tenants/themes/compact/css/coupons.css']; } jsFiles() { return ['platform/automation/enums/noitfyalerts.js', 'platform/automation/components/notifier.js']; } html(id, containerid) { var html = ""; return html; } load(id, containerid, callback) { } ScanCoupons(serialno, container, propobj, callback) { Unibase.Platform.Helpers.FileCacheHelper.Instance().loadCssFile("tenants/themes/compact/css/coupons.css", null); Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/paybacks/managers/schememanager.js", function () { var IsScannedCoupon = false; if (isMobileApp()) { IsScannedCoupon = true; } propobj[0].IsScannedCoupon = IsScannedCoupon; Bizgaze.Apps.Paybacks.Managers.SchemeManager.Instance().ScanCoupon(serialno.toUpperCase(), propobj).then(function (response) { let audiotype; if (response.result == null) { $(".scan_couponscancontol").val(''); if (response.message.includes('invoiceitemid_unique')) { response.message = "Coupon Already Redeemed"; } MessageHelper.Instance().showError(response.message, $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id')); setTimeout(function () { $(".bizgaze_FormErrorMessages").empty(); }, 3000); } if (response.status == 0) { if (isMobileApp()) Bizgaze.Apps.PayBacks.Components.Redemption.Instance().andriodTextToSpeech('Coupon Applied'); else { audiotype = Unibase.Platform.Automation.Enums.NotifyAlerts.CouponBeep; Unibase.Platform.Automation.Components.Notifier.Instance().playAudio(audiotype); } if (response.result != null) { var html = '
' + '
' + 'couponimg' + '

' + response.result.couponvalue + ' *

' + '
' + '

Coupon Code :   ' + response.result.CouponNo + '

' + '

Product Code :   ' + response.result.ItemName + '

' + '
' + '
tag image

Coupon Value

' + '

:

' + (response.result.Basevalue + response.result.LuckyCouponValue) + '

' + '
discount image' + '

Add. Discount

:

' + response.result.DiscountValue + '

' + '
discount image' + '

Spl. Discount

:

' + response.result.IncentiveValue + '

' + '
couponimg
'; $("#divMainContainer").removeClass('col-sm-12'); $("#divListContainer").removeClass('col-sm-6'); $("#divListContainer").addClass('col-12'); $("#divHtmlContainer:first").after(html); $("#lblcouponvalue_" + response.result.CouponId).text(""); $("#lblcouponvalue_" + response.result.CouponId).text(response.result.CouponValue); $("#lbldiscountvalue_" + response.result.CouponId).text(response.result.DiscountValue); $("#lbldisincentivevalue_" + response.result.CouponId).text(response.result.IncentiveValue); if (Number($(".lblSum").text()) == 0) { Bizgaze.Apps.PayBacks.Components.Redemption.Instance()._totalamount = 0; Bizgaze.Apps.PayBacks.Components.Redemption.Instance()._totalcount = 0; } Bizgaze.Apps.PayBacks.Components.Redemption.Instance()._totalamount += response.result.CouponValue; Bizgaze.Apps.PayBacks.Components.Redemption.Instance()._totalcount += 1; $(".lblSum").text(Bizgaze.Apps.PayBacks.Components.Redemption.Instance()._totalamount); $(".lblCount").text(Bizgaze.Apps.PayBacks.Components.Redemption.Instance()._totalcount); } } else { if (isMobileApp()) if (response.message.includes('Redeemed')) Bizgaze.Apps.PayBacks.Components.Redemption.Instance().andriodTextToSpeech("Coupon already redeemed"); else Bizgaze.Apps.PayBacks.Components.Redemption.Instance().andriodTextToSpeech(response.message); else { if (response.message.includes('Invalid/duplicate')) { audiotype = Unibase.Platform.Automation.Enums.NotifyAlerts.InvalidDuplicateCoupon; Unibase.Platform.Automation.Components.Notifier.Instance().playAudio(audiotype); } else if (response.message.includes('Redeemed')) { audiotype = Unibase.Platform.Automation.Enums.NotifyAlerts.CouponAlreadyRedeemed; Unibase.Platform.Automation.Components.Notifier.Instance().playAudio(audiotype); } else if (response.message.includes('UnAuthentic')) { audiotype = Unibase.Platform.Automation.Enums.NotifyAlerts.UnAuthenticCoupon; Unibase.Platform.Automation.Components.Notifier.Instance().playAudio(audiotype); } else if (response.message.includes('contact')) { return null; } else if (response.message.includes('Deactivated')) { return null; } else { audiotype = Unibase.Platform.Automation.Enums.NotifyAlerts.InvalidDuplicateCoupon; Unibase.Platform.Automation.Components.Notifier.Instance().playAudio(audiotype); } } } return false; }); }); } bindContact(autocontactid, textcontainerid) { var instance = this; var isCustomer = Unibase.Platform.Membership.Infos.Identity.getCurrentUser().isRestrictedUser; var UserId = Unibase.Platform.Membership.Infos.Identity.getCurrentUser().userId; if (isCustomer) { instance.fileCacheHelper.loadJsFile("apps/crm/contacts/managers/contactmanager.js", function () { Bizgaze.Apps.Crm.Contacts.Managers.ContactManager.Instance().getsprlOrgContact(UserId).then(function (response) { debugger; var contactId = response.result.OrgContactId; var orgContactName = response.result.OrgContactName; var organizationName = response.result.OrganizationName; var PhoneNumber = response.result.PhoneNumber; var SapCode = ""; if (response.result.SAPCIN != null) { SapCode = response.result.SAPCIN; } if (response.result.StatusName != 'Confirmed') { $('.divCustomProperties_bizgazepaybacks_couponredemptions').remove(); } if (response.result.StatusId == 2) { $('.divCustomProperties_bizgazepaybacks_couponredemptions').remove(); } var organiozationid = response.result.OrganizationId; var contactName = organizationName + '-' + SapCode + '-' + PhoneNumber; var contact = new Option(contactName, organiozationid.toString(), true); $(autocontactid).append(contact); $(autocontactid).val(organiozationid).trigger("change"); Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("platform/tag/managers/tagmanager.js", function (response) { Unibase.Platform.Forms.Managers.TagManager.Instance().GetTagItemsByRefId(Number(organiozationid)).then(function (response) { if (response.result != null) { var data = response.result; $(autocontactid).attr('data-addldata', data[0].TagId); } }); }); }); }); } } andriodTextToSpeech(textToSpeech) { if (isMobileApp()) { Unibase.Platform.Helpers.MobileHelper.Instance().textToSpeech(textToSpeech); } } RefreshCouponData() { Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/paybacks/managers/schememanager.js", function () { Bizgaze.Apps.Paybacks.Managers.SchemeManager.Instance().RefreshCouponData().then(function (response) { var res = response; }); }); } static Instance() { if (this.instance === undefined) { this.instance = new Redemption(); } return this.instance; } } Components.Redemption = Redemption; })(Components = PayBacks.Components || (PayBacks.Components = {})); })(PayBacks = Apps.PayBacks || (Apps.PayBacks = {})); })(Apps = Bizgaze.Apps || (Bizgaze.Apps = {})); })(Bizgaze || (Bizgaze = {}));