<?php $this->load->view('includes/header'); ?>
<div class="page-title">                    
  <h2><span ></span><?php echo $heading_title; ?></h2>
  <a href="<?php echo base_url("sitepanel/location/village_add"); ?>" class="btn btn-primary pull-right">Add New Village</a> 
</div>
<div class="page-content-wrap">                
  <div class="row">
    <div class="col-md-12">
      <?php if ($this->session->flashdata('success')) { ?>
        <div class="alert alert-info">
          <?php echo $this->session->flashdata('success'); ?>
        </div>
      <?php } ?>
      <!-- START DEFAULT DATATABLE -->
      <div class="panel panel-default">
        <div class="panel-body">
          <div class="table-responsive">
            <?php
            if (is_array($res) && !empty($res)) {
              echo form_open("sitepanel/location/village", 'id="data_form"', '"class=form-horizontal"');
              ?>

              <table class="table datatable" id="my_data">
                <thead>
                  <tr>
                    <th width="20" style="text-align: center;">
                      <input type="checkbox" onclick="$('input:checkbox').not(this).prop('checked', this.checked);" />
                    </th>
                    <th>Village</th>
                    <th>Panchayat</th>
                    <th>Block</th>
                    <th>District</th>
                    <th>State</th>
                    <th>Country </th>											
                    <th>Status</th>
                    <th>Action</th>
                  </tr>
                </thead>
                <tbody>
                  <?php
                  foreach ($res as $catKey => $pageVal) {
                    ?>
                    <tr>
                      <td style="text-align: center;">
                        <input type="checkbox" name="arr_ids[]" value="<?php echo $pageVal['id']; ?>" />
                      </td>
                      <td>
                        <?php
                        echo $pageVal['name'];
                        //echo '<br><br>';
                        //echo ($pageVal['is_featured'] == '1') ? 'Featured : <b>Yes</b>' : '';
                        ?>
                      </td>
                      <td>
                        <?php echo get_db_field_value("wps_panchayats_list", "name", array("id" => $pageVal['panchayat_id'])); ?>								
                      </td>
                      <td>
                        <?php echo get_db_field_value("wps_blocks_list", "name", array("id" => $pageVal['block_id'])); ?>								
                      </td>
                      <td>
                        <?php echo get_db_field_value("wps_cities_list", "city", array("id" => $pageVal['city_id'])); ?>								
                      </td>
                      <td>
                        <?php echo get_db_field_value("wps_states_list", "name", array("id" => $pageVal['state_id'])); ?>								
                      </td>
                      <td>
                        <?php echo get_db_field_value("wps_countries_list", "name", array("id" => $pageVal['country_id'])); ?>								
                      </td>							
                      <td><?php echo ($pageVal['status'] == 1) ? "Active" : "In-active"; ?></td>
                      <td >
                        <?php echo anchor("sitepanel/location/village_edit/$pageVal[id]/" . query_string(), '<span>Edit</span>', 'class="btn btn-info"'); ?>
                      </td>
                    </tr>
                    <?php
                  }
                  ?>

                </tbody>
              </table>
              <table class="list" width="100%"> 
                <tr>
                  <td align="left" style="padding:5px">
                    <input name="status_action" type="submit"  value="Activate" class="button2" id="Activate" onClick="return validcheckstatus('arr_ids[]', 'Activate', 'Record', 'u_status_arr[]');"/>
                    <input name="status_action" type="submit" class="button2" value="Deactivate" id="Deactivate"  onClick="return validcheckstatus('arr_ids[]', 'Deactivate', 'Record', 'u_status_arr[]');"/>
                    <input name="status_action" type="submit" class="button2" id="Delete" value="Delete"  onClick="return validcheckstatus('arr_ids[]', 'delete', 'Record');"/> 
                    <?php //echo form_dropdown("set_as", $this->config->item('city_set_as_config'), $this->input->post('set_as'), 'style="width:120px;" onchange="return onclickgroup()"'); ?>

                    <?php //echo form_dropdown("unset_as", $this->config->item('city_unset_as_config'), $this->input->post('unset_as'), 'style="width:120px;" onchange="return onclickgroup()"'); ?>
                  </td>
                </tr>
              </table>
              <?php
              echo form_close();
            } else {
              echo "<center><strong> No Record(s) Found !</strong></center>";
            }
            ?>

          </div>
        </div>
      </div>
    </div>
  </div>
</div>
<?php $this->load->view('includes/footer'); ?>
<script type="text/javascript">
  function onclickgroup() {
    if (validcheckstatus('arr_ids[]', 'set', 'record', 'u_status_arr[]')) {
      $('#data_form').submit();
    }
  }
</script>