var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; var _pagesize = 10; var pageIndex = 0; var Bizgaze; (function (Bizgaze) { let Apps; (function (Apps) { let Transact; (function (Transact) { let Components; (function (Components) { let Wallets; (function (Wallets) { class PayoutRequestSubmissionApproval extends Unibase.Platform.Core.BaseComponent { constructor() { super(...arguments); this.Installedappid = 0; } cssFiles() { return [""]; } jsFiles() { return ["apps/transact/components/Wallets/payoutrequestsubmissionapproval.js", "apps/transact/managers/wallets/walletmanager.js", "tenants/themes/default/components/details/details.js", "apps/transact/managers/inventory/itemmanager.js", "tenants/themes/default/notificationrefresh.js", "apps/paybacks/components/secondaryqrcodedetails.js", "libs/bizgaze/helpers/messages/messagehelper.js", ]; } init(containerid) { var instance = this; Bizgaze.Apps.Transact.Components.Wallets.PayoutRequestSubmissionApproval.Instance().render(containerid); Bizgaze.Apps.Transact.Components.Wallets.PayoutRequestSubmissionApproval.Instance().LoadPayoutRequestSubmissionStages(); Bizgaze.Apps.Transact.Components.Wallets.PayoutRequestSubmissionApproval.Instance().getInstalledapp(); $('#txt_CouponSubmission_Org_search').change(function () { $(".CpnSubmission").remove(); pageIndex = 0; var StageId = Number($('select#txt_CouponSubmission_Org_search option:selected').val()); if (StageId != 0) Bizgaze.Apps.Transact.Components.Wallets.PayoutRequestSubmissionApproval.Instance().getPayoutRequestSubmissionApproval(StageId, 0); }); $("#checkAll").change(function () { $("input:checkbox").prop('checked', $(this).prop("checked")); }); $('#btn_list_load_more__modal_bizgaze_srpl').click(function () { pageIndex++; var StageId = Number($('select#txt_CouponSubmission_Org_search option:selected').val()); if (StageId != 0) Bizgaze.Apps.Transact.Components.Wallets.PayoutRequestSubmissionApproval.Instance().getPayoutRequestSubmissionApproval(StageId, pageIndex); }); var Stagestatusname = ""; $('#btnsubmissions').click(function () { if ($('select#txt_CouponSubmission_Org_search option:selected').text() == "Successfully Generated") { Bizgaze.Apps.Transact.Components.Wallets.PayoutRequestSubmissionApproval.Instance().ApprovedByFinanceStage(); } if ($('select#txt_CouponSubmission_Org_search option:selected').text() == "In-Progress") { Stagestatusname = "authenticsucessfullygenerated"; Bizgaze.Apps.Transact.Components.Wallets.PayoutRequestSubmissionApproval.Instance().SuccessfullyGenerateStage(Stagestatusname); } if ($('select#txt_CouponSubmission_Org_search option:selected').text() == "Payment In-Progress") { Stagestatusname = "authenticapprovedbyfinance"; Bizgaze.Apps.Transact.Components.Wallets.PayoutRequestSubmissionApproval.Instance().SuccessfullyGenerateStage(Stagestatusname); } }); } html(id, containerid) { var html = ``; return html; } load(id, containerid, callback) { return __awaiter(this, void 0, void 0, function* () { var instance = this; }); } loadhtml(id, containerid) { var instance = this; var html = ``; return html; } render(containerid) { var html = `
Submission No
Contact Name
Contact Type
Stage Name
Redeem Value
Created Date
`; $("#" + containerid).html(html); } getInstalledapp() { var instance = this; let uniqueid = 'Bizgaze_Extension_Transact_PayoutRequest_App_PayoutRequest'; Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("platform/apps/managers/appmanager.js", function () { Unibase.Platform.Apps.Managers.AppManager.Instance().getInstallAppId(uniqueid).then(function (response) { var data = response.result; Bizgaze.Apps.Transact.Components.Wallets.PayoutRequestSubmissionApproval.Instance().Installedappid = data.InstalledAppId; }); }); } getPayoutRequestSubmissionApproval(StageId, page) { if (StageId != 0) Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/transact/managers/wallets/walletmanager.js", function () { Bizgaze.Apps.Transact.Managers.WalletManager.Instance().getPayoutRequestSubmissionApprovalData(StageId, page).then(function (response) { var totalRecords = 0; $('._btnsubmissions_div').addClass('hidden'); if (response.result._rows.length != 0) { var _datetimehelper = Unibase.Platform.Helpers.DateTimeHelper.Instance(); var isCheckCouponSubmission = false; var Stagestatusname = ''; var finalhtml = ''; let StageName = response.result._rows[0].Cells[4]; if (StageName == "Successfully Generated") $(".checkAll").removeClass("hidden"); else if (StageName == "In-Progress") $(".checkAll").removeClass("hidden"); else if (StageName == "Payment In-Progress") $(".checkAll").removeClass("hidden"); else $(".checkAll").addClass("hidden"); totalRecords = response.result._totalRecords; for (var i = 0; i < response.result._rows.length; i++) { var data = response.result._rows[i]; var submissionId = data.Cells[0]; var SubmissionNo = data.Cells[1]; var CustomerName = data.Cells[2]; var CustomerTagName = 'NA'; var RedeemValue = data.Cells[5]; var StageId = data.Cells[4]; var _StageName = data.Cells[3]; var submissionDate = _datetimehelper.formatLocalDate1(data.Cells[6], ''); var html = ''; if (CustomerName == null) { CustomerName = 'NA'; } if (CustomerTagName == null) { CustomerTagName = 'NA'; } var index = Number(i); html += '
' + '' + '' + '' + '
' + '' + '' + '
' + CustomerName + '
' + '' + '
' + CustomerTagName + '
' + '' + '
' + _StageName + '
' + '' + '
' + RedeemValue + '
' + '' + '
' + submissionDate + '
' + ''; html += '
'; $(".Couponsubmissiondiv:last").after("
"); $("#AddCouponsubmissiondiv_" + submissionId).append(html); } } if ($('select#txt_CouponSubmission_Org_search option:selected').text() == "Successfully Generated" || $('select#txt_CouponSubmission_Org_search option:selected').text() == "Payment In-Progress") { $('#btnsubmissions').text('Approved By Finance'); $(".CheckCouponSubmissionNumber").removeClass("hidden"); $('._btnsubmissions_div').removeClass('hidden'); } else if ($('select#txt_CouponSubmission_Org_search option:selected').text() == "In-Progress") { $('#btnsubmissions').text('Verify'); $(".CheckCouponSubmissionNumber").removeClass("hidden"); $('._btnsubmissions_div').removeClass('hidden'); } $('#conta').removeClass('hidden'); if (totalRecords > _pagesize) { $("#gridPager2").show(); $("#cpntotalrecords").show(); } else { $("#gridPager2").hide(); } if (totalRecords > _pagesize) { var totalCount = totalRecords; var startingValue = 0; var _count = 0; var t = (1 + page) * 10; if (totalCount > 0) { startingValue = 1; _count = totalCount; } if (totalCount > t) _count = t; if (1 > 0) { startingValue += t - 10; } var res = startingValue + " - " + _count + " of " + totalRecords; $('#lblcpnTotals').text(res); if (_count == totalRecords) { $("#btn_list_load_more__modal_bizgaze_srpl").addClass("hidden"); } else { $("#btn_list_load_more__modal_bizgaze_srpl").removeClass("hidden"); } } else $('#lblcpnTotals').text(totalRecords); }); }); } cspValidation() { var inpStageID = 0; var InstalledAppId = Unibase.Themes.Providers.DetailHelper.installedAppId; var stagename = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + InstalledAppId + "_stagename").Value; var stageID = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + InstalledAppId + "_stageid").Value; $("#li_DetailSetting_" + InstalledAppId + "_Verify").addClass('hidden'); if (stagename == "In-Progress") { $("#li_DetailSetting_" + InstalledAppId + "_Verify").removeClass('hidden'); Unibase.Platform.Apps.Managers.StageManager.Instance().getStages(InstalledAppId).then(function (response) { for (let x of response.result) { if (x.StageName == "Successfully Generated") { inpStageID = x.StageId; } } }); } $(".DetailSetting_" + InstalledAppId + "_Verify").unbind().click(function () { Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile('platform/core/infos/status.js', function () { }); var recordid = Unibase.Themes.Providers.DetailHelper.recordId; var installedappid = Unibase.Themes.Providers.DetailHelper.installedAppId; Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile('tenants/themes/compact/components/details/details.js', function () { Unibase.Themes.Compact.Components.Details.Instance().changeStage(inpStageID, installedappid); }); }); } LoadPayoutRequestSubmissionStages() { var StageStatusName = "authenticsucessfullygenerated"; Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/transact/managers/wallets/walletmanager.js", function () { Bizgaze.Apps.Transact.Managers.WalletManager.Instance().getPayoutRequestSubmissionStages(StageStatusName).then(function (response) { var stagedata = response.result; for (var i = 0; i < stagedata.length; i++) { if (response.result[i].StageName == "Successfully Generated") { $('#txt_CouponSubmission_Org_search').append(''); Bizgaze.Apps.Transact.Components.Wallets.PayoutRequestSubmissionApproval.Instance().getPayoutRequestSubmissionApproval(stagedata[i].StageId, 0); } else $('#txt_CouponSubmission_Org_search').append(''); } }); }); } CouponSubmissionStageUpdate(Docarr) { Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/transact/managers/wallets/walletmanager.js", function () { Bizgaze.Apps.Transact.Managers.WalletManager.Instance().PayoutRequestSubmissonstagechanged(Docarr).then(function (response) { if (response.errors != null) { MessageHelper.Instance().showError(response.message, 'spn_cpnaprl_errormsg'); } else { $('.spn_cpnaprl_errormsg').html(''); MessageHelper.Instance().showSuccess(response.message, 'spn_cpnaprl_errormsg'); var StageId = Number($('select#txt_CouponSubmission_Org_search option:selected').val()); if (StageId != 0) Bizgaze.Apps.Transact.Components.Wallets.PayoutRequestSubmissionApproval.Instance().getPayoutRequestSubmissionApproval(StageId, 0); } }); }); } ApprovedByFinanceStage() { var StageId = $('select#txt_CouponSubmission_Org_search option:selected').val(); var StageStatusName = "authenticapprovedbyfinance"; var CheckedStages = []; $.each($("input[name='CheckCouponSubmissionNumber']:checked"), function () { CheckedStages.push($(this).val()); }); if (CheckedStages.length >= 1) { bootbox.confirm("Are you sure ! You want to change selected submission's to 'Approved By Finance' stage?", function (result) { if (result) { var Docarr = []; for (var i = 0; i < CheckedStages.length; i++) { var Stagedata = CheckedStages[i]; $(".Couponsubmissiondiv").find(".Couponsubmissiondiv1").each(function () { var sid = Number($(this).find('.hfCouponSubmissionId').val()); if (Number(Stagedata) == sid) { var data = { PayoutRequestId: Number($(this).find('.hfCouponSubmissionId').val()), SubmissionNo: $(this).find('.cpnsub_SubmissionNo').val(), CustomerName: $(this).find('.cpnsub_CustomerName').val(), CustomerTagName: $(this).find('.cpnsub_CustomerTagName').val(), StageStatusName: StageStatusName, CouponPoints: $(this).find('.cpnsub_CouponPoints').val(), SubmissionDate: $(this).find('.cpnsub_SubmissionDate').val(), StageId: StageId, }; Docarr.push(data); } }); } Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/transact/managers/wallets/walletmanager.js", function () { Bizgaze.Apps.Transact.Managers.WalletManager.Instance().PayoutRequestSubmissonstagechanged(Docarr).then(function (response) { if (response.errors != null) { MessageHelper.Instance().showError(response.message, 'spn_cpnaprl_errormsg'); } else { var objList = []; $('.spn_cpnaprl_errormsg').html(''); MessageHelper.Instance().showSuccess(response.message, 'spn_cpnaprl_errormsg'); var StageId = Number($('select#txt_CouponSubmission_Org_search option:selected').val()); if (StageId != 0) Bizgaze.Apps.Transact.Components.Wallets.PayoutRequestSubmissionApproval.Instance().getPayoutRequestSubmissionApproval(StageId, 0); } }); }); $("#checkAll").prop('checked', false); $(".CpnSubmission").remove(); } }); } else { alert("No submission is selected"); } } SuccessfullyGenerateStage(StageStatusName) { var StageId = $('select#txt_CouponSubmission_Org_search option:selected').val(); var CheckedStages = []; $.each($("input[name='CheckCouponSubmissionNumber']:checked"), function () { CheckedStages.push($(this).val()); }); var msg = ""; if (StageStatusName == "authenticsucessfullygenerated") { msg = "Successfully Generated"; } if (StageStatusName == "authenticapprovedbyfinance") { msg = "Approved By Finance"; } if (CheckedStages.length >= 1) { bootbox.confirm("Are you sure ! You want to change selected submission's to '" + msg + "' stage?", function (result) { if (result) { var Docarr = []; for (var i = 0; i < CheckedStages.length; i++) { var Stagedata = CheckedStages[i]; $(".Couponsubmissiondiv").find(".Couponsubmissiondiv1").each(function () { var sid = Number($(this).find('.hfCouponSubmissionId').val()); if (Number(Stagedata) == sid) { var data = { CouponSubmissionId: Number($(this).find('.hfCouponSubmissionId').val()), SubmissionNo: $(this).find('.cpnsub_SubmissionNo').val(), CustomerName: $(this).find('.cpnsub_CustomerName').val(), CustomerTagName: $(this).find('.cpnsub_CustomerTagName').val(), StageStatusName: StageStatusName, CouponPoints: $(this).find('.cpnsub_CouponPoints').val(), SubmissionDate: $(this).find('.cpnsub_SubmissionDate').val(), StageId: StageId, }; Docarr.push(data); } }); } Bizgaze.Apps.Transact.Components.Wallets.PayoutRequestSubmissionApproval.Instance().CouponSubmissionStageUpdate(Docarr); $("#checkAll").prop('checked', false); $(".CpnSubmission").remove(); } }); } else { alert("No submission is selected"); } } static Instance() { if (this.instance === undefined) { this.instance = new PayoutRequestSubmissionApproval(); } return this.instance; } } Wallets.PayoutRequestSubmissionApproval = PayoutRequestSubmissionApproval; })(Wallets = Components.Wallets || (Components.Wallets = {})); })(Components = Transact.Components || (Transact.Components = {})); })(Transact = Apps.Transact || (Apps.Transact = {})); })(Apps = Bizgaze.Apps || (Bizgaze.Apps = {})); })(Bizgaze || (Bizgaze = {}));