Built files from Bizgaze WebServer
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

rulereconfigure.js 19KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. var Unibase;
  2. (function (Unibase) {
  3. let Apps;
  4. (function (Apps) {
  5. let Automation;
  6. (function (Automation) {
  7. class RuleReConfigure extends Unibase.Platform.Core.BaseComponent {
  8. jsFiles() {
  9. return ["platform/tag/managers/tagmanager.js", "platform/apps/managers/appmanager.js", "apps/transact/managers/interfaces/automation/irulemanager.js", "apps/transact/managers/automation/rulemanager.js"];
  10. }
  11. cssFiles() {
  12. return [];
  13. }
  14. html(id, containerid) {
  15. var html = `<div class="b-b bg-white modal-header"><strong class="text-dark">Re-Configure</strong> </div>
  16. <div class="modal-body" id="CardViewer_modal">
  17. <div class="card">
  18. <div class="card-body" style="">
  19. <div class="row" id="div_Kanban">
  20. <div class="col-sm-2"><button type="button" class="btn btn-success" id="reconfigure">Re-Configure</button></div>
  21. </div>
  22. </div>
  23. </div>
  24. </div>
  25. <div class="bg-white modal-footer">
  26. <a class="btn btn-light btn-sm btn-center mr-auto" id="btnClose">Close</a>
  27. </div>`;
  28. return html;
  29. }
  30. load(id, containerid, callback) {
  31. $("#btnClose").click(function () {
  32. $('#' + containerid).modal('hide');
  33. $('#' + containerid).remove();
  34. });
  35. var instance = this;
  36. var appid = instance.appSettings.InstalledAppId;
  37. $("#reconfigure").click(function () {
  38. Unibase.Platform.Apps.Managers.AppManager.Instance().getInstallApp(appid).then(function (resu) {
  39. if (resu.result.AppTitle == "Credit Limit Rule") {
  40. Bizgaze.Apps.Transact.Managers.RuleManager.Instance().refreshCreditRule(0).then(function (res) {
  41. MessageHelper.Instance().showSuccess("We Will Notify Once The Process Is Done", '');
  42. Unibase.Platform.Helpers.NavigationHelper.Instance().closePopUp();
  43. });
  44. }
  45. else {
  46. if (resu.result.AppTitle == "Order Approval Rules") {
  47. Bizgaze.Apps.Transact.Managers.RuleManager.Instance().refreshcreditlimitrules("0", "OrderApproval Rule", 0).then(function (response) {
  48. MessageHelper.Instance().showSuccess("We Will Notify Once The Process Is Done", '');
  49. Unibase.Platform.Helpers.NavigationHelper.Instance().closePopUp();
  50. });
  51. }
  52. else if (resu.result.AppTitle == "Price Code Rules") {
  53. Bizgaze.Apps.Transact.Managers.RuleManager.Instance().refreshPriceCodeRule(0).then(function (res) {
  54. MessageHelper.Instance().showSuccess("We Will Notify Once The Process Is Done", '');
  55. Unibase.Platform.Helpers.NavigationHelper.Instance().closePopUp();
  56. });
  57. }
  58. else {
  59. Bizgaze.Apps.Transact.Managers.RuleManager.Instance().refreshcreditlimitrules("0", "PaymentTerm Rule", 0).then(function (res) {
  60. MessageHelper.Instance().showSuccess("We Will Notify Once The Process Is Done", '');
  61. Unibase.Platform.Helpers.NavigationHelper.Instance().closePopUp();
  62. });
  63. }
  64. }
  65. });
  66. });
  67. }
  68. refreshWidgets() {
  69. var Installedappid = Unibase.Themes.Providers.DetailHelper.installedAppId;
  70. var ModalContainers = Unibase.Platform.Helpers.NavigationHelper.ModalContainerIds;
  71. var ContainerId = ModalContainers[ModalContainers.length - 1];
  72. Unibase.Themes.Compact.Components.Details.Instance().loadWidgets(Installedappid, Number($(".nav-link.active").find("#hf_PortletId").val()), "#" + ContainerId);
  73. var detailInstance = Unibase.Themes.Compact.Components.Details.Instance();
  74. var panel = "#" + detailInstance._containerId;
  75. var obj = Unibase.Themes.Compact.Components.Details.Instance();
  76. obj._recordId = Unibase.Themes.Providers.DetailHelper.recordId;
  77. obj._installedAppId = Unibase.Themes.Providers.DetailHelper.installedAppId;
  78. detailInstance.loadAppDefaultWidget(obj, panel, detailInstance._containerId, function () {
  79. });
  80. }
  81. updatePriceCodeRuleContact(ContactDefaultId, ContactId, LobId, IsPriceCodeAutomated, IsPriceCodeExcluded) {
  82. let instance = this;
  83. let Msg = "";
  84. if (IsPriceCodeAutomated == 0) {
  85. Msg = "Do you really want to Delete Contact from this Rule ?";
  86. }
  87. else {
  88. if (!IsPriceCodeExcluded) {
  89. Msg = "Do you really want to Exclude Contact from this Rule ?";
  90. IsPriceCodeExcluded = true;
  91. }
  92. else {
  93. Msg = "Do you really want to Include Contact into this Rule ?";
  94. IsPriceCodeExcluded = false;
  95. }
  96. }
  97. bootbox.confirm(Msg, function (result) {
  98. if (result) {
  99. let PriceCodeRuleId = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.filter(function (o) { return o.Key === "hf_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_pricecoderuleid"; })[0].Value;
  100. let PriceCodeId = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.filter(function (o) { return o.Key === "hf_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_pricecodeid"; })[0].Value;
  101. let postData = {
  102. ContactDefaultId: ContactDefaultId,
  103. PriceCodeRuleId: PriceCodeRuleId,
  104. ContactIds: (ContactId).toString(),
  105. IsPriceCodeAutomated: IsPriceCodeAutomated,
  106. IsPriceCodeExcluded: IsPriceCodeExcluded,
  107. LobId: LobId,
  108. PriceCodeId: PriceCodeId,
  109. ContactId: Number(ContactId)
  110. };
  111. Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFiles(["apps/transact/managers/interfaces/automation/irulemanager.js", "apps/transact/managers/automation/rulemanager.js"], function () {
  112. Bizgaze.Apps.Transact.Managers.RuleManager.Instance().UpdatePriceCodeRuleContact(postData).then(function (res) {
  113. instance.refreshWidgets();
  114. });
  115. });
  116. }
  117. });
  118. }
  119. updateCreditLimitRuleContact(ContactDetailId, ContactId, CreditLimit, IsAutomated, IsExcluded) {
  120. let instance = this;
  121. let Msg = "";
  122. if (IsAutomated == 0) {
  123. Msg = "Do you really want to Delete Contact from this Rule ?";
  124. }
  125. else {
  126. if (!IsExcluded) {
  127. Msg = "Do you really want to Exclude Contact from this Rule ?";
  128. IsExcluded = true;
  129. }
  130. else {
  131. Msg = "Do you really want to Include Contact into this Rule ?";
  132. IsExcluded = false;
  133. }
  134. }
  135. bootbox.confirm(Msg, function (result) {
  136. if (result) {
  137. var CreditRuleId = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.filter(function (o) { return o.Key === "hf_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_creditruleid"; })[0].Value;
  138. let postData = {
  139. ContactDetailId: ContactDetailId,
  140. CreditRuleId: CreditRuleId,
  141. ContactIds: ContactId.toString(),
  142. CreditLimit: CreditLimit,
  143. IsAutomated: IsAutomated,
  144. IsExcluded: IsExcluded,
  145. ContactId: Number(ContactId)
  146. };
  147. Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFiles(["apps/transact/managers/interfaces/automation/irulemanager.js", "apps/transact/managers/automation/rulemanager.js"], function () {
  148. Bizgaze.Apps.Transact.Managers.RuleManager.Instance().UpdateCreditLimitRuleContact(postData).then(function (res) {
  149. instance.refreshWidgets();
  150. });
  151. });
  152. }
  153. });
  154. }
  155. updatePaymentTermRuleContact(ContactDefaultId, ContactId, LobId, IsPaymentTermAutomated, IsPaymentTermExcluded) {
  156. let instance = this;
  157. let Msg = "";
  158. if (IsPaymentTermAutomated == 0) {
  159. Msg = "Do you really want to Delete Contact from this Rule ?";
  160. }
  161. else {
  162. if (!IsPaymentTermExcluded) {
  163. Msg = "Do you really want to Exclude Contact from this Rule ?";
  164. IsPaymentTermExcluded = true;
  165. }
  166. else {
  167. Msg = "Do you really want to Include Contact into this Rule ?";
  168. IsPaymentTermExcluded = false;
  169. }
  170. }
  171. bootbox.confirm(Msg, function (result) {
  172. if (result) {
  173. let PaymentTermRuleId = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.filter(function (o) { return o.Key === "hf_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_paymenttermruleid"; })[0].Value;
  174. let PaymentTermId = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.filter(function (o) { return o.Key === "hf_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_paymenttermid"; })[0].Value;
  175. let postData = {
  176. ContactDefaultId: ContactDefaultId,
  177. PaymentTermRuleId: PaymentTermRuleId,
  178. ContactIds: (ContactId).toString(),
  179. IsPaymentTermAutomated: IsPaymentTermAutomated,
  180. IsPaymentTermExcluded: IsPaymentTermExcluded,
  181. LobId: LobId,
  182. PaymentTermId: PaymentTermId,
  183. ContactId: Number(ContactId)
  184. };
  185. Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFiles(["apps/transact/managers/interfaces/automation/irulemanager.js", "apps/transact/managers/automation/rulemanager.js"], function () {
  186. Bizgaze.Apps.Transact.Managers.RuleManager.Instance().UpdatePaymentTermRuleContact(postData).then(function (res) {
  187. instance.refreshWidgets();
  188. });
  189. });
  190. }
  191. });
  192. }
  193. updateOrderApprovalRuleContact(ContactDefaultId, ContactId, LobId, IsOrderApprovalAutomated, IsOrderApprovalExcluded) {
  194. let instance = this;
  195. let Msg = "";
  196. if (IsOrderApprovalAutomated == 0) {
  197. Msg = "Do you really want to Delete Contact from this Rule ?";
  198. }
  199. else {
  200. if (!IsOrderApprovalExcluded) {
  201. Msg = "Do you really want to Exclude Contact from this Rule ?";
  202. IsOrderApprovalExcluded = true;
  203. }
  204. else {
  205. Msg = "Do you really want to Include Contact into this Rule ?";
  206. IsOrderApprovalExcluded = false;
  207. }
  208. }
  209. bootbox.confirm(Msg, function (result) {
  210. if (result) {
  211. let OrderApprovalRuleId = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.filter(function (o) { return o.Key === "hf_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_orderapprovalruleid"; })[0].Value;
  212. let postData = {
  213. ContactDefaultId: ContactDefaultId,
  214. OrderApprovalRuleId: OrderApprovalRuleId,
  215. ContactIds: (ContactId).toString(),
  216. IsOrderApprovalAutomated: IsOrderApprovalAutomated,
  217. IsOrderApprovalExcluded: IsOrderApprovalExcluded,
  218. LobId: 0,
  219. OrderApprovalId: 0,
  220. ContactId: Number(ContactId)
  221. };
  222. Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFiles(["apps/transact/managers/interfaces/automation/irulemanager.js", "apps/transact/managers/automation/rulemanager.js"], function () {
  223. Bizgaze.Apps.Transact.Managers.RuleManager.Instance().UpdateOrderApprovalRuleContact(postData).then(function (res) {
  224. instance.refreshWidgets();
  225. });
  226. });
  227. }
  228. });
  229. }
  230. reconfigurePaymentTerm() {
  231. $(".li_DetailSetting_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_Re-Configure").click(function () {
  232. Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/transact/managers/automation/rulemanager.js", function () {
  233. let pkid = Unibase.Themes.Providers.DetailHelper.recordId;
  234. MessageHelper.Instance().showSuccess("We Will Notify Once The Process Is Done", '');
  235. Bizgaze.Apps.Transact.Managers.RuleManager.Instance().refreshPaymentTermRule(pkid);
  236. });
  237. });
  238. }
  239. reconfigureOrderApprovalRule() {
  240. $(".li_DetailSetting_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_Re-Configure").click(function () {
  241. Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/transact/managers/automation/rulemanager.js", function () {
  242. let pkid = Unibase.Themes.Providers.DetailHelper.recordId;
  243. MessageHelper.Instance().showSuccess("We Will Notify Once The Process Is Done", '');
  244. Bizgaze.Apps.Transact.Managers.RuleManager.Instance().refreshOrderApprovalRule(pkid);
  245. });
  246. });
  247. }
  248. reconfigureCreditLimitRule() {
  249. $(".li_DetailSetting_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_Re-Configure").click(function () {
  250. Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/transact/managers/automation/rulemanager.js", function () {
  251. let pkid = Unibase.Themes.Providers.DetailHelper.recordId;
  252. MessageHelper.Instance().showSuccess("We Will Notify Once The Process Is Done", '');
  253. Bizgaze.Apps.Transact.Managers.RuleManager.Instance().refreshCreditRule(pkid);
  254. });
  255. });
  256. }
  257. reconfigurePriceCodeRule() {
  258. $(".li_DetailSetting_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_Re-Configure").click(function () {
  259. Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/transact/managers/automation/rulemanager.js", function () {
  260. let pkid = Unibase.Themes.Providers.DetailHelper.recordId;
  261. MessageHelper.Instance().showSuccess("We Will Notify Once The Process Is Done", '');
  262. Bizgaze.Apps.Transact.Managers.RuleManager.Instance().refreshPriceCodeRule(pkid);
  263. });
  264. });
  265. }
  266. reconfigureSkuRecommendation() {
  267. $(".li_DetailSetting_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_Re-Configure").click(function () {
  268. Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/transact/managers/automation/rulemanager.js", function () {
  269. let pkid = Unibase.Themes.Providers.DetailHelper.recordId;
  270. MessageHelper.Instance().showSuccess("We Will Notify Once The Process Is Done", '');
  271. Bizgaze.Apps.Transact.Managers.RuleManager.Instance().refreshSkuRecommendation(pkid);
  272. });
  273. });
  274. }
  275. static Instance() {
  276. if (this._instance === undefined)
  277. this._instance = new RuleReConfigure();
  278. return this._instance;
  279. }
  280. }
  281. Automation.RuleReConfigure = RuleReConfigure;
  282. })(Automation = Apps.Automation || (Apps.Automation = {}));
  283. })(Apps = Unibase.Apps || (Unibase.Apps = {}));
  284. })(Unibase || (Unibase = {}));