Rev 33886 | View as "text/plain" | Blame | Compare with Previous | Last modification | View Log | RSS feed
var blockTargetRow = null;var unblockTargetRow = null;$(function () {$(document).on('click', ".partner-credit-detail", function () {loadCreditDetail("main-content");});// Switch a partner to a different credit gateway (e.g. SIDBI) and activate it.$(document).on('click', '.switch-credit-gateway', function () {var row = $(this).closest("tr");var id = $(this).data('id');let gateway = $(row).find('select').val();if (typeof gateway === "undefined") {gateway = row.find('.mk_gateway').data("gateway");}if (confirm(`Are you sure you want to activate ${gateway}?`)) {doPostAjaxRequestHandler(`${context}/switchCreditGateway?id=${id}&gateway=${gateway}`,function (response) {row.html(response);alert(`${gateway} successfully activated`);});}});// Block credit -> open modal to capture the mandatory reason.$(document).on('click', '.block-credit', function () {blockTargetRow = $(this).closest("tr");$('#blockCreditId').val($(this).data('id'));$('#blockCreditReason').val('');$('#blockCreditModal').modal('show');});$(document).on('click', '#confirmBlockCredit', function () {var id = $('#blockCreditId').val();var reason = $('#blockCreditReason').val().trim();if (reason === '') {alert('Reason is mandatory to block credit');return;}doPostAjaxRequestHandler(`${context}/blockCredit?id=${id}&reason=${encodeURIComponent(reason)}`,function (response) {if (blockTargetRow) {blockTargetRow.html(response);}$('#blockCreditModal').modal('hide');alert('Credit blocked successfully');});});// Unblock credit -> open modal, load the full block/unblock history, then confirm.$(document).on('click', '.unblock-credit', function () {unblockTargetRow = $(this).closest("tr");var id = $(this).data('id');var fofoId = $(this).data('fofo-id');$('#unblockCreditId').val(id);$('#unblockCreditReason').val('');$('#creditBlockLogsContainer').html('Loading...');doGetAjaxRequestHandler(`${context}/creditBlockLogs?fofoId=${fofoId}`,function (response) {$('#creditBlockLogsContainer').html(response);});$('#unblockCreditModal').modal('show');});$(document).on('click', '#confirmUnblockCredit', function () {var id = $('#unblockCreditId').val();var reason = $('#unblockCreditReason').val().trim();var url = `${context}/unblockCredit?id=${id}`;if (reason !== '') {url += `&reason=${encodeURIComponent(reason)}`;}doPostAjaxRequestHandler(url,function (response) {if (unblockTargetRow) {unblockTargetRow.html(response);}$('#unblockCreditModal').modal('hide');alert('Credit unblocked successfully');});});});function loadCreditDetail(domId) {doGetAjaxRequestHandler(context + "/getCreditDetail",function (response) {$('#' + domId).html(response);});}