Subversion Repositories SmartDukaan

Rev

Rev 36464 | 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
 
37133 amit 172
	$(document).on('click', ".vendor-pricing-bulk-approve", function() {
173
		var fileSelector = $('#bulkApproveFile')[0];
174
		if (fileSelector == undefined || fileSelector.files[0] == undefined) {
175
			alert("Please upload file!");
176
			return false;
177
		}
178
		if (confirm("Approve all requests in this file?")) {
179
			doAjaxUploadRequestHandler(context + "/bulkVendorCatalogPricing/verify", "POST", fileSelector.files[0], function(response) {
180
				if (response) {
181
					alert("Bulk approval successful");
182
					loadVendorCatalogPricingRequests("main-content");
183
				}
184
			});
185
		}
186
		return false;
187
	});
188
 
189
 
32074 tejbeer 190
	$(document).on('click', ".vendor-pricing-rejected-request-send", function() {
191
		var row = $(this).closest("tr");
192
		console.log(row);
193
		var rowIndex = $(this).closest('tr').prevAll().length;
194
		console.log(rowIndex);
195
 
196
		var id = $(this).data('id');
197
 
198
		if (confirm("Are you sure you want to rejected  the request") == true) {
199
			doPostAjaxRequestHandler(context + "/verifyVendorCatalogPricingRequest?id=" + id + "&status=" + 'REJECTED',
200
				function(response) {
201
 
202
					console.log(response);
203
					if (response == 'true') {
204
						alert("successfully rejected");
205
						loadVendorCatalogPricingRequests("main-content")
206
					}
207
				});
208
 
209
 
210
		}
211
 
212
	});
213
 
214
 
215
 
216
	$(document).on('click', ".vendorpricecircular", function() {
217
 
218
		var vendorId = $('#vendorId').val();
219
		var effectedDate = $('#effectedDate').val();
220
 
221
		if (vendorId === "" && effectedDate === "") {
222
			alert("Field can't be empty");
223
			return;
224
		}
225
 
226
 
33183 shampa 227
		// if (vendorId === "") {
228
		// 	alert("Please select the vendor");
229
		// 	return;
230
		// }
32074 tejbeer 231
		if (effectedDate === "") {
232
			alert("Please choose date");
233
			return;
234
		}
235
 
236
		doGetAjaxRequestHandler(context + "/getVendorPriceCircular?vendorId=" + vendorId + "&effectedDate="  + effectedDate, function(response) {
237
			$('.vendorpricecircularview').html(response);
238
 
239
		});
240
 
241
	});
33183 shampa 242
 
243
	$(document).on('click', '.download-price-circular-report', function() {
244
		var startDate = $("#effectedDate").val();
245
		if (startDate == "" || startDate == undefined) {
246
			alert("start date is not be empty!!");
247
			return;
248
		}
249
 
250
		let endPoint = `${context}/downloadPriceCircularReport?startDate=${startDate}`;
251
 
252
		window.location.href = endPoint;
253
 
254
 
255
	});
36464 amit 256
 
257
	$(document).on('click', '.download-vendor-pricing-changes', function() {
258
		var startDate = $("#pricingChangesStartDate").val();
259
		var endDate = $("#pricingChangesEndDate").val();
260
		if (startDate === "" || startDate === undefined) {
261
			alert("Start date is required!");
262
			return;
263
		}
264
		if (endDate === "" || endDate === undefined) {
265
			alert("End date is required!");
266
			return;
267
		}
268
		if (startDate > endDate) {
269
			alert("Start date must be before end date!");
270
			return;
271
		}
272
		window.location.href = context + "/downloadVendorPricingChangesReport?startDate=" + startDate + "&endDate=" + endDate;
273
	});
32074 tejbeer 274
});
275
 
276
function loadCreateVendorCatalogPricing(domId) {
277
	doGetAjaxRequestHandler(context + "/vendorCatalogPricing", function(response) {
278
		$('#' + domId).html(response);
279
	});
280
}
281
 
282
function loadVendorCatalogPricingRequests(domId) {
283
	doGetAjaxRequestHandler(context + "/vendorCatalogPricingRequests", function(response) {
284
		$('#' + domId).html(response);
285
	});
286
}
287
 
33750 ranu 288
function loadVendorCatalogPricingPendingRequests(domId) {
289
	doGetAjaxRequestHandler(context + "/vendorCatalogPricingPendingRequests", function (response) {
290
		$('#' + domId).html(response);
291
	});
292
}
293
 
294
$(document).on('click', '.dateWisePricing', function () {
295
 
296
	var startDate = getDatesFromPicker('input[name="pricing-duration"]').startDate;
297
	var endDate = getDatesFromPicker('input[name="pricing-duration"]').endDate;
298
 
299
 
300
	doGetAjaxRequestHandler(context + "/datewiseVendorCatalogPricingPendingRequests?startDate=" + startDate + "&endDate=" + endDate, function (response) {
301
		$('#catalog-pricing-container').html(response);
302
 
303
	});
304
});
305
 
32074 tejbeer 306
function loadVendorPriceCircular(domId) {
307
	doGetAjaxRequestHandler(context + "/vendorPriceCircular", function(response) {
308
		$('#' + domId).html(response);
309
	});
33465 ranu 310
}
311
 
312
function createBulkPricing(domId) {
313
	doGetAjaxRequestHandler(context + "/createBulkPricing",
314
		function (response) {
315
			$('#' + domId).html(response);
316
		});
32074 tejbeer 317
}