| 37031 |
amit |
1 |
var blockTargetRow = null;
|
|
|
2 |
var unblockTargetRow = null;
|
|
|
3 |
|
| 33045 |
amit.gupta |
4 |
$(function () {
|
| 29811 |
tejbeer |
5 |
|
| 33045 |
amit.gupta |
6 |
$(document).on('click', ".partner-credit-detail", function () {
|
| 29811 |
tejbeer |
7 |
|
| 33045 |
amit.gupta |
8 |
loadCreditDetail("main-content");
|
|
|
9 |
});
|
| 29811 |
tejbeer |
10 |
|
|
|
11 |
|
| 37031 |
amit |
12 |
// Switch a partner to a different credit gateway (e.g. SIDBI) and activate it.
|
|
|
13 |
$(document).on('click', '.switch-credit-gateway', function () {
|
| 33045 |
amit.gupta |
14 |
var row = $(this).closest("tr");
|
|
|
15 |
var id = $(this).data('id');
|
|
|
16 |
let gateway = $(row).find('select').val();
|
| 37031 |
amit |
17 |
if (typeof gateway === "undefined") {
|
| 33886 |
amit.gupta |
18 |
gateway = row.find('.mk_gateway').data("gateway");
|
| 33047 |
amit.gupta |
19 |
}
|
| 33045 |
amit.gupta |
20 |
if (confirm(`Are you sure you want to activate ${gateway}?`)) {
|
| 37031 |
amit |
21 |
doPostAjaxRequestHandler(`${context}/switchCreditGateway?id=${id}&gateway=${gateway}`,
|
| 33045 |
amit.gupta |
22 |
function (response) {
|
|
|
23 |
row.html(response);
|
|
|
24 |
alert(`${gateway} successfully activated`);
|
| 37031 |
amit |
25 |
});
|
|
|
26 |
}
|
|
|
27 |
});
|
| 29811 |
tejbeer |
28 |
|
|
|
29 |
|
| 37031 |
amit |
30 |
// Block credit -> open modal to capture the mandatory reason.
|
|
|
31 |
$(document).on('click', '.block-credit', function () {
|
|
|
32 |
blockTargetRow = $(this).closest("tr");
|
|
|
33 |
$('#blockCreditId').val($(this).data('id'));
|
|
|
34 |
$('#blockCreditReason').val('');
|
|
|
35 |
$('#blockCreditModal').modal('show');
|
|
|
36 |
});
|
|
|
37 |
|
|
|
38 |
$(document).on('click', '#confirmBlockCredit', function () {
|
|
|
39 |
var id = $('#blockCreditId').val();
|
|
|
40 |
var reason = $('#blockCreditReason').val().trim();
|
|
|
41 |
if (reason === '') {
|
|
|
42 |
alert('Reason is mandatory to block credit');
|
|
|
43 |
return;
|
| 33045 |
amit.gupta |
44 |
}
|
| 37031 |
amit |
45 |
doPostAjaxRequestHandler(`${context}/blockCredit?id=${id}&reason=${encodeURIComponent(reason)}`,
|
|
|
46 |
function (response) {
|
|
|
47 |
if (blockTargetRow) {
|
|
|
48 |
blockTargetRow.html(response);
|
|
|
49 |
}
|
|
|
50 |
$('#blockCreditModal').modal('hide');
|
|
|
51 |
alert('Credit blocked successfully');
|
|
|
52 |
});
|
| 33045 |
amit.gupta |
53 |
});
|
| 29811 |
tejbeer |
54 |
|
| 37031 |
amit |
55 |
|
|
|
56 |
// Unblock credit -> open modal, load the full block/unblock history, then confirm.
|
|
|
57 |
$(document).on('click', '.unblock-credit', function () {
|
|
|
58 |
unblockTargetRow = $(this).closest("tr");
|
| 33045 |
amit.gupta |
59 |
var id = $(this).data('id');
|
| 37031 |
amit |
60 |
var fofoId = $(this).data('fofo-id');
|
|
|
61 |
$('#unblockCreditId').val(id);
|
|
|
62 |
$('#unblockCreditReason').val('');
|
|
|
63 |
$('#creditBlockLogsContainer').html('Loading...');
|
|
|
64 |
doGetAjaxRequestHandler(`${context}/creditBlockLogs?fofoId=${fofoId}`,
|
|
|
65 |
function (response) {
|
|
|
66 |
$('#creditBlockLogsContainer').html(response);
|
|
|
67 |
});
|
|
|
68 |
$('#unblockCreditModal').modal('show');
|
|
|
69 |
});
|
|
|
70 |
|
|
|
71 |
$(document).on('click', '#confirmUnblockCredit', function () {
|
|
|
72 |
var id = $('#unblockCreditId').val();
|
|
|
73 |
var reason = $('#unblockCreditReason').val().trim();
|
|
|
74 |
var url = `${context}/unblockCredit?id=${id}`;
|
|
|
75 |
if (reason !== '') {
|
|
|
76 |
url += `&reason=${encodeURIComponent(reason)}`;
|
| 33190 |
amit.gupta |
77 |
}
|
| 37031 |
amit |
78 |
doPostAjaxRequestHandler(url,
|
|
|
79 |
function (response) {
|
|
|
80 |
if (unblockTargetRow) {
|
|
|
81 |
unblockTargetRow.html(response);
|
|
|
82 |
}
|
|
|
83 |
$('#unblockCreditModal').modal('hide');
|
|
|
84 |
alert('Credit unblocked successfully');
|
|
|
85 |
});
|
| 33045 |
amit.gupta |
86 |
});
|
| 30877 |
tejbeer |
87 |
|
| 29811 |
tejbeer |
88 |
});
|
|
|
89 |
|
|
|
90 |
function loadCreditDetail(domId) {
|
| 33045 |
amit.gupta |
91 |
doGetAjaxRequestHandler(context + "/getCreditDetail",
|
|
|
92 |
function (response) {
|
|
|
93 |
$('#' + domId).html(response);
|
|
|
94 |
});
|
| 29811 |
tejbeer |
95 |
|
| 30877 |
tejbeer |
96 |
|
| 37031 |
amit |
97 |
}
|