Subversion Repositories SmartDukaan

Rev

Rev 33894 | Rev 35534 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
33865 tejus.loha 1
$(function () {
30866 tejbeer 2
 
33865 tejus.loha 3
    $(document).on('click', ".sd-credit", function () {
31020 tejbeer 4
 
33865 tejus.loha 5
        loadSdCredit("main-content");
6
    });
30859 tejbeer 7
 
8
 
33865 tejus.loha 9
    $(document).on('click', ".sanction-request", function () {
30859 tejbeer 10
 
33865 tejus.loha 11
        loadSanctionRequest("main-content");
12
    });
30859 tejbeer 13
 
34355 ranu 14
    $(document).on('click', ".rbm-sanction-request", function () {
30859 tejbeer 15
 
34355 ranu 16
        loadRBML2SanctionRequest("main-content");
17
    });
18
 
19
 
33865 tejus.loha 20
    $(document).on('click', ".loan-summary", function () {
30859 tejbeer 21
 
33865 tejus.loha 22
        loadLoanDetail("main-content");
23
    });
30859 tejbeer 24
 
25
 
33865 tejus.loha 26
    $(document).on('click', ".sanction-order-hold", function () {
30929 tejbeer 27
 
33865 tejus.loha 28
        loadSanctionHoldOrder("main-content");
29
    });
30929 tejbeer 30
 
31
 
33865 tejus.loha 32
    $(document).on('click', ".sanction-order-unhold", function () {
31020 tejbeer 33
 
33865 tejus.loha 34
        loadSanctionUnholdOrder("main-content");
35
    });
36
    var table = $('#sdCredit').DataTable();
37
    $(document).on('dblclick', '#sdCredit tbody tr', function () {
38
        console.log("dblclick");
39
        var data = table.row(this).data();
31020 tejbeer 40
 
41
 
33865 tejus.loha 42
        $(this).find(":input").attr('disabled', false).show();
31020 tejbeer 43
 
33865 tejus.loha 44
        /*	$(this).find("input[name=interestRate]").attr('disabled', true);
45
            $(this).find("input[name=freeDays]").attr('disabled', true);
46
            $(this).find("input[name=creditDays]").attr('disabled', true);
47
     */
31020 tejbeer 48
 
33865 tejus.loha 49
    });
32439 tejbeer 50
 
33865 tejus.loha 51
    $(document).on('input', 'table#sdCredit input[type=file]', function () {
52
        if (confirm('Confirm upload ?')) {
53
            var fileSelector = $(this)[0];
54
            if (fileSelector != undefined
55
                && fileSelector.files[0] != undefined) {
56
                var url = `${context}/document-upload`;
57
                console.log(url);
58
                var file = this.files[0];
59
                console.log("file" + file);
60
                let fileInput = $(this);
61
                console.log("fileInput" + file);
62
                doAjaxUploadRequestHandler(
63
                    url,
64
                    'POST',
65
                    file,
66
                    function (response) {
67
                        console.log(response);
68
                        var documentId = response.response.document_id;
69
                        console.log("documentId : " + documentId);
70
                        fileInput.closest('td').find("input[type=hidden]").val(documentId);
71
                    });
72
                // alert("Retailer Shop Document
73
                // is required");
74
            }
75
        } else {
76
            // Do nothing!
77
        }
78
    });
32439 tejbeer 79
 
30859 tejbeer 80
 
33865 tejus.loha 81
    $(document).on('click', ".reset-hard-limit", function () {
82
        var id = $(this).data('id');
33894 tejus.loha 83
        const self = this;
33865 tejus.loha 84
        if (confirm("Are you sure you want to reset hard limit")) {
33894 tejus.loha 85
            var hardLimitInput = $(this).closest('td').find('input[name="hardLimit"]');
33865 tejus.loha 86
            doPutAjaxRequestHandler(`${context}/resetHardLimit?id=${id}`, function (response) {
87
                if (response) {
88
                    alert("Hard Limit reset.");
89
                    hardLimitInput.val('false');
33894 tejus.loha 90
                    $(self).closest('td').find('.reset-hard-limit').hide();
91
 
33865 tejus.loha 92
                }
93
            });
94
        }
95
    });
30951 tejbeer 96
 
33865 tejus.loha 97
    $(document).on('click', '.credit-requirement-send', function () {
98
        var row = $(this).closest("tr");
99
        console.log(row);
100
        var rowIndex = $(this).closest('tr').prevAll().length;
101
        console.log(rowIndex);
102
        var fofoId = $(row).find("td:eq(0)").text();
30859 tejbeer 103
 
33865 tejus.loha 104
        var securityCheck = $(row).find("input[type=hidden]").val();
30859 tejbeer 105
 
106
 
33865 tejus.loha 107
        console.log(securityCheck);
30859 tejbeer 108
 
109
 
33865 tejus.loha 110
        var limit = $(row).find("td:eq(5) input[type='text']").val();
111
        var interest = $(row).find("td:eq(9) input[type='text']").val();
112
        var freedays = $(row).find("td:eq(10) input[type='text']").val();
113
        var creditDays = $(row).find("td:eq(11) input[type='text']").val();
30866 tejbeer 114
 
30871 tejbeer 115
 
30859 tejbeer 116
		var sdCreditReq = {};
117
		sdCreditReq['fofoId'] = fofoId
118
		sdCreditReq['securityCheck'] = securityCheck
119
		sdCreditReq['limit'] = limit
120
		sdCreditReq['interest'] = interest
121
		sdCreditReq['freeDays'] = freedays
122
		sdCreditReq['creditDays'] = creditDays
123
 
33865 tejus.loha 124
        var jsonObject = JSON.stringify(sdCreditReq);
30859 tejbeer 125
 
126
		console.log(jsonObject);
33865 tejus.loha 127
        if (confirm("Are you sure you want to submit the request")) {
30859 tejbeer 128
			doAjaxRequestWithJsonHandler(context + "/creditRequirement", "POST", jsonObject, function(response) {
129
				row.html(response);
130
				row.css("background-color", "#F8F8FF");
131
 
33865 tejus.loha 132
            });
133
        }
30859 tejbeer 134
 
135
 
33865 tejus.loha 136
    })
30859 tejbeer 137
 
33865 tejus.loha 138
    $(document).on('click', '.sanction-request-send', function () {
139
        var row = $(this).closest("tr");
140
        console.log(row);
141
        var rowIndex = $(this).closest('tr').prevAll().length;
142
        console.log(rowIndex);
143
        var id = $(row).find("td:eq(0)").text();
30859 tejbeer 144
 
145
 
33865 tejus.loha 146
        var approvalAmount = $(row).find(".approveamount input[type='text']").val();
147
        var freedays = $(row).find(".freedays input[type='text']").val();
30859 tejbeer 148
 
31020 tejbeer 149
 
33865 tejus.loha 150
        var status = $(row).find(".sanctionstatus option:selected").val();
30859 tejbeer 151
 
33865 tejus.loha 152
        var stockHold = $(row).find(".stockholdcheckbox input[type='checkbox']").is(":checked") ? true : false;
31020 tejbeer 153
 
154
 
33865 tejus.loha 155
        console.log(freedays)
30859 tejbeer 156
 
33865 tejus.loha 157
        var sanctionReq = {};
158
        sanctionReq['id'] = id
159
        sanctionReq['status'] = status
160
        sanctionReq['approvalAmount'] = approvalAmount
161
        sanctionReq['freeDays'] = freedays
30859 tejbeer 162
 
33865 tejus.loha 163
        sanctionReq['stockHold'] = stockHold
31020 tejbeer 164
 
165
 
33865 tejus.loha 166
        var jsonObject = JSON.stringify(sanctionReq);
30859 tejbeer 167
 
33865 tejus.loha 168
        console.log(jsonObject);
169
        if (confirm("Are you sure you want to submit the request") == true) {
170
            doAjaxRequestWithJsonHandler(context + "/sanctionRequest", "POST", jsonObject, function (response) {
171
                row.html(response);
172
                row.css("background-color", "#F8F8FF");
30859 tejbeer 173
 
33865 tejus.loha 174
            });
175
        }
30859 tejbeer 176
 
177
 
33865 tejus.loha 178
    })
31020 tejbeer 179
 
34355 ranu 180
    $(document).on('click', '.l2-sanction-approval-send', function () {
181
        var row = $(this).closest("tr");
182
        console.log(row);
183
        var rowIndex = $(this).closest('tr').prevAll().length;
184
        console.log(rowIndex);
185
        var id = $(row).find("td:eq(0)").text();
31020 tejbeer 186
 
34355 ranu 187
 
188
        var approvalAmount = $(row).find(".approveamount input[type='text']").val();
189
        var freedays = $(row).find(".freedays input[type='text']").val();
190
 
191
 
192
        var status = $(row).find(".sanctionstatus option:selected").val();
193
 
194
        var stockHold = $(row).find(".stockholdcheckbox input[type='checkbox']").is(":checked") ? true : false;
195
 
196
 
197
        console.log(freedays)
198
 
199
        var sanctionReq = {};
200
        sanctionReq['id'] = id
201
        sanctionReq['status'] = status
202
        sanctionReq['approvalAmount'] = approvalAmount
203
        sanctionReq['freeDays'] = freedays
204
 
205
        sanctionReq['stockHold'] = stockHold
206
 
207
 
208
        var jsonObject = JSON.stringify(sanctionReq);
209
 
210
        console.log(jsonObject);
211
        if (confirm("Are you sure you want to submit the request") == true) {
212
            doAjaxRequestWithJsonHandler(context + "/rbmL2ApprovalSanctionRequest", "POST", jsonObject, function (response) {
213
                row.html(response);
214
                row.css("background-color", "#F8F8FF");
215
 
216
            });
217
        }
218
 
219
 
220
    })
221
 
222
 
33865 tejus.loha 223
    $(document).on('click', '.sanction-request-unhold', function () {
224
        var row = $(this).closest("tr");
225
        console.log(row);
226
        var transactionId = $(row).find("td:eq(3)").text();
227
        if (confirm("Are you sure you want to Unhold the request") == true) {
31020 tejbeer 228
 
33865 tejus.loha 229
            doPostAjaxRequestHandler(context + "/unholdOrder?transactionId="
230
                + transactionId, function (response) {
231
                if (response == 'true') {
232
                    alert("unhold successfully");
233
                    loadSanctionUnholdOrder("main-content");
234
                }
31020 tejbeer 235
 
33865 tejus.loha 236
            });
237
        }
31020 tejbeer 238
 
239
 
33865 tejus.loha 240
    })
31020 tejbeer 241
 
33865 tejus.loha 242
});
31020 tejbeer 243
 
