| 7226 |
anupam.sin |
1 |
$(function() {
|
| 7255 |
amit.gupta |
2 |
|
|
|
3 |
$("#query").autocomplete({ autoFocus: true, minLength: 3,
|
| 7323 |
anupam.sin |
4 |
source: "/storewebsite/auto-suggest",
|
| 7255 |
amit.gupta |
5 |
select: function( event, ui ) {
|
|
|
6 |
this.value = ui.item.value;
|
|
|
7 |
$('#formSearch').submit();
|
|
|
8 |
return false;
|
|
|
9 |
}
|
|
|
10 |
});
|
|
|
11 |
|
| 7323 |
anupam.sin |
12 |
$("#formSearch").submit(function() {
|
|
|
13 |
if($("#query").val() == "" || $("#query").val() == "Search for more items...") {
|
|
|
14 |
return false;
|
|
|
15 |
}
|
|
|
16 |
});
|
|
|
17 |
|
| 7226 |
anupam.sin |
18 |
$('#pincodeForm').submit(function() {
|
|
|
19 |
|
|
|
20 |
if($('#pincodeSubmit:hidden').length == 1) {
|
|
|
21 |
return false;
|
|
|
22 |
}
|
|
|
23 |
|
|
|
24 |
if ($('#pincodeText').val().length != 6) {
|
|
|
25 |
alert('Please enter 6 digit pin code');
|
|
|
26 |
return false;
|
|
|
27 |
}
|
|
|
28 |
|
|
|
29 |
var result = $('#pincodeText').val().match(/^\d*$/);
|
|
|
30 |
if(result == null || result.length == 0) {
|
|
|
31 |
alert('Please enter a valid pin code');
|
|
|
32 |
return false;
|
|
|
33 |
}
|
|
|
34 |
|
| 7293 |
anupam.sin |
35 |
$('#priceDiv').empty();
|
| 7226 |
anupam.sin |
36 |
showLoading();
|
|
|
37 |
$.ajax({
|
|
|
38 |
type: "POST",
|
| 7268 |
anupam.sin |
39 |
url: "/storewebsite/estimate",
|
| 7226 |
anupam.sin |
40 |
dataType:"json",
|
| 7268 |
anupam.sin |
41 |
data:$('#pincodeForm').serialize(),
|
|
|
42 |
// timeout: 10000,
|
| 7226 |
anupam.sin |
43 |
success:function(msg) {
|
|
|
44 |
hideLoading();
|
|
|
45 |
if(msg.length != 0) {
|
| 7695 |
anupam.sin |
46 |
if(msg.selling_price == 0.0 || msg.delivery_estimate == '01 January 1970') {
|
| 7293 |
anupam.sin |
47 |
$('#loading').hide();
|
|
|
48 |
$('#shippingAddress').hide();
|
|
|
49 |
$('#priceDiv').html("<div class='error'>There was some error. Please try again.</div>");
|
|
|
50 |
$('#pincodeSubmit').show();
|
|
|
51 |
} else {
|
|
|
52 |
$('#priceDiv').html(
|
|
|
53 |
"<div class='date'><span class='infoText'>Get this product by </span><span class='infoValue'>" + msg.delivery_estimate + "</span></div>" +
|
| 7323 |
anupam.sin |
54 |
"<div class='price'><span class='infoText'>Total Price</span><span class='infoValue'> Rs. " + $('#shippingAddress input[name=price]').val() + "</span></div>" +
|
|
|
55 |
"<div class='advance'><span class='infoText'>Advance to be paid</span><span id='advPrice' class='infoValue'> Rs. " + msg.min_advance_amount + "</span></div>");
|
| 7427 |
anupam.sin |
56 |
if(msg.min_advance_amount > parseFloat($('#shippingAddress input[name=price]').val())) {
|
|
|
57 |
$('#shippingAddress input[name=advanceAmount]').val($('#shippingAddress input[name=price]').val());
|
| 7529 |
anupam.sin |
58 |
$('#shippingAddress input[name=minAdvanceAmount]').val($('#shippingAddress input[name=price]').val());
|
| 7427 |
anupam.sin |
59 |
$('#editPriceBox').val($('#shippingAddress input[name=price]').val());
|
|
|
60 |
} else {
|
|
|
61 |
$('#shippingAddress input[name=advanceAmount]').val(msg.min_advance_amount);
|
| 7529 |
anupam.sin |
62 |
$('#shippingAddress input[name=minAdvanceAmount]').val(msg.min_advance_amount);
|
| 7427 |
anupam.sin |
63 |
$('#editPriceBox').val(msg.min_advance_amount);
|
|
|
64 |
}
|
| 7293 |
anupam.sin |
65 |
$('#shippingAddress input[name=deliveryDate]').val(msg.delivery_estimate);
|
|
|
66 |
$('#shippingAddress input[name=minPrice]').val(msg.min_selling_price);
|
|
|
67 |
$('#shippingAddress input[name=maxPrice]').val(msg.max_selling_price);
|
| 7323 |
anupam.sin |
68 |
$('#shippingAddress input[name=bestDealText]').val(msg.best_deal_text);
|
|
|
69 |
$('#bestDealText').text(msg.best_deal_text);
|
|
|
70 |
$('#bestDealContainer').show();
|
| 7293 |
anupam.sin |
71 |
$('#pincodeInput').val($('#pincodeText').val());
|
|
|
72 |
$('#editPriceButton').show();
|
| 7427 |
anupam.sin |
73 |
|
| 7293 |
anupam.sin |
74 |
}
|
|
|
75 |
|
| 7226 |
anupam.sin |
76 |
} else {
|
|
|
77 |
$('#priceDiv').html("<div class='error'>No info found for this pincode. Please try again.</div>");
|
|
|
78 |
}
|
|
|
79 |
},
|
|
|
80 |
error : function(msg) {
|
|
|
81 |
$('#loading').hide();
|
|
|
82 |
$('#shippingAddress').hide();
|
|
|
83 |
$('#priceDiv').html("<div class='error'>There was some error. Please try again.</div>");
|
|
|
84 |
$('#pincodeSubmit').show();
|
|
|
85 |
},
|
|
|
86 |
complete : function() {
|
|
|
87 |
$('#pinSpan').html($('#pincodeText').val());
|
|
|
88 |
|
|
|
89 |
}
|
|
|
90 |
});
|
|
|
91 |
return false;
|
|
|
92 |
});
|
|
|
93 |
|
|
|
94 |
function showLoading() {
|
|
|
95 |
$('#pincodeSubmit').hide();
|
|
|
96 |
$('#shippingAddress').hide();
|
|
|
97 |
$('#loading').show();
|
|
|
98 |
}
|
|
|
99 |
|
|
|
100 |
function hideLoading() {
|
|
|
101 |
$('#loading').hide();
|
|
|
102 |
$('#shippingAddress').show();
|
|
|
103 |
}
|
|
|
104 |
|
|
|
105 |
$('#changePincode').click(function() {
|
| 7323 |
anupam.sin |
106 |
window.location.reload();
|
| 7226 |
anupam.sin |
107 |
});
|
| 7248 |
anupam.sin |
108 |
|
| 7386 |
anupam.sin |
109 |
$('#reloadSuccessPage').click(function() {
|
|
|
110 |
window.location.reload();
|
|
|
111 |
});
|
|
|
112 |
|
| 7248 |
anupam.sin |
113 |
$('#pincodeEdit').click(function(event){
|
| 7449 |
anupam.sin |
114 |
window.location.href = '/storewebsite/order-details!create?product_id=' + $('#createOrderForm input[name=product_id]').val() + '&price=' + $('#createOrderForm input[name=price]').val();
|
| 7248 |
anupam.sin |
115 |
});
|
|
|
116 |
|
|
|
117 |
$('#addressEdit').click(function() {
|
|
|
118 |
$('#createOrder, #showPinDiv, #showAddDiv').hide();
|
|
|
119 |
$('#editAddBlock').show();
|
|
|
120 |
});
|
|
|
121 |
|
|
|
122 |
$('#saveEditedAdd').click(function() {
|
|
|
123 |
var editedFields = $('#editAddBlock input');
|
| 7449 |
anupam.sin |
124 |
var msg = "";
|
|
|
125 |
var displayAlert = false;
|
| 7248 |
anupam.sin |
126 |
editedFields.each(function(i, inputField) {
|
|
|
127 |
if($(inputField).val() == "") {
|
| 7449 |
anupam.sin |
128 |
if($(inputField).attr('name') != 'line2') {
|
|
|
129 |
msg = "Please enter correct " + $(inputField).attr('name');
|
|
|
130 |
displayAlert = true;
|
|
|
131 |
return;
|
|
|
132 |
}
|
| 7248 |
anupam.sin |
133 |
}
|
|
|
134 |
|
|
|
135 |
if ($(inputField).attr('name') == "phone") {
|
|
|
136 |
if ($(inputField).val().length != 10) {
|
| 7449 |
anupam.sin |
137 |
msg = 'Please enter a 10 digit mobile number';
|
|
|
138 |
displayAlert = true;
|
|
|
139 |
return;
|
| 7248 |
anupam.sin |
140 |
}
|
|
|
141 |
|
|
|
142 |
var result = $(inputField).val().match(/^\d*$/);
|
|
|
143 |
if(result == null || result.length == 0) {
|
| 7449 |
anupam.sin |
144 |
msg = 'Please enter a valid mobile number';
|
|
|
145 |
displayAlert = true;
|
|
|
146 |
return;
|
| 7248 |
anupam.sin |
147 |
}
|
|
|
148 |
}
|
|
|
149 |
|
|
|
150 |
var nameToSearch = $(inputField).attr("name");
|
|
|
151 |
$('#showAddDiv [name="' + nameToSearch + '"]').html($(inputField).val());
|
|
|
152 |
$('#createOrderForm input[name="' + nameToSearch + '"]').val($(inputField).val());
|
|
|
153 |
});
|
| 7449 |
anupam.sin |
154 |
|
|
|
155 |
if(displayAlert == true) {
|
|
|
156 |
alert(msg);
|
|
|
157 |
} else {
|
|
|
158 |
$('#editAddBlock').hide();
|
|
|
159 |
$('#createOrder, #showPinDiv, #showAddDiv').show();
|
|
|
160 |
}
|
| 7248 |
anupam.sin |
161 |
});
|
|
|
162 |
|
| 7293 |
anupam.sin |
163 |
$('#editPriceButton').click(function() {
|
|
|
164 |
$('#editPriceButton').hide();
|
|
|
165 |
$('#editPriceSpan').show();
|
|
|
166 |
});
|
|
|
167 |
|
|
|
168 |
$('#priceFixButton').click(function() {
|
|
|
169 |
var result = $('#editPriceBox').val().match(/^\d*$/);
|
|
|
170 |
if(result == null || result.length == 0) {
|
|
|
171 |
alert('Please enter a valid amount');
|
|
|
172 |
return false;
|
|
|
173 |
}
|
|
|
174 |
|
| 7427 |
anupam.sin |
175 |
if(parseFloat($('#editPriceBox').val()) > parseFloat($('#shippingAddress input[name=price]').val())) {
|
| 7358 |
anupam.sin |
176 |
alert('Advance cannot be more than Rs.' + $('#shippingAddress input[name=price]').val());
|
| 7293 |
anupam.sin |
177 |
return false;
|
|
|
178 |
}
|
|
|
179 |
|
| 7529 |
anupam.sin |
180 |
if(parseFloat($('#editPriceBox').val()) < parseFloat($('#shippingAddress input[name=minAdvanceAmount]').val())) {
|
|
|
181 |
alert('Advance cannot be below Rs. ' + $('#shippingAddress input[name=minAdvanceAmount]').val());
|
| 7293 |
anupam.sin |
182 |
return false;
|
|
|
183 |
}
|
|
|
184 |
|
| 7323 |
anupam.sin |
185 |
$('#editPriceButton').show();
|
|
|
186 |
$('#editPriceSpan').hide();
|
|
|
187 |
$('#advPrice').empty();
|
|
|
188 |
$('#advPrice').text(' Rs. ' + parseFloat($('#editPriceBox').val()).toFixed(1));
|
|
|
189 |
$('#shippingAddress input[name=advanceAmount]').val($('#editPriceBox').val());
|
|
|
190 |
});
|
|
|
191 |
|
|
|
192 |
$('#editSellingPriceButton').click(function() {
|
|
|
193 |
$('#editSellingPriceButton').hide();
|
|
|
194 |
$('#pricePopupBox').show();
|
|
|
195 |
});
|
|
|
196 |
|
|
|
197 |
$('#cancelPriceEdit').click(function() {
|
|
|
198 |
$('#pricePopupBox').hide();
|
|
|
199 |
$('#editSellingPriceButton').show();
|
|
|
200 |
});
|
|
|
201 |
|
|
|
202 |
$('#savePriceEdit').click(function() {
|
|
|
203 |
var result = ($('#sellingPriceBox').val().split('.')[0]).match(/^\d*$/);
|
|
|
204 |
if(result == null || result.length == 0) {
|
|
|
205 |
alert('Please enter a valid amount');
|
|
|
206 |
return false;
|
|
|
207 |
}
|
|
|
208 |
|
|
|
209 |
if(parseFloat($('#sellingPriceBox').val()) > parseFloat($('#maxPrice').text())) {
|
|
|
210 |
alert('You cannot sell this product at more than Rs.' + $('#maxPrice').text());
|
|
|
211 |
return false;
|
|
|
212 |
}
|
|
|
213 |
|
| 7358 |
anupam.sin |
214 |
if(parseFloat($('#sellingPriceBox').val()) < parseFloat($('#absMin').val())) {
|
|
|
215 |
alert('You cannot sell below Rs.' + $('#absMin').val());
|
|
|
216 |
return false;
|
|
|
217 |
}
|
|
|
218 |
|
| 7323 |
anupam.sin |
219 |
if(parseFloat($('#sellingPriceBox').val()) < parseFloat($('#minPrice').text())) {
|
| 7427 |
anupam.sin |
220 |
alert('You will need permission of the zonal head to sell at this price');
|
| 7293 |
anupam.sin |
221 |
}
|
|
|
222 |
|
| 7323 |
anupam.sin |
223 |
$('#editSellingPriceButton').show();
|
|
|
224 |
$('#pricePopupBox').hide();
|
|
|
225 |
|
|
|
226 |
$('#mrp').html(parseFloat($('#sellingPriceBox').val()).toFixed(2));
|
| 7293 |
anupam.sin |
227 |
});
|
| 7343 |
anupam.sin |
228 |
|
|
|
229 |
$("#dateselector").change(function() {
|
|
|
230 |
if($(this).val()=="3"){
|
|
|
231 |
$("#daterange").show();
|
|
|
232 |
}else {
|
|
|
233 |
$("#daterange").hide();
|
|
|
234 |
}
|
|
|
235 |
});
|
| 7348 |
anupam.sin |
236 |
|
| 7427 |
anupam.sin |
237 |
$("#dateselector1").change(function() {
|
|
|
238 |
if($(this).val()=="3"){
|
|
|
239 |
$("#daterange1").show();
|
|
|
240 |
}else {
|
|
|
241 |
$("#daterange1").hide();
|
|
|
242 |
}
|
|
|
243 |
});
|
|
|
244 |
|
| 7348 |
anupam.sin |
245 |
$(".returnButton").click(function() {
|
|
|
246 |
$("#returnPopupOrder").val($(this).attr("order"));
|
|
|
247 |
$("#returnPopupBox").show();
|
|
|
248 |
});
|
|
|
249 |
|
|
|
250 |
$("#cancelReturnRequest").click(function() {
|
|
|
251 |
$("#returnPopupOrder").val("");
|
|
|
252 |
$("#returnPopupBox").hide();
|
|
|
253 |
});
|
| 7349 |
anupam.sin |
254 |
|
|
|
255 |
$(".refundButton").click(function() {
|
|
|
256 |
$("#refundPopupOrder").val($(this).attr("order"));
|
|
|
257 |
$("#refundPopupBox").show();
|
|
|
258 |
});
|
|
|
259 |
|
|
|
260 |
$("#cancelRefundRequest").click(function() {
|
|
|
261 |
$("#refundPopupOrder").val("");
|
|
|
262 |
$("#refundPopupBox").hide();
|
|
|
263 |
});
|
|
|
264 |
|
| 7386 |
anupam.sin |
265 |
$('#createOrderForm input[name=cardAmount]').focusin(function() {
|
|
|
266 |
$('#bankSelector').show();
|
|
|
267 |
});
|
|
|
268 |
|
|
|
269 |
$('#createOrderForm input[name=cardAmount]').focusout(function() {
|
|
|
270 |
tmp = parseFloat($('#createOrderForm input[name=cardAmount]').val());
|
|
|
271 |
if(isNaN(tmp) || tmp < 1) {
|
|
|
272 |
$('#bankSelector').hide();
|
|
|
273 |
}
|
|
|
274 |
else {
|
|
|
275 |
$('#bankSelector').show();
|
|
|
276 |
}
|
|
|
277 |
});
|
| 7226 |
anupam.sin |
278 |
});
|
|
|
279 |
|
|
|
280 |
function validateAddress() {
|
| 7248 |
anupam.sin |
281 |
if ($('input[name=name]').val() == "") {
|
|
|
282 |
alert("Please enter the customer's name");
|
|
|
283 |
return false;
|
|
|
284 |
}
|
|
|
285 |
|
|
|
286 |
if ($('input[name=phone]').val().length != 10) {
|
|
|
287 |
alert('Please enter a 10 digit mobile number');
|
|
|
288 |
return false;
|
|
|
289 |
}
|
|
|
290 |
|
|
|
291 |
var result = $('input[name=phone]').val().match(/^\d*$/);
|
|
|
292 |
if(result == null || result.length == 0) {
|
|
|
293 |
alert('Please enter a valid mobile number');
|
|
|
294 |
return false;
|
|
|
295 |
}
|
|
|
296 |
|
| 7226 |
anupam.sin |
297 |
if ($('input[name=line1]').val() == "") {
|
|
|
298 |
alert('Please enter a shipping address');
|
|
|
299 |
return false;
|
|
|
300 |
}
|
| 7358 |
anupam.sin |
301 |
|
| 7226 |
anupam.sin |
302 |
if ($('input[name=city]').val() == "") {
|
|
|
303 |
alert('Please enter the name of the city');
|
|
|
304 |
return false;
|
|
|
305 |
}
|
| 7386 |
anupam.sin |
306 |
if ($('#shipState').val() == "") {
|
| 7226 |
anupam.sin |
307 |
alert('Please enter the name of the state');
|
|
|
308 |
return false;
|
|
|
309 |
}
|
| 7386 |
anupam.sin |
310 |
|
|
|
311 |
if ($('input[name=email]').val() == "") {
|
|
|
312 |
alert("Please enter the customer's name");
|
|
|
313 |
return false;
|
|
|
314 |
}
|
|
|
315 |
|
| 7226 |
anupam.sin |
316 |
return true;
|
| 7248 |
anupam.sin |
317 |
}
|
|
|
318 |
|
|
|
319 |
function validatePaymentDetails() {
|
| 7386 |
anupam.sin |
320 |
if($('#createOrderForm input[name=advanceAmount]').val() == ""){
|
|
|
321 |
total = 0;
|
|
|
322 |
} else {
|
|
|
323 |
total = parseFloat($('#createOrderForm input[name=advanceAmount]').val());
|
|
|
324 |
}
|
|
|
325 |
|
|
|
326 |
if($('#createOrderForm input[name=cashAmount]').val() == ""){
|
|
|
327 |
cashAmount = 0;
|
|
|
328 |
} else {
|
|
|
329 |
cashAmount = parseFloat($('#createOrderForm input[name=cashAmount]').val());
|
|
|
330 |
}
|
|
|
331 |
|
|
|
332 |
if($('#createOrderForm input[name=cardAmount]').val() == ""){
|
|
|
333 |
cardAmount = 0;
|
|
|
334 |
} else {
|
|
|
335 |
cardAmount = parseFloat($('#createOrderForm input[name=cardAmount]').val());
|
|
|
336 |
}
|
|
|
337 |
|
|
|
338 |
if(isNaN(total) || isNaN(cashAmount) || isNaN(cardAmount)) {
|
|
|
339 |
alert("Please enter valid amounts");
|
|
|
340 |
return false;
|
|
|
341 |
}
|
|
|
342 |
|
|
|
343 |
if(total != cashAmount + cardAmount) {
|
|
|
344 |
alert("Sum of cash and card is not equal to advance amount");
|
|
|
345 |
return false;
|
|
|
346 |
}
|
|
|
347 |
|
|
|
348 |
if(cardAmount > 0) {
|
|
|
349 |
if($('#edcSelector').val() == "") {
|
|
|
350 |
alert('Please select the name of EDC bank');
|
| 7248 |
anupam.sin |
351 |
return false;
|
|
|
352 |
}
|
| 7426 |
anupam.sin |
353 |
|
|
|
354 |
if($('#createOrderForm input[name=approvalCode]').val() == "") {
|
|
|
355 |
alert("Please enter approval code");
|
|
|
356 |
return false;
|
|
|
357 |
}
|
| 7248 |
anupam.sin |
358 |
}
|
| 7435 |
anupam.sin |
359 |
|
|
|
360 |
$('#createOrder').hide();
|
|
|
361 |
$('#waitSpan').show();
|
|
|
362 |
$('#addressEdit').hide();
|
|
|
363 |
$('#pincodeEdit').hide();
|
| 7349 |
anupam.sin |
364 |
}
|
|
|
365 |
|
|
|
366 |
function validateAmount() {
|
|
|
367 |
var result = $('#refundAmountText').val().match(/^\d*$/);
|
|
|
368 |
if(result == null || result.length == 0) {
|
|
|
369 |
alert('Please enter a valid amount');
|
|
|
370 |
return false;
|
|
|
371 |
}
|
| 7226 |
anupam.sin |
372 |
}
|