<?php $this->load->view("top_application"); 

if ($this->input->get_post('category_id')) {
  //category_id,qty_per_year,selling_price_msp,selling_month

  $category_ids = $this->input->get_post('category_id');
  $category_id_val = $category_ids[0];

  $qty_per_years = $this->input->get_post('qty_per_year');
  $qty_per_year_val = $qty_per_years[0];

  $selling_price_msps = $this->input->get_post('selling_price_msp');
  $selling_price_msp_val = $selling_price_msps[0];

  $selling_months = $this->input->get_post('selling_month');
  $selling_month_val = $selling_months[0];

} else {

  $category_ids = array();
  $category_id_val = '';
  $qty_per_years = array();
  $qty_per_year_val = '';
  $selling_price_msps = array();
  $selling_price_msp_val = '';
  $selling_months = array();
  $selling_month_val = '';

}

?>
<!-- page wapper-->
<!-- ============================================== HEADER : END ============================================== -->
<style type="text/css">
  .box-authentication input, select, textarea {margin-top: 15px;}
  .required{ color:#FF3300;}
  .validation{ color:#FF3300;}
  .success{ color:#00CC33;}
</style>
<div class="breadcrumb">
  <div class="container">
    <div class="breadcrumb-inner">
      <ul class="list-inline list-unstyled">
        <li><a href="<?php echo site_url(); ?>">Home</a></li>
        <li class='active'>Login / Register</li>
      </ul>
    </div>
    <!-- /.breadcrumb-inner -->
  </div>
  <!-- /.container -->
</div>
<!-- /.breadcrumb -->
<div class="body-content">
  <div class="container">
    <div class="sign-in-page">
      <div class="row">
        <!-- Sign-in -->
        <div class="col-md-6 col-sm-6 sign-in">
          <h4 class="">Sign in</h4>
          <?php
          echo validation_message();
          echo error_message();
          ?>
          <p class="">Hello, Welcome to your account.</p>
          <div class="social-sign-in outer-top-xs"> 
            <a onclick="window.parent.location.href = '<?php echo site_url(); ?>hauth/login/Facebook';" class="facebook-sign-in" style="cursor: pointer;"><i class="fa fa-facebook"></i> Sign In with Facebook</a> 
            <a onclick="window.parent.location.href = '<?php echo site_url(); ?>hauth/login/Google';" class="googleplus-sign-in" style="cursor: pointer;"><i class="fa fa-google-plus"></i> Sign In With Google+</a> 
          </div>
          <?php echo form_open('users/register', 'name="login_frm" id="logFrm"'); ?>
          <div class="form-group">
            <label class="info-title" for="exampleInputEmail1">Email Address<span>*</span></label>

            <input id="emmail_login" name="login_email" placeholder="Login ID/Email*" type="text" class="form-control unicase-form-control text-input">
            <?php echo form_error('login_email'); ?> 
          </div>
          <div class="form-group">
            <label class="info-title" for="exampleInputPassword1">Password<span>*</span></label>
            <input id="password_login" name="login_password" placeholder="Password*" type="password" class="form-control unicase-form-control text-input">
            <?php echo form_error('login_password'); ?> 
          </div>
          <div class="radio outer-xs">
            <label>
              <p class="forgot-password pull-right"><a href="<?php echo site_url('users/forgotten_password'); ?>">Forgot your password?</a></p>
            </label>
          </div>
          <button class="btn-upper btn btn-primary checkout-page-button" type="submit"><i class="fa fa-lock"></i> Sign in</button>
          <input type="hidden" name="action" value="login" />
          <?php echo form_close(); ?> 
        </div>
        <!-- Sign-in -->
        <!-- create a new account -->
        <div class="col-md-6 col-sm-6 create-new-account">
          <h4 class="checkout-subtitle">Create a new account</h4>
          <p class="text title-tag-line">Create your new account.</p>
          <?php echo form_open('users/register', 'name="login_frm" id="regisFrm"'); ?>
          <div class="form-group">
              <label class="info-title" for="mobile_number">Mobile Number<span>*</span></label>
              <input type="text" class="form-control" name="mobile_number" id="mobile_number" value="<?php echo set_value("mobile_number");?>" placeholder="Mobile Number*"> 
              <?php echo form_error("mobile_number");?>
          </div>
          <div class="form-group">
            <label class="info-title" for="password">Password<span>*</span></label>
            <input id="password" name="password" type="password" class="form-control" placeholder="Password*"><?php echo form_error('password'); ?>
            </div>
          <div class="form-group">
            <label class="info-title" for="c_password">Confirm Password<span>*</span></label>
            <input id="c_password" name="c_password" type="password" class="form-control" placeholder="Confirm Password*"><?php echo form_error('c_password'); ?>
            </div>
          <input type="hidden" name="country_id" id="country" value="105"> 
          <?php /*
          <div class="form-group">
            <label class="info-title" for="country">Country<span>*</span></label>
            <?php $country_id=set_value("country_id"); ?>                                                                                                                                                        
              <select name="country_id" class="form-control" id="country">
                <option value="">--Select Country--</option>
                <?php
                if ($country) {
                  foreach ($country as $cnt) {
                    if ($cnt['id'] == $country_id) {
                      $sel = "selected";
                    } else {
                      $sel = "";
                    }
                    ?>
                    <option value="<?php echo $cnt['id']; ?>" <?php echo $sel; ?>><?php echo $cnt['name']; ?></option>
                    <?php
                  }
                }
                ?>
              </select>
              <?php echo form_error("country_id");?>
          </div>*/?>
          <div class="form-group">
            <label class="info-title" for="state">State<span>*</span></label>
            <?php $state_id=set_value("state_id"); ?>
              <select name="state_id" class="form-control" id="state">
                <option value="">--Select State--</option>
                <?php
                if (is_array($states) && !empty($states)) {
                  foreach ($states as $state) {
                    if ($state['id'] == $state_id) {
                      $sel = "selected";
                    } else {
                      $sel = "";
                    }
                    ?>
                    <option value="<?php echo $state['id']; ?>" <?php echo $sel; ?>><?php echo $state['name']; ?></option>
                    <?php
                  }
                }
                ?>
              </select>
              <?php echo form_error("state_id");?>
          </div>

          <div class="form-group">
          <label class="info-title" for="city">District<span>*</span></label>
              <select name="city_id" class="form-control" id="city">
                <option value="">--Select District--</option>
              </select>
              <?php echo form_error("city_id");?>
          </div>
          <div class="form-group">
            <label class="info-title" for="block">Block<span>*</span></label>
              <select name="block_id" class="form-control" id="block">
                <option value="">--Select Block--</option>
              </select>
              <?php echo form_error("block_id");?>
          </div>
          <div class="form-group">
            <label class="info-title" for="panchayat">Panchayat<span>*</span></label>
              <select name="panchayat_id" class="form-control" id="panchayat">
                <option value="">--Select Panchayat--</option>
              </select>
              <?php echo form_error("panchayat_id");?>
          </div>
          <div class="form-group">
            <label class="info-title" for="village">Village<span>*</span></label>
              <select name="village_id" class="form-control" id="village">
                <option value="">--Select Village--</option>
              </select>
              <?php echo form_error("village_id");?>
          </div>


          <div class="form-group">
              <label class="info-title" for="first_name">Name<span>*</span></label>
              <input type="text" class="form-control" name="first_name" id="first_name" value="<?php echo set_value("first_name");?>" placeholder="Name*"> 
              <?php echo form_error("first_name");?>
          </div>
          <div class="form-group">
              <label class="info-title" for="fathers_name">Father's Name<span>*</span></label>
              <input type="text" class="form-control" name="fathers_name" id="fathers_name" value="<?php echo set_value("fathers_name");?>" placeholder="Father's Name*"> 
              <?php echo form_error("fathers_name");?>
          </div>
          <div class="form-group">
              <label class="info-title" for="fathers_name">D.O.B.<span>*</span></label>
              <input class="form-control" name="birth_date" id="birth_date"  type="date" min="1930-01-01" max="<?php echo date('Y-m-d');?>" value="<?php echo set_value("birth_date");?>" placeholder="D.O.B.*"> 
              <?php echo form_error("birth_date");?>
          </div>
          <div class="form-group">
              <label class="info-title" for="alt_name">Alt Name<span></span></label>
              <input type="text" class="form-control" name="alt_name" id="alt_name" value="<?php echo set_value("alt_name");?>" placeholder="Alt Name"> 
              <?php echo form_error("alt_name");?>
          </div>
          <div class="form-group">
              <label class="info-title" for="alt_mobile">Alt Mobile Number<span></span></label>
              <input type="text" class="form-control" name="alt_mobile" id="alt_mobile" value="<?php echo set_value("alt_mobile");?>" placeholder="Alt Mobile Number"> 
              <?php echo form_error("alt_mobile");?>
          </div>
          <div class="form-group">
              <label class="info-title" for="relationship">Relationship<span></span></label>
              <input type="text" class="form-control" name="relationship" id="relationship" value="<?php echo set_value("relationship");?>" placeholder="Relationship"> 
              <?php echo form_error("relationship");?>
          </div>

          <div class="form-group">
            <label class="info-title" for="land_size_owned">Land Size (Owned)<span></span></label>
            <div class="col-md-3">                                     
              <input type="text" class="form-control lsowned" name="land_size_owned" id="land_size_owned" value="<?php echo set_value("land_size_owned",0);?>"> 
              <?php echo form_error("land_size_owned");?>
            </div>
            <div class="col-md-3">
            <?php $land_size_owned_unit=set_value("land_size_owned_unit"); ?>  
              <select name="land_size_owned_unit" id="land_size_owned_unit"  class="form-control land_size_unit_id">
                <?php foreach($landSizeUnitArray as $key=>$val){
                      if ($val == $land_size_owned_unit) {
                        $sel = "selected";
                      } else {
                        $sel = "";
                      }
                  ?>
                    <option value="<?php echo $val;?>" <?php echo $sel; ?>><?php echo $key;?></option>
                <?php } ?>
              </select>                                   
              <?php echo form_error("land_size_owned_unit");?>
            </div>
          </div>
          <div class="form-group">
            <label class="info-title" for="land_size_leased">Land Size (Leased)<span></span></label>
            <div class="col-md-3">                                     
              <input type="text" class="form-control lsowned" name="land_size_leased" id="land_size_leased" value="<?php echo set_value("land_size_leased",0);?>"> 
              <?php echo form_error("land_size_leased");?>
            </div>
            <div class="col-md-3">  
            <?php $land_size_leased_unit=set_value("land_size_owned_unit"); ?>  
              <select name="land_size_leased_unit" id="land_size_leased_unit"  class="form-control land_size_unit_id">
              <?php foreach($landSizeUnitArray as $key=>$val){
                      if ($val == $land_size_leased_unit) {
                        $sel = "selected";
                      } else {
                        $sel = "";
                      }
                  ?>
                    <option value="<?php echo $val;?>" <?php echo $sel; ?>><?php echo $key;?></option>
                <?php } ?>
              </select>                                   
              <?php echo form_error("land_size_leased_unit");?>
            </div>
          </div>
          <div class="form-group">
            <label class="info-title" for="total_land_size">Total Land<span></span></label>
            <div class="col-md-3">                                     
              <input type="text" class="form-control" name="total_land_size" id="total_land_size" readonly value="<?php echo set_value("total_land_size",0);?>"> 
              <?php echo form_error("total_land_size");?>
            </div>
            <div class="col-md-3"> 
              <?php $total_land_size_unit=set_value("total_land_size_unit"); ?>  
              <select name="total_land_size_unit" id="total_land_size_unit" class="form-control land_size_unit_id">
              <?php foreach($landSizeUnitArray as $key=>$val){
                      if ($val == $total_land_size_unit) {
                        $sel = "selected";
                      } else {
                        $sel = "";
                      }
                  ?>
                    <option value="<?php echo $val;?>" <?php echo $sel; ?>><?php echo $key;?></option>
                <?php } ?>
              </select>                                   
              <?php echo form_error("total_land_size_unit");?>
            </div>
          </div>
          <div class="form-group">
          <label class="info-title" for="current_annual_income">Current Annual Income<span></span></label>
              <input type="text" class="form-control" name="current_annual_income" id="current_annual_income" value="<?php echo set_value("current_annual_income");?>" placeholder="Current Annual Income"> 
              <?php echo form_error("current_annual_income");?>
          </div>

          <div class="form-group" style="background:#eee"  style="width:100%">
            <label class="col-md-3 control-label"><strong>Crops</strong></label>
          </div>
          <?php
            $sellingMonthsArray=$this->config->item('sellingMonthsArray');
          ?>
          <div class="form-group">
            <div  class="row" style="margin-bottom: 15px;">
              <div class="col-md-3">
                <select name="category_id[]" size="1" class="form-control">
                    <?php echo get_nested_dropdown_menu(0,$category_id_val); ?>
                </select>
              </div>
              <div class="col-md-3">
                <input type="text" class="form-control" name="qty_per_year[]" id="qty_per_year" value="<?php echo set_value("qty_per_year",$qty_per_year_val);?>" Placeholder="Qty. Per Year"> 
              </div>
              <div class="col-md-3">
                <input type="text" class="form-control" name="selling_price_msp[]" id="selling_price_msp" value="<?php echo set_value("selling_price_msp",$selling_price_msp_val);?>" Placeholder="Selling Price (MSP)"> 
              </div>
              <div class="col-md-2"> 
                  <?php $selling_month=set_value("selling_month",$selling_month_val); ?>  
                  <select name="selling_month[]" id="selling_month" class="form-control">
                  <?php foreach($sellingMonthsArray as $val){
                          if ($val == $selling_month) {
                            $sel = "selected";
                          } else {
                            $sel = "";
                          }
                      ?>
                        <option value="<?php echo $val;?>" <?php echo $sel; ?>><?php echo $val;?></option>
                    <?php } ?>
                  </select>                                   
              </div>
              <div class="col-md-1">
                <a href="javascript:void(0);" class="btn add-more">Add more</a>
              </div>
            <div>
          </div>
          <div class="clearfix"></div>
          <div class="main-class"></div>
          
          <div class="form-group"style="width:100%"> </div>
          <div class="form-group" style="background:#eee"  style="width:100%">
            <label class="col-md-3 control-label"><strong>KYC Docs</strong></label>
          </div>
          <div class="form-group">
            <label class="col-md-3 col-xs-12 info-title" for="aadhar_card">Aadhar Card<span></span></label>
            <div class="col-md-6 col-xs-12">
              <a class="file-input-wrapper btn btn-default  fileinput btn-primary"><span>Browse file</span><input type="file" class="fileinput btn-primary" name="aadhar_card" id="aadhar_card" title="Browse file" accept="image/*"></a>
            </div>
          </div>
          <div class="form-group">
            <label class="col-md-3 col-xs-12 info-title" for="pan_card">PAN Card<span></span></label>
            <div class="col-md-6 col-xs-12">
              <a class="file-input-wrapper btn btn-default  fileinput btn-primary"><span>Browse file</span><input type="file" class="fileinput btn-primary" name="pan_card" id="pan_card" title="Browse file" accept="image/*"></a>
            </div>
          </div>
          <div class="form-group">
            <label class="col-md-3 col-xs-12 info-title" for="cancelled_Cheque">Cancelled Cheque<span></span></label>
            <div class="col-md-6 col-xs-12">
              <a class="file-input-wrapper btn btn-default  fileinput btn-primary"><span>Browse file</span><input type="file" class="fileinput btn-primary" name="cancelled_Cheque" id="cancelled_Cheque" title="Browse file" accept="image/*"></a>
            </div>
          </div>
          <div class="form-group">
            <label class="col-md-3 col-xs-12 info-title" for="address_proof">Address Proof<span></span></label>
            <div class="col-md-6 col-xs-12">
              <a class="file-input-wrapper btn btn-default  fileinput btn-primary"><span>Browse file</span><input type="file" class="fileinput btn-primary" name="address_proof" id="address_proof" title="Browse file" accept="image/*"></a>
            </div>
          </div>
          <div class="form-group">
            <label class="info-title" for="major_issues">Major Issues/Problems/Challenges Faced by Farmer<span></span></label>
              <textarea class="form-control" name="major_issues" id="major_issues"><?php echo set_value("major_issues");?></textarea> 
              <?php echo form_error("major_issues");?>
          </div>

          <button class="btn-upper btn btn-primary checkout-page-button" type="submit"><i class="fa fa-user"></i> Create an account</button>
          <input type="hidden" name="action" value="register" />
          <?php echo form_close(); ?>
        </div>
        <!-- create a new account -->
      </div>
      <!-- /.row -->
    </div>
  </div>
  <!-- /.container -->
</div>
<!-- /.body-content -->
<?php $this->load->view("bottom_application"); ?>
<script>
  $(document).ready(function () {
    <?php
    if ($this->input->get_post('category_id')) {
      for ($i=1;$i<count($this->input->get_post('category_id'));$i++) {
        $category_id_val = $category_ids[$i];
        $qty_per_year_val = $qty_per_years[$i];
        $selling_price_msp_val = $selling_price_msps[$i];
        $selling_month_val = $selling_months[$i];
        ?>
            $(".main-class").append('<div class="row" style="margin-bottom: 15px;"><div class="col-md-3"><select name="category_id[]" size="1" class="form-control"><?php echo get_nested_dropdown_menu(0,$category_id_val);?></select></div><div class="col-md-3"><input type="text" class="form-control" name="qty_per_year[]" id="qty_per_year" value="<?php echo set_value("qty_per_year",$qty_per_year_val);?>" Placeholder="Qty. Per Year"></div><div class="col-md-3"><input type="text" class="form-control" name="selling_price_msp[]" id="selling_price_msp" value="<?php echo set_value("selling_price_msp",$selling_price_msp_val);?>" Placeholder="Selling Price (MSP)"></div><div class="col-md-2"><?php $selling_month=set_value("selling_month",$selling_month_val); ?><select name="selling_month[]" id="selling_month" class="form-control"><?php foreach($sellingMonthsArray as $val){if ($val == $selling_month){ $sel = "selected";} else {$sel = "";}?><option value="<?php echo $val;?>" <?php echo $sel; ?>><?php echo $val;?></option><?php } ?></select></div><div class="col-md-1"><a href="javascript:void(0);" class="btn removes">Remove</a></div><div><div>');

        <?php
      }
    }
    ?>

    $(".add-more").click(function(){
      $(".main-class").append('<div class="row" style="margin-bottom: 15px;"><div class="col-md-3"><select name="category_id[]" size="1" class="form-control"><?php echo get_nested_dropdown_menu(0); ?></select></div><div class="col-md-3"><input type="text" class="form-control" name="qty_per_year[]" id="qty_per_year" value="<?php echo set_value("qty_per_year");?>" Placeholder="Qty. Per Year"></div><div class="col-md-3"><input type="text" class="form-control" name="selling_price_msp[]" id="selling_price_msp" value="<?php echo set_value("selling_price_msp");?>" Placeholder="Selling Price (MSP)"></div><div class="col-md-2"><?php $selling_month=set_value("selling_month"); ?><select name="selling_month[]" id="selling_month" class="form-control"><?php foreach($sellingMonthsArray as $val){if ($val == $selling_month){ $sel = "selected";} else {$sel = "";}?><option value="<?php echo $val;?>" <?php echo $sel; ?>><?php echo $val;?></option><?php } ?></select></div><div class="col-md-1"><a href="javascript:void(0);" class="btn removes">Remove</a></div><div><div>');
    });

    $(".main-class").on('click','.removes',function(){
      $(this).parent().parent('div').remove();
    });

    $(".lsowned").keyup(function(){
      //
      //NaN
      var a=parseFloat($("#land_size_owned").val());
      var b=parseFloat($("#land_size_leased").val());
          a=(isNaN(a))?0:a;
          b=(isNaN(b))?0:b;
        $("#total_land_size").val((a+b));
    });
    
    $(".land_size_unit_id").on("change",function(){
        val=$(this).val();
        $('#land_size_owned_unit').val(val);
        $('#land_size_leased_unit').val(val);
        $('#total_land_size_unit').val(val);
    });
    
    $("#country").change(function () {
      states();
    });
    $("#state").change(function () {
      cities();
    });
    $("#city").change(function () {
      blocks();
    });
    $("#block").change(function () {
      panchayats();
    });
    $("#panchayat").change(function () {
      villages();
    });

  });
  <?php if($this->input->post()){ ?>
    states('<?php echo $this->input->post('state_id');?>','<?php echo $this->input->post('country_id');?>');
    cities('<?php echo $this->input->post('city_id');?>','<?php echo $this->input->post('state_id');?>','<?php echo $this->input->post('country_id');?>');
    blocks('<?php echo $this->input->post('block_id');?>','<?php echo $this->input->post('city_id');?>','<?php echo $this->input->post('state_id');?>','<?php echo $this->input->post('country_id');?>');
    panchayats('<?php echo $this->input->post('panchayat_id');?>','<?php echo $this->input->post('block_id');?>','<?php echo $this->input->post('city_id');?>','<?php echo $this->input->post('state_id');?>','<?php echo $this->input->post('country_id');?>');
    villages('<?php echo $this->input->post('village_id');?>','<?php echo $this->input->post('panchayat_id');?>','<?php echo $this->input->post('block_id');?>','<?php echo $this->input->post('city_id');?>','<?php echo $this->input->post('state_id');?>','<?php echo $this->input->post('country_id');?>');
  <?php }else{ ?>
    states('',105);
  <?php } ?>


  function states(sel,country_id){ 
    if(country_id){
      var country =country_id;
    }else{
      var country = $("#country").val();
    };
    if(country){
        $("#state").html('<option value="">--Select State--</option>');
        $("#city").html('<option value="">--Select District--</option>');
        $("#block").html('<option value="">--Select Block--</option>');
        $("#panchayat").html('<option value="">--Select Panchayat--</option>');
        $("#village").html('<option value="">--Select Village--</option>');
        $.ajax({
          url: '<?php echo base_url('sitepanel/location/ajax_state'); ?>',
          type: 'post',
          data: ({'country_id': country,'sel': sel}),
          success: function (data) {
            $("#state").html(data);
          }
        });
    }else{
      $("#state").html('<option value="">--Select State--</option>');
      $("#city").html('<option value="">--Select District--</option>');
      $("#block").html('<option value="">--Select Block--</option>');
      $("#panchayat").html('<option value="">--Select Panchayat--</option>');
      $("#village").html('<option value="">--Select Village--</option>');
    }
  }


  function cities(sel,state_id,country_id){ 
    if(country_id){
        var country_id =country_id;
      }else{
        var country_id = $("#country").val();
      };
      if(state_id){
        var state_id =state_id;
        }else{
          var state_id = $("#state").val();
        };
      $("#block").html('<option value="">--Select Block--</option>');
      $("#panchayat").html('<option value="">--Select Panchayat--</option>');
      $("#village").html('<option value="">--Select Village--</option>');
      $.ajax({
        url: '<?php echo base_url('sitepanel/location/ajax_city'); ?>',
        type: 'post',
        data: ({'country_id': country_id,'state_id': state_id,'sel': sel}),
        success: function (data) {
          $("#city").html(data);
        }
      });
  }

  function blocks(sel,city_id,state_id,country_id){ 
    if(country_id){
        var country_id =country_id;
      }else{
        var country_id = $("#country").val();
      };
    if(city_id){
        var city_id =city_id;
        }else{
          var city_id = $("#city").val();
        };
      if(state_id){
        var state_id =state_id;
        }else{
          var state_id = $("#state").val();
        };
      $("#panchayat").html('<option value="">--Select Panchayat--</option>');
      $("#village").html('<option value="">--Select Village--</option>');
      $.ajax({
        url: '<?php echo base_url('sitepanel/location/ajax_block'); ?>',
        type: 'post',
        data: ({'country_id': country_id,'state_id': state_id,'city_id': city_id,'sel': sel}),
        success: function (data) {
          $("#block").html(data);
        }
      });
  }
  
  function panchayats(sel,block_id,city_id,state_id,country_id){ 
    if(country_id){
        var country_id =country_id;
      }else{
        var country_id = $("#country").val();
      };
    if(block_id){
        var block_id =block_id;
        }else{
          var block_id = $("#block").val();
        };
    if(city_id){
        var city_id =city_id;
        }else{
          var city_id = $("#city").val();
        };
      if(state_id){
        var state_id =state_id;
        }else{
          var state_id = $("#state").val();
        };
        $("#village").html('<option value="">--Select Village--</option>');
      $.ajax({
        url: '<?php echo base_url('sitepanel/location/ajax_panchayat'); ?>',
        type: 'post',
        data: ({'country_id': country_id,'state_id': state_id,'city_id': city_id,'block_id': block_id,'sel': sel}),
        success: function (data) {
          $("#panchayat").html(data);
        }
      });
  }

  function villages(sel,panchayat_id,block_id,city_id,state_id,country_id){ 
    if(country_id){
        var country_id =country_id;
      }else{
        var country_id = $("#country").val();
      };
      if(state_id){
        var state_id =state_id;
        }else{
          var state_id = $("#state").val();
        };
        if(city_id){
        var city_id =city_id;
        }else{
          var city_id = $("#city").val();
        };
      if(block_id){
        var block_id =block_id;
      }else{
        var block_id = $("#block").val();
      };
      if(panchayat_id){
        var panchayat_id =panchayat_id;
      }else{
        var panchayat_id = $("#panchayat").val();
      };

        $("#village").html('<option value="">--Select Village--</option>');
      $.ajax({
        url: '<?php echo base_url('sitepanel/location/ajax_village'); ?>',
        type: 'post',
        data: ({'country_id': country_id,'state_id': state_id,'city_id': city_id,'block_id': block_id,'panchayat_id': panchayat_id,'sel': sel}),
        success: function (data) {
          $("#village").html(data);
        }
      });
  }

</script>