<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">Main Categories</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 Main Categories</div>



                    <div class="card-body">



        <?php if($this->uri->segment(3)){?>



      <form  action="<?php echo base_url();?>admin/add_mcategory/<?php echo $this->uri->segment(3);?>" method="post" enctype="multipart/form-data">



       



          <div class="form-group ">



            <label for="email">Main Category Title</label>



            <input type="text" required class="form-control" name="cat" value="<?php echo $editcat->mcat_name;?>">



          </div>
                                    <input type="hidden" class="form-control" name="shipping_amt">

          <div class="form-group ">



            <label for="email">Main Category Slug/URL</label>



            <input type="text" required class="form-control" name="cat_slug" value="<?php echo $editcat->cat_slug;?>">



          </div>
          
          



          <div class="form-group ">



            <label for="email">Meta Title</label>



            <input type="text"  class="form-control" name="metatitle" value="<?php echo $editcat->mtitle;?>">



          </div>



          <div class="form-group ">



            <label for="email">Meta Keywords</label>



            <input type="text"  class="form-control" name="metakey" value="<?php echo $editcat->mkey;?>">



          </div>



          <div class="form-group ">



            <label for="email">Meta Description</label>



            <textarea class="form-control" rows="3" name="metadesc"><?php echo $editcat->mdesc;?></textarea>



          </div><div class="form-group ">



            <label for="email">Main Category Image</label>



          	<input type="hidden" value="<?php echo $editcat->mcat_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->mcat_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_mcategory" method="post" enctype="multipart/form-data">



         



          <div class="form-group ">



            <label for="email">Main Category Title</label>



            <input type="text" required class="form-control" name="cat">



          </div>
         
                                    <input type="hidden" class="form-control" name="shipping_amt"  value="<?php echo $editcat->shipping_amt;?>">

		
          <div class="form-group ">



            <label for="email">Main Category Slug/URL</label>



            <input type="text" required class="form-control" name="cat_slug">



          </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">Main Cateogory Image</label>



          <input type="file" name="img" class="btn btn-default"/></div><br/>



          <button type="submit" class="btn btn-success" name="submit">Add Main Category</button>



        </form>



        <?php }?>



                    </div>



                    



               </div>                  



            </div>



            <div class="col-lg-8">



               <div class="card">



                    <div class="card-header">Listed Main Categories</div>



                    <div class="card-body">



                          <form action="<?php echo base_url();?>admin/msort" method="post">



                     <table class="table table-condensed table-bordered" id="default-datatable">



        	<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" class="form-control" value="<?php echo $cat->msort;?>" name="<?php echo $cat->mid;?>" /></td>



                <td width="100px"><img width="100px" src="<?php echo base_url();?>assets/images/category/<?php echo $cat->mcat_image;?>" class="img img-responsive"></td>



                <td><?php echo $cat->mcat_name;?></td>



                <td>



                <?php if($cat->mcat_status==""){$st="Disable";}else{$st="Enable";}?>



                <a href="<?php echo $cat->mid;?>" class="btn btn-sm btn-default enable"><?php echo $st;?></a>



                <a href="<?php echo base_url();?>admin/mcategory/<?php echo $cat->mid;?>" class="btn btn-sm btn-warning"><i class="fa fa-edit"></i></a>



                	<a href="<?php echo $cat->mid;?>" id="<?php echo $cat->mcat_image;?>" class="btn btn-sm btn-danger catdelete"><i class="fa fa-trash-o"></i></a></td>



                <?php $i++;}?></tr>



                <tr><td><button type="submit" class="btn btn btn-default">Sort</button></td><td></td><td></td><td></td></tr>



            </tbody>



        </table></form>



                    </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 © 2022</div>



      </div>



    </footer>



	<!--End footer-->



   



  </div><!--End wrapper-->







  <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();



		$(".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/mcatenable',



							 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/mcatdelete',



							 data: {id:id},



							 success: function(response){



								 //alert(response);



							 }



							 });



		});



	});



</script>



<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>



</body>



</html>



