| 7226 |
anupam.sin |
1 |
$(function() {
|
| 7255 |
amit.gupta |
2 |
|
|
|
3 |
$("#query").autocomplete({ autoFocus: true, minLength: 3,
|
|
|
4 |
source: "auto-suggest",
|
|
|
5 |
select: function( event, ui ) {
|
|
|
6 |
this.value = ui.item.value;
|
|
|
7 |
$('#formSearch').submit();
|
|
|
8 |
return false;
|
|
|
9 |
}
|
|
|
10 |
});
|
|
|
11 |
|
| 7226 |
anupam.sin |
12 |
$('#pincodeForm').submit(function() {
|
|
|
13 |
|
|
|
14 |
if($('#pincodeSubmit:hidden').length == 1) {
|
|
|
15 |
return false;
|
|
|
16 |
}
|
|
|
17 |
|
|
|
18 |
if ($('#pincodeText').val().length != 6) {
|
|
|
19 |
alert('Please enter 6 digit pin code');
|
|
|
20 |
return false;
|
|
|
21 |
}
|
|
|
22 |
|
|
|
23 |
var result = $('#pincodeText').val().match(/^\d*$/);
|
|
|
24 |
if(result == null || result.length == 0) {
|
|
|
25 |
alert('Please enter a valid pin code');
|
|
|
26 |
return false;
|
|
|
27 |
}
|
|
|
28 |
|
|
|
29 |
showLoading();
|
|
|
30 |
$.ajax({
|
|
|
31 |
type: "POST",
|
| 7268 |
anupam.sin |
32 |
url: "/storewebsite/estimate",
|
| 7226 |
anupam.sin |
33 |
dataType:"json",
|
| 7268 |
anupam.sin |
34 |
data:$('#pincodeForm').serialize(),
|
|
|
35 |
// timeout: 10000,
|
| 7226 |
anupam.sin |
36 |
success:function(msg) {
|
|
|
37 |
hideLoading();
|
|
|
38 |
if(msg.length != 0) {
|
|
|
39 |
$('#priceDiv').html(
|
| 7263 |
anupam.sin |
40 |
"<div class='date'><span class='infoText'>Get this product by </span><span class='infoValue'>" + msg.delivery_estimate + "</span></div>" +
|
|
|
41 |
"<div class='price'><span class='infoText'>Total Price</span><span class='infoValue'> Rs. " + msg.selling_price + "</span></div>" +
|
|
|
42 |
"<div class='advance'><span class='infoText'>Advance to be paid</span><span class='infoValue'> Rs. " + msg.min_advance_amount + "</span></div>");
|
| 7226 |
anupam.sin |
43 |
$('#pincodeInput').val($('#pincodeText').val());
|
|
|
44 |
} else {
|
|
|
45 |
$('#priceDiv').html("<div class='error'>No info found for this pincode. Please try again.</div>");
|
|
|
46 |
}
|
|
|
47 |
},
|
|
|
48 |
error : function(msg) {
|
|
|
49 |
$('#loading').hide();
|
|
|
50 |
$('#shippingAddress').hide();
|
|
|
51 |
$('#priceDiv').html("<div class='error'>There was some error. Please try again.</div>");
|
|
|
52 |
$('#pincodeSubmit').show();
|
|
|
53 |
},
|
|
|
54 |
complete : function() {
|
|
|
55 |
$('#pinSpan').html($('#pincodeText').val());
|
|
|
56 |
|
|
|
57 |
}
|
|
|
58 |
});
|
|
|
59 |
return false;
|
|
|
60 |
});
|
|
|
61 |
|
|
|
62 |
function showLoading() {
|
|
|
63 |
$('#pincodeSubmit').hide();
|
|
|
64 |
$('#shippingAddress').hide();
|
|
|
65 |
$('#loading').show();
|
|
|
66 |
}
|
|
|
67 |
|
|
|
68 |
function hideLoading() {
|
|
|
69 |
$('#loading').hide();
|
|
|
70 |
$('#shippingAddress').show();
|
|
|
71 |
}
|
|
|
72 |
|
|
|
73 |
$('#changePincode').click(function() {
|
|
|
74 |
$('#shippingAddress')[0].reset();
|
|
|
75 |
$('#shippingAddress input:hidden').val('');
|
|
|
76 |
$('#shippingAddress').hide();
|
|
|
77 |
$('#priceDiv').empty();
|
|
|
78 |
$('#pincodeSubmit').show();
|
|
|
79 |
});
|
| 7248 |
anupam.sin |
80 |
|
|
|
81 |
$('#pincodeEdit').click(function(event){
|
|
|
82 |
event.preventDefault();
|
|
|
83 |
var newForm = jQuery('<form>', {
|
|
|
84 |
'action': '/storewebsite/order-details',
|
|
|
85 |
'target': '_top'
|
|
|
86 |
}).append(jQuery('<input>', {
|
|
|
87 |
'name': 'product_id',
|
|
|
88 |
'value': '9161',
|
|
|
89 |
'type': 'hidden'
|
|
|
90 |
}));
|
|
|
91 |
newForm.submit();
|
|
|
92 |
});
|
|
|
93 |
|
|
|
94 |
$('#addressEdit').click(function() {
|
|
|
95 |
$('#createOrder, #showPinDiv, #showAddDiv').hide();
|
|
|
96 |
$('#editAddBlock').show();
|
|
|
97 |
});
|
|
|
98 |
|
|
|
99 |
$('#saveEditedAdd').click(function() {
|
|
|
100 |
var editedFields = $('#editAddBlock input');
|
|
|
101 |
editedFields.each(function(i, inputField) {
|
|
|
102 |
if($(inputField).val() == "") {
|
|
|
103 |
alert("Please enter correct " + $(inputField).attr('name'));
|
|
|
104 |
return false;
|
|
|
105 |
}
|
|
|
106 |
|
|
|
107 |
if ($(inputField).attr('name') == "phone") {
|
|
|
108 |
if ($(inputField).val().length != 10) {
|
|
|
109 |
alert('Please enter a 10 digit mobile number');
|
|
|
110 |
return false;
|
|
|
111 |
}
|
|
|
112 |
|
|
|
113 |
var result = $(inputField).val().match(/^\d*$/);
|
|
|
114 |
if(result == null || result.length == 0) {
|
|
|
115 |
alert('Please enter a valid mobile number');
|
|
|
116 |
return false;
|
|
|
117 |
}
|
|
|
118 |
}
|
|
|
119 |
|
|
|
120 |
var nameToSearch = $(inputField).attr("name");
|
|
|
121 |
$('#showAddDiv [name="' + nameToSearch + '"]').html($(inputField).val());
|
|
|
122 |
$('#createOrderForm input[name="' + nameToSearch + '"]').val($(inputField).val());
|
|
|
123 |
});
|
|
|
124 |
|
|
|
125 |
$('#editAddBlock').hide();
|
|
|
126 |
$('#createOrder, #showPinDiv, #showAddDiv').show();
|
|
|
127 |
});
|
|
|
128 |
|
|
|
129 |
$('#paymode').change(function() {
|
|
|
130 |
if($('#paymode input:radio[name="paymode"]:checked').val() == "card") {
|
|
|
131 |
$('#bankSelector').show();
|
|
|
132 |
} else {
|
|
|
133 |
$('#bankSelector').hide();
|
|
|
134 |
}
|
|
|
135 |
});
|
| 7226 |
anupam.sin |
136 |
});
|
|
|
137 |
|
|
|
138 |
function validateAddress() {
|
| 7248 |
anupam.sin |
139 |
if ($('input[name=name]').val() == "") {
|
|
|
140 |
alert("Please enter the customer's name");
|
|
|
141 |
return false;
|
|
|
142 |
}
|
|
|
143 |
|
|
|
144 |
if ($('input[name=phone]').val().length != 10) {
|
|
|
145 |
alert('Please enter a 10 digit mobile number');
|
|
|
146 |
return false;
|
|
|
147 |
}
|
|
|
148 |
|
|
|
149 |
var result = $('input[name=phone]').val().match(/^\d*$/);
|
|
|
150 |
if(result == null || result.length == 0) {
|
|
|
151 |
alert('Please enter a valid mobile number');
|
|
|
152 |
return false;
|
|
|
153 |
}
|
|
|
154 |
|
| 7226 |
anupam.sin |
155 |
if ($('input[name=line1]').val() == "") {
|
|
|
156 |
alert('Please enter a shipping address');
|
|
|
157 |
return false;
|
|
|
158 |
}
|
|
|
159 |
if ($('input[name=line2]').val() == "") {
|
|
|
160 |
alert('Please enter a shipping address');
|
|
|
161 |
return false;
|
|
|
162 |
}
|
|
|
163 |
if ($('input[name=city]').val() == "") {
|
|
|
164 |
alert('Please enter the name of the city');
|
|
|
165 |
return false;
|
|
|
166 |
}
|
|
|
167 |
if ($('input[name=state]').val() == "") {
|
|
|
168 |
alert('Please enter the name of the state');
|
|
|
169 |
return false;
|
|
|
170 |
}
|
|
|
171 |
return true;
|
| 7248 |
anupam.sin |
172 |
}
|
|
|
173 |
|
|
|
174 |
function validatePaymentDetails() {
|
|
|
175 |
if($('#paymode input:radio[name="paymode"]:checked').val() == "card") {
|
|
|
176 |
if($('#bankSelector input:radio[name="bank"]:checked').length == 0) {
|
|
|
177 |
alert('Please select the name of the bank of card terminal');
|
|
|
178 |
return false;
|
|
|
179 |
}
|
|
|
180 |
}
|
| 7226 |
anupam.sin |
181 |
}
|