Subversion Repositories SmartDukaan

Rev

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

Rev Author Line No. Line
30866 tejbeer 1
 
30859 tejbeer 2
$(function() {
3
 
4
	$(document).on('click', ".sd-credit", function() {
5
 
6
		loadSdCredit("main-content");
7
	});
8
 
9
 
10
 
11
	$(document).on('click', ".sanction-request", function() {
12
 
13
		loadSanctionRequest("main-content");
14
	});
15
 
16
 
30929 tejbeer 17
 
18
	$(document).on('click', ".loan-summary", function() {
19
 
20
		loadLoanDetail("main-content");
21
	});
22
 
30859 tejbeer 23
	var table = $('#sdCredit').DataTable();
24
	$(document).on('dblclick', '#sdCredit tbody tr', function() {
25
		console.log("dblclick");
26
		var data = table.row(this).data();
27
 
30951 tejbeer 28
 
30859 tejbeer 29
		$(this).find(":input").attr('disabled', false).show();
30
 
30951 tejbeer 31
		$(this).find("input[name=interestRate]").attr('disabled', true);
32
		$(this).find("input[name=freeDays]").attr('disabled', true);
33
		$(this).find("input[name=creditDays]").attr('disabled', true);
30859 tejbeer 34
 
30951 tejbeer 35
 
30859 tejbeer 36
	});
37
 
38
	$(document).on('input', 'table#sdCredit input[type=file]', function() {
39
		if (confirm('Confirm upload ?')) {
40
			var fileSelector = $(this)[0];
41
			if (fileSelector != undefined
42
				&& fileSelector.files[0] != undefined) {
43
				var url = `${context}/document-upload`;
44
				console.log(url);
45
				var file = this.files[0];
46
				console.log("file" + file);
47
				let fileInput = $(this);
48
				console.log("fileInput" + file);
49
				doAjaxUploadRequestHandler(
50
					url,
51
					'POST',
52
					file,
53
					function(response) {
54
						console.log(response);
55
						var documentId = response.response.document_id;
56
						console.log("documentId : " + documentId);
57
						fileInput.closest('td').find("input[type=hidden]").val(documentId);
58
					});
59
				// alert("Retailer Shop Document
60
				// is required");
61
			}
62
		} else {
63
			// Do nothing!
64
		}
65
	});
66
 
67
 
30866 tejbeer 68
 
69
 
30929 tejbeer 70
 
30859 tejbeer 71
	$(document).on('click', '.credit-requirement-send', function() {
72
		var row = $(this).closest("tr");
73
		console.log(row);
74
		var rowIndex = $(this).closest('tr').prevAll().length;
75
		console.log(rowIndex);
30871 tejbeer 76
		var fofoId = $(row).find("td:eq(0)").text();
77
 
30872 tejbeer 78
		var securityCheck = $(row).find("input[type=hidden]").val();
30866 tejbeer 79
 
30859 tejbeer 80
 
30871 tejbeer 81
		console.log(securityCheck);
30866 tejbeer 82
 
83
 
30859 tejbeer 84
		var limit = $(row).find("td:eq(5) input[type='text']").val();
85
		var interest = $(row).find("td:eq(8) input[type='text']").val();
86
		var freedays = $(row).find("td:eq(9) input[type='text']").val();
87
		var creditDays = $(row).find("td:eq(10) input[type='text']").val();
88
 
89
		console.log(freedays)
90
 
91
		var sdCreditReq = {};
92
		sdCreditReq['fofoId'] = fofoId
93
		sdCreditReq['securityCheck'] = securityCheck
94
		sdCreditReq['limit'] = limit
95
		sdCreditReq['interest'] = interest
96
		sdCreditReq['freeDays'] = freedays
97
		sdCreditReq['creditDays'] = creditDays
98
 
99
		var jsonObject = JSON.stringify(sdCreditReq);
100
 
101
		console.log(jsonObject);
102
		if (confirm("Are you sure you want to submit the request") == true) {
103
			doAjaxRequestWithJsonHandler(context + "/creditRequirement", "POST", jsonObject, function(response) {
104
				row.html(response);
105
				row.css("background-color", "#F8F8FF");
106
 
107
			});
108
		}
109
 
110
 
111
	})
112
 
113
 
114
	$(document).on('click', '.sanction-request-send', function() {
115
		var row = $(this).closest("tr");
116
		console.log(row);
117
		var rowIndex = $(this).closest('tr').prevAll().length;
118
		console.log(rowIndex);
119
		var id = $(row).find("td:eq(0)").text();
120
 
121
 
122
		var approvalAmount = $(row).find("td:eq(12) input[type='text']").val();
123
		var freedays = $(row).find("td:eq(13) input[type='text']").val();
124
 
125
		var status = $(row).find("td:eq(14) option:selected").val();
126
 
127
		console.log(freedays)
128
 
129
		var sanctionReq = {};
130
		sanctionReq['id'] = id
131
		sanctionReq['status'] = status
132
		sanctionReq['approvalAmount'] = approvalAmount
133
		sanctionReq['freeDays'] = freedays
134
 
135
		var jsonObject = JSON.stringify(sanctionReq);
136
 
137
		console.log(jsonObject);
138
		if (confirm("Are you sure you want to submit the request") == true) {
139
			doAjaxRequestWithJsonHandler(context + "/sanctionRequest", "POST", jsonObject, function(response) {
140
				row.html(response);
141
				row.css("background-color", "#F8F8FF");
142
 
143
			});
144
		}
145
 
146
 
147
	})
148
});
149
 
150
function loadSdCredit(domId) {
151
 
152
	doGetAjaxRequestHandler(context + "/getSDCreditReq", function(
153
		response) {
154
		$('#' + domId).html(response);
155
	});
156
}
157
 
158
function loadSanctionRequest(domId) {
159
	doGetAjaxRequestHandler(context + "/getSanctionRequest", function(
160
		response) {
161
		$('#' + domId).html(response);
162
	});
163
}
30929 tejbeer 164
 
165
function loadLoanDetail(domId) {
166
 
167
	doGetAjaxRequestHandler(context + "/getLoans", function(
168
		response) {
169
		$('#' + domId).html(response);
170
	});
171
}