Built files from Bizgaze WebServer
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

loyaltypoints.js 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. var Bizgaze;
  2. (function (Bizgaze) {
  3. let Apps;
  4. (function (Apps) {
  5. let PayBacks;
  6. (function (PayBacks) {
  7. let Components;
  8. (function (Components) {
  9. class LoyaltyPoints extends Unibase.Platform.Core.BaseComponent {
  10. constructor() {
  11. super();
  12. this._totalamount = 0;
  13. this._totalcount = 0;
  14. }
  15. cssFiles() {
  16. return ['tenants/themes/compact/css/coupons.css'];
  17. }
  18. jsFiles() {
  19. return ['platform/automation/enums/noitfyalerts.js', 'platform/automation/components/notifier.js'];
  20. }
  21. html(id, containerid) {
  22. var html = "";
  23. return html;
  24. }
  25. load(id, containerid, callback) {
  26. }
  27. ScanSerialNo(serialno, container, propobj, callback) {
  28. $('.spanpoints').text('Points:');
  29. Unibase.Platform.Helpers.FileCacheHelper.Instance().loadCssFile("tenants/themes/compact/css/coupons.css", null);
  30. Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/paybacks/managers/schememanager.js", function () {
  31. var IsScannedCoupon = false;
  32. if (isMobileApp()) {
  33. IsScannedCoupon = true;
  34. }
  35. propobj[0].IsScannedCoupon = IsScannedCoupon;
  36. Bizgaze.Apps.Paybacks.Managers.SchemeManager.Instance().LoyaltyPoints(serialno.toUpperCase(), propobj).then(function (response) {
  37. let audiotype;
  38. debugger;
  39. if (response.result == null) {
  40. $(".scan_couponscancontol").val('');
  41. if (response.message.includes('Congratulations')) {
  42. MessageHelper.Instance().show_MandatoryFieldMessage('<strong>Success !</strong>' + response.message, "alert alert-success mb-0", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id'));
  43. setTimeout(function () {
  44. $(".bizgaze_FormErrorMessages").empty();
  45. }, 3000);
  46. }
  47. else {
  48. MessageHelper.Instance().showError(response.message, $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id'));
  49. setTimeout(function () {
  50. $(".bizgaze_FormErrorMessages").empty();
  51. }, 3000);
  52. }
  53. }
  54. if (response.status == 0) {
  55. if (isMobileApp())
  56. Bizgaze.Apps.PayBacks.Components.LoyaltyPoints.Instance().andriodTextToSpeech('Coupon Applied');
  57. else {
  58. audiotype = Unibase.Platform.Automation.Enums.NotifyAlerts.CouponBeep;
  59. Unibase.Platform.Automation.Components.Notifier.Instance().playAudio(audiotype);
  60. }
  61. }
  62. else {
  63. if (isMobileApp())
  64. if (response.message.includes('Redeemed'))
  65. Bizgaze.Apps.PayBacks.Components.LoyaltyPoints.Instance().andriodTextToSpeech("Coupon already redeemed");
  66. else
  67. Bizgaze.Apps.PayBacks.Components.LoyaltyPoints.Instance().andriodTextToSpeech(response.message);
  68. else {
  69. if (response.message.includes('Invalid/duplicate')) {
  70. audiotype = Unibase.Platform.Automation.Enums.NotifyAlerts.InvalidDuplicateCoupon;
  71. Unibase.Platform.Automation.Components.Notifier.Instance().playAudio(audiotype);
  72. }
  73. else if (response.message.includes('Redeemed')) {
  74. audiotype = Unibase.Platform.Automation.Enums.NotifyAlerts.CouponAlreadyRedeemed;
  75. Unibase.Platform.Automation.Components.Notifier.Instance().playAudio(audiotype);
  76. }
  77. else if (response.message.includes('UnAuthentic')) {
  78. audiotype = Unibase.Platform.Automation.Enums.NotifyAlerts.UnAuthenticCoupon;
  79. Unibase.Platform.Automation.Components.Notifier.Instance().playAudio(audiotype);
  80. }
  81. else if (response.message.includes('contact')) {
  82. return null;
  83. }
  84. else if (response.message.includes('Deactivated')) {
  85. return null;
  86. }
  87. else if (response.message.includes('Congratulations')) {
  88. audiotype = Unibase.Platform.Automation.Enums.NotifyAlerts.Congratulations;
  89. Unibase.Platform.Automation.Components.Notifier.Instance().playAudio(audiotype);
  90. }
  91. else {
  92. audiotype = Unibase.Platform.Automation.Enums.NotifyAlerts.InvalidDuplicateCoupon;
  93. Unibase.Platform.Automation.Components.Notifier.Instance().playAudio(audiotype);
  94. }
  95. }
  96. }
  97. return false;
  98. });
  99. });
  100. }
  101. getloyaltypoints(contactid) {
  102. Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/paybacks/managers/schememanager.js", function () {
  103. Bizgaze.Apps.Paybacks.Managers.SchemeManager.Instance().getloyaltypointsbycontactid(contactid).then(function (response) {
  104. if (response.result !== null && response.result != '') {
  105. Bizgaze.Apps.PayBacks.Components.LoyaltyPoints.Instance()._totalamount = response.result.Points;
  106. $(".lblSum").text(Bizgaze.Apps.PayBacks.Components.LoyaltyPoints.Instance()._totalamount);
  107. $('#divsumDisplayText').text('Total Loyalty Points').addClass('mr-10');
  108. }
  109. });
  110. });
  111. }
  112. bindContact(autocontactid, textcontainerid) {
  113. var instance = this;
  114. var isCustomer = Unibase.Platform.Membership.Infos.Identity.getCurrentUser().isRestrictedUser;
  115. var UserId = Unibase.Platform.Membership.Infos.Identity.getCurrentUser().userId;
  116. if (isCustomer) {
  117. instance.fileCacheHelper.loadJsFile("apps/crm/contacts/managers/contactmanager.js", function () {
  118. Bizgaze.Apps.Crm.Contacts.Managers.ContactManager.Instance().getsprlOrgContact(UserId).then(function (response) {
  119. ;
  120. var contactId = response.result.OrgContactId;
  121. var orgContactName = response.result.OrgContactName;
  122. var organizationName = response.result.OrganizationName;
  123. var PhoneNumber = response.result.PhoneNumber;
  124. var SapCode = "";
  125. if (response.result.SAPCIN != null) {
  126. SapCode = response.result.SAPCIN;
  127. }
  128. if (response.result.StatusName != 'Confirmed') {
  129. $('.divCustomProperties_bizgazepaybacks_couponredemptions').remove();
  130. }
  131. if (response.result.StatusId == 2) {
  132. $('.divCustomProperties_bizgazepaybacks_couponredemptions').remove();
  133. }
  134. var organiozationid = response.result.OrganizationId;
  135. var contactName = organizationName + '-' + SapCode + '-' + PhoneNumber;
  136. var contact = new Option(contactName, organiozationid.toString(), true);
  137. $(autocontactid).append(contact);
  138. $(autocontactid).val(organiozationid).trigger("change");
  139. Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("platform/tag/managers/tagmanager.js", function (response) {
  140. Unibase.Platform.Forms.Managers.TagManager.Instance().GetTagItemsByRefId(Number(organiozationid)).then(function (response) {
  141. if (response.result != null) {
  142. var data = response.result;
  143. $(autocontactid).attr('data-addldata', data[0].TagId);
  144. }
  145. });
  146. });
  147. });
  148. });
  149. }
  150. }
  151. andriodTextToSpeech(textToSpeech) {
  152. if (isMobileApp()) {
  153. Unibase.Platform.Helpers.MobileHelper.Instance().textToSpeech(textToSpeech);
  154. }
  155. }
  156. static Instance() {
  157. if (this.instance === undefined) {
  158. this.instance = new LoyaltyPoints();
  159. }
  160. return this.instance;
  161. }
  162. }
  163. Components.LoyaltyPoints = LoyaltyPoints;
  164. })(Components = PayBacks.Components || (PayBacks.Components = {}));
  165. })(PayBacks = Apps.PayBacks || (Apps.PayBacks = {}));
  166. })(Apps = Bizgaze.Apps || (Bizgaze.Apps = {}));
  167. })(Bizgaze || (Bizgaze = {}));