<!DOCTYPE html>
<html class="no-js" lang="zxx">
<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<title>Grocery</title>
	<meta name="description" content="">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<!-- Favicon -->
	<link rel="icon" href="<?php echo base_url();?>assets/images/favicon.png">

	<link href="<?php echo base_url();?>assets/css/bootstrap.min.css" rel="stylesheet">

	<!-- FontAwesome CSS -->
	<link href="<?php echo base_url();?>assets/css/font-awesome.min.css" rel="stylesheet">

	<!-- Elegent CSS -->
	<link href="<?php echo base_url();?>assets/css/elegent.min.css" rel="stylesheet">

	<!-- Plugins CSS -->
	<link href="<?php echo base_url();?>assets/css/plugins.css" rel="stylesheet">

	<!-- Helper CSS -->
	<link href="<?php echo base_url();?>assets/css/helper.css" rel="stylesheet">

	<!-- Main CSS -->
	<link href="<?php echo base_url();?>assets/css/main.css" rel="stylesheet">

	<!-- Modernizer JS -->
	<script src="<?php echo base_url();?>assets/js/vendor/modernizr-2.8.3.min.js"></script>
	<script src="<?php echo base_url();?>assets/js/vendor/jquery.min.js"></script>
	<script src="<?php echo base_url();?>assets/js/bootstrap.min.js"></script>
    <script>
	$(document).ready(function(){
		$("#exampleInputPassword1").keyup(function(){
			var words=$(this).val();
			if(words.length>=3){console.log("searching..");
			 $.ajax({
				 type: "POST",
				 url: '<?php echo base_url();?>home/search_design_box',
				 data: {words:words},
				 success: function(res){
					 //console.log(res);
					 $(".instant-results").slideDown();
					 $(".result-bucket").html(res);
					 }
				 });}else{$(".instant-results").hide();}
		});
		<?php if(!$this->session->userdata("city")){?>
		$('#city_modal').modal({backdrop: 'static', keyboard: false})  ;
		<?php }?>
		$("#showsignup").click(function(){
			$("#loginform").slideUp();
			$("#signupform").slideDown();
		});
		
		$("#showlogin").click(function(){
			$("#loginform").slideDown();
			$("#signupform").slideUp();
		});
		
		$("#verify_otp").submit(function(e){e.preventDefault();
			//var plid=$("#plid").val();
			var formdata=$(this).serialize();
			$.ajax({
				 type: "POST",
				 url: '<?php echo base_url();?>home/ajax_verify_otp',
				 data: {formdata:formdata},
				 success: function(res){//alert(res);return false;
					 if(res==1){
							$(".otp_error").html("<br/>Your Registration is Successful."); 
							$("#verify_otp1").hide();
						window.setTimeout(function () {
							window.location.href = "<?php echo base_url();?>home";
						}, 2000);
					 }else{
						$(".otp_error").html(res);
					 }
				 }
				 });
		});
		$("#signupform").submit(function(e){e.preventDefault();
			var formdata=$(this).serialize();
			//alert(formdata);return false;
			if($("#pass").val()!=$("#cpass").val()){
			$(".error").slideDown();setTimeout(function(){ $(".error").html(""); $(".error").slideUp(); }, 3000);
			$(".error").html("Your Both Passwords Doesnot Match.");return false;
			}
			if($("#pass").val().length<6){
			$(".error").slideDown();setTimeout(function(){ $(".error").html(""); $(".error").slideUp(); }, 3000);
			$(".error").html("Make Sure Your Password is of 6 Character long.");return false;		
			}
			//var phone=$("#phone").val();
//										if(phone.length!=10 || !$.isNumeric(phone)){
//										$(".error").slideDown();setTimeout(function(){ $(".error").html(""); $(".error").slideUp(); }, 3000);
//										$(".error").html("Please Enter a Valid 10 digit Phone Number.");return false;	
//										}
			$("#submitbtn").attr("disabled",true);
			$("#submitbtn").text('Loading..',true);
			$.ajax({
				 type: "POST",
				 url: '<?php echo base_url();?>home/ajax_signup',
				 data: {formdata:formdata},
				 success: function(res){//alert(res);return false;
					 if(res==0){
						//$("#resend_otp").attr("href",res);
						$("#signupform").hide(); 
						$("#verify_otp").show();
						//window.location.href = "<?php //echo base_url(uri_string());?>"; 
					 }else{
						  $(".error").slideDown();setTimeout(function(){ $(".error").html(""); $(".error").slideUp(); }, 3000);
						 $(".error").html(res);
					 }
					 $("#submitbtn").removeAttr("disabled");
					 $("#submitbtn").text('Signup');
				 }
				 });
		});
							$("#login_here").click(function(e){e.preventDefault();
								$("#loginform").slideDown();
								$("#forgot_form").slideUp();
							});
							$("#forgot_password").click(function(e){e.preventDefault();
								$("#loginform").slideUp();
								$("#forgot_form").slideDown();
							});
							$("#forgot_form_btn").click(function(e){e.preventDefault();
								var phone=$("#forgot_mob").val();
								//if(phone.length!=10 || !$.isNumeric(phone)){
								//$(".forgot_error").html("Please Enter Valid 10 digit Phone No.");return false;	
								//}
								$.ajax({
									 type: "POST",
									 url: '<?php echo base_url();?>home/forgor_password_link',
									 data: {email:phone},
									 success: function(res){
										// if(res==1){
//											$("#forgot_form").slideUp();
//											$("#verify_form").slideDown(); 
//										 }else{
//											$(".forgot_error").html(res); 
//										 }
$(".forgot_error").html(res);//return false;
										 //alert(res);
										//$(".otp_error").html(res);
									 }
									 });
							});
					$("#loginform").submit(function(e){e.preventDefault();
							var formdata=$(this).serialize();
							$.ajax({
								 type: "POST",
								 url: '<?php echo base_url();?>home/ajax_login',
								 data: {formdata:formdata},
								 success: function(res){//alert(res);
									 if(res==1){
									 $(".login-success").show(); 
									 $(".login-error").hide();
									 window.setTimeout(function () {
											window.location.href = "<?php echo base_url(uri_string());?>";
										}, 3000);
									 }else{
									 $(".login-error").show();
									 $(".login-success").hide(); 
									 }
								 }
								 });
					});
		});
					</script>
    <script>
	$(document).ready(function(){
		$("#usercity").change(function(){
			var ucity=$(this).val();
			if(ucity!=""){
			window.location.href = "<?php echo base_url();?>home/set_city/"+ucity; 
			}
		});
	});
	</script>
