<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
                    <button type="button" class="btn btn-warning btn-sm pull-right" data-toggle="modal" data-target="#myModal">Add New Customer</button></div>
                    <div class="card-body">
                          
                      <table class="table table-condensed table-bordered">
                        <thead>
                                                            <tr>
                                                                <th>S.No.</th>
                                                                <th>Member Since</th>
                                                                <th>Name</th>
                                                                <th>Contact</th>
                                                                <th>Total Orders</th>
                                                                <th>Total Purchase</th>
                                                                <th>Action</th>
                                                            </tr>
                                                        </thead>
                        <tbody id="list_customers">
                            
                        </tbody>
                      </table>
                      <ul class="pagination">
                            <?php $j=$customers/10; for($i=0;$i<=$j;$i++){?>
  <li class="<?php if($i==0){echo 'active';}?> lisclass page-item"><a href="<?php echo $i*10;?>" class="page-link change_page"><?php echo $i+1;?></a></li>
  <?php }?>     
                      </ul>
                      <div id="myModal" class="modal fade" role="dialog">
                          <div class="modal-dialog modal-md">
                            <!-- Modal content-->
                            <div class="modal-content">
                              <div class="modal-header">
                                <h4 class="modal-title">Add New Customer</h4>
                                <button type="button" class="close" data-dismiss="modal">&times;</button>
                              </div>
                              <div class="modal-body cust_div">
                                <form action="<?php echo base_url().'admin/add_customer';?>" method="post">
                                	<div class="form-group">
                                    	<label>Name</label>
                                        <input type="text" class="form-control" name="name" required />
                                    </div>
                                    <div class="form-group">
                                    	<label>Email</label>
                                        <input type="email" class="form-control" name="email" required />
                                    </div>
                                    <div class="form-group">
                                    	<label>Phone</label>
                                        <input type="text" class="form-control" name="phone" required />
                                    </div>
                                    <div class="form-group">
                                    	<label>Password</label>
                                        <input type="password" class="form-control" name="password" required />
                                    </div>
                                    <button type="submit" class="btn btn-danger btn-block">Add Customer</button>
                                </form>
                              </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(){ 
		 $.ajax({
				 type: "POST",
				 url: '<?php echo base_url();?>admin/ajax_list_customers',
				 data: {offset:0},
				 success: function(res){
					$("#list_customers").html(res)
				 }
		 });
		 $(".change_page").click(function(e){e.preventDefault();
			 $(".lisclass").removeClass("active");
			 $(this).closest("li").addClass("active");
			 var offset=$(this).attr("href");
			 $.ajax({
				 type: "POST",
				 url: '<?php echo base_url();?>admin/ajax_list_customers',
				 data: {offset:offset},
				 success: function(res){
					$("#list_customers").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>
