Rev 7349 | Rev 7386 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
$(function() {$("#query").autocomplete({ autoFocus: true, minLength: 3,source: "/storewebsite/auto-suggest",select: function( event, ui ) {this.value = ui.item.value;$('#formSearch').submit();return false;}});$("#formSearch").submit(function() {if($("#query").val() == "" || $("#query").val() == "Search for more items...") {return false;}});$('#pincodeForm').submit(function() {if($('#pincodeSubmit:hidden').length == 1) {return false;}if ($('#pincodeText').val().length != 6) {alert('Please enter 6 digit pin code');return false;}var result = $('#pincodeText').val().match(/^\d*$/);if(result == null || result.length == 0) {alert('Please enter a valid pin code');return false;}$('#priceDiv').empty();showLoading();$.ajax({type: "POST",url: "/storewebsite/estimate",dataType:"json",data:$('#pincodeForm').serialize(),// timeout: 10000,success:function(msg) {hideLoading();if(msg.length != 0) {if(msg.selling_price == 0.0) {$('#loading').hide();$('#shippingAddress').hide();$('#priceDiv').html("<div class='error'>There was some error. Please try again.</div>");$('#pincodeSubmit').show();} else {$('#priceDiv').html("<div class='date'><span class='infoText'>Get this product by </span><span class='infoValue'>" + msg.delivery_estimate + "</span></div>" +"<div class='price'><span class='infoText'>Total Price</span><span class='infoValue'> Rs. " + $('#shippingAddress input[name=price]').val() + "</span></div>" +"<div class='advance'><span class='infoText'>Advance to be paid</span><span id='advPrice' class='infoValue'> Rs. " + msg.min_advance_amount + "</span></div>");$('#shippingAddress input[name=advanceAmount]').val(msg.min_advance_amount);$('#shippingAddress input[name=deliveryDate]').val(msg.delivery_estimate);$('#shippingAddress input[name=minPrice]').val(msg.min_selling_price);$('#shippingAddress input[name=maxPrice]').val(msg.max_selling_price);$('#shippingAddress input[name=bestDealText]').val(msg.best_deal_text);$('#bestDealText').text(msg.best_deal_text);$('#bestDealContainer').show();$('#pincodeInput').val($('#pincodeText').val());$('#editPriceButton').show();$('#editPriceBox').val(msg.min_advance_amount);}} else {$('#priceDiv').html("<div class='error'>No info found for this pincode. Please try again.</div>");}},error : function(msg) {$('#loading').hide();$('#shippingAddress').hide();$('#priceDiv').html("<div class='error'>There was some error. Please try again.</div>");$('#pincodeSubmit').show();},complete : function() {$('#pinSpan').html($('#pincodeText').val());}});return false;});function showLoading() {$('#pincodeSubmit').hide();$('#shippingAddress').hide();$('#loading').show();}function hideLoading() {$('#loading').hide();$('#shippingAddress').show();}$('#changePincode').click(function() {window.location.reload();});$('#pincodeEdit').click(function(event){event.preventDefault();var newForm = jQuery('<form>', {'action': '/storewebsite/order-details','target': '_top'}).append(jQuery('<input>', {'name': 'product_id','value': $('#createOrderForm input[name=product_id]').val(),'type': 'hidden'})).append(jQuery('<input>', {'name': 'price','value': $('#createOrderForm input[name=price]').val(),'type': 'hidden'}));newForm.submit();});$('#addressEdit').click(function() {$('#createOrder, #showPinDiv, #showAddDiv').hide();$('#editAddBlock').show();});$('#saveEditedAdd').click(function() {var editedFields = $('#editAddBlock input');editedFields.each(function(i, inputField) {if($(inputField).val() == "") {alert("Please enter correct " + $(inputField).attr('name'));return false;}if ($(inputField).attr('name') == "phone") {if ($(inputField).val().length != 10) {alert('Please enter a 10 digit mobile number');return false;}var result = $(inputField).val().match(/^\d*$/);if(result == null || result.length == 0) {alert('Please enter a valid mobile number');return false;}}var nameToSearch = $(inputField).attr("name");$('#showAddDiv [name="' + nameToSearch + '"]').html($(inputField).val());$('#createOrderForm input[name="' + nameToSearch + '"]').val($(inputField).val());});$('#editAddBlock').hide();$('#createOrder, #showPinDiv, #showAddDiv').show();});$('#paymode').change(function() {if($('#paymode input:radio[name="paymode"]:checked').val() == "card") {$('#bankSelector').show();} else {$('#bankSelector').hide();}});$('#editPriceButton').click(function() {$('#editPriceButton').hide();$('#editPriceSpan').show();});$('#priceFixButton').click(function() {var result = $('#editPriceBox').val().match(/^\d*$/);if(result == null || result.length == 0) {alert('Please enter a valid amount');return false;}if(parseFloat($('#editPriceBox').val()) > parseFloat($('#shippingAddress input[name=price]').val()) + 1) {alert('Advance cannot be more than Rs.' + $('#shippingAddress input[name=price]').val());return false;}if(parseFloat($('#editPriceBox').val()) < parseFloat($('#shippingAddress input[name=advanceAmount]').val())) {alert('Advance cannot be below Rs. ' + $('#shippingAddress input[name=advanceAmount]').val());return false;}$('#editPriceButton').show();$('#editPriceSpan').hide();$('#advPrice').empty();$('#advPrice').text(' Rs. ' + parseFloat($('#editPriceBox').val()).toFixed(1));$('#shippingAddress input[name=advanceAmount]').val($('#editPriceBox').val());});$('#editSellingPriceButton').click(function() {$('#editSellingPriceButton').hide();$('#pricePopupBox').show();});$('#cancelPriceEdit').click(function() {$('#pricePopupBox').hide();$('#editSellingPriceButton').show();});$('#savePriceEdit').click(function() {var result = ($('#sellingPriceBox').val().split('.')[0]).match(/^\d*$/);if(result == null || result.length == 0) {alert('Please enter a valid amount');return false;}if(parseFloat($('#sellingPriceBox').val()) > parseFloat($('#maxPrice').text())) {alert('You cannot sell this product at more than Rs.' + $('#maxPrice').text());return false;}if(parseFloat($('#sellingPriceBox').val()) < parseFloat($('#absMin').val())) {alert('You cannot sell below Rs.' + $('#absMin').val());return false;}if(parseFloat($('#sellingPriceBox').val()) < parseFloat($('#minPrice').text())) {alert('You will need permission of the zonal head to to sell at this price');}$('#editSellingPriceButton').show();$('#pricePopupBox').hide();$('#mrp').html(parseFloat($('#sellingPriceBox').val()).toFixed(2));});$("#dateselector").change(function() {if($(this).val()=="3"){$("#daterange").show();}else {$("#daterange").hide();}});$(".cancelButton").click(function() {var newForm = jQuery('<form>', {'action': '/storewebsite/report!cancelRequest','target': '_top'}).append(jQuery('<input>', {'name': 'orderId','value': $(this).attr('order'),'type': 'hidden'}));newForm.submit();});$(".returnButton").click(function() {$("#returnPopupOrder").val($(this).attr("order"));$("#returnPopupBox").show();});$("#cancelReturnRequest").click(function() {$("#returnPopupOrder").val("");$("#returnPopupBox").hide();});$(".refundButton").click(function() {$("#refundPopupOrder").val($(this).attr("order"));$("#refundPopupBox").show();});$("#cancelRefundRequest").click(function() {$("#refundPopupOrder").val("");$("#refundPopupBox").hide();});});function validateAddress() {if ($('input[name=name]').val() == "") {alert("Please enter the customer's name");return false;}if ($('input[name=phone]').val().length != 10) {alert('Please enter a 10 digit mobile number');return false;}var result = $('input[name=phone]').val().match(/^\d*$/);if(result == null || result.length == 0) {alert('Please enter a valid mobile number');return false;}if ($('input[name=line1]').val() == "") {alert('Please enter a shipping address');return false;}if ($('input[name=city]').val() == "") {alert('Please enter the name of the city');return false;}if ($('input[name=state]').val() == "") {alert('Please enter the name of the state');return false;}return true;}function validatePaymentDetails() {if($('#paymode input:radio[name="paymode"]:checked').val() == "card") {if($('#bankSelector input:radio[name="bank"]:checked').length == 0) {alert('Please select the name of the bank of card terminal');return false;}}}function validateAmount() {var result = $('#refundAmountText').val().match(/^\d*$/);if(result == null || result.length == 0) {alert('Please enter a valid amount');return false;}}