
<div class="clearfix"></div>
	
  <div class="content-wrapper">
    <div class="container-fluid">

      <!--Start Dashboard Content-->
      
      <div class="row mt-4">
        <div class="col-12 col-lg-6 col-xl-4">
          <div class="card gradient-purpink">
            <div class="card-body">
              <div class="media">
              <a href="<?php echo base_url().'store/mystore';?>" class="media-body text-left">
                <h4 class="text-white"><?php echo $this->db->get_where("prod_stock",array("admin_id"=>$this->session->userdata("userid")))->num_rows();?></h4>
                <span class="text-white">Products Listed</span>
              </a>
			  <div class="align-self-center"><i class="fa fa-cubes fa-3x"></i></div>
            </div>
            </div>
          </div>
        </div>
		<div class="col-12 col-lg-6 col-xl-4">
          <div class="card gradient-scooter">
            <div class="card-body">
              <div class="media">
              <div class="media-body text-left">
                <h4 class="text-white"><?php 
				  $this->db->select_sum('grand_total');  
				  $this->db->where("ostatus","Completed"); 
				  $this->db->where("admin_id",$this->session->userdata("userid")); 
				  $pending=$this->db->get('orders')->row();
				echo $pending->grand_total;?></h4>
                <span class="text-white">Revenue</span>
              </div>
			  <div class="align-self-center"><i class="fa fa-inr fa-3x"></i></div>
            </div>
            </div>
          </div>
        </div>
        <div class="col-12 col-lg-6 col-xl-4">
          <div class="card gradient-ibiza">
            <div class="card-body">
              <div class="media">
			  <a href="<?php echo base_url().'store/orders';?>" class="media-body text-left">
              <h4 class="text-white"><?php echo $this->db->get_where("orders",array("admin_id"=>$this->session->userdata("userid")))->num_rows();?></h4>
                <span class="text-white">Orders</span>
              </a>
               <div class="align-self-center"><i class="fa fa-shopping-cart fa-3x"></i></div>
            </div>
            </div>
          </div>
        </div>
        
        
        <div class="col-lg-6">
			   <?php if($this->session->flashdata("msg")){echo $this->session->flashdata("msg"); }?>
               <div class="card">
               		<div class="card-header">Add/Edit TimeSlot</div>
                    <div class="card-body">
                    	<?php if(isset($_GET['dtid'])){
							$edit=$this->db->get_where("delivery_times",array("dtid"=>$_GET['dtid']))->row();?>
						<form class="form-inline" method="post" action="<?php echo base_url().'store/update_time';?>">
							<input type="hidden" name="dtid" value="<?php echo $edit->dtid;?>" />
						  <div class="form-group">
							<input type="text" class="form-control" value="<?php echo $edit->dt_slot;?>" name="dt_slot">
                            <input type="hidden" name="admin_id" value="<?php echo $this->session->userdata("userid");?>" />
                            <input type="hidden" name="city_id" value="<?php echo $this->session->userdata("city_id");?>" />
						  </div>
						  <div class="form-group">
							<input type="number"  style="width:150px;" value="<?php echo $edit->max_del;?>" class="form-control" name="max_del">
						  </div>
						  <button type="submit" class="btn btn-default">Submit</button>
						</form>
						<?php }else{?>
						<form class="form-inline" method="post" action="<?php echo base_url().'store/add_time';?>">
						  <div class="form-group">
							<input type="text" placeholder="Slot" class="form-control" name="dt_slot">
                            <input type="hidden" name="admin_id" value="<?php echo $this->session->userdata("userid");?>" />
                            <input type="hidden" name="city_id" value="<?php echo $this->session->userdata("city_id");?>" />
						  </div>
						  <div class="form-group">
							<input type="number" style="width:150px;" placeholder="Max Delivery" class="form-control" name="max_del">
						  </div>
						  <button type="submit" class="btn btn-success"><i class="fa fa-check"></i></button>
						</form>
						<?php }?>
						<hr/>
						<table class="table table-condensed table-bordered">
							<thead><tr><th>S.No.</th><th>Time</th><th>Max Orders</th><th>Action</th></tr></thead>
							<tbody>
							<?php $i=1;foreach($delivery_times as $dt){?>
							<tr><td><?php echo $i;?></td>
								<td><?php echo $dt->dt_slot;?></td>
								<td><?php echo $dt->max_del;?></td>
								<td>
<a href="<?php echo base_url();?>store?dtid=<?php echo $dt->dtid;?>" class="btn btn-sm btn-warning"><i class="fa fa-edit"></i></a>
<a href="#" id="<?php echo $dt->dtid;?>" class="btn btn-sm btn-danger time_delete"><i class="fa fa-trash-o"></i></a></td>
							<?php $i++;}?>
							</tbody>
						</table>
                    </div>
               </div>
            </div>
      </div><!--End Row-->

	  
    <!-- 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 © 2020 Grocery Store
        </div>
      </div>
    </footer>
	<!--End footer-->
   
  </div><!--End wrapper-->

  <!-- Bootstrap core JavaScript-->
  <script>

		$(document).ready(function(){

			$(".time_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();?>store/time_delete',

					 data: {id:id},

					 success: function(response){

						 //alert(response);

					 }

				});

			});
			
			$(".dt_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/dt_delete',

					 data: {id:id},

					 success: function(response){

						 //alert(response);

					 }

				});

			});

		});

		</script>
  <!-- sidebar-menu 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>
