Subversion Repositories SmartDukaan

Rev

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