Subversion Repositories SmartDukaan

Rev

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