Subversion Repositories SmartDukaan

Rev

Rev 33854 | Rev 33894 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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