Subversion Repositories SmartDukaan

Rev

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

Rev Author Line No. Line
30866 tejbeer 1
 
31020 tejbeer 2
 
30859 tejbeer 3
$(function() {
4
 
5
	$(document).on('click', ".sd-credit", function() {
6
 
7
		loadSdCredit("main-content");
8
	});
9
 
10
 
11
 
12
	$(document).on('click', ".sanction-request", function() {
13
 
14
		loadSanctionRequest("main-content");
15
	});
16
 
17
 
30929 tejbeer 18
 
19
	$(document).on('click', ".loan-summary", function() {
20
 
21
		loadLoanDetail("main-content");
22
	});
23
 
31020 tejbeer 24
 
25
 
26
 
27
	$(document).on('click', ".sanction-order-hold", function() {
28
 
29
		loadSanctionHoldOrder("main-content");
30
	});
31
 
32439 tejbeer 32
 
33
	$(document).on('click', ".sanction-order-unhold", function() {
34
 
35
		loadSanctionUnholdOrder("main-content");
36
	});
30859 tejbeer 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
 
30951 tejbeer 42
 
30859 tejbeer 43
		$(this).find(":input").attr('disabled', false).show();
44
 
32055 tejbeer 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);
48
	 */
30859 tejbeer 49
 
50
	});
51
 
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);
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
 
81
 
33854 tejus.loha 82
	$(document).on('click', ".reset-hard-limit", function () {
83
		var id = $(this).data('id');
84
		if (confirm("Are you sure you want to reset hard limit")) {
85
			doPutAjaxRequestHandler(`${context}/resetHardLimit?id=${id}`, function (response) {
86
				if (response) {
87
					alert("Hard Limit reset.");
88
					var hardLimitInput = $('input[name="hardLimit"]');
89
					hardLimitInput.prop('disabled', false);
90
					hardLimitInput.val('false');
91
					hardLimitInput.prop('disabled', true);
92
				}
93
			});
94
		}
95
	});
30866 tejbeer 96
 
30859 tejbeer 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);
30871 tejbeer 102
		var fofoId = $(row).find("td:eq(0)").text();
103
 
30872 tejbeer 104
		var securityCheck = $(row).find("input[type=hidden]").val();
30866 tejbeer 105
 
30859 tejbeer 106
 
30871 tejbeer 107
		console.log(securityCheck);
30866 tejbeer 108
 
109
 
30859 tejbeer 110
		var limit = $(row).find("td:eq(5) input[type='text']").val();
111
		var interest = $(row).find("td:eq(8) input[type='text']").val();
33854 tejus.loha 112
		var freedays = $(row).find("td:eq(10) input[type='text']").val();
113
		var creditDays = $(row).find("td:eq(11) input[type='text']").val();
30859 tejbeer 114
 
115
		console.log(freedays)
116
 
117
		var sdCreditReq = {};
118
		sdCreditReq['fofoId'] = fofoId
119
		sdCreditReq['securityCheck'] = securityCheck
120
		sdCreditReq['limit'] = limit
121
		sdCreditReq['interest'] = interest
122
		sdCreditReq['freeDays'] = freedays
123
		sdCreditReq['creditDays'] = creditDays
124
 
125
		var jsonObject = JSON.stringify(sdCreditReq);
126
 
127
		console.log(jsonObject);
128
		if (confirm("Are you sure you want to submit the request") == true) {
129
			doAjaxRequestWithJsonHandler(context + "/creditRequirement", "POST", jsonObject, function(response) {
130
				row.html(response);
131
				row.css("background-color", "#F8F8FF");
132
 
133
			});
134
		}
135
 
136
 
137
	})
138
 
139
	$(document).on('click', '.sanction-request-send', function() {
140
		var row = $(this).closest("tr");
141
		console.log(row);
142
		var rowIndex = $(this).closest('tr').prevAll().length;
143
		console.log(rowIndex);
144
		var id = $(row).find("td:eq(0)").text();
145
 
146
 
32055 tejbeer 147
		var approvalAmount = $(row).find(".approveamount input[type='text']").val();
148
		var freedays = $(row).find(".freedays input[type='text']").val();
30859 tejbeer 149
 
31020 tejbeer 150
 
32528 tejbeer 151
		var status = $(row).find(".sanctionstatus option:selected").val();
30859 tejbeer 152
 
32528 tejbeer 153
		var stockHold = $(row).find(".stockholdcheckbox input[type='checkbox']").is(":checked") ? true : false;
31020 tejbeer 154
 
155
 
30859 tejbeer 156
		console.log(freedays)
157
 
158
		var sanctionReq = {};
159
		sanctionReq['id'] = id
160
		sanctionReq['status'] = status
161
		sanctionReq['approvalAmount'] = approvalAmount
162
		sanctionReq['freeDays'] = freedays
163
 
31020 tejbeer 164
		sanctionReq['stockHold'] = stockHold
165
 
166
 
30859 tejbeer 167
		var jsonObject = JSON.stringify(sanctionReq);
168
 
169
		console.log(jsonObject);
170
		if (confirm("Are you sure you want to submit the request") == true) {
171
			doAjaxRequestWithJsonHandler(context + "/sanctionRequest", "POST", jsonObject, function(response) {
172
				row.html(response);
173
				row.css("background-color", "#F8F8FF");
174
 
175
			});
176
		}
177
 
178
 
31020 tejbeer 179
 
30859 tejbeer 180
	})
31020 tejbeer 181
 
182
 
183
	$(document).on('click', '.sanction-request-unhold', function() {
184
		var row = $(this).closest("tr");
185
		console.log(row);
186
		var transactionId = $(row).find("td:eq(3)").text();
187
		if (confirm("Are you sure you want to Unhold the request") == true) {
188
 
189
			doPostAjaxRequestHandler(context + "/unholdOrder?transactionId="
190
				+ transactionId, function(response) {
191
					if (response == 'true') {
192
						alert("unhold successfully");
32459 tejbeer 193
						loadSanctionUnholdOrder("main-content");
31020 tejbeer 194
					}
195
 
196
				});
197
		}
198
 
199
 
200
	})
201
 
30859 tejbeer 202
});
203
function loadSdCredit(domId) {
204
 
205
	doGetAjaxRequestHandler(context + "/getSDCreditReq", function(
206
		response) {
207
		$('#' + domId).html(response);
208
	});
209
}
210
 
211
function loadSanctionRequest(domId) {
212
	doGetAjaxRequestHandler(context + "/getSanctionRequest", function(
213
		response) {
214
		$('#' + domId).html(response);
215
	});
216
}
30929 tejbeer 217
 
218
function loadLoanDetail(domId) {
219
 
220
	doGetAjaxRequestHandler(context + "/getLoans", function(
221
		response) {
222
		$('#' + domId).html(response);
223
	});
224
}
31020 tejbeer 225
 
226
 
227
function loadSanctionHoldOrder(domId) {
228
 
229
	doGetAjaxRequestHandler(context + "/getSanctionHoldOrder", function(
230
		response) {
231
		$('#' + domId).html(response);
232
	});
233
}
32439 tejbeer 234
 
235
function loadSanctionUnholdOrder(domId) {
236
 
237
	doGetAjaxRequestHandler(context + "/getSanctionUnholdOrder", function(
238
		response) {
239
		$('#' + domId).html(response);
240
	});
241
}
242
 
243