30859 tejbeer 244
function loadSdCredit(domId) {
245
 
33865 tejus.loha 246
    doGetAjaxRequestHandler(context + "/getSDCreditReq", function (
247
        response) {
248
        $('#' + domId).html(response);
249
    });
30859 tejbeer 250
}
251
 
252
function loadSanctionRequest(domId) {
33865 tejus.loha 253
    doGetAjaxRequestHandler(context + "/getSanctionRequest", function (
254
        response) {
255
        $('#' + domId).html(response);
256
    });
30859 tejbeer 257
}
30929 tejbeer 258
 
34355 ranu 259
function loadRBML2SanctionRequest(domId) {
260
    doGetAjaxRequestHandler(context + "/getRbmL2SanctionRequest", function (
261
        response) {
262
        $('#' + domId).html(response);
263
    });
264
}
265
 
30929 tejbeer 266
function loadLoanDetail(domId) {
267
 
33865 tejus.loha 268
    doGetAjaxRequestHandler(context + "/getLoans", function (
269
        response) {
270
        $('#' + domId).html(response);
271
    });
30929 tejbeer 272
}
31020 tejbeer 273
 
274
 
275
function loadSanctionHoldOrder(domId) {
276
 
33865 tejus.loha 277
    doGetAjaxRequestHandler(context + "/getSanctionHoldOrder", function (
278
        response) {
279
        $('#' + domId).html(response);
280
    });
31020 tejbeer 281
}
32439 tejbeer 282
 
283
function loadSanctionUnholdOrder(domId) {
284
 
33865 tejus.loha 285
    doGetAjaxRequestHandler(context + "/getSanctionUnholdOrder", function (
286
        response) {
287
        $('#' + domId).html(response);
288
    });
32439 tejbeer 289
}
290
 
291