<form class="form-horizontal" id="user_basic_data">
    <div class="ibox float-e-margins">
        <div class="ibox-content">
            <div class="col-lg-6">
                <div class="form-group">
                    <label class="col-lg-3 control-label" style="text-align: left;">Name</label>
                    <div class="col-lg-8">
                        <input placeholder="Name" class="form-control pull-left name" type="text" name="name" value="<?php echo !empty($user_details->name) ? $user_details->name : '';?>"> 
                        <!-- <span class="help-block m-b-none">Example block-level help text here.</span> -->
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-lg-3 control-label" style="text-align: left;">Company</label>
                    <div class="col-lg-8">
                        <input placeholder="Company Name" class="form-control pull-left company_name" type="text" name="company_name" value="<?php echo !empty($user_details->company_name) ? $user_details->company_name : '';?>">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-lg-3 control-label" style="text-align: left;">Contact Display</label>
                    <div class="col-lg-8">
                        <input placeholder="Display Name" class="form-control pull-left contact_display_name" type="text" name="contact_display_name" value="<?php echo !empty($user_details->contact_display_name) ? $user_details->contact_display_name : '';?>">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-lg-3 control-label" style="text-align: left;">Email</label>
                    <div class="col-lg-8">
                        <input placeholder="Email" class="form-control pull-left contact_email" type="email" name="contact_email" value="<?php echo !empty($user_details->contact_email) ? $user_details->contact_email : '';?>">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-lg-3 control-label" style="text-align: left;">Phone</label>
                    <div class="col-lg-8">
                        <input placeholder="Phone" class="form-control pull-left contact_phone" type="text" name="contact_phone" value="<?php echo !empty($user_details->contact_phone) ? $user_details->contact_phone : '';?>">
                    </div>
                </div>
                
            </div>
            <div class="col-lg-6">
                <div class="form-group">
                    <label class="col-lg-3 control-label" style="text-align: left;">Website</label>
                    <div class="col-lg-8">
                        <input placeholder="Website" class="form-control pull-left contact_website" type="text" name="contact_website" value="<?php echo !empty($user_details->contact_website) ? $user_details->contact_website : '';?>">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-lg-4 control-label pull-left" style="text-align: left;">Has GST Number</label>
                    <div class="col-lg-8">
                        <input type="checkbox" class="i-checks has_gst" name="has_gst" value="<?php echo !empty($user_details->has_gst) ? $user_details->has_gst : '0';?>" <?php echo !empty($user_details->has_gst) && ($user_details->has_gst==1) ? 'checked=""' : '';?>>
                    </div>
                </div>
                <div class="form-group gstn_block <?php echo !empty($user_details->has_gst) && ($user_details->has_gst==1) ? '' : 'hide';?>">
                    <label class="col-lg-3 control-label" style="text-align: left;">GST Number</label>
                    <div class="col-lg-8">
                        <input placeholder="GST No." class="form-control pull-left gstn" type="text" name="gstn" value="<?php echo !empty($user_details->gstn) ? $user_details->gstn : '';?>">
                    </div>
                </div>
                <div class="form-group hide">
                    <label class="col-lg-3 control-label" style="text-align: left;">Contact Type</label>
                    <div class="col-lg-8">
                        <!-- <input placeholder="Phone" class="form-control pull-left contact_type" type="text" name="contact_type" value=""> -->
                        <select class="form-control pull-left contact_type " name="contact_type">
                            <option value="1" <?php echo (!empty($user_details->contact_type) && ($user_details->contact_type == 1)) ? 'selected="selected"' : '';?>>Customer</option>                            
                        </select>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <div class="ibox float-e-margins">
        <div class="ibox-content">
            <!-- ================================== BiLLING INFO ====================================================-->
            <div class="col-lg-6">
                <div class="form-group">
                    <label class="col-lg-4 control-label" style="text-align: left;">Billing Address</label>
                    <div class="col-lg-8">
                        <input placeholder="ADDRESS" class="form-control pull-left billing_address" type="text" name="billing_address" value="<?php echo !empty($user_details->billing_address) ? $user_details->billing_address : '';?>">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-lg-4 control-label" style="text-align: left;">Billing City</label>
                    <div class="col-lg-8">
                        <input placeholder="CITY" class="form-control pull-left billing_city" type="text" name="billing_city" value="<?php echo !empty($user_details->billing_city) ? $user_details->billing_city : '';?>">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-lg-4 control-label" style="text-align: left;">Billing State</label>
                    <div class="col-lg-8">
                       <!-- <input placeholder="STATE" class="form-control pull-left billing_state" type="text" name="billing_state" value="<?php // echo !empty($user_details->billing_state) ? $user_details->billing_state : '';?>"> -->
                    
                        <select name="billing_state" class="form-control pull-left billing_state">
                            <option value="">Select One</option>
                            <option value="01" <?php echo (!empty($user_details->billing_state) && ($user_details->billing_state==1)) ? 'selected="selected"' : '';?>>01-Jammu & Kashmir</option>
                            <option value="02" <?php echo (!empty($user_details->billing_state) && ($user_details->billing_state==2)) ? 'selected="selected"' : '';?>>02-Himachal Pradesh</option>
                            <option value="03" <?php echo (!empty($user_details->billing_state) && ($user_details->billing_state==3)) ? 'selected="selected"' : '';?>>03-Punjab</option>
                            <option value="04" <?php echo (!empty($user_details->billing_state) && ($user_details->billing_state==4)) ? 'selected="selected"' : '';?>>04-Chandigarh</option>
                            <option value="05" <?php echo (!empty($user_details->billing_state) && ($user_details->billing_state==5)) ? 'selected="selected"' : '';?>>05-Uttarakhand</option>
                            <option value="06" <?php echo (!empty($user_details->billing_state) && ($user_details->billing_state==6)) ? 'selected="selected"' : '';?>>06-Haryana</option>
                            <option value="07" <?php echo (!empty($user_details->billing_state) && ($user_details->billing_state==7)) ? 'selected="selected"' : '';?>>07-Delhi</option>
                            <option value="08" <?php echo (!empty($user_details->billing_state) && ($user_details->billing_state==8)) ? 'selected="selected"' : '';?>>08-Rajasthan</option>
                            <option value="09" <?php echo (!empty($user_details->billing_state) && ($user_details->billing_state==9)) ? 'selected="selected"' : '';?>>09-Uttar Pradesh</option>
                            <option value="10" <?php echo (!empty($user_details->billing_state) && ($user_details->billing_state==10)) ? 'selected="selected"' : '';?>>10-Bihar</option>
                            <option value="11" <?php echo (!empty($user_details->billing_state) && ($user_details->billing_state==11)) ? 'selected="selected"' : '';?>>11-Sikkim</option>
                            <option value="12" <?php echo (!empty($user_details->billing_state) && ($user_details->billing_state==12)) ? 'selected="selected"' : '';?>>12-Arunachal Pradesh</option>
                            <option value="13" <?php echo (!empty($user_details->billing_state) && ($user_details->billing_state==13)) ? 'selected="selected"' : '';?>>13-Nagaland</option>
                            <option value="14" <?php echo (!empty($user_details->billing_state) && ($user_details->billing_state==14)) ? 'selected="selected"' : '';?>>14-Manipur</option>
                            <option value="15" <?php echo (!empty($user_details->billing_state) && ($user_details->billing_state==15)) ? 'selected="selected"' : '';?>>15-Mizoram</option>
                            <option value="16" <?php echo (!empty($user_details->billing_state) && ($user_details->billing_state==16)) ? 'selected="selected"' : '';?>>16-Tripura</option>
                            <option value="17" <?php echo (!empty($user_details->billing_state) && ($user_details->billing_state==17)) ? 'selected="selected"' : '';?>>17-Meghalaya</option>
                            <option value="18" <?php echo (!empty($user_details->billing_state) && ($user_details->billing_state==18)) ? 'selected="selected"' : '';?>>18-Assam</option>
                            <option value="19" <?php echo (!empty($user_details->billing_state) && ($user_details->billing_state==19)) ? 'selected="selected"' : '';?>>19-West Bengal</option>
                            <option value="20" <?php echo (!empty($user_details->billing_state) && ($user_details->billing_state==20)) ? 'selected="selected"' : '';?>>20-Jharkhand</option>
                            <option value="21" <?php echo (!empty($user_details->billing_state) && ($user_details->billing_state==21)) ? 'selected="selected"' : '';?>>21-Odisha</option>
                            <option value="22" <?php echo (!empty($user_details->billing_state) && ($user_details->billing_state==22)) ? 'selected="selected"' : '';?>>22-Chhattisgarh</option>
                            <option value="23" <?php echo (!empty($user_details->billing_state) && ($user_details->billing_state==23)) ? 'selected="selected"' : '';?>>23-Madhya Pradesh</option>
                            <option value="24" <?php echo (!empty($user_details->billing_state) && ($user_details->billing_state==24)) ? 'selected="selected"' : '';?>>24-Gujarat</option>
                            <option value="25" <?php echo (!empty($user_details->billing_state) && ($user_details->billing_state==25)) ? 'selected="selected"' : '';?>>25-Daman & Diu</option>
                            <option value="26" <?php echo (!empty($user_details->billing_state) && ($user_details->billing_state==26)) ? 'selected="selected"' : '';?>>26-Dadra & Nagar Haveli</option>
                            <option value="27" <?php echo (!empty($user_details->billing_state) && ($user_details->billing_state==27)) ? 'selected="selected"' : '';?>>27-Maharashtra</option>
                            <option value="29" <?php echo (!empty($user_details->billing_state) && ($user_details->billing_state==28)) ? 'selected="selected"' : '';?>>29-Karnataka</option>
                            <option value="30" <?php echo (!empty($user_details->billing_state) && ($user_details->billing_state==29)) ? 'selected="selected"' : '';?>>30-Goa</option>
                            <option value="31" <?php echo (!empty($user_details->billing_state) && ($user_details->billing_state==30)) ? 'selected="selected"' : '';?>>31-Lakshdweep</option>
                            <option value="32" <?php echo (!empty($user_details->billing_state) && ($user_details->billing_state==31)) ? 'selected="selected"' : '';?>>32-Kerala</option>
                            <option value="33" <?php echo (!empty($user_details->billing_state) && ($user_details->billing_state==32)) ? 'selected="selected"' : '';?>>33-Tamil Nadu</option>
                            <option value="34" <?php echo (!empty($user_details->billing_state) && ($user_details->billing_state==34)) ? 'selected="selected"' : '';?>>34-Pondicherry</option>
                            <option value="35" <?php echo (!empty($user_details->billing_state) && ($user_details->billing_state==35)) ? 'selected="selected"' : '';?>>35-Andaman & Nicobar Islands</option>
                            <option value="36" <?php echo (!empty($user_details->billing_state) && ($user_details->billing_state==36)) ? 'selected="selected"' : '';?>>36-Telengana</option>
                            <option value="37" <?php echo (!empty($user_details->billing_state) && ($user_details->billing_state==37)) ? 'selected="selected"' : '';?>>37-Andhra Pradesh</option>
                            <option value="98" <?php echo (!empty($user_details->billing_state) && ($user_details->billing_state==98)) ? 'selected="selected"' : '';?>>98 - Other Territory</option>
                        </select>
                    
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-lg-4 control-label" style="text-align: left;">Billing PIN</label>
                    <div class="col-lg-8">
                        <input placeholder="PIN CODE" class="form-control pull-left billing_zip" type="text" name="billing_zip" value="<?php echo !empty($user_details->billing_zip) ? $user_details->billing_zip : '';?>">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-lg-4 control-label" style="text-align: left;">Billing Country</label>
                    <div class="col-lg-8">
                        <input placeholder="COUNTRY" class="form-control pull-left billing_country" type="text" name="billing_country" value="<?php echo !empty($user_details->billing_country) ? $user_details->billing_country : '';?>">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-lg-4 control-label" style="text-align: left;">Billing FAX</label>
                    <div class="col-lg-8">
                        <input placeholder="FAX Number" class="form-control pull-left billing_fax" type="text" name="billing_fax" value="<?php echo !empty($user_details->billing_fax) ? $user_details->billing_fax : '';?>">
                    </div>
                </div>
            </div>

            <!-- ================================== SHIPPING INFO ====================================================-->
            <div class="col-lg-6" id="shipping_block">
                <div class="form-group">
                    <label class="col-lg-4 control-label" style="text-align: left;">Shipping Address</label>
                    <div class="col-lg-8">
                        <input placeholder="ADDRESS" class="form-control pull-left shipping_address" type="text" name="shipping_address" value="<?php echo !empty($user_details->shipping_address) ? $user_details->shipping_address : '';?>">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-lg-4 control-label" style="text-align: left;">Shipping City</label>
                    <div class="col-lg-8">
                        <input placeholder="CITY" class="form-control pull-left shipping_city" type="text" name="shipping_city" value="<?php echo !empty($user_details->shipping_city) ? $user_details->shipping_city : '';?>">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-lg-4 control-label" style="text-align: left;">Shipping State</label>
                    <div class="col-lg-8">
                        <!-- <input placeholder="STATE" class="form-control pull-left shipping_state" type="text" name="shipping_state" value="<?php // echo !empty($user_details->shipping_state) ? $user_details->shipping_state : '';?>"> -->
                    
                    
                        <select name="shipping_state" class="form-control pull-left shipping_state">
                            <option value="">Select One</option>
                            <option value="01" <?php echo (!empty($user_details->shipping_state) && ($user_details->shipping_state==1)) ? 'selected="selected"' : '';?>>01-Jammu & Kashmir</option>
                            <option value="02" <?php echo (!empty($user_details->shipping_state) && ($user_details->shipping_state==2)) ? 'selected="selected"' : '';?>>02-Himachal Pradesh</option>
                            <option value="03" <?php echo (!empty($user_details->shipping_state) && ($user_details->shipping_state==3)) ? 'selected="selected"' : '';?>>03-Punjab</option>
                            <option value="04" <?php echo (!empty($user_details->shipping_state) && ($user_details->shipping_state==4)) ? 'selected="selected"' : '';?>>04-Chandigarh</option>
                            <option value="05" <?php echo (!empty($user_details->shipping_state) && ($user_details->shipping_state==5)) ? 'selected="selected"' : '';?>>05-Uttarakhand</option>
                            <option value="06" <?php echo (!empty($user_details->shipping_state) && ($user_details->shipping_state==6)) ? 'selected="selected"' : '';?>>06-Haryana</option>
                            <option value="07" <?php echo (!empty($user_details->shipping_state) && ($user_details->shipping_state==7)) ? 'selected="selected"' : '';?>>07-Delhi</option>
                            <option value="08" <?php echo (!empty($user_details->shipping_state) && ($user_details->shipping_state==8)) ? 'selected="selected"' : '';?>>08-Rajasthan</option>
                            <option value="09" <?php echo (!empty($user_details->shipping_state) && ($user_details->shipping_state==9)) ? 'selected="selected"' : '';?>>09-Uttar Pradesh</option>
                            <option value="10" <?php echo (!empty($user_details->shipping_state) && ($user_details->shipping_state==10)) ? 'selected="selected"' : '';?>>10-Bihar</option>
                            <option value="11" <?php echo (!empty($user_details->shipping_state) && ($user_details->shipping_state==11)) ? 'selected="selected"' : '';?>>11-Sikkim</option>
                            <option value="12" <?php echo (!empty($user_details->shipping_state) && ($user_details->shipping_state==12)) ? 'selected="selected"' : '';?>>12-Arunachal Pradesh</option>
                            <option value="13" <?php echo (!empty($user_details->shipping_state) && ($user_details->shipping_state==13)) ? 'selected="selected"' : '';?>>13-Nagaland</option>
                            <option value="14" <?php echo (!empty($user_details->shipping_state) && ($user_details->shipping_state==14)) ? 'selected="selected"' : '';?>>14-Manipur</option>
                            <option value="15" <?php echo (!empty($user_details->shipping_state) && ($user_details->shipping_state==15)) ? 'selected="selected"' : '';?>>15-Mizoram</option>
                            <option value="16" <?php echo (!empty($user_details->shipping_state) && ($user_details->shipping_state==16)) ? 'selected="selected"' : '';?>>16-Tripura</option>
                            <option value="17" <?php echo (!empty($user_details->shipping_state) && ($user_details->shipping_state==17)) ? 'selected="selected"' : '';?>>17-Meghalaya</option>
                            <option value="18" <?php echo (!empty($user_details->shipping_state) && ($user_details->shipping_state==18)) ? 'selected="selected"' : '';?>>18-Assam</option>
                            <option value="19" <?php echo (!empty($user_details->shipping_state) && ($user_details->shipping_state==19)) ? 'selected="selected"' : '';?>>19-West Bengal</option>
                            <option value="20" <?php echo (!empty($user_details->shipping_state) && ($user_details->shipping_state==20)) ? 'selected="selected"' : '';?>>20-Jharkhand</option>
                            <option value="21" <?php echo (!empty($user_details->shipping_state) && ($user_details->shipping_state==21)) ? 'selected="selected"' : '';?>>21-Odisha</option>
                            <option value="22" <?php echo (!empty($user_details->shipping_state) && ($user_details->shipping_state==22)) ? 'selected="selected"' : '';?>>22-Chhattisgarh</option>
                            <option value="23" <?php echo (!empty($user_details->shipping_state) && ($user_details->shipping_state==23)) ? 'selected="selected"' : '';?>>23-Madhya Pradesh</option>
                            <option value="24" <?php echo (!empty($user_details->shipping_state) && ($user_details->shipping_state==24)) ? 'selected="selected"' : '';?>>24-Gujarat</option>
                            <option value="25" <?php echo (!empty($user_details->shipping_state) && ($user_details->shipping_state==25)) ? 'selected="selected"' : '';?>>25-Daman & Diu</option>
                            <option value="26" <?php echo (!empty($user_details->shipping_state) && ($user_details->shipping_state==26)) ? 'selected="selected"' : '';?>>26-Dadra & Nagar Haveli</option>
                            <option value="27" <?php echo (!empty($user_details->shipping_state) && ($user_details->shipping_state==27)) ? 'selected="selected"' : '';?>>27-Maharashtra</option>
                            <option value="29" <?php echo (!empty($user_details->shipping_state) && ($user_details->shipping_state==28)) ? 'selected="selected"' : '';?>>29-Karnataka</option>
                            <option value="30" <?php echo (!empty($user_details->shipping_state) && ($user_details->shipping_state==29)) ? 'selected="selected"' : '';?>>30-Goa</option>
                            <option value="31" <?php echo (!empty($user_details->shipping_state) && ($user_details->shipping_state==30)) ? 'selected="selected"' : '';?>>31-Lakshdweep</option>
                            <option value="32" <?php echo (!empty($user_details->shipping_state) && ($user_details->shipping_state==31)) ? 'selected="selected"' : '';?>>32-Kerala</option>
                            <option value="33" <?php echo (!empty($user_details->shipping_state) && ($user_details->shipping_state==32)) ? 'selected="selected"' : '';?>>33-Tamil Nadu</option>
                            <option value="34" <?php echo (!empty($user_details->shipping_state) && ($user_details->shipping_state==34)) ? 'selected="selected"' : '';?>>34-Pondicherry</option>
                            <option value="35" <?php echo (!empty($user_details->shipping_state) && ($user_details->shipping_state==35)) ? 'selected="selected"' : '';?>>35-Andaman & Nicobar Islands</option>
                            <option value="36" <?php echo (!empty($user_details->shipping_state) && ($user_details->shipping_state==36)) ? 'selected="selected"' : '';?>>36-Telengana</option>
                            <option value="37" <?php echo (!empty($user_details->shipping_state) && ($user_details->shipping_state==37)) ? 'selected="selected"' : '';?>>37-Andhra Pradesh</option>
                            <option value="98" <?php echo (!empty($user_details->shipping_state) && ($user_details->shipping_state==98)) ? 'selected="selected"' : '';?>>98 - Other Territory</option>
                        </select>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-lg-4 control-label" style="text-align: left;">Shipping PIN</label>
                    <div class="col-lg-8">
                        <input placeholder="PIN CODE" class="form-control pull-left shipping_zip" type="text" name="shipping_zip" value="<?php echo !empty($user_details->shipping_zip) ? $user_details->shipping_zip : '';?>">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-lg-4 control-label" style="text-align: left;">Shipping Country</label>
                    <div class="col-lg-8">
                        <input placeholder="COUNTRY" class="form-control pull-left shipping_country" type="text" name="shipping_country" value="<?php echo !empty($user_details->shipping_country) ? $user_details->shipping_country : '';?>">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-lg-4 control-label" style="text-align: left;">Shipping FAX</label>
                    <div class="col-lg-8">
                        <input placeholder="FAX Number" class="form-control pull-left shipping_fax" type="text" name="shipping_fax" value="<?php echo !empty($user_details->shipping_fax) ? $user_details->shipping_fax : '';?>">
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="ibox float-e-margins">
        <div class="ibox-content">
            <div class="form-group">
                <?php //if (!isset($user_details)) { ?>
                    <label class="col-lg-3 control-label pull-left" style="text-align: left;">Billing And Shipping Same</label>
                    <div class="col-lg-1">
                        <input type="checkbox" class="i-checks same_billing_shipping pull-left" value="0" name="same_billing_shipping">
                    </div>
                <?php //}?>
                <div class="col-lg-3">
                    <button class="btn btn-sm btn-primary pull-right m-t-n-xs save_userData" type="submit"><strong>Save Data</strong></button>
                </div>
            </div>
        </div>
    </div>
