Subversion Repositories SmartDukaan

Rev

Rev 19051 | Blame | Compare with Previous | Last modification | View Log | RSS feed

<script>
var request;
$(document).on('keyup','#pindet',function(){
        console.log($(this).val());     
    var pin_val = $(this).val().trim();
    if(request) {
        request.abort();
    };
    if(pin_val.length == 6){
       
     request =   $.ajax({
            method: "GET",
            url:  "<?php echo $base_url;?>shippings/getstate/"+pin_val,
        },'json')
        .done(function(msg){ 
                msg = eval('('+msg+')');
                if(msg=="{}" || $('#tinstate').html().trim() != msg['state'].trim() )                  
                {
                        $("#cities").empty();
                        $('#alert_msg').empty();
                        $('#alert_msg').html("Pincode does not belong to "+$('#tinstate').html().trim());
                                $('#alert_msg').removeClass('hidden');
                                setTimeout(function() {
                        $('#alert_msg').addClass('hidden');
                    }, 2000); 
//                      $("#state").val("");            
                }
                else
                {
                
                        $("#cities").empty();
                        for(var i in msg['cities']){
                                var html = '<option value="'+msg['cities'][i]+'"></option>';
                                $("#cities").append(html);
                        }
                         $('#citydet').removeClass('hidden');
                
//                      $("#state").val(msg['state']);
//                      $("#cities").empty();
//                      for(var i in msg['cities']){
//                              var html = "<option value="+msg['cities'][i]+">"+msg['cities'][i]+"</option>"
//                              $("#cities").append(html);
//                      }       
                }
            
        });                     
    } 
    else{
        $("#cities").empty();
        $('#citydet').addClass('hidden');
    }
});
        $(document).ready(function(){   
                $('.tryagaintin').click(function(){
                        $('#tin').val('');
                        $('.searchres').removeClass('hidden');
                        $('.tryagaintin').addClass('hidden');
                        $('#tindetail').empty();
                        
                });
//              $('#gettin').click(function(){
                $(document).on('submit', '#tinform', function(e){
                
                        var tin = $('#tin').val().trim();
//                      alert(tin);
                        var value = "true";
                        if(tin == '')
                    {
                        value = "false";
                        message = "*Please enter tin number";    
                        
                    }

                    else if(tin.match(/^\d{11}$/) == null)
                    {
                        value = "false";
                        message = "*Tin number should be of 11 digit.Delhi user add 0 before tin no.";    
                    }

                    if(value == "false"){
                        $('#message').html(message);
                        $('#message').removeClass('hidden');
//                      setTimeout(function() {
//                                  $('#message').addClass('hidden');
//                              }, 2000);  
                        return false;
                            }
                    else{
                        $('#searchloader').removeClass('hidden');
                        $('#message').addClass('hidden');
                        $.ajax({
                        method: "GET",
                        url:  "<?php echo $base_url;?>tins/tin_search/"+tin,
                    },'json')
                    .done(function(msg){
                        console.log(msg);
                        $('#tindetail').html(msg);
                        $('#searchloader').addClass('hidden');
                                        $('.tryagaintin').removeClass('hidden');
                                        $('.searchres').addClass('hidden');
                                        });
                        return false;   
                            }
                                
        
                                
                        });
                });
        $(document).on('click','#submit_det',function(){
                $('#alert_msg').empty();
                var gettindet = $('#tinres').data('tinres');
                var value = "true";
                var phone_data =  $('#phonedet').val().trim();
                if($('#pindet').length == 1){
                        var pin_data =  $('#pindet').val().trim();
                        var city_data =  $('#citydet').val().trim();
                        
                         if(pin_data == '')
                            {
                                value = "false";
                                message = "Please fill pin field!";
                            }
                         else if(pin_data.match(/^\d{6}$/) == null)
                            {
                                value = "false";
                                message = "Invalid pin number!";    
                            }
                         else if(city_data == "")
                            {
                                value = "false";
                                message = "Please fill city field!";    
                            }
                }

                if (phone_data == "")
                    {
                        value = "false";
                        message = "Please fill contact number field!";    
                        
                    }

            else if(phone_data.match(/^\d{10}$/) == null)
            {
                value = "false";
                message = "Invalid contact number";    
            }


                if(value == "false"){
                                $('#alert_msg').append(message);
                                $('#alert_msg').removeClass('hidden');
                                setTimeout(function() {
                        $('#alert_msg').addClass('hidden');
                    }, 2000);  
//           return false;
                         }
            else{
                         gettindet['pin'] = $('#pindet').val().trim();
                         gettindet['city'] = $('#citydet').val().trim();
                         gettindet['mobile'] = $('#phonedet').val().trim();
                         $.ajax({
                                                method: "POST",
                                                url:  apihost + "tins/confirm",
                                                data: gettindet,
                                            },'json')
                                            .done(function(msg){  
                                                var newmsg = JSON.parse(msg)
                                                var showcontent =""; 
                                                if(newmsg["response"]["isError"] == false)
                                                {
                                                        showcontent= "<div style='padding:5px;'>Your tin has been registered.</div><div>Redirecting to deals... </div>";                   
                                    
                                                    }
                                                else{
                                                        showcontent= "<div style='padding:5px;'>Some problem occurred while registering.Please try again after some time</div><div>Redirecting to deals... </div>";
                                                    }
                                                $('#tin_response').html(showcontent);
                                                $("#tinModal").modal('show');;
                                                
                                                setTimeout(function(){ document.location = apihost+"category/3" ;}, 5000);
                                                console.log(msg);                      
                                            });
                         }
        });
</script>
<style>
        #alert_msg{ 
        position: fixed; 
        top: 0px; 
        left: 0px; 
        right: 0px; 
        margin-top: 0px; 
        z-index: 10; 
 } 
#searchloader{
    position:absolute;
    /*top:40%;*/
    left:50%;
    z-index:2001;
}
</style>
<div class="alert alert-danger hidden" id="alert_msg"></div>

<div class="text-center hidden" id="searchloader">
    <br><br><br><br>
          <div class="hexdots-loader"></div>         
</div>


<div class = "container">             
        <div class = "row card" style='padding-bottom:15px;'>
                <div class="tryagaintin hidden" style='padding:5px;'>
                        Not your tax details? <span style="color:#58d936;" ><u>Try Again</u></span>
                </div>
                
                
                <form method="post" action="#" name='tinform' id='tinform'> 
                        
                        <div class="input-group col-xs-12 text-right searchres" style="padding:10px 0px 1px;">

                    <input type="text" class="form-control" autocomplete="off" placeholder="Enter tin number*" id="tin" name="tin" style="width:98%;">
                    
                    <div class="input-group-btn w25px">
                       <!--  <button class="btn" id='gettin' style="background-color:#58d936;color:white;">OK</button> -->
                       <input type="submit" value="OK" style="background-color:#58d936;color:white;" id='gettin' class="btn">
                    </div>
                </div>
                
                    <span id="message" class="hidden" style="color:red;font-size:12px;float:left;"></span>
                    
            </form>
                    
            <div style="border:1px solid #58d936; padding:2px;margin:20px 0px 5px;font-size:12px;" class="searchres">
                                                        
                                                                <div style="line-height: 15px;">
                                                                        <b>*</b> Tax invoice will be available only for Delhi.<br>
                                                                        <b>*</b> Available only on purchase through ProfitMandi and billed by Saholic.com.<br>
                                                                        <b>*</b> Not available on purchase from other sites ie. Snapdeal, Flipkart, Shopclues, Paytm and Homeshop18.
                                                                </div>
                                                                <hr style="margin:5px;border-color: #58d936;">
                                                                <div style="line-height: 15px;margin-top: 4px;">
                                                                        <b>*</b> टैक्स बिल केवल दिल्ली के लिए ही उपलब्ध है।<br> 
                                                                        <b>*</b> ProfitMandi से खरीदने पर और Saholic.com द्वारा बिलिंग पर उपलब्ध  है ।<br>
                                                                        <b>*</b> दूसरी अन्य वेबसाइट से खरीदारी पे उपलब्ध नहीं है । जैसे - Snapdeal, Flipkart, Shopclues, Paytm और Homeshop18 । 
                                                                </div>

                </div>

                        
<!--                    <input type="text" id="tin" name="tin" placeholder="Enter tin number*" required/> -->
<!--                    <button id='gettin'>Get Detail</button> -->
                
        </div>

        <div id='tindetail'>
        
        </div>
</div>
<link rel="stylesheet" href="/css/hexdots.css" type="text/css">