Subversion Repositories SmartDukaan

Rev

Rev 33750 | Details | Compare with Previous | 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
 
33750 ranu 11
	$(document).on('click', ".vendor-catalog-pricing-pending-request", function () {
12
		loadVendorCatalogPricingPendingRequests("main-content");
13
	});
14
 
32074 tejbeer 15
	$(document).on('click', ".vendor-price-circular", function() {
16
		loadVendorPriceCircular("main-content");
17
	});
18
 
33465 ranu 19
	$(document).on('click', ".create-bulk-vendor-catalog-pricing", function () {
20
		createBulkPricing("main-content");
21
	});
32074 tejbeer 22
 
33465 ranu 23
 
32074 tejbeer 24
	$(document).on('click', ".vendorcatalogpricing", function() {
32676 shampa 25
        if (typeof currentModel === 'undefined' || currentModel === null || currentModel === '') {
26
            alert('Please search for the right model');
27
        } else {
28
            doGetAjaxRequestHandler(context + "/getVendorCatalogPricingByModel?catalogId=" + currentModel, function(response) {
29
                $('.vendorCatatlogPricingView').html(response);
30
            });
31
        }
32
    });
32074 tejbeer 33
 
34
 
35
 
36
 
37
	$(document).on('click', ".createvendorcatalogpricing", function() {
38
 
39
		var row = $(this).closest("tr");
40
 
41
		var vendorId = $(this).data('vendorid');
42
 
43
		console.log(vendorId)
44
 
45
		var transferPrice = $(row).find(".transferp").val();
46
		var dealerPrice = $(row).find(".dealerp").val();
47
		var mop = $(row).find(".mopp").val();
48
		var effectedOn = $(row).find(".effectedDate").val();
49
 
50
 
51
		if (transferPrice === "" && dealerPrice === "" && mop === "" && effectedOn === "") {
52
			alert("Field can't be empty");
53
			return;
54
		}
55
 
56
 
57
		if (transferPrice === "") {
58
			alert("Transfer Price is required");
59
			return;
60
		}
61
		if (dealerPrice === "") {
62
			alert("Dealer Price is required");
63
			return;
64
		}
65
		if (mop === "") {
66
			alert("Mop is required");
67
			return;
68
		}
69
		if (effectedOn === "") {
70
			alert("EffectedOn  Date is required");
71
			return;
72
		}
73
 
74
		var vendorCatalogPricing = {};
75
		vendorCatalogPricing['vendorId'] = vendorId;
76
		vendorCatalogPricing['catalogId'] = currentModel
77
		vendorCatalogPricing['tp'] = transferPrice
78
		vendorCatalogPricing['dp'] = dealerPrice
79
		vendorCatalogPricing['mop'] = mop
80
		vendorCatalogPricing['effectedOn'] = effectedOn
81
 
82
 
83
		console.log(JSON.stringify(vendorCatalogPricing))
84
		doAjaxRequestWithJsonHandler(context + "/createVendorCatalogPricing", 'POST', JSON.stringify(vendorCatalogPricing), function(response) {
85
			if (response == "true") {
86
				alert("Successfully Done")
87
				$(".vendorcatalogpricing").click();
88
 
89
			}
90
		});
91
 
92
	});
93
 
94
 
95
	$(document).on('click', ".createnewvendorcatalogpricing", function() {
96
 
97
		var vendorId = $('#vendorId').val();
98
 
99
		var transferPrice = $('#transferPrice').val();
100
		var dealerPrice = $('#dealerPrice').val();
101
		var mop = $('#mop').val();
102
		var effectedOn = $('#effectedOn').val();
103
 
104
		if (transferPrice === "" && dealerPrice === "" && mop === "" && effectedOn === "") {
105
			alert("Field can't be empty");
106
			return;
107
		}
108
 
109
 
110
		if (transferPrice === "") {
111
			alert("Transfer Price is required");
112
			return;
113
		}
114
		if (dealerPrice === "") {
115
			alert("Dealer Price is required");
116
			return;
117
		}
118
		if (mop === "") {
119
			alert("Mop is required");
120
			return;
121
		}
122
		if (effectedOn === "") {
123
			alert("EffectedOn  Date is required");
124
			return;
125
		}
126
 
127
		var vendorCatalogPricing = {};
128
		vendorCatalogPricing['vendorId'] = vendorId;
129
		vendorCatalogPricing['catalogId'] = currentModel
130
		vendorCatalogPricing['tp'] = transferPrice
131
		vendorCatalogPricing['dp'] = dealerPrice
132
		vendorCatalogPricing['mop'] = mop
133
		vendorCatalogPricing['effectedOn'] = effectedOn
134
 
135
 
136
		doAjaxRequestWithJsonHandler(context + "/createVendorCatalogPricing", 'POST', JSON.stringify(vendorCatalogPricing), function(response) {
137
			if (response == "true") {
138
				alert("Successfully Done")
139
				$(".vendorcatalogpricing").click();
140
				loadCreateVendorCatalogPricing("main-content")
141
			}
142
		});
143
 
144
	});
145
 
146
 
147
	$(document).on('click', ".vendor-pricing-approve-request-send", function() {
148
		var row = $(this).closest("tr");
149
		console.log(row);
150
		var rowIndex = $(this).closest('tr').prevAll().length;
151
		console.log(rowIndex);
152
		var id = $(this).data('id');
153
 
154
 
155
		if (confirm("Are you sure you want to approve the request") == true) {
156
			doPostAjaxRequestHandler(context + "/verifyVendorCatalogPricingRequest?id=" + id + "&status=" + 'APPROVED',
157
				function(response) {
158
 
159
					console.log(response);
160
					if (response == 'true') {
161
						alert("successfully approved");
162
						loadVendorCatalogPricingRequests("main-content")
163
					}
164
				});
165
 
166
 
167
		}
168
 
169
	});
170
 
171
 
172
	$(document).on('click', ".vendor-pricing-rejected-request-send", function() {
173
		var row = $(this).closest("tr");
174
		console.log(row);
175
		var rowIndex = $(this).closest('tr').prevAll().length;
176
		console.log(rowIndex);
177
 
178
		var id = $(this).data('id');
179
 
180
		if (confirm("Are you sure you want to rejected  the request") == true) {
181
			doPostAjaxRequestHandler(context + "/verifyVendorCatalogPricingRequest?id=" + id + "&status=" + 'REJECTED',
182
				function(response) {
183
 
184
					console.log(response);
185
					if (response == 'true') {
186
						alert("successfully rejected");
187
						loadVendorCatalogPricingRequests("main-content")
188
					}
189
				});
190
 
191
 
192
		}
193
 
194
	});
195
 
196
 
197
 
198
	$(document).on('click', ".vendorpricecircular", function() {
199
 
200
		var vendorId = $('#vendorId').val();
201
		var effectedDate = $('#effectedDate').val();
202
 
203
		if (vendorId === "" && effectedDate === "") {
204
			alert("Field can't be empty");
205
			return;
206
		}
207
 
208
 
33183 shampa 209
		// if (vendorId === "") {
210
		// 	alert("Please select the vendor");
211
		// 	return;
212
		// }
32074 tejbeer 213
		if (effectedDate === "") {
214
			alert("Please choose date");
215
			return;
216
		}
217
 
218
		doGetAjaxRequestHandler(context + "/getVendorPriceCircular?vendorId=" + vendorId + "&effectedDate="  + effectedDate, function(response) {
219
			$('.vendorpricecircularview').html(response);
220
 
221
		});
222
 
223
	});
33183 shampa 224
 
225
	$(document).on('click', '.download-price-circular-report', function() {
226
		var startDate = $("#effectedDate").val();
227
		if (startDate == "" || startDate == undefined) {
228
			alert("start date is not be empty!!");
229
			return;
230
		}
231
 
232
		let endPoint = `${context}/downloadPriceCircularReport?startDate=${startDate}`;
233
 
234
		window.location.href = endPoint;
235
 
236
 
237
	});
36464 amit 238
 
239
	$(document).on('click', '.download-vendor-pricing-changes', function() {
240
		var startDate = $("#pricingChangesStartDate").val();
241
		var endDate = $("#pricingChangesEndDate").val();
242
		if (startDate === "" || startDate === undefined) {
243
			alert("Start date is required!");
244
			return;
245
		}
246
		if (endDate === "" || endDate === undefined) {
247
			alert("End date is required!");
248
			return;
249
		}
250
		if (startDate > endDate) {
251
			alert("Start date must be before end date!");
252
			return;
253
		}
254
		window.location.href = context + "/downloadVendorPricingChangesReport?startDate=" + startDate + "&endDate=" + endDate;
255
	});
32074 tejbeer 256
});
257
 
258
function loadCreateVendorCatalogPricing(domId) {
259
	doGetAjaxRequestHandler(context + "/vendorCatalogPricing", function(response) {
260
		$('#' + domId).html(response);
261
	});
262
}
263
 
264
function loadVendorCatalogPricingRequests(domId) {
265
	doGetAjaxRequestHandler(context + "/vendorCatalogPricingRequests", function(response) {
266
		$('#' + domId).html(response);
267
	});
268
}
269
 
33750 ranu 270
function loadVendorCatalogPricingPendingRequests(domId) {
271
	doGetAjaxRequestHandler(context + "/vendorCatalogPricingPendingRequests", function (response) {
272
		$('#' + domId).html(response);
273
	});
274
}
275
 
276
$(document).on('click', '.dateWisePricing', function () {
277
 
278
	var startDate = getDatesFromPicker('input[name="pricing-duration"]').startDate;
279
	var endDate = getDatesFromPicker('input[name="pricing-duration"]').endDate;
280
 
281
 
282
	doGetAjaxRequestHandler(context + "/datewiseVendorCatalogPricingPendingRequests?startDate=" + startDate + "&endDate=" + endDate, function (response) {
283
		$('#catalog-pricing-container').html(response);
284
 
285
	});
286
});
287
 
32074 tejbeer 288
function loadVendorPriceCircular(domId) {
289
	doGetAjaxRequestHandler(context + "/vendorPriceCircular", function(response) {
290
		$('#' + domId).html(response);
291
	});
33465 ranu 292
}
293
 
294
function createBulkPricing(domId) {
295
	doGetAjaxRequestHandler(context + "/createBulkPricing",
296
		function (response) {
297
			$('#' + domId).html(response);
298
		});
32074 tejbeer 299
}