</form>
<script type="text/javascript">
    $(document).ready(function () {
        $('.i-checks').iCheck({
            checkboxClass: 'icheckbox_square-green'
        });

        $('.has_gst').on('ifChecked', function(){
            $(this).val('1');
            $('.gstn_block').removeClass('hide');
        });

        $('.has_gst').on('ifUnchecked', function(){
            $(this).val('0');
           $('.gstn_block').addClass('hide'); 
        });

        $('.same_billing_shipping').on('ifChecked', function(){
            $(this).val('1');
            $("#shipping_block :input").attr("disabled", true);
        });

        $('.same_billing_shipping').on('ifUnchecked', function(){
            $(this).val('0');
           $("#shipping_block :input").attr("disabled", false);
        });

        
        $( "#user_basic_data" ).on( "submit", function( event ) {
            event.preventDefault();
            
            if ($('.name').val() == '') {
                $('.name').parent().parent().addClass('has-error');
                return false;
            } else {
                $('.name').parent().parent().removeClass('has-error');
            }

            if ($('.company_name').val() == '') {
                $('.company_name').parent().parent().addClass('has-error');
                return false;
            } else {
                $('.company_name').parent().parent().removeClass('has-error');
            }

            if ($('.contact_display_name').val() == '') {
                $('.contact_display_name').parent().parent().addClass('has-error');
                return false;
            } else {
                $('.contact_display_name').parent().parent().removeClass('has-error');
            }

           /* if ($('.contact_email').val() == '') {
                $('.contact_email').parent().parent().addClass('has-error');
                return false;
            } else {
                $('.contact_email').parent().parent().removeClass('has-error');
            } */

            if ($('.contact_phone').val() == '') {
                $('.contact_phone').parent().parent().addClass('has-error');
                return false;
            } else {
                $('.contact_phone').parent().parent().removeClass('has-error');
            } 

           /* if ($('.contact_website').val() == '') {
                $('.contact_website').parent().parent().addClass('has-error');
                return false;
            } else {
                $('.contact_website').parent().parent().removeClass('has-error');
            }   */
            
            // if ($('.has_gst').val() == '') {
            //     $('.has_gst').parent().parent().addClass('has-error');
            //     return false;
            // } 

            if (($('.has_gst').val() == 1) && ($('.gstn').val() == '')) {
                $('.gstn').parent().parent().addClass('has-error');
                return false;
            } else {
                $('.gstn').parent().parent().removeClass('has-error');
            }  

            if ($('.contact_type').val() == '') {
                $('.contact_type').parent().parent().addClass('has-error');
                return false;
            } else {
                $('.contact_type').parent().parent().removeClass('has-error');
            }   

            var user_id = '<?php echo $user_id;?>';

            var name = $('.name').val();
            var company_name = $('.company_name').val();
            var contact_display_name = $('.contact_display_name').val();
            var contact_email = $('.contact_email').val();
            var contact_phone = $('.contact_phone').val();
            var contact_website = $('.contact_website').val();
            var has_gst = $('.has_gst').val();
            var gstn = $('.gstn').val();
            var contact_type = $('.contact_type').val();

            var billing_address = $('.billing_address').val();
            var billing_city = $('.billing_city').val();
            var billing_state = $('.billing_state').val();
            var billing_zip = $('.billing_zip').val();
            var billing_country = $('.billing_country').val();
            var billing_fax = $('.billing_fax').val();
            
            var same_address = $('.same_billing_shipping').val();
            var shipping_address = ($('.same_billing_shipping').val() == 1) ? billing_address : $('.shipping_address').val();
            var shipping_city = ($('.same_billing_shipping').val() == 1) ? billing_city : $('.shipping_city').val();
            var shipping_state = ($('.same_billing_shipping').val() == 1) ? billing_state : $('.shipping_state').val();
            var shipping_zip = ($('.same_billing_shipping').val() == 1) ? billing_zip : $('.shipping_zip').val();
            var shipping_country = ($('.same_billing_shipping').val() == 1) ? billing_country : $('.shipping_country').val();
            var shipping_fax = ($('.same_billing_shipping').val() == 1) ? billing_fax : $('.shipping_fax').val();
            
            $.ajax({
                url: '<?php echo site_url('user/save_basic_info');?>',
                type: "POST",
                data:{
                    user_id : user_id,
                    name : name,
                    company_name : company_name,
                    contact_display_name : contact_display_name,
                    contact_email : contact_email,
                    contact_phone : contact_phone,
                    contact_website : contact_website,
                    has_gst : has_gst,
                    gstn : gstn,
                    contact_type : contact_type,
                    same_address : same_address,
                    billing_address : billing_address,
                    billing_city : billing_city,
                    billing_state : billing_state,
                    billing_zip : billing_zip,
                    billing_country : billing_country,
                    billing_fax : billing_fax,
                    shipping_address : shipping_address,
                    shipping_city : shipping_city,
                    shipping_state : shipping_state,
                    shipping_zip : shipping_zip,
                    shipping_country : shipping_country,
                    shipping_fax : shipping_fax
                },
                success: function(data){ 
                    if (user_id == 0) {
                        //window.location.href = '<?php echo site_url("user/newuser/'+data+'");?>';
                        window.location.href = '<?php echo site_url('user');?>';
                    } else {
                        window.location.href = '<?php echo site_url('user');?>';
                    }
                }
            });

        });

    });
</script>