<style>.list-group-item.active{ background:#489147; border:#489147;}.table td, .table th {padding: 5px;}
.instant-results {
background: #fff;
width: 38%;
color: gray;
position: absolute;
top: -10%;
border: 1px solid rgba(0, 0, 0, .15);
border-radius: 4px;

display: none;
z-index: 9;
}</style>
</head>

<body>

	<!--=============================================
	=            Header         =
	=============================================-->

	<header>
		<!--=======  header top  =======-->

		<div class="header-top pt-10 pb-10 pt-lg-10 pb-lg-10 pt-md-10 pb-md-10">
			<div class="container">
				<div class="row">
					<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12 text-center text-sm-left hidden-xs">
					</div>
					<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12  text-center text-sm-right">
						<!-- header top menu -->
						<div class="header-top-menu">
							<ul>
                            <?php if($this->session->userdata("type")){
								?><li><b>  Hi, <?php echo $this->session->userdata("loggeduser");?></b></li>
                                <li> <a href="<?php echo base_url();?>admin"> <i class="fa fa-dashboard"></i> Dashboard</a></li>
								<li> <a href="<?php echo base_url();?>home/logout"> <i class="fa fa-sign-out"></i> Logout</a></li>
								<?php
							}else if($this->session->userdata("user")){?>
                            <li><img width="20px" class="img img-circle" src="<?php echo $this->session->userdata("img");?>"><b>  Hi, <?php echo $this->session->userdata("name");?></b></li>
									
			<li><a href="<?php echo base_url();?>home/wishlist"><i class="fa fa-heart"></i> My Wishlist</a></li>
            <li><a href="<?php echo base_url();?>home/orders"><i class="fa fa-shopping-cart"></i> My Orders</a></li>
            <?php if($this->cart->total_items()>0){?>
            <!--<li><a href="<?php //echo base_url();?>home/checkout"><i class="fa fa-check"></i> Checkout</a></li>--><?php }?>
            <li> <a href="<?php echo base_url();?>home/logout"> <i class="fa fa-sign-out"></i> Logout</a></li>
									
								</li>
                            <?php }else{?>
                            <li><!--<a href="<?php echo base_url();?>home/login"><i class="fa fa-user"></i> Login/Signup</a-->
                            <a  id="loginsignupbtn" data-toggle="modal" data-target="#myModal" ><i class="fa fa-user"></i> Login/Signup</a></li>
                            <?php }?>&nbsp;&nbsp;
                            <select style="padding-left:5px;" id="usercity">
                            	<option value="">Select City</option>
                                <?php   $this->db->select("*");
										$this->db->from("cities");
										$this->db->join("city_stores","city_stores.city_id=cities.city_id");
										$this->db->order_by("cities.city_name","asc");
										$cities=$this->db->get()->result();
									  foreach($cities as $ct){?>
                                      <option value="<?php echo $ct->city_id;?>" <?php if($this->session->userdata("city")==$ct->city_id){echo "selected";}?>><?php echo $ct->city_name;?></option><?php }?>
                            </select>
							</ul>
						</div>
						<!-- end of header top menu -->
					</div>
				</div>
			</div>
		</div>

		<!--=======  End of header top  =======-->

		<!--=======  header bottom  =======-->

		<div class="header-bottom header-bottom-one header-sticky">
			<div class="container">
				<div class="row">
					<div class="col-md-3 col-sm-12 col-xs-6 text-lg-left text-md-center text-sm-center">
						<!-- logo -->
						<div class="logo mt-15 mb-15">
							<a href="<?php echo base_url();?>">
									<img src="<?php echo base_url();?>assets/images/logo.png" class="img-fluid" alt="">
								</a>
						</div>
						<!-- end of logo -->
					</div>
					<div class="col-md-9 col-sm-12 col-xs-6">
						<div class="menubar-top d-flex justify-content-between align-items-center flex-sm-wrap flex-md-wrap flex-lg-nowrap mt-sm-15">
							<!-- header phone number -->
							<div class="header-contact d-flex">
								<div class="phone-icon">
									<img src="<?php echo base_url();?>assets/images/icon-phone.png" class="img-fluid" alt="">
								</div>
								<div class="phone-number">
									Phone: <span class="number">1-888-123-456-89</span>
								</div>
							</div>
							<!-- end of header phone number -->
							<!-- search bar -->
							<div class="header-advance-search">
								<form  action="<?php echo base_url().'home/search';?>" id="search_form" method="get">
									<input name="search"  type="text" required id="exampleInputPassword1" placeholder="Search your product">
									<button type="submit"><span class="icon_search"></span></button>
								</form>
                                <div class="instant-results" style="margin-top:50px; max-height:400px; overflow:auto;">
                                    <ul class="list-unstyled result-bucket" style="padding:10px;">
                                        
                                    </ul>
                                </div>
							</div>
							<!-- end of search bar -->
							<!-- shopping cart -->
							<div class="shopping-cart" id="shopping-cart">
								<a href="<?php echo base_url();?>home/cart">
									<div class="cart-icon d-inline-block">
										<span class="icon_bag_alt"></span>
									</div>
									<div class="cart-info d-inline-block">
										<p>Shopping Cart 
											<span id="items_total">
							<?php echo $this->cart->total_items();?> item(s) - <i class="fa fa-inr"></i><b><?php echo $this->cart->total();?>/-</b>
											</span>
										</p>
									</div>
								</a>
							<!-- end of shopping cart -->

							<!-- cart floating box -->
							<div class="cart-floating-box" id="cart-floating-box">
								<?php if($this->cart->total_items()>0){
	 $tot=0;?>
<div class="cart-items">
	<?php  foreach($this->cart->contents() as $cart){?>
    <div class="cart-float-single-item d-flex">
        <!--<span class="remove-item"><a href="#"><i class="fa fa-times"></i></a></span>-->
        <div class="cart-float-single-item-image">
            <a href="#"><img src="<?php echo $cart['img'];?>" class="img-fluid" alt=""></a>
        </div>
        <div class="cart-float-single-item-desc">
            <p class="product-title"> <a href="#"><?php echo $cart['name'];?> </a></p>
            <p class="price"><span class="count"><?php echo $cart['pack'];?> <b>Qty. <?php echo $cart['qty'];?></b> x </span><?php  echo $subt=$cart['price'];?></p>
        </div>
    </div>
    <?php }?>
</div>
<div class="cart-calculation">
    <div class="calculation-details">
        <p class="total">Subtotal <span><i class="fa fa-inr"></i><?php echo $this->cart->total();?></span></p>
    </div>
    <div class="floating-cart-btn text-center">
        <a href="<?php echo base_url();?>home/checkout">Checkout</a>
        <a href="<?php echo base_url();?>home/cart">View Cart</a>
    </div>
</div>
<?php }else{?><h3 class="pull-right text-warning"><i class="fa fa-shopping-cart"></i> Your Cart is empty</h3>
<?php }?>
							</div>
							<!-- end of cart floating box -->
							</div>
						</div>

						<!-- navigation section -->
                        <div class="main-menu">
							<nav>
								<ul>
									<li><a href="<?php echo base_url();?>">Home</a></li>
                                    <?php $mcats=$this->db->get("mcategory")->result();
									foreach($mcats as $mcat){?>
                                    <li class="menu-item-has-children"><a href="#"><?php echo $mcat->mcat_name;?></a>
                                        <ul class="sub-menu">
                                        <?php  $this->db->order_by("csort","asc");$this->db->limit(10);
                 $cat=$this->db->get_where("category",array("cat_status"=>"","mid"=>$mcat->mid))->result();foreach($cat as $c){
					 ?> 
                                            <li class="menu-item-has-children"><a href="<?php echo base_url();?><?php echo str_replace(" ","-",$c->cat_name);?>/<?php echo $c->cid;?>" ><?php echo $c->cat_name;?></a>
                                            <?php if($this->db->get_where("subcategory",array("cid"=>$c->cid))->num_rows()>0){?>
                                                <ul class="sub-menu">
                                                <?php $this->db->order_by("sid","desc");
                        $subcat=$this->db->get_where("subcategory",array("cid"=>$c->cid))->result();
                                        foreach($subcat as $subc){?>
                                                    <li><a href="<?php echo base_url();?><?php echo str_replace(" ","-",$c->cat_name);?>/<?php echo str_replace(" ","-",$subc->subcat_name);?>/<?php echo $c->cid;?>/<?php echo $subc->sid;?>"><?php echo $subc->subcat_name;?></a></li>
                                                    <?php }?>
                                                </ul><?php }?>
                                            </li>
                                            <?php }?>
                                        </ul>
                                    </li>
                                    <?php }?>
                                    <li><a href="#">About us</a></li>
                                    <li><a href="#">CONTACT</a></li>
                                   <!-- <li><a href=""><i style="border:2px solid; padding:5px;">Deals & Offers</i></a></li>-->
								</ul>
							</nav>
						</div>
						<!-- end of navigation section -->
					</div>
					<div class="col-12">
						<!-- Mobile Menu -->
						<div class="mobile-menu d-block d-lg-none"></div>
					</div>
				</div>
			</div>
		</div>
</header>
<div id="myModal" class="modal fade" role="dialog">
  <div class="modal-dialog modal-sm">
    <!-- Modal content-->
    <div class="modal-content">
      <div class="modal-header" style="background:#007bff;">
        <h4 class="modal-title" style="color:#FFF;">User Login/Register</h4>
        <button type="button" class="close" data-dismiss="modal">&times;</button>
      </div>
      <div class="modal-body">
        <div class="alert alert-success login-success" style="display:none;"><i class="fa fa-spin fa-spinner"></i> Login Success. Redirecting You to Dashboard.</div>
        <div class="alert alert-danger login-error" style="display:none;">Your Login Details are Invalid.</div>
      	<form action="#" method="post" id="loginform">
                            	<div class="form-group">
                            	<label>Mobile</label>
                                <input class="form-control" name="email" required placeholder="Mobile" type="text">
                                </div>
                                <div class="form-group">
                                <label>Password</label>
                                <input class="form-control" name="password" required placeholder="Password" type="password">
                                </div>
                                   
                                        <label><input  type="checkbox">
                                        Remember me</label>
                                        <a href="#" id="forgot_password" class="pull-right text-danger">Forgot Password?</a>
                                    
                                    <button class="btn btn-primary" type="submit">Login</button>
                                    <button class="btn btn-warning pull-right" type="button" id="showsignup">Signup</button>
                                
                            </form>
        <div class="text-center" id="forgot_form" style="display:none;">
                                <h3 class="text-danger text-center">Forgot Password?</h3>
                                <p>Enter Registered Email Id.</p>
                                <i class="fa fa-envelope fa-5x text-warning"></i><br/>
                                <input type="text" class="form-control" name="mob" id="forgot_mob" required /><br/>
                                <b class="text-danger forgot_error"></b>
                                <button class="btn btn-block btn-warning" id="forgot_form_btn" type="button">Get Password Reset Link</button>
                                <hr/>
                                <div class="text-center">
                                    <p>Remember Login Details? <a href="#" id="login_here">Login here.</a></p>
                                </div>
                                </div>
        <form action="" method="post" id="signupform" style="display:none;">
        	<div class="row">
            	<div class="form-group col-md-6">
                <label>First Name</label>
                <input type="text" class="form-control" required name="fname">
                </div>
                <div class="form-group col-md-6">
                <label>Last Name</label>
                <input type="text" class="form-control" required name="lname">
                </div>
            
            <div class="form-group col-md-12">
            	<label>Email</label>
                <input type="email" class="form-control" required name="email">
            </div>
            <div class="form-group col-md-12">
            	<label>Phone</label>
                <input type="text" class="form-control" name="mobile">
            </div>
            	<div class="form-group col-md-6">
                <label>Create Password</label>
                <input type="password" id="pass"  class="form-control" required name="password">
                </div>
                <div class="form-group col-md-6">
                <label>Confirm Password</label>
                <input type="password" id="cpass"  class="form-control" required name="cpassword">
                </div>
            </div>
            <div class="alert alert-danger text-center error" style="display:none;"></div>
            <button class="btn btn-primary" type="submit" id="submitbtn">Signup</button>
            <button class="btn btn-warning pull-right" type="button" id="showlogin">Login</button>
        </form>
        <form action="#" method="post" id="verify_otp"  style="display:none;">
            <div class="row">
                <div class="form-group col-md-6 offset-md-3 text-center">
                <p class="text-warning">We have sent an OTP to Your Mobile Number & Email id Please confirm the OTP.</p>
                    <i class="fa fa-mobile fa-5x text-warning"></i><br/>
<input type="text" class="form-control" required name="otp" placeholder="6 Digit Code" style="margin-bottom:0px;font-size:20px;text-align:center;" />
<a href="#" id="resend_otp">Resend OTP</a>
                    <b class="text-danger  text-center otp_error"></b><br/>
                    <button type="submit" id="verify_otp1" class="btn btn-warning">Verify OTP</button> 
                </div>
            </div>
        </form>
        <!--<div class="alert alert-success" id="verify_otp" style="display:none;">
        <h3>Registeration completed successfully.</h3>
        <p>We have sent an email activation link to you. Please check your email and verify to activate your login.</p>
        </div-->
      </div>
    </div>

  </div>
</div>
<div id="city_modal" class="modal hide fade in" data-keyboard="false" data-backdrop="static">
  <div class="modal-dialog">

    <!-- Modal content-->
    <div class="modal-content">
      <div class="modal-header">
        <h4 class="modal-title">Select City</h4>
      </div>
      <div class="modal-body row">
        <?php foreach($cities as $ct){?>
        <div class="col-md-3 text-center col-xs-4" style="padding:10px;">
        	<a href="<?php echo base_url().'home/change_city/'.$ct->city_id;?>" style="background:#186d2d;">
            <img class="img img-responsive" width="100%" src="https://i.pinimg.com/originals/3f/9f/ed/3f9fed05f53b28aac803243d71a57055.jpg">
            <h4 style="color:#fff;"><?php echo $ct->city_name;?></h4>
            </a>
        </div>
        <?php }?>
      </div>
    </div>

  </div>
</div>