				<section role="main" class="content-body">

					<header class="page-header">

						<h2>Dashboard</h2>

					

						<div class="right-wrapper pull-right">

							<ol class="breadcrumbs">

								<li>

									<a href="<?php echo base_url();?>admin">

										<i class="fa fa-home"></i>

									</a>

								</li>

								<li><span>Dashboard</span></li>

							</ol>

					

						</div>

					</header>

					 <style>.widget-summary .summary-icon {

    font-size: 3.2rem;

    width: 50px;

    height: 50px;

    line-height: 50px;}</style>

					<!-- start: page -->

					<div class="row">

                   		 <div class="col-md-12 col-lg-12 col-xs-6">

							<div class="row">

                            	<div class="col-md-3 col-lg-3 col-xs-12">

									<section class="panel panel-featured-left panel-featured-success">

										<div class="panel-body">

											<div class="widget-summary">

												<div class="widget-summary-col widget-summary-col-icon">

													<div class="summary-icon bg-success">

														<i class="fa fa-gavel"></i>

													</div>

												</div>

												<div class="widget-summary-col">

													<div class="summary">

														<h4 class="title">Product Stock</h4>

														<div class="info">

														<strong class="amount">

                                                        <?php if($this->session->userdata("type")=="admin"){echo $this->db->get("products")->num_rows(); }else{echo $this->db->get_where("products",array("vendor"=>$this->session->userdata("userid")))->num_rows(); }?>

                                                       

                                                        </strong>

														</div>

													</div>

													<div class="summary-footer">

														<a href="#" class="text-muted text-uppercase">View all</a>

													</div>

												</div>

											</div>

										</div>

									</section>

								</div>

                                <?php if($this->session->userdata("type")=="admin"){?>

								<div class="col-md-3 col-lg-3 col-xs-12">

									<section class="panel panel-featured-left panel-featured-primary">

										<div class="panel-body">

											<div class="widget-summary">

												<div class="widget-summary-col widget-summary-col-icon">

													<div class="summary-icon bg-primary">

														<i class="fa fa-life-ring"></i>

													</div>

												</div>

												<div class="widget-summary-col">

													<div class="summary">

														<h4 class="title">Reg. Users</h4>

														<div class="info">

				<strong class="amount"><?php echo $this->db->get_where("users",array("act_status"=>"active"))->num_rows();?></strong>

															

														</div>

													</div>

													<div class="summary-footer">

														<a href="#" class="text-muted text-uppercase">View all</a>

													</div>

												</div>

											</div>

										</div>

									</section>

								</div>

								

                                <?php }?>

								<div class="col-md-3 col-lg-3 col-xs-12">

									<section class="panel panel-featured-left panel-featured-tertiary">

										<div class="panel-body">

											<div class="widget-summary">

												<div class="widget-summary-col widget-summary-col-icon">

													<div class="summary-icon bg-tertiary">

														<i class="fa fa-shopping-cart"></i>

													</div>

												</div>

												<div class="widget-summary-col">

													<div class="summary">

														<h4 class="title">Total Orders</h4>

														<div class="info">

		<strong class="amount"> <?php if($this->session->userdata("type")=="admin"){echo $this->db->get_where("orders",array("pay_status"=>"success"))->num_rows(); }else{echo $this->db->get_where("orders",array("pay_status"=>"success","vid"=>$this->session->userdata("userid")))->num_rows(); }?></strong>

														</div>

													</div>

													<div class="summary-footer">

											<a href="<?php echo base_url();?>admin/orders" class="text-muted text-uppercase">View All</a>

													</div>

												</div>

											</div>

										</div>

									</section>

								</div>

								

							</div>

						 </div>

                         

                         <?php if($this->session->userdata("type")=="admin"){?>

                         <div class="col-md-4">

                          	<div class="panel panel-primary">

                            	<div class="panel-heading">Home Banners</div>

                                <div class="panel-body">

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

										$edit=$this->db->get_where("banner",array("banner_id"=>$this->uri->segment(3)))->row();?>

                                    <form action="<?php echo base_url();?>admin/update_banner" method="post" enctype="multipart/form-data">

                                    <input type="hidden" name="bid" value="<?php echo $edit->banner_id;?>" />

                                            	<div class="form-group">

                                                <label for="email">Jump to Category</label>

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

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

                                                    <?php $cats=$this->db->get("category")->result();

													foreach($cats as $cat){?>

           <option value="<?php echo $cat->cid;?>" <?php if($edit->banner_cat==$cat->cid){echo "selected";}?>><?php echo $cat->cat_name;?></option>

                                                    <?php }?>

                                                </select>

                                                </div>

                            <div class="form-group">

                                <label class="control-label">Title</label>

                                <input type="text"  value="<?php echo $edit->banner_title;?>"  name="banner_title" class="form-control">

                            </div>

                            <div class="form-group">

                                <label class="control-label">Short Description</label>

                                <textarea class="form-control" rows="3" name="banner_desc"><?php echo $edit->banner_desc;?></textarea>

                            </div>   

                                                <div class="form-group">

                                                    <label class="control-label">Title</label>

                                                    <input type="file"  name="img" class="form-control">

                                                    <input type="hidden" name="oldimg" value="<?php echo $edit->banner_img;?>" />

                                                     <img src="<?php echo base_url();?>assets/images/category/<?php echo $edit->banner_img;?>" class="img img-responsive">

                                                </div><br/>

                                                <button type="submit" class="btn btn-primary btn-block">Update</button>

                                            </form>

                                    <?php }else{?>

                                    <form action="<?php echo base_url();?>admin/add_banner" method="post" enctype="multipart/form-data">

                                            	<div class="form-group">

                                                <label for="email">Jump to Category</label>

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

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

                                                    <?php $cats=$this->db->get("category")->result();

													foreach($cats as $cat){?>

                                                    <option value="<?php echo $cat->cid;?>"><?php echo $cat->cat_name;?></option>

                                                    <?php }?>

                                                </select>

                                                </div>

                                                <div class="form-group">

                                                    <label class="control-label">Title</label>

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

                                                </div>

                                                <div class="form-group">

                                                    <label class="control-label">Short Description</label>

                                                    <textarea class="form-control" rows="3" name="banner_desc"></textarea>

                                                </div>   

                                                <div class="form-group">

                                                    <label class="control-label">Title</label>

                                                    <input type="file"  name="img" class="form-control">

                                                   

                                                </div><br/>

                                                <button type="submit" class="btn btn-primary btn-block">Submit</button>

                                            </form>

                                            <?php }?>

                                </div>

                            </div>

                         </div>

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

                          	<div class="panel panel-primary">

                            	<div class="panel-heading">Listing Banners</div>

                                <div class="panel-body">

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

                                    	<thead><tr><th>Banner</th><th>Desc</th><th>Action</th></tr></thead>

                                        <tbody>

                                        <?php $this->db->select("*");

									$this->db->from("banner");

									$this->db->join("category","category.cid=banner.banner_cat","left");

									$ban=$this->db->get()->result();

									foreach($ban as $b){?>

                                    <tr><td width="150px"><img src="<?php echo base_url();?>assets/images/category/<?php echo $b->banner_img;?>" class="img img-responsive"></td>

                                    <td><label class="label label-success"><?php echo $b->cat_name;?></label>

                                    <h4><?php echo $b->banner_title;?></h4>

                                    <p><?php echo $b->banner_desc;?></p></td>

                                    <td><a href="<?php echo base_url();?>admin/index/<?php echo $b->banner_id;?>" class="btn btn-xs btn-warning"><i class="fa fa-edit"></i></a>

                                    <a href="#" id="<?php echo $b->banner_id;?>" class="btn btn-xs btn-danger banner_delete"><i class="fa fa-trash-o"></i></a></td></tr><?php }?>

                                        </tbody>

                                    </table>

                                </div>

                            </div>

                         </div>
                         
                         <div class="col-md-6">

                          	<div class="panel panel-primary">

                            	<div class="panel-heading">Delivery Time Slots</div>

                                <div class="panel-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().'admin/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">
                                      </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().'admin/add_time';?>">
                                      <div class="form-group">
                                        <input type="text" placeholder="Slot" class="form-control" name="dt_slot">
                                      </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-default">Submit</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();?>admin?dtid=<?php echo $dt->dtid;?>" class="btn btn-xs btn-warning"><i class="fa fa-edit"></i></a>
		<a href="#" id="<?php echo $dt->dtid;?>" class="btn btn-xs btn-danger dt_delete"><i class="fa fa-trash-o"></i></a></td>
                                        <?php $i++;}?>
                                        </tbody>
                                    </table>
                                </div>

                            </div>

                         </div>

                         <?php }?>

					</div>

                    <div class="row">

                         <?php if(!$this->session->userdata("type")=="admin"){?>

             <div class="col-md-5"> <?php if($this->session->flashdata("msg")){echo $this->session->flashdata("msg"); }?>

							<section class="panel panel-featured">

								<div class="panel-heading">Update Details</div>

								<div class="panel-body">

                                <?php 

								$this->db->select("*");

								$this->db->from("vendors");

								$this->db->join("states","vendors.vstate=states.state_id");

								$this->db->join("cities","vendors.vcity=cities.city_id");

								$this->db->where("vendors.vid",$this->session->userdata("userid"));

								$vendor=$this->db->get()->row();?>

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

       	  <div class="form-group ">

            <label for="email">Business Name/Title</label>

            <input type="text" required class="form-control" name="bname"  value="<?php echo $vendor->vb_name;?>">

          </div>

          <div class="form-group ">

            <label for="email">Vendor Name</label>

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

          </div>

         

          <div class="form-group ">

            <label for="email">Email</label>

            <input type="text"  class="form-control" readonly="readonly" name="email" value="<?php echo $vendor->v_email;?>">

          </div>

          <div class="form-group ">

            <label for="email">Phone</label>

            <input type="text"  class="form-control" name="phone" value="<?php echo $vendor->v_phone;?>">

          </div>

          <div class="row">

          <div class="form-group col-md-7">

            <label for="email">Address</label>

            <textarea class="form-control" rows="3" name="address"><?php echo $vendor->v_address;?></textarea>

          </div>

          <div class="form-group  col-md-5">

            <label for="email">Vendor Logo</label>

          	<input type="hidden" value="<?php echo $vendor->v_logo;?>" name="oldimg">

            <input type="file"  class="form-control" name="img"/>

            <img width="200px" src="<?php echo base_url();?>assets/images/<?php echo $vendor->v_logo;?>" class="img img-responsive">

          </div>

          </div>

          <div class="row">

          <div class="form-group col-md-6">

            <label for="email">State</label>

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

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

                <?php $st=$this->db->get_where("states",array("country_id"=>101))->result();

                foreach($st as $st){?>

                <option value="<?php echo $st->state_id;?>" <?php if($st->state_id==$vendor->vstate){echo "selected";}?>><?php echo $st->state_name;?></option>

                <?php }?>

            </select>

          </div>

          <div class="form-group  col-md-6">

            <label for="email">City</label>

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

             <?php $st=$this->db->get_where("cities",array("state_id"=>$vendor->vstate))->result();

                foreach($st as $st){?>

                <option value="<?php echo $st->city_id;?>" <?php if($st->city_id==$vendor->vcity){echo "selected";}?>><?php echo $st->city_name;?></option><?php }?>

            </select>

          </div>

          <div class="form-group col-md-6">

            <label for="email">Pincode</label>

            <input type="text"  class="form-control" name="pincode"  value="<?php echo $vendor->vpincode;?>">

          </div><div class="col-md-6">

          <br/>

          <button style="margin-top:5px;" type="submit" class="btn-block btn btn-success" name="submit">Update</button>

          </div>

          </div>

        </form>

      </div>

							</section>

						</div><?php }?>

                    </div>

				</section>

			</div>



			

		</section>

       

		<script>

		$(document).ready(function(){

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

					 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>

		<script src="<?php echo base_url();?>admin_assets/vendor/jquery-browser-mobile/jquery.browser.mobile.js"></script>

		<script src="<?php echo base_url();?>admin_assets/vendor/bootstrap/js/bootstrap.js"></script>

		<script src="<?php echo base_url();?>admin_assets/vendor/nanoscroller/nanoscroller.js"></script>

		<script src="<?php echo base_url();?>admin_assets/vendor/bootstrap-datepicker/js/bootstrap-datepicker.js"></script>

		<script src="<?php echo base_url();?>admin_assets/vendor/magnific-popup/magnific-popup.js"></script>

		<script src="<?php echo base_url();?>admin_assets/vendor/jquery-placeholder/jquery.placeholder.js"></script>

		

		<!-- Specific Page Vendor -->

		<script src="<?php echo base_url();?>admin_assets/vendor/jquery-ui/js/jquery-ui-1.10.4.custom.js"></script>

		<script src="<?php echo base_url();?>admin_assets/vendor/jquery-ui-touch-punch/jquery.ui.touch-punch.js"></script>

		<script src="<?php echo base_url();?>admin_assets/vendor/jquery-appear/jquery.appear.js"></script>

		

		<!-- Theme Base, Components and Settings -->

		<script src="<?php echo base_url();?>admin_assets/javascripts/theme.js"></script>

		

		<!-- Theme Custom -->

		<script src="<?php echo base_url();?>admin_assets/javascripts/theme.custom.js"></script>

		

		<!-- Theme Initialization Files -->

		<script src="<?php echo base_url();?>admin_assets/javascripts/theme.init.js"></script>





		<!-- Examples -->

		<script src="<?php echo base_url();?>admin_assets/javascripts/dashboard/examples.dashboard.js"></script>

	</body>

</html>