<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.1.3/Chart.min.js"></script>	
<div class="vd_content-wrapper">
      <div class="vd_container">
        <div class="vd_content clearfix">
          <div class="vd_head-section clearfix">
            <div class="vd_panel-header">
              <ul class="breadcrumb">
                <li><a href="<?php echo base_url();?>admin">Home</a> </li>
                <li class="active">Category</li>
              </ul>
              
 
            </div>
          </div>
          <!-- vd_head-section -->
          
          <div class="vd_title-section clearfix">
            <div class="vd_panel-header">
              <h1>Manage Category</h1>
              <small class="subtitle">Add, Edit Delete Category</small>
              
<!-- vd_panel-menu --> 
            </div>
            <!-- vd_panel-header --> 
          </div>
          <!-- vd_title-section -->
          
          <div class="vd_content-section clearfix">
            
         <div class="row">
                	
                    
                    <!-- User Activity -->
                    <div class="col-md-5"><?php if($this->session->flashdata("msg")!==""){echo $this->session->flashdata("msg"); }?>
                        <div class="panel panel-success">
							
      <div class="panel-heading">Add/Edit Category</div>
      <div class="panel-body">
      
      <?php if($this->uri->segment(3)){?>
      	<form  action="<?php echo base_url();?>admin/add_category/<?php echo $this->uri->segment(3);?>" method="post" enctype="multipart/form-data">
       
          <div class="form-group ">
            <label for="email">Category Title</label>
            <input type="text" required class="form-control" name="cat" value="<?php echo $editcat->cat_name;?>">
          </div>
          <div class="form-group ">
            <label for="email">Meta Title</label>
            <input type="text"  class="form-control" name="metatitle" value="<?php echo $editcat->metatitle;?>">
          </div>
          <div class="form-group ">
            <label for="email">Meta Keywords</label>
            <input type="text"  class="form-control" name="metakey" value="<?php echo $editcat->metakey;?>">
          </div>
          <div class="form-group ">
            <label for="email">Meta Description</label>
            <textarea class="form-control" rows="3" name="metadesc"><?php echo $editcat->metadesc;?></textarea>
          </div><div class="form-group ">
            <label for="email">Category Image</label>
          	<input type="hidden" value="<?php echo $editcat->cat_image;?>" name="oldimg">
            <input type="file"  class="btn btn-primary" name="img"/>
            <img width="30%" src="<?php echo base_url();?>assets/images/category/<?php echo $editcat->cat_image;?>" class="img img-responsive">
          </div><br/>
          <button type="submit" class="btn btn-success" name="submit">Update</button>
        </form>
      <?php }else{?>
      	<form  action="<?php echo base_url();?>admin/add_category" method="post" enctype="multipart/form-data">
         
          <div class="form-group ">
            <label for="email">Category Title</label>
            <input type="text" required class="form-control" name="cat">
          </div>
         
          <div class="form-group ">
            <label for="email">Meta Title</label>
            <input type="text"  class="form-control" name="metatitle">
          </div>
          <div class="form-group ">
            <label for="email">Meta Keywords</label>
            <input type="text"  class="form-control" name="metakey">
          </div>
          <div class="form-group ">
            <label for="email">Meta Description</label>
            <textarea class="form-control" rows="3" name="metadesc"></textarea>
          </div><div class="form-group ">
            <label for="email">Cateogory Image</label>
          <input type="file" name="img" class="btn btn-default"/></div><br/>
          <button type="submit" class="btn btn-success" name="submit">Add Category</button>
        </form>
        <?php }?>
      </div>
    </div>
                    </div>
                    
                    <div class="col-md-7">
                     <div class="panel panel-success">
							
      <div class="panel-heading">Listing All Category</div>
      <div class="panel-body">
      <form action="<?php echo base_url();?>admin/csort" method="post">
                    <table class="table table-striped table-responsive">
        	<thead><tr><th>Sort.</th><th>Image</th><th>Title</th><th>Action</th></tr></thead>
            <tbody>
            	<?php $i=1;foreach($cats as $cat){?>
                <tr><td width="80px"><input type="number" value="<?php echo $cat->csort;?>" name="<?php echo $cat->cid;?>" /></td>
                <td width="100px"><img src="<?php echo base_url();?>assets/images/category/<?php echo $cat->cat_image;?>" class="img img-responsive"></td>
                <td><?php echo $cat->cat_name;?></td>
                <td>
                <?php if($cat->cat_status==""){$st="Disable";}else{$st="Enable";}?>
                <a href="<?php echo $cat->cid;?>" class="btn btn-xs btn-default enable"><?php echo $st;?></a>
                <a href="<?php echo base_url();?>admin/category/<?php echo $cat->cid;?>" class="btn btn-xs btn-warning"><i class="fa fa-edit"></i></a>
                	<a href="<?php echo $cat->cid;?>" id="<?php echo $cat->cat_image;?>" class="btn btn-xs btn-danger catdelete"><i class="fa fa-trash-o"></i></a></td>
                <?php $i++;}?></tr>
                <tr><td><button type="submit" class="btn btn-default">Sort</button></td><td></td><td></td><td></td></tr>
            </tbody>
        </table></form>
        </div></div>
                    </div>
                    
                    
                    <!-- End Chat Room -->
                </div>
                <script>
	$(document).ready(function(){
		$(".enable").click(function(e){e.preventDefault();
			var st=$(this).text();
			var id=$(this).attr("href");
			if(st=="Enable"){
			$(this).text("Disable");
			}else{
			$(this).text("Enable");	
			}
			$.ajax({
							 type: "POST",
							 url: '<?php echo base_url();?>admin/catenable',
							 data: {id:id,st:st},
							 success: function(response){
								 //alert(response);
							 }
							 });
		});
		$(".catdelete").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/catdelete',
							 data: {id:id},
							 success: function(response){
								 //alert(response);
							 }
							 });
		});
	});
