<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">List Products</h4>

	   </div>

     

     </div>

    <!-- End Breadcrumb-->

      <div class="row">

			

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

               <div class="card">

                    <div class="card-header">Listed Products</div>

                    <div class="card-body">

                      <form class="form-inline" action="/action_page.php" style="display:none;">

                      <div class="form-group">

                        <select class="cat form-control" name="mcat" id="mcat" required>

                            <option value="">MainCategory</option>

                            <?php $mcat=$this->db->get("mcategory")->result();

                                foreach($mcat as $cat){?>

                            <option value="<?php echo $cat->mid;?>"><?php echo $cat->mcat_name;?></option>

                            <?php }?>

                        </select>

                      </div>

                      <div class="form-group">

                        <select class="cat form-control" name="cat" id="cat" required>

                            <option value="">Category</option>

                        </select>

                      </div>

                      <div class="form-group">

                      	<select class="subcat form-control" name="subcat" id="subcat" required>

                            <option value="">Subcategory</option>

                        </select>

                      </div>

                      <div class="form-group">

                      	<select class=" form-control" name="brand" id="brand">

                            <option value="">Select Brand</option>

                            <?php $this->db->order_by("brname","asc");

							$vn=$this->db->get("brands")->result();

                                    foreach($vn as $v){?>

                            <option value="<?php echo $v->brid;?>"><?php echo $v->brname;?></option>

                            <?php }?>

                        </select>

                      </div>

                      <div class="form-group">

                      	<input type="text" placeholder="Product Title" id="ptitle" name="product_name" style="width:100%;" class="form-control" />

                      </div>

                      <button type="button" id="filter" class="btn btn-success">Filter</button>

                    </form>  <br/>

                      <table class="table table-condensed table-bordered">

                        <thead>

                                                            <tr>

                                                                <th>S.No.</th>

                                                                <th>Photo</th>

                                                                <th>Title</th>

                                                                <th>Category</th>

                                                                <th>Variant/MRP/Book Amt</th>

                                                                <th>Action</th>

                                                            </tr>

                                                        </thead>

                        <tbody id="list_products">

                            

                        </tbody>

                      </table>

                      <ul class="pagination">

                                

                      </ul>

                      <div id="myModal" class="modal fade" role="dialog">

                          <div class="modal-dialog modal-lg">

                            <!-- Modal content-->

                            <div class="modal-content">

                              <div class="modal-header">

                                <h4 class="modal-title">Add/Edit Variants</h4>

                                <button type="button" class="close" data-dismiss="modal">&times;</button>

                              </div>

                              <div class="modal-body variant_div">

                                	

                              </div>

                            </div>

                        

                          </div>

                        </div>

                    </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(){ 

		$("#mcat").change(function(){



				var cid=$(this).val();



				$.ajax({



				 type: "POST",



				 url: '<?php echo base_url();?>admin/ajax_mcat',



				 data: {cid:cid},



				 success: function(res){



				//alert(res);



				$("#cat").html(res);



				}



				 }); 



			});



	    $(".cat").change(function(){



				var cid=$(this).val();



				$.ajax({



				 type: "POST",



				 url: '<?php echo base_url();?>admin/ajax_showsubcat1',



				 data: {cid:cid},



				 success: function(res){



				//alert(res);



				$(".subcat").html(res);



				}



				 }); 



			});

			

	    $("#filter").click(function(){

			var mid=$("#mcat").val();

			var cid=$("#cat").val();

			var sid=$("#subcat").val();

			var brand=$("#brand").val();

			var title=$("#ptitle").val();

			$.ajax({

				 type: "POST",

				 url: '<?php echo base_url();?>admin/products_nav',

				 data: {mid:mid,cid:cid,sid:sid,brand:brand,title:title},

				 success: function(res){

					// alert(res);

					$(".pagination").html(res)

				 }

			});

		});

		$.ajax({

				 type: "POST",

				 url: '<?php echo base_url();?>admin/products_nav',

				 data: {mid:'',cid:'',sid:'',brand:'',title:''},

				 success: function(res){

					$(".pagination").html(res)

				 }

		});

		//$('#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>

