| 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) {
|
| 7293 |
anupam.sin |
46 |
if(msg.selling_price == 0.0) {
|
|
|
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>");
|
| 7293 |
anupam.sin |
56 |
$('#shippingAddress input[name=advanceAmount]').val(msg.min_advance_amount);
|
|
|
57 |
$('#shippingAddress input[name=deliveryDate]').val(msg.delivery_estimate);
|
|
|
58 |
$('#shippingAddress input[name=minPrice]').val(msg.min_selling_price);
|
|
|
59 |
$('#shippingAddress input[name=maxPrice]').val(msg.max_selling_price);
|
| 7323 |
anupam.sin |
60 |
$('#shippingAddress input[name=bestDealText]').val(msg.best_deal_text);
|
|
|
61 |
$('#bestDealText').text(msg.best_deal_text);
|
|
|
62 |
$('#bestDealContainer').show();
|
| 7293 |
anupam.sin |
63 |
$('#pincodeInput').val($('#pincodeText').val());
|
|
|
64 |
$('#editPriceButton').show();
|
| 7323 |
anupam.sin |
65 |
$('#editPriceBox').val(msg.min_advance_amount);
|
| 7293 |
anupam.sin |
66 |
}
|
|
|
67 |
|
| 7226 |
anupam.sin |
68 |
} else {
|
|
|
69 |
$('#priceDiv').html("<div class='error'>No info found for this pincode. Please try again.</div>");
|
|
|
70 |
}
|
|
|
71 |
},
|
|
|
72 |
error : function(msg) {
|
|
|
73 |
$('#loading').hide();
|
|
|
74 |
$('#shippingAddress').hide();
|
|
|
75 |
$('#priceDiv').html("<div class='error'>There was some error. Please try again.</div>");
|
|
|
76 |
$('#pincodeSubmit').show();
|
|
|
77 |
},
|
|
|
78 |
complete : function() {
|
|
|
79 |
$('#pinSpan').html($('#pincodeText').val());
|
|
|
80 |
|
|
|
81 |
}
|
|
|
82 |
});
|
|
|
83 |
return false;
|
|
|
84 |
});
|
|
|
85 |
|
|
|
86 |
function showLoading() {
|
|
|
87 |
$('#pincodeSubmit').hide();
|
|
|
88 |
$('#shippingAddress').hide();
|
|
|
89 |
$('#loading').show();
|
|
|
90 |
}
|
|
|
91 |
|
|
|
92 |
function hideLoading() {
|
|
|
93 |
$('#loading').hide();
|
|
|
94 |
$('#shippingAddress').show();
|
|
|
95 |
}
|
|
|
96 |
|
|
|
97 |
$('#changePincode').click(function() {
|
| 7323 |
anupam.sin |
98 |
window.location.reload();
|
| 7226 |
anupam.sin |
99 |
});
|
| 7248 |
anupam.sin |
100 |
|
|
|
101 |
$('#pincodeEdit').click(function(event){
|
|
|
102 |
event.preventDefault();
|
|
|
103 |
var newForm = jQuery('<form>', {
|
|
|
104 |
'action': '/storewebsite/order-details',
|
|
|
105 |
'target': '_top'
|
|
|
106 |
}).append(jQuery('<input>', {
|
|
|
107 |
'name': 'product_id',
|
| 7323 |
anupam.sin |
108 |
'value': $('#createOrderForm input[name=product_id]').val(),
|
| 7248 |
anupam.sin |
109 |
'type': 'hidden'
|
| 7323 |
anupam.sin |
110 |
})).append(jQuery('<input>', {
|
|
|
111 |
'name': 'price',
|
|
|
112 |
'value': $('#createOrderForm input[name=price]').val(),
|
|
|
113 |
'type': 'hidden'
|
| 7248 |
anupam.sin |
114 |
}));
|
|
|
115 |
newForm.submit();
|
|
|
116 |
});
|
|
|
117 |
|
|
|
118 |
$('#addressEdit').click(function() {
|
|
|
119 |
$('#createOrder, #showPinDiv, #showAddDiv').hide();
|
|
|
120 |
$('#editAddBlock').show();
|
|
|
121 |
});
|
|
|
122 |
|
|
|
123 |
$('#saveEditedAdd').click(function() {
|
|
|
124 |
var editedFields = $('#editAddBlock input');
|
|
|
125 |
editedFields.each(function(i, inputField) {
|
|
|
126 |
if($(inputField).val() == "") {
|
|
|
127 |
alert("Please enter correct " + $(inputField).attr('name'));
|
|
|
128 |
return false;
|
|
|
129 |
}
|
|
|
130 |
|
|
|
131 |
if ($(inputField).attr('name') == "phone") {
|
|
|
132 |
if ($(inputField).val().length != 10) {
|
|
|
133 |
alert('Please enter a 10 digit mobile number');
|
|
|
134 |
return false;
|
|
|
135 |
}
|
|
|
136 |
|
|
|
137 |
var result = $(inputField).val().match(/^\d*$/);
|
|
|
138 |
if(result == null || result.length == 0) {
|
|
|
139 |
alert('Please enter a valid mobile number');
|
|
|
140 |
return false;
|
|
|
141 |
}
|
|
|
142 |
}
|
|
|
143 |
|
|
|
144 |
var nameToSearch = $(inputField).attr("name");
|
|
|
145 |
$('#showAddDiv [name="' + nameToSearch + '"]').html($(inputField).val());
|
|
|
146 |
$('#createOrderForm input[name="' + nameToSearch + '"]').val($(inputField).val());
|
|
|
147 |
});
|
|
|
148 |
|
|
|
149 |
$('#editAddBlock').hide();
|
|
|
150 |
$('#createOrder, #showPinDiv, #showAddDiv').show();
|
|
|
151 |
});
|
|
|
152 |
|
|
|
153 |
$('#paymode').change(function() {
|
|
|
154 |
if($('#paymode input:radio[name="paymode"]:checked').val() == "card") {
|
|
|
155 |
$('#bankSelector').show();
|
|
|
156 |
} else {
|
|
|
157 |
$('#bankSelector').hide();
|
|
|
158 |
}
|
|
|
159 |
});
|
| 7293 |
anupam.sin |
160 |
|
|
|
161 |
$('#editPriceButton').click(function() {
|
|
|
162 |
$('#editPriceButton').hide();
|
|
|
163 |
$('#editPriceSpan').show();
|
|
|
164 |
});
|
|
|
165 |
|
|
|
166 |
$('#priceFixButton').click(function() {
|
|
|
167 |
var result = $('#editPriceBox').val().match(/^\d*$/);
|
|
|
168 |
if(result == null || result.length == 0) {
|
|
|
169 |
alert('Please enter a valid amount');
|
|
|
170 |
return false;
|
|
|
171 |
}
|
|
|
172 |
|
|
|
173 |
if(parseFloat($('#editPriceBox').val()) > parseFloat($('#shippingAddress input[name=maxPrice]').val())) {
|
| 7323 |
anupam.sin |
174 |
alert('Advance cannot be more than Rs.' + $('#shippingAddress input[name=maxPrice]').val());
|
| 7293 |
anupam.sin |
175 |
return false;
|
|
|
176 |
}
|
|
|
177 |
|
|
|
178 |
if(parseFloat($('#editPriceBox').val()) < parseFloat($('#shippingAddress input[name=advanceAmount]').val())) {
|
| 7323 |
anupam.sin |
179 |
alert('Advance cannot be below Rs. ' + $('#shippingAddress input[name=advanceAmount]').val());
|
| 7293 |
anupam.sin |
180 |
return false;
|
|
|
181 |
}
|
|
|
182 |
|
| 7323 |
anupam.sin |
183 |
$('#editPriceButton').show();
|
|
|
184 |
$('#editPriceSpan').hide();
|
|
|
185 |
$('#advPrice').empty();
|
|
|
186 |
$('#advPrice').text(' Rs. ' + parseFloat($('#editPriceBox').val()).toFixed(1));
|
|
|
187 |
$('#shippingAddress input[name=advanceAmount]').val($('#editPriceBox').val());
|
|
|
188 |
});
|
|
|
189 |
|
|
|
190 |
$('#editSellingPriceButton').click(function() {
|
|
|
191 |
$('#editSellingPriceButton').hide();
|
|
|
192 |
$('#pricePopupBox').show();
|
|
|
193 |
});
|
|
|
194 |
|
|
|
195 |
$('#cancelPriceEdit').click(function() {
|
|
|
196 |
$('#pricePopupBox').hide();
|
|
|
197 |
$('#editSellingPriceButton').show();
|
|
|
198 |
});
|
|
|
199 |
|
|
|
200 |
$('#savePriceEdit').click(function() {
|
|
|
201 |
var result = ($('#sellingPriceBox').val().split('.')[0]).match(/^\d*$/);
|
|
|
202 |
if(result == null || result.length == 0) {
|
|
|
203 |
alert('Please enter a valid amount');
|
|
|
204 |
return false;
|
|
|
205 |
}
|
|
|
206 |
|
|
|
207 |
if(parseFloat($('#sellingPriceBox').val()) > parseFloat($('#maxPrice').text())) {
|
|
|
208 |
alert('You cannot sell this product at more than Rs.' + $('#maxPrice').text());
|
|
|
209 |
return false;
|
|
|
210 |
}
|
|
|
211 |
|
|
|
212 |
if(parseFloat($('#sellingPriceBox').val()) < parseFloat($('#minPrice').text())) {
|
| 7293 |
anupam.sin |
213 |
alert('You will need permission of the zonal head to to sell at this price');
|
|
|
214 |
}
|
|
|
215 |
|
| 7323 |
anupam.sin |
216 |
$('#editSellingPriceButton').show();
|
|
|
217 |
$('#pricePopupBox').hide();
|
|
|
218 |
|
|
|
219 |
$('#mrp').html(parseFloat($('#sellingPriceBox').val()).toFixed(2));
|
|
|
220 |
/*
|
|
|
221 |
* ****************** fix price in submit form
|
|
|
222 |
*
|
|
|
223 |
|
|
|
224 |
$('#advPrice').text(' Rs. ' + parseFloat($('#editPriceBox').val()).toFixed(1));
|
| 7293 |
anupam.sin |
225 |
$('#shippingAddress input[name=price]').val($('#editPriceBox').val());
|
| 7323 |
anupam.sin |
226 |
*/
|
| 7293 |
anupam.sin |
227 |
});
|
| 7226 |
anupam.sin |
228 |
});
|
|
|
229 |
|
|
|
230 |
function validateAddress() {
|
| 7248 |
anupam.sin |
231 |
if ($('input[name=name]').val() == "") {
|
|
|
232 |
alert("Please enter the customer's name");
|
|
|
233 |
return false;
|
|
|
234 |
}
|
|
|
235 |
|
|
|
236 |
if ($('input[name=phone]').val().length != 10) {
|
|
|
237 |
alert('Please enter a 10 digit mobile number');
|
|
|
238 |
return false;
|
|
|
239 |
}
|
|
|
240 |
|
|
|
241 |
var result = $('input[name=phone]').val().match(/^\d*$/);
|
|
|
242 |
if(result == null || result.length == 0) {
|
|
|
243 |
alert('Please enter a valid mobile number');
|
|
|
244 |
return false;
|
|
|
245 |
}
|
|
|
246 |
|
| 7226 |
anupam.sin |
247 |
if ($('input[name=line1]').val() == "") {
|
|
|
248 |
alert('Please enter a shipping address');
|
|
|
249 |
return false;
|
|
|
250 |
}
|
|
|
251 |
if ($('input[name=line2]').val() == "") {
|
|
|
252 |
alert('Please enter a shipping address');
|
|
|
253 |
return false;
|
|
|
254 |
}
|
|
|
255 |
if ($('input[name=city]').val() == "") {
|
|
|
256 |
alert('Please enter the name of the city');
|
|
|
257 |
return false;
|
|
|
258 |
}
|
|
|
259 |
if ($('input[name=state]').val() == "") {
|
|
|
260 |
alert('Please enter the name of the state');
|
|
|
261 |
return false;
|
|
|
262 |
}
|
|
|
263 |
return true;
|
| 7248 |
anupam.sin |
264 |
}
|
|
|
265 |
|
|
|
266 |
function validatePaymentDetails() {
|
|
|
267 |
if($('#paymode input:radio[name="paymode"]:checked').val() == "card") {
|
|
|
268 |
if($('#bankSelector input:radio[name="bank"]:checked').length == 0) {
|
|
|
269 |
alert('Please select the name of the bank of card terminal');
|
|
|
270 |
return false;
|
|
|
271 |
}
|
|
|
272 |
}
|
| 7226 |
anupam.sin |
273 |
}
|