Subversion Repositories SmartDukaan

Rev

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