Subversion Repositories SmartDukaan

Rev

Rev 32676 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
32074 tejbeer 1
$(function() {
2
	$(document).on('click', ".vendor-catalog-pricing", function() {
3
		loadCreateVendorCatalogPricing("main-content");
4
	});
5
 
6
 
7
	$(document).on('click', ".vendor-catalog-pricing-request", function() {
8
		loadVendorCatalogPricingRequests("main-content");
9
	});
10
 
11
	$(document).on('click', ".vendor-price-circular", function() {
12
		loadVendorPriceCircular("main-content");
13
	});
14
 
15
 
16
	$(document).on('click', ".vendorcatalogpricing", function() {
17
 
18
		doGetAjaxRequestHandler(context + "/getVendorCatalogPricingByModel?catalogId=" + currentModel, function(response) {
19
			$('.vendorCatatlogPricingView').html(response);
20
 
21
		});
22
 
23
	});
24
 
25
 
26
 
27
 
28
	$(document).on('click', ".createvendorcatalogpricing", function() {
29
 
30
		var row = $(this).closest("tr");
31
 
32
		var vendorId = $(this).data('vendorid');
33
 
34
		console.log(vendorId)
35
 
36
		var transferPrice = $(row).find(".transferp").val();
37
		var dealerPrice = $(row).find(".dealerp").val();
38
		var mop = $(row).find(".mopp").val();
39
		var effectedOn = $(row).find(".effectedDate").val();
40
 
41
 
42
		if (transferPrice === "" && dealerPrice === "" && mop === "" && effectedOn === "") {
43
			alert("Field can't be empty");
44
			return;
45
		}
46
 
47
 
48
		if (transferPrice === "") {
49
			alert("Transfer Price is required");
50
			return;
51
		}
52
		if (dealerPrice === "") {
53
			alert("Dealer Price is required");
54
			return;
55
		}
56
		if (mop === "") {
57
			alert("Mop is required");
58
			return;
59
		}
60
		if (effectedOn === "") {
61
			alert("EffectedOn  Date is required");
62
			return;
63
		}
64
 
65
		var vendorCatalogPricing = {};
66
		vendorCatalogPricing['vendorId'] = vendorId;
67
		vendorCatalogPricing['catalogId'] = currentModel
68
		vendorCatalogPricing['tp'] = transferPrice
69
		vendorCatalogPricing['dp'] = dealerPrice
70
		vendorCatalogPricing['mop'] = mop
71
		vendorCatalogPricing['effectedOn'] = effectedOn
72
 
73
 
74
		console.log(JSON.stringify(vendorCatalogPricing))
75
		doAjaxRequestWithJsonHandler(context + "/createVendorCatalogPricing", 'POST', JSON.stringify(vendorCatalogPricing), function(response) {
76
			if (response == "true") {
77
				alert("Successfully Done")
78
				$(".vendorcatalogpricing").click();
79
 
80
			}
81
		});
82
 
83
	});
84
 
85
 
86
	$(document).on('click', ".createnewvendorcatalogpricing", function() {
87
 
88
		var vendorId = $('#vendorId').val();
89
 
90
		var transferPrice = $('#transferPrice').val();
91
		var dealerPrice = $('#dealerPrice').val();
92
		var mop = $('#mop').val();
93
		var effectedOn = $('#effectedOn').val();
94
 
95
		if (transferPrice === "" && dealerPrice === "" && mop === "" && effectedOn === "") {
96
			alert("Field can't be empty");
97
			return;
98
		}
99
 
100
 
101
		if (transferPrice === "") {
102
			alert("Transfer Price is required");
103
			return;
104
		}
105
		if (dealerPrice === "") {
106
			alert("Dealer Price is required");
107
			return;
108
		}
109
		if (mop === "") {
110
			alert("Mop is required");
111
			return;
112
		}
113
		if (effectedOn === "") {
114
			alert("EffectedOn  Date is required");
115
			return;
116
		}
117
 
118
		var vendorCatalogPricing = {};
119
		vendorCatalogPricing['vendorId'] = vendorId;
120
		vendorCatalogPricing['catalogId'] = currentModel
121
		vendorCatalogPricing['tp'] = transferPrice
122
		vendorCatalogPricing['dp'] = dealerPrice
123
		vendorCatalogPricing['mop'] = mop
124
		vendorCatalogPricing['effectedOn'] = effectedOn
125
 
126
 
127
		doAjaxRequestWithJsonHandler(context + "/createVendorCatalogPricing", 'POST', JSON.stringify(vendorCatalogPricing), function(response) {
128
			if (response == "true") {
129
				alert("Successfully Done")
130
				$(".vendorcatalogpricing").click();
131
				loadCreateVendorCatalogPricing("main-content")
132
			}
133
		});
134
 
135
	});
136
 
137
 
138
	$(document).on('click', ".vendor-pricing-approve-request-send", function() {
139
		var row = $(this).closest("tr");
140
		console.log(row);
141
		var rowIndex = $(this).closest('tr').prevAll().length;
142
		console.log(rowIndex);
143
		var id = $(this).data('id');
144
 
145
 
146
		if (confirm("Are you sure you want to approve the request") == true) {
147
			doPostAjaxRequestHandler(context + "/verifyVendorCatalogPricingRequest?id=" + id + "&status=" + 'APPROVED',
148
				function(response) {
149
 
150
					console.log(response);
151
					if (response == 'true') {
152
						alert("successfully approved");
153
						loadVendorCatalogPricingRequests("main-content")
154
					}
155
				});
156
 
157
 
158
		}
159
 
160
	});
161
 
162
 
163
	$(document).on('click', ".vendor-pricing-rejected-request-send", function() {
164
		var row = $(this).closest("tr");
165
		console.log(row);
166
		var rowIndex = $(this).closest('tr').prevAll().length;
167
		console.log(rowIndex);
168
 
169
		var id = $(this).data('id');
170
 
171
		if (confirm("Are you sure you want to rejected  the request") == true) {
172
			doPostAjaxRequestHandler(context + "/verifyVendorCatalogPricingRequest?id=" + id + "&status=" + 'REJECTED',
173
				function(response) {
174
 
175
					console.log(response);
176
					if (response == 'true') {
177
						alert("successfully rejected");
178
						loadVendorCatalogPricingRequests("main-content")
179
					}
180
				});
181
 
182
 
183
		}
184
 
185
	});
186
 
187
 
188
 
189
	$(document).on('click', ".vendorpricecircular", function() {
190
 
191
		var vendorId = $('#vendorId').val();
192
		var effectedDate = $('#effectedDate').val();
193
 
194
		if (vendorId === "" && effectedDate === "") {
195
			alert("Field can't be empty");
196
			return;
197
		}
198
 
199
 
200
		if (vendorId === "") {
201
			alert("Please select the vendor");
202
			return;
203
		}
204
		if (effectedDate === "") {
205
			alert("Please choose date");
206
			return;
207
		}
208
 
209
		doGetAjaxRequestHandler(context + "/getVendorPriceCircular?vendorId=" + vendorId + "&effectedDate="  + effectedDate, function(response) {
210
			$('.vendorpricecircularview').html(response);
211
 
212
		});
213
 
214
	});
215
});
216
 
217
function loadCreateVendorCatalogPricing(domId) {
218
	doGetAjaxRequestHandler(context + "/vendorCatalogPricing", function(response) {
219
		$('#' + domId).html(response);
220
	});
221
}
222
 
223
function loadVendorCatalogPricingRequests(domId) {
224
	doGetAjaxRequestHandler(context + "/vendorCatalogPricingRequests", function(response) {
225
		$('#' + domId).html(response);
226
	});
227
}
228
 
229
function loadVendorPriceCircular(domId) {
230
	doGetAjaxRequestHandler(context + "/vendorPriceCircular", function(response) {
231
		$('#' + domId).html(response);
232
	});
233
}