var Bizgaze; (function (Bizgaze) { let Apps; (function (Apps) { let Transact; (function (Transact) { let Controls; (function (Controls) { class CustomerCreditHealth extends Unibase.Platform.Core.BaseComponent { constructor() { super(...arguments); this.ContainerId = ""; this.PopUpContainerId = ""; } init(formpropertyid, prop, callback) { var instance = this; instance.loadControlSettings(prop.ControlJsonText, prop.FormPropertyId); instance.loadPropertySettings(prop.PropertySettings, prop.FormPropertyId); } loadControl(containerid, prop) { let instance = this; instance.ContainerId = Unibase.Platform.Helpers.NavigationHelper.Instance().getLastContainerId(); let html = instance.getCustomerCreditHealth_html(); $("#" + containerid).html(html); } getCustomerCreditHealth_html() { var html = '
'; return html; } loadControlSettings(controlsettingjson, formpropertyid) { return null; } loadPropertySettings(propertysettings, formpropertyid) { return null; } bindEditFormDetails(formpropertyid, propval, DocPropertyName) { return null; } getCreditHealth(OrgContactId, OrganizationId, Type) { var instance = this; instance.ContainerId = Unibase.Platform.Helpers.NavigationHelper.Instance().getLastContainerId(); let ContactId = Number(OrganizationId == 0 ? OrgContactId : OrganizationId); if (ContactId == 0) { return; } instance.bindKPIEvents(ContactId, Type); instance.getCCH_KPIDetails(OrgContactId, OrganizationId, Type); } bindKPIEvents(ContactId, Type) { let instance = this; let TypeName = "Sales"; if (Type.toLowerCase().indexOf("purchase") != -1) { TypeName = "Purchase"; } instance.fileCacheHelper.loadJsFile("apps/transact/controls/orders/credithealth.js", function () { $("#" + instance.ContainerId).find("#div_Due").unbind().click(function () { Unibase.Platform.Analytics.Managers.ReportManager.Instance().getReportByUniqueId("Bizgaze_Platform_Analytics_Reports_Due_CCH_" + TypeName + "Orders").then(function (res) { if (res.result != null && res.result != "") { var filter = []; filter.push({ "Key": "organizationid", "Value": ContactId.toString(), ExpOp: 1 }); Unibase.Platform.Analytics.Components.ReportViewer.Instance().report_ViewAllByUniqueId("Bizgaze_Platform_Analytics_Reports_Due_CCH_" + TypeName + "Orders", null, filter, null); } else { instance.getKPIPopUp("Due", "div_Due"); instance.getInvoiceDetails(ContactId, "Due"); } }); }); $("#" + instance.ContainerId).find('#div_OverDue').unbind().click(function () { Unibase.Platform.Analytics.Managers.ReportManager.Instance().getReportByUniqueId("Bizgaze_Platform_Analytics_Reports_OverDue_CCH_" + TypeName + "Orders").then(function (res) { if (res.result != null && res.result != "") { var filter = []; filter.push({ "Key": "organizationid", "Value": ContactId.toString(), ExpOp: 1 }); Unibase.Platform.Analytics.Components.ReportViewer.Instance().report_ViewAllByUniqueId("Bizgaze_Platform_Analytics_Reports_OverDue_CCH_" + TypeName + "Orders", null, filter, null); } else { instance.getKPIPopUp("Over Due", "div_Due"); instance.getInvoiceDetails(ContactId, "OverDue"); } }); }); $("#" + instance.ContainerId).find("#div_Credits").unbind().click(function () { Unibase.Platform.Analytics.Managers.ReportManager.Instance().getReportByUniqueId("Bizgaze_Platform_Analytics_Reports_Credits_CCH_" + TypeName + "Orders").then(function (res) { if (res.result != null && res.result != "") { var filter = []; filter.push({ "Key": "organizationid", "Value": ContactId.toString(), ExpOp: 1 }); Unibase.Platform.Analytics.Components.ReportViewer.Instance().report_ViewAllByUniqueId("Bizgaze_Platform_Analytics_Reports_Credits_CCH_" + TypeName + "Orders", null, filter, null); } else { instance.getKPIPopUp("Credits", "div_Credit"); instance.getCreditNotesDetails(ContactId); } }); }); $("#" + instance.ContainerId).find("#div_Clearance").unbind().click(function () { Unibase.Platform.Analytics.Managers.ReportManager.Instance().getReportByUniqueId("Bizgaze_Platform_Analytics_Reports_Clearance_CCH_Orders").then(function (res) { if (res.result != null && res.result != "") { var filter = []; filter.push({ "Key": "organizationid", "Value": ContactId.toString(), ExpOp: 1 }); Unibase.Platform.Analytics.Components.ReportViewer.Instance().report_ViewAllByUniqueId("Bizgaze_Platform_Analytics_Reports_Clearance_CCH_Orders", null, filter, null); } else { instance.getKPIPopUp("Clearance", "div_Clearance"); instance.getPaymentDetails(ContactId); } }); }); }); } getKPIPopUp(WidgetTitle, CurrentDiv) { let instance = this; instance.PopUpContainerId = '_modal_bizgaze_popup_' + moment().unix(); instance.navigationHelper.popup(0, instance.PopUpContainerId, Bizgaze.Apps.Transact.Orders.CreditHealth.Instance(), null, Unibase.Platform.Helpers.Size.ExtraLarge); $("#" + instance.PopUpContainerId).find("." + CurrentDiv).removeClass("hidden"); $("#" + instance.PopUpContainerId).find(".title_widget").text(WidgetTitle); $("#" + instance.PopUpContainerId).find("#widget_list_container").empty(); } noData() { let instance = this; $("#" + instance.PopUpContainerId).find(".header_list").html('