</script>
          </div>
          <!-- .vd_content-section --> 
          
        </div>
        <!-- .vd_content --> 
      </div>
      <!-- .vd_container --> 
    </div>
    <!-- .vd_content-wrapper --> 
    
    <!-- Middle Content End --> 
    
  </div>
  <!-- .container --> 
</div>
<!-- .content -->

<!-- Footer Start -->
  <footer class="footer-1"  id="footer">      
    <div class="vd_bottom ">
        <div class="container">
            <div class="row">
              <div class=" col-xs-12">
                <div class="copyright">
                  	Copyright &copy;2018 HadesIndia. All Rights Reserved 
                </div>
              </div>
            </div><!-- row -->
        </div><!-- container -->
    </div>
  </footer>
<!-- Footer END -->
  

</div>

<!-- .vd_body END  -->
<a id="back-top" href="#" data-action="backtop" class="vd_back-top visible"> <i class="fa  fa-angle-up"> </i> </a>

<!--
<a class="back-top" href="#" id="back-top"> <i class="icon-chevron-up icon-white"> </i> </a> -->

<!-- Javascript =============================================== --> 
<!-- Placed at the end of the document so the pages load faster --> 

<script type="text/javascript" src='<?php echo base_url();?>adminassets/plugins/jquery-ui/jquery-ui.custom.min.js'></script>
<script type="text/javascript" src="<?php echo base_url();?>adminassets/plugins/jquery-ui-touch-punch/jquery.ui.touch-punch.min.js"></script>

<script type="text/javascript" src="<?php echo base_url();?>adminassets/js/caroufredsel.js"></script> 
<script type="text/javascript" src="<?php echo base_url();?>adminassets/js/plugins.js"></script>

<script type="text/javascript" src="<?php echo base_url();?>adminassets/plugins/breakpoints/breakpoints.js"></script>
<script type="text/javascript" src="<?php echo base_url();?>adminassets/plugins/dataTables/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="<?php echo base_url();?>adminassets/plugins/prettyPhoto-plugin/js/jquery.prettyPhoto.js"></script> 

<script type="text/javascript" src="<?php echo base_url();?>adminassets/plugins/mCustomScrollbar/jquery.mCustomScrollbar.concat.min.js"></script>
<script type="text/javascript" src="<?php echo base_url();?>adminassets/plugins/tagsInput/jquery.tagsinput.min.js"></script>
<script type="text/javascript" src="<?php echo base_url();?>adminassets/plugins/bootstrap-switch/bootstrap-switch.min.js"></script>
<script type="text/javascript" src="<?php echo base_url();?>adminassets/plugins/blockUI/jquery.blockUI.js"></script>
<script type="text/javascript" src="<?php echo base_url();?>adminassets/plugins/pnotify/js/jquery.pnotify.min.js"></script>

<script type="text/javascript" src="<?php echo base_url();?>adminassets/js/theme.js"></script>
<script type="text/javascript" src="<?php echo base_url();?>adminassets/custom/custom.js"></script>


</body>
</html>