<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">Manage Brands</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 Brands</div>
                    <div class="card-body">
                          <?php if($this->uri->segment(3)){?>
                          <form action="<?php echo base_url();?>admin/update_dept" method="post"  enctype="multipart/form-data">
                          <input type="hidden" name="depid" value="<?php echo $edit->brid;?>" />
                          <div class="form-group">
                            <label for="new">Brand Title</label>
                            <input type="text" class="form-control" name="machine" value="<?php echo $edit->brname;?>" />
                          </div> 
                          <input type="hidden" class="form-control"   name="oldbrand_logo">
                          <div class="form-group ">
                            <label>Brand Logo</label> 
                            <input type="file" required class="form-control" value="<?php echo $edit->brand_logo;?>"  name="brand_logo">
                          </div>
                          <img class="img img-responsive" width="100%" src="<?php echo base_url().'assets/images/'.$edit->brand_logo;?>" />
                          <button type="submit" name="submit" class="btn btn-primary">Update Brand</button>
                          </form>
                          <?php }else{?>
                          <form action="<?php echo base_url();?>admin/add_dept" method="post" enctype="multipart/form-data">
                          <div class="form-group">
                            <label for="new">Brand Title</label>
                            <input type="text" class="form-control" name="machine" />
                          </div> 
                          <div class="form-group "> 
                            <label>Brand Logo</label> 
                            <input type="file" class="form-control"   name="brand_logo">
                          </div>
                          <button type="submit" name="submit" class="btn btn-primary">Add Brand</button>
                          </form>
                          <?php }?>
                          
                    </div>
                    
               </div>                  
            </div>
            <div class="col-lg-6">
               <div class="card">
                    <div class="card-header">Listed Brands</div>
                    <div class="card-body">
                          <table class="table table-condensed table-bordered">
                                <thead><tr><th>S.No.</th><th>Logo</th><th>Brand Name.</th><th>Total Products</th><th>Action</th></tr></thead>
                                <tbody>
                                    <?php $i=1;foreach($deps as $dep){?>
                                    <tr><td ><?php echo $i;?></td>
                                    <td width="100px"><img class="img img-responsive" width="100%" src="<?php echo base_url().'assets/images/'.$dep->brand_logo;?>" /></td>
                                    <td><?php echo $dep->brname?></td>
                                    <td><?php echo $this->db->get_where("products",array("brand"=>$dep->brid))->num_rows();?></td>
                                    <td>
                            <a href="<?php echo base_url().'admin/brands/'.$dep->brid;?>" class="btn btn-sm btn-warning"><i class="fa fa-edit"></i></a>
                            <a href="<?php echo $dep->brid;?>" class="btn btn-sm btn-danger brand_delete"><i class="fa fa-trash-o"></i></a></td>
                                    <?php $i++;}?></tr>
                                </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>
	$(document).ready(function(){
		$(".brand_delete").click(function(e){e.preventDefault();
		if (!confirm("Sure you want to delete?")){
				  return false;
				}
			var id=$(this).attr("href");$(this).closest("tr").remove();
			$.ajax({
							 type: "POST",
							 url: '<?php echo base_url();?>admin/brand_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 -->
  <script src="<?php echo base_url();?>adminassets/js/index.js"></script>

    
	
</body>
</html>
