Built files from Bizgaze WebServer
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

redemption.js 15KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  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 Redemption 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. ScanCoupons(serialno, container, propobj, callback) {
  28. Unibase.Platform.Helpers.FileCacheHelper.Instance().loadCssFile("tenants/themes/compact/css/coupons.css", null);
  29. Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/paybacks/managers/schememanager.js", function () {
  30. var IsScannedCoupon = false;
  31. if (isMobileApp()) {
  32. IsScannedCoupon = true;
  33. }
  34. propobj[0].IsScannedCoupon = IsScannedCoupon;
  35. Bizgaze.Apps.Paybacks.Managers.SchemeManager.Instance().ScanCoupon(serialno.toUpperCase(), propobj).then(function (response) {
  36. let audiotype;
  37. if (response.result == null) {
  38. $(".scan_couponscancontol").val('');
  39. if (response.message.includes('invoiceitemid_unique')) {
  40. response.message = "Coupon Already Redeemed";
  41. }
  42. MessageHelper.Instance().showError(response.message, $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id'));
  43. setTimeout(function () {
  44. $(".bizgaze_FormErrorMessages").empty();
  45. }, 3000);
  46. }
  47. if (response.status == 0) {
  48. if (isMobileApp())
  49. Bizgaze.Apps.PayBacks.Components.Redemption.Instance().andriodTextToSpeech('Coupon Applied');
  50. else {
  51. audiotype = Unibase.Platform.Automation.Enums.NotifyAlerts.CouponBeep;
  52. Unibase.Platform.Automation.Components.Notifier.Instance().playAudio(audiotype);
  53. }
  54. if (response.result != null) {
  55. var html = '<div id="divHtmlContainer_' + response.result.CouponId + '" class="divHtmlContainer_CPN"> <div class="align-items-stretch d-flex flex-column flex-lg-row justify-content-between scanned-coupon-card m-2">' +
  56. ' <div class="scanned-coupon-value p-2 d-flex align-items-center justify-content-between justify-content-lg-center"> <div class="scanned-coupon-card-img"> ' +
  57. '<img src="/tenants/themes/compact/imgs/discount-parallel.svg" alt="couponimg" class="d-block d-lg-none img-fluid p-2 p-lg-3 rounded-circle h-50p h-lg-100p w-50p w-lg-100p" />' +
  58. ' </div> <h1 class="text-white font-weight-700" id="lblcouponvalue_' + response.result.CouponId + '">' + response.result.couponvalue + ' *</h1> </div> <div class="scanned-coupon-card-details mt-sm-0 pa-10 pa-sm-15 pl-5 pl-sm-15 pt-5 pt-sm-15 word-break" style="flex-grow: 2; border-left: 2px dashed orange;">' +
  59. ' <div class="d-flex justify-content-between scanned-coupon-card-details-header"> <div class="scanned-coupon-card-details-header-left d-flex flex-column ml-2 ml-sm-0"> ' +
  60. '<p class="font-weight-600 mt-1"> <span class="d-none d-lg-inline">Coupon Code </span> <span> <span class="d-none d-lg-inline">: &nbsp; </span> ' + response.result.CouponNo + ' </span> </p>' +
  61. ' <p class="font-14 font-sm-16"> <span class="d-none d-lg-inline">Product Code </span> <span> <span class="d-none d-lg-inline">: &nbsp; </span>' + response.result.ItemName + ' </span> </p> </div> </div>' +
  62. ' <div class="scanned-coupon-card-detail-value pl-2 pl-sm-0 font-12 font-sm-16"> <div class="row"> <div class="col-xxl-6 d-flex mt-0 mt-sm-10 value line-height-5"> ' +
  63. '<div class="coupon-detail-icon w-50 d-flex align-items-center"> <img src="/tenants/themes/compact/imgs/discount.svg" alt="tag image" class="w-25p h-25p mr-2 d-none d-lg-inline" /> <p>Coupon Value</p> </div>' +
  64. ' <p class="w-10">:</p> <p class="w-30" id="lblbasevalue_' + response.result.CouponId + '">' + (response.result.Basevalue + response.result.LuckyCouponValue) + '</p> </div>' +
  65. '</div> <div class="row"><div class="col-xxl-6 d-flex mt-0 mt-sm-10 value line-height-5"> <div class="coupon-detail-icon w-50 d-flex align-items-center"> <img src="/tenants/themes/compact/imgs/tag.svg" alt="discount image" class="w-25p h-25p mr-5 d-none d-lg-inline" />' +
  66. ' <p>Add. Discount</p> </div> <p class="w-10">:</p> <p class="w-30" id="lbldiscountvalue_' + response.result.CouponId + '">' + response.result.DiscountValue + '</p> </div> ' +
  67. '<div class="col-xxl-6 d-flex mt-0 mt-sm-10 value line-height-5"> <div class="coupon-detail-icon w-50 d-flex align-items-center"> <img src="/tenants/themes/compact/imgs/tag.svg" alt="discount image" class="w-25p h-25p mr-5 d-none d-lg-inline" />' +
  68. ' <p>Spl. Discount</p> </div> <p class="w-10">:</p> <p class="w-30" id="lbldisincentivevalue_' + response.result.CouponId + '">' + response.result.IncentiveValue + '</p> </div> </div> </div> </div> ' +
  69. '<div class="scanned-coupon-card-right align-items-center pr-15 d-none d-lg-flex"> <div class="align-items-center d-flex h-100p justify-content-center scanned-coupon-card-img w-100p ml-3 ml-sm-0"> <img src="/tenants/themes/compact/imgs/discount-parallel.svg" alt="couponimg" class="img-fluid p-3 rounded-circle" /> </div> </div> </div></div>';
  70. $("#divMainContainer").removeClass('col-sm-12');
  71. $("#divListContainer").removeClass('col-sm-6');
  72. $("#divListContainer").addClass('col-12');
  73. $("#divHtmlContainer:first").after(html);
  74. $("#lblcouponvalue_" + response.result.CouponId).text("");
  75. $("#lblcouponvalue_" + response.result.CouponId).text(response.result.CouponValue);
  76. $("#lbldiscountvalue_" + response.result.CouponId).text(response.result.DiscountValue);
  77. $("#lbldisincentivevalue_" + response.result.CouponId).text(response.result.IncentiveValue);
  78. if (Number($(".lblSum").text()) == 0) {
  79. Bizgaze.Apps.PayBacks.Components.Redemption.Instance()._totalamount = 0;
  80. Bizgaze.Apps.PayBacks.Components.Redemption.Instance()._totalcount = 0;
  81. }
  82. Bizgaze.Apps.PayBacks.Components.Redemption.Instance()._totalamount += response.result.CouponValue;
  83. Bizgaze.Apps.PayBacks.Components.Redemption.Instance()._totalcount += 1;
  84. $(".lblSum").text(Bizgaze.Apps.PayBacks.Components.Redemption.Instance()._totalamount);
  85. $(".lblCount").text(Bizgaze.Apps.PayBacks.Components.Redemption.Instance()._totalcount);
  86. }
  87. }
  88. else {
  89. if (isMobileApp())
  90. if (response.message.includes('Redeemed'))
  91. Bizgaze.Apps.PayBacks.Components.Redemption.Instance().andriodTextToSpeech("Coupon already redeemed");
  92. else
  93. Bizgaze.Apps.PayBacks.Components.Redemption.Instance().andriodTextToSpeech(response.message);
  94. else {
  95. if (response.message.includes('Invalid/duplicate')) {
  96. audiotype = Unibase.Platform.Automation.Enums.NotifyAlerts.InvalidDuplicateCoupon;
  97. Unibase.Platform.Automation.Components.Notifier.Instance().playAudio(audiotype);
  98. }
  99. else if (response.message.includes('Redeemed')) {
  100. audiotype = Unibase.Platform.Automation.Enums.NotifyAlerts.CouponAlreadyRedeemed;
  101. Unibase.Platform.Automation.Components.Notifier.Instance().playAudio(audiotype);
  102. }
  103. else if (response.message.includes('UnAuthentic')) {
  104. audiotype = Unibase.Platform.Automation.Enums.NotifyAlerts.UnAuthenticCoupon;
  105. Unibase.Platform.Automation.Components.Notifier.Instance().playAudio(audiotype);
  106. }
  107. else if (response.message.includes('contact')) {
  108. return null;
  109. }
  110. else if (response.message.includes('Deactivated')) {
  111. return null;
  112. }
  113. else {
  114. audiotype = Unibase.Platform.Automation.Enums.NotifyAlerts.InvalidDuplicateCoupon;
  115. Unibase.Platform.Automation.Components.Notifier.Instance().playAudio(audiotype);
  116. }
  117. }
  118. }
  119. return false;
  120. });
  121. });
  122. }
  123. bindContact(autocontactid, textcontainerid) {
  124. var instance = this;
  125. var isCustomer = Unibase.Platform.Membership.Infos.Identity.getCurrentUser().isRestrictedUser;
  126. var UserId = Unibase.Platform.Membership.Infos.Identity.getCurrentUser().userId;
  127. if (isCustomer) {
  128. instance.fileCacheHelper.loadJsFile("apps/crm/contacts/managers/contactmanager.js", function () {
  129. Bizgaze.Apps.Crm.Contacts.Managers.ContactManager.Instance().getsprlOrgContact(UserId).then(function (response) {
  130. debugger;
  131. var contactId = response.result.OrgContactId;
  132. var orgContactName = response.result.OrgContactName;
  133. var organizationName = response.result.OrganizationName;
  134. var PhoneNumber = response.result.PhoneNumber;
  135. var SapCode = "";
  136. if (response.result.SAPCIN != null) {
  137. SapCode = response.result.SAPCIN;
  138. }
  139. if (response.result.StatusName != 'Confirmed') {
  140. $('.divCustomProperties_bizgazepaybacks_couponredemptions').remove();
  141. }
  142. if (response.result.StatusId == 2) {
  143. $('.divCustomProperties_bizgazepaybacks_couponredemptions').remove();
  144. }
  145. var organiozationid = response.result.OrganizationId;
  146. var contactName = organizationName + '-' + SapCode + '-' + PhoneNumber;
  147. var contact = new Option(contactName, organiozationid.toString(), true);
  148. $(autocontactid).append(contact);
  149. $(autocontactid).val(organiozationid).trigger("change");
  150. Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("platform/tag/managers/tagmanager.js", function (response) {
  151. Unibase.Platform.Forms.Managers.TagManager.Instance().GetTagItemsByRefId(Number(organiozationid)).then(function (response) {
  152. if (response.result != null) {
  153. var data = response.result;
  154. $(autocontactid).attr('data-addldata', data[0].TagId);
  155. }
  156. });
  157. });
  158. });
  159. });
  160. }
  161. }
  162. andriodTextToSpeech(textToSpeech) {
  163. if (isMobileApp()) {
  164. Unibase.Platform.Helpers.MobileHelper.Instance().textToSpeech(textToSpeech);
  165. }
  166. }
  167. RefreshCouponData() {
  168. Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/paybacks/managers/schememanager.js", function () {
  169. Bizgaze.Apps.Paybacks.Managers.SchemeManager.Instance().RefreshCouponData().then(function (response) {
  170. var res = response;
  171. });
  172. });
  173. }
  174. static Instance() {
  175. if (this.instance === undefined) {
  176. this.instance = new Redemption();
  177. }
  178. return this.instance;
  179. }
  180. }
  181. Components.Redemption = Redemption;
  182. })(Components = PayBacks.Components || (PayBacks.Components = {}));
  183. })(PayBacks = Apps.PayBacks || (Apps.PayBacks = {}));
  184. })(Apps = Bizgaze.Apps || (Bizgaze.Apps = {}));
  185. })(Bizgaze || (Bizgaze = {}));