<div class="clearfix"></div>
	
  <div class="content-wrapper">
    <div class="container-fluid">
      <!-- Breadcrumb-->
     <div class="row pt-2 pb-2">
        <div class="col-sm-9">
		    <h4 class="page-title">Listed <b><?php echo $city->city_name;?></b> Areas</h4>
	   </div>
     
     </div>
    <!-- End Breadcrumb-->
      <div class="row">
			<div class="col-lg-4">
			   <?php if($this->session->flashdata("msg")){echo $this->session->flashdata("msg"); }?>
               <div class="card">
                    	  <div class="card-header">Add/Edit Areas</div>
                    <div class="card-body">
                        <?php if($this->uri->segment(4)){?>
                        <form action="<?php echo base_url();?>admin/update_area" method="post" enctype="multipart/form-data">
                        	  <input type="hidden" name="area_id" value="<?php echo $edit->area_id;?>" />
                              <input type="hidden" name="city_id" value="<?php echo $edit->city_id;?>" />
                              <div class="form-group "> <label for="email">Area Name</label>
                                <input type="text" required class="form-control" value="<?php echo $edit->area_name;?>" name="area_name">
                              </div>
                              <div class="form-group ">
                                <label for="email">Area Pin Code</label>
                                <input type="text"  class="form-control" value="<?php echo $edit->area_pincode;?>" name="area_pincode" required>
                              </div>
                              <button type="submit" class="btn btn-success">Update Area</button>
                            </form>
                        <?php }else{?>
                        <form action="<?php echo base_url();?>admin/add_area" method="post" enctype="multipart/form-data">
                        	  <input type="hidden" name="city_id" value="<?php echo $city->city_id;?>" />
                        	  <div class="form-group"> <label for="email">Area Name</label>
                                <input type="text" required class="form-control" name="area_name">
                              </div>
                              <div class="form-group ">
                                <label for="email">Area PinCode</label>
                                <input type="text"  class="form-control" name="area_pincode" required>
                              </div>
                              <button type="submit" class="btn btn-success">Add Area</button>
                            </form>
                        <?php }?>
                    </div>
                    
               </div>                  
            </div>
            <div class="col-lg-8">
               <div class="card">
                    <div class="card-header">Listed City Areas</div>
                    <div class="card-body">
                           <table class="table table-condensed table-bordered" id="default-datatable">
                        <thead><tr><th>S.No.</th><th>Area/Pincode</th><th>Action</th></tr></thead>
                         <tbody>
                                <?php $i=1;foreach($city_areas as $s){?>
                                <tr><td><?php echo $i;?></td>
                                    <td><?php echo $s->area_name.' '.$s->area_pincode;?><br/>
                                    <label class="badge badge-dark">ID - <?php echo $s->area_id;?></label></td>
                                    <td>
                                    <a href="<?php echo base_url().'admin/areas/'.$s->city_id.'/'.$s->area_id;?>" class="btn btn-sm btn-warning"><i class="fa fa-edit"></i></a>
        <a href="#" id="<?php echo $s->area_id;?>" class="btn btn-sm btn-danger area_delete"><i class="fa fa-trash-o"></i></a></td></tr><?php $i++;}?>
                            </tbody>
                    </table>
                    </div>
                    
               </div>                  
            </div>
            
        </div><!--End Row-->
	  
	  <!--End Row-->

    </div>
    <!-- End container-fluid-->
    
    </div><!--End content-wrapper-->
   <!--Start Back To Top Button-->
    <a href="javaScript:void();" class="back-to-top"><i class="fa fa-angle-double-up"></i> </a>
    <!--End Back To Top Button-->
	
	<!--Start footer-->
	<footer class="footer">
      <div class="container">
        <div class="text-center">
          Copyright © 2020 Grocery Store
        </div>
      </div>
    </footer>
	<!--End footer-->
   
  </div><!--End wrapper-->


  <!-- Bootstrap core JavaScript-->
   <script src="<?php echo base_url();?>adminassets/plugins/bootstrap-datatable/js/jquery.dataTables.min.js"></script>
  <script src="<?php echo base_url();?>adminassets/plugins/bootstrap-datatable/js/dataTables.bootstrap4.min.js"></script>
	<script>
	$(document).ready(function(){
		$('#default-datatable').DataTable();
		$(".area_delete").click(function(e){e.preventDefault();
				if(!confirm("Sure you want to delete?")){
					  return false;
				}
				var id=$(this).attr("id");$(this).closest("tr").remove();
				$.ajax({
					 type: "POST",
					 url: '<?php echo base_url();?>admin/ajax_area_delete',
					 data: {id:id},
					 success: function(response){
						 //alert(response);
					 }
				});
			});
	});
</script>
	<!-- simplebar js -->
  <script src="<?php echo base_url();?>adminassets/js/sidebar-menu.js"></script>
  <!-- Custom scripts -->
  <script src="<?php echo base_url();?>adminassets/js/app-script.js"></script>
  
  <!-- Vector map JavaScript -->
  <!-- Index js -->

    
	
</body>
</html>
