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

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

                            <thead><tr><th>S.No.</th><th>Image</th><th>Products</th><th>Category</th><th>Price</th><th>Action</th></tr></thead>

                            <tbody>

                                <?php $i=1;
								$this->db->select("*");
								$this->db->from("products");
								$this->db->join("mcategory","mcategory.mid=products.cid");
								$this->db->join("category","category.cid=products.sid","left");
								$prods=$this->db->get()->result();
								foreach($prods as $dep){?>

                                <tr><td><?php echo $i;?></td>

                <td width="100px"><img  width="100%" src="<?php echo base_url().'assets/images/products/'.$dep->img;?>" class="img img-responsive"></td>
                                    <td><?php echo $dep->title;?><br/>
                                    <input type="checkbox" name="in_trend" <?php if($dep->feat!=""){echo "checked";}?> value="<?php echo $dep->pid;?>" class="in_feat" /> <?php if($dep->feat!=""){?><span class="badge badge-warning">Featured</span><?php }else{echo "Featured";}?></span><br/>
                                    <!-- <input type="checkbox" name="in_trend2" <?php //if($dep->book_pro!=""){echo "checked";}?> value="<?php //echo $dep->pid;?>" class="in_feat2" /> <?php //if($dep->book_pro!=""){?><span class="badge badge-warning">In Sale</span><?php //}else{echo "In Booking";}?></span></td> -->
                                    <td><?php echo $dep->mcat_name.'/'.$dep->cat_name;?><br/>
								<span class="badge badge-danger"><?php echo $dep->color;?></span>
								<span class="badge badge-warning"><?php echo $dep->fabric;?></span><br/>
								<span class="badge badge-dark"><?php echo $dep->psizes;?></span><br/></td>
                                    <td><?php echo $dep->oprice;?><br/><del><?php echo $dep->price;?></del></td>

                                    <td>
<button type="button" id="<?php echo $dep->pid;?>" title="Gallery" class="btn btn-success btn-sm gallery" data-toggle="modal" data-target="#galleryModal"><?php echo $this->db->get_where("pgallery",array("pid"=>$dep->pid))->num_rows();?> Gallery</button>
                                      <?php if($dep->pstatus==""){$st="Disable";}else{$st="Enable";}?>

                <a href="<?php echo $dep->pid;?>" class="btn btn-sm btn-default enable"><?php echo $st;?></a>
                                    <a href="<?php echo base_url().'admin/addprod?prod_id='.$dep->pid;?>" class="btn btn-sm btn-warning"><i class="fa fa-edit"></i></a>

        <a href="#" id="<?php echo $dep->pid;?>" class="btn btn-sm btn-danger prod_delete"><i class="fa fa-trash-o"></i></a></td></tr><?php $i++;}?>

                            </tbody>

                        </table>

                    </div>

                    

               </div>                  

            </div>

            

        </div><!--End Row-->
<div id="galleryModal" class="modal fade" role="dialog">

  <div class="modal-dialog">



    <!-- Modal content-->

    <div class="modal-content ">

      <div class="modal-header">

        <h4 class="modal-title">Gallery</h4>

        

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

      </div>

      <div class="modal-body gallery_div">

        <i class="fa fa-spin fa-spinner fa-3x"></i>
      </div>

      <div class="modal-footer">

        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>

      </div>

    </div>



  </div>

</div>
	  

	  <!--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(){
		$(".gallery").click(function(){
			var id=$(this).attr('id');
			$.ajax({
				 type: "POST",
				 url: '<?php echo base_url();?>admin/ajax_gallery',
				 data: {id:id},
				 success: function(res){
				//alert(res);
				$(".gallery_div").html(res);
				}
			}); 
		});
		$(".open_popup").click(function(e){e.preventDefault();



			var name=$(this).attr("title");//alert(name);



			var id=$(this).attr("id");



			$("#agentid").val(id);



			$("#agentname").text(name);



		});
		//$('#default-datatable').DataTable();
		$(".in_feat").click(function(){
			var id=$(this).val();
			var v="";
			if ($(this).is(':checked')) {
				var v=$(this).val();
			}
			//alert(v);
			$.ajax({
			 type: "POST",
			 url: '<?php echo base_url();?>admin/pro_trend',
			 data: {v:v,id:id},
			 success: function(response){
				// alert(response);
			 }
			 });
		});
		$(".in_feat2").click(function(){
			var id=$(this).val();
			var v="";
			if ($(this).is(':checked')) {
				var v=$(this).val();
			}
			//alert(v);
			$.ajax({
			 type: "POST",
			 url: '<?php echo base_url();?>admin/pro_trend2',
			 data: {v:v,id:id},
			 success: function(response){
				// alert(response);
			 }
			 });
		});
		$(".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/proenable',

							 data: {id:id,st:st},

							 success: function(response){

								 //alert(response);

							 }

							 });

		});
		$(".prod_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_prod_delete',

					 data: {id:id},

					 success: function(response){

						 //alert(response);

					 }

				});

			});

		$('#default-datatable').DataTable();});

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

