<?php
	$user_page='';
	
	if(isset($_SESSION['customer'])) {
	    $user_page = base_url('profile');
	}
	else
	{
	    $user_page='#bd-example-modal';
	}
	
	if($cur_page!='index.php' && $cur_page!='signin.php' && $cur_page!='signup.php'){
	    if($cur_page=='my-profile.php' || $cur_page=='orderlist.php'){
	        if(!isset($_SESSION['customer'])) {
	            header('Location: index.php');
	        }
	    }
	}
	$toggle='';
	if(!isset($_SESSION['customer'])) {
	    $toggle="data-toggle='modal'";
	}
	?>
<?php if($cur_page!='faq.php' && $cur_page!='signin.php' && $cur_page!='signup.php' && $cur_page!='verification.php' && $cur_page!='terms_conditions.php' && $cur_page!='edit_profile.php' && $cur_page!='change_password.php' && $cur_page!='signin.php' && $cur_page!='signin.php'){ ?>
<div class="osahan-menu-fotter fixed-bottom bg-white text-center shadow border-top d-lg-none" style="z-index: 99;">
	<div class="row m-0">
		<a <?php if($cur_page=='index.php'){ ?> href="javascript:void(0);"  class="text-dark small col font-weight-bold text-decoration-none p-2 selected"<?php }else{ ?> href="<?=base_url();?>" class="text-dark small col font-weight-bold text-decoration-none p-2" <?php } ?>>
			<p class="h5 m-0"><i class="text-success mdi mdi-home"></i></p>
			<b>SHOP</b>
		</a>
		<a  <?php if($cur_page=='cart.php'){ ?> href="javascript:void(0);" data-toggle="offcanvas" class="text-dark small col font-weight-bold text-decoration-none p-2 selected"<?php }else{ ?> href="#" data-toggle="offcanvas" class="text-dark small col font-weight-bold text-decoration-none p-2" <?php } ?>>
			<p class="h5 m-0"><i class="mdi mdi-cart"></i></p>
			<b>CART</b>
		</a>
		<a  <?php if($cur_page=='orderlist.php'){ ?> href="javascript:void(0);"  class="text-dark small col font-weight-bold text-decoration-none p-2 selected"<?php }else{ ?> href="<?=base_url('orderlist');?>" class="text-dark small col font-weight-bold text-decoration-none p-2" <?php } ?>>
			<p class="h5 m-0"><i class="mdi mdi-apps"></i></p>
			<b>MY ORDER</b>
		</a>
		<a <?php if($cur_page==$user_page){ ?> href="javascript:void(0);"  class="text-dark small col font-weight-bold text-decoration-none p-2 selected"<?php }else{ ?> href="<?php echo $user_page; ?>" class="text-dark small col font-weight-bold text-decoration-none p-2" <?php } echo $toggle;?> >
			<p class="h5 m-0"><i class="mdi mdi-account"></i></p>
			<b>ACCOUNT</b>
		</a>
	</div>
</div>
<?php } ?>
<section class="section-padding bg-white border-top">
	<div class="container">
		<div class="row">
			<div class="col-lg-4 col-sm-6 col-12 ">
				<div class="feature-box">
					<i class="mdi mdi-truck-fast"></i>
					<h6>Same Day Delivery & Easy Return</h6>
					<p>Same Day Delivery & Easy To Return</p>
				</div>
			</div>
			<div class="col-lg-4 col-sm-6 col-12">
				<div class="feature-box">
					<i class="mdi mdi-basket"></i>
					<h6>100% Satisfaction Guarantee </h6>
					<p>Full safety procedures packing and delivery</p>
				</div>
			</div>
			<div class="col-lg-4 col-sm-6 col-12">
				<div class="feature-box">
					<i class="mdi mdi-tag-heart"></i>
					<h6>Great Daily Deals Discount</h6>
					<p>Great Daily Deals Discount</p>
				</div>
			</div>
		</div>
	</div>
</section>
<!-- Footer -->
<section class="section-padding no-padding2 footer bg-white border-top">
	<div class="container">
		<div class="row">
			<div class="col-lg-3 col-md-3">
				<h6 class="mb-4 d-md-block d-sm-none d-xs-none d-lg-block d-xl-block">CONTACTS </h6>
				<h6 class="collapsed d-md-none  d-lg-none d-xl-none  d-sm-block d-xs-block" data-target="#Touch" data-toggle="collapse">CONTACTS<i class=" float-right mdi mdi-arrow-down-bold-circle mr-0 pr-3"></i></h6>
				<ul  class="list-unstyled collapse d-md-block  d-lg-block d-xl-block" id="Touch">
					<li class="mb-2 mt-0 bg-success"><a class="logo" href="<?= base_url();?>"><img src="<?= base_url('uploads/website/footer_logo/'.$footer_logo);?>" alt="<?= $base_name;?>"></a></li>
					<li><a class="text-dark" href="#"><i class="mdi mdi-map-marker"></i> <?= $contact_address;?></a></li>
					<li><a class="text-dark font-weight-bolder" target="blank" href="tel:<?= $contact_fax;?>"><i class="mdi mdi-phone"></i><?= $contact_fax;?></a></li>
					<li><a class="text-dark font-weight-bolder" target="blank" href="tel:<?= $contact_phone;?>"><i class="mdi mdi-cellphone-iphone"></i> <?= $contact_phone;?></a></li>
					<li><a class="text-dark font-weight-bolder" target="blank" href="mailto:<?= $contact_email;?>"><i class="mdi mdi-email"></i> <?= $contact_email;?></a></li>
					<!--<li><a class="text-primary" href="#"><i class="mdi mdi-web"></i> <?= $domain;?></a></li>-->
				</ul>
			</div>
			<div class="col-lg-2 col-md-2 d-none">
				<h6 class="mb-4 d-md-block d-sm-none d-xs-none d-lg-block d-xl-block">TOP CITIES </h6>
				<h6 class="collapsed d-md-none  d-lg-none d-xl-none  d-sm-block d-xs-block" data-target="#CITIES" data-toggle="collapse">TOP CITIES <i class=" float-right mdi mdi-arrow-down-bold-circle mr-0 pr-3"></i></h6>
				<ul  class="list-unstyled collapse d-md-block  d-lg-block d-xl-block" id="CITIES">
				<?php
					if(isset($top_cities)){
					foreach ($top_cities as $row) {
					?>
				<li><a href="#"><?= $row['name']; ?></a></li>
				<?php }} ?>
				</ul>
			</div>
			<div class="col-lg-3 col-md-2">
				<h6 class="mb-4 d-md-block d-sm-none d-xs-none d-lg-block d-xl-block">CATEGORIES </h6>
				<h6 class="collapsed d-md-none  d-lg-none d-xl-none  d-sm-block d-xs-block" data-target="#CATEGORIES" data-toggle="collapse">CATEGORIES <i class=" float-right mdi mdi-arrow-down-bold-circle mr-0 pr-3"></i></h6>
				<ul  class="list-unstyled d-md-block collapse d-lg-block d-xl-block" id="CATEGORIES">
				<?php
					if(isset($mid_category)){
					foreach ($mid_category as $row1) {
						?>
				<li><a href="<?=base_url('product_special/index');?>?id=<?= $row1['mcat_id'];?>&type=mid-category&mid=<?= $row1['mcat_id'];?>"><?= $row1['mcat_name'];?></a></li>
				<?php }} ?>
				</ul>
			</div>
			<div class="col-lg-3 col-md-2">
				<h6 class="mb-4 d-md-block d-sm-none d-xs-none d-lg-block d-xl-block">ABOUT US </h6>
				<h6 class="collapsed d-md-none  d-lg-none d-xl-none  d-sm-block d-xs-block" data-target="#ABOUT" data-toggle="collapse">ABOUT US <i class=" float-right mdi mdi-arrow-down-bold-circle mr-0 pr-3"></i></h6>
				<ul  class="list-unstyled d-md-block collapse  d-lg-block d-xl-block" id="ABOUT">
    				<li><a href="<?=base_url('about');?>">Company Information</a></li>
    				<li><a href="<?=base_url('faqs');?>">FAQ'S</a></li>
    				<li><a href="<?=base_url('career');?>">Career</a></li>
    				<li><a href="<?=base_url('terms_condition');?>">Terms &amp; Condition</a></li>
    				<li><a href="<?=base_url('privacy_policy');?>">Privacy Policy</a></li>
    				<li><a href="<?=base_url('contact');?>">Contact Us</a></li>
				</ul>
			</div>
			<div class="col-lg-3 col-md-3">
				<h6 class="mb-4 d-md-block d-sm-none d-xs-none d-lg-block d-xl-block">DOWNLOAD APP </h6>
				<h6 class="collapsed d-md-none  d-lg-none d-xl-none  d-sm-block d-xs-block" data-target="#App" data-toggle="collapse">DOWNLOAD APP <i class=" float-right mdi mdi-arrow-down-bold-circle mr-0 pr-3"></i></h6>
				<ul  class="list-unstyled d-md-block collapse hover-white  d-lg-block d-xl-block" id="App">
					<li>
						<div class="app">
							<a href="<?= $app_url; ?>" target="blank"><img src="<?=base_url('site_assets/');?>img/google.png" alt=""></a>
							<!--<a href="#"><img src="img/apple.png" alt=""></a>-->
						</div>
					</li>
				</ul>
				<br>
				<div class="w-100-h-1"></div>
				<h6 class="mb-4 d-md-block d-sm-none d-xs-none d-lg-block d-xl-block">GET IN TOUCH </h6>
				<h6 class="collapsed d-md-none  d-lg-none d-xl-none  d-sm-block d-xs-block mt-0" data-target="#GET" data-toggle="collapse">GET IN TOUCH <i class=" float-right mdi mdi-arrow-down-bold-circle mr-0 pr-3"></i></h6>
				<ul  class="list-unstyled d-md-block collapse  d-lg-block d-xl-block" id="GET">
					<li>
						<div class="footer-social">
							<?php 
								if(isset($social)){
								    foreach ($social as $row2) {
								    ?>
							<a class="btn-<?= $row2['social_name'];?> text-white" href="<?= $row2['social_url'];?>"  target="blank"  class="btn btn-sm bg-theme-color text-white">
							<i class="<?= $row2['social_icon'];?>"></i>
							</a>
							<?php
								    }
								}
								?>
						</div>
					</li>
				</ul>
				<br>
			</div>
		</div>
	</div>
</section>
<!-- End Footer -->
<!-- Copyright -->
<section class="pt-4 pb-4 footer-bottom">
	<div class="container">
		<div class="row no-gutters">
			<div class="col-lg-6 col-sm-6 col-12 text-center  text-lg-left text-md-left">
				<p class="mt-1 mb-0"><?= $footer_copyright;?>
				</p>
			</div>
			<div class="col-lg-6 col-sm-6 col-12 text-center text-lg-right text-md-right">
				<p  class="mt-1 mb-0">Made with <i class="mdi mdi-heart text-danger"></i> by <a href="https://decentdesign.in/" target="_blank" class="text-primary">Decent Web Services LLP</a>
				</p>
			</div>
		</div>
	</div>
</section>
<div class="mb-5 d-lg-none d-md-none"><br></div>
<!-- End Copyright -->
<!--MY CUSTOM JAVASCRIPT-->
<nav id="main-nav">
	<ul class="first-nav bg-me2">
		<li class="search" data-nav-custom-content>
			<div class="form-container">
				<?php
					if(isset($_SESSION['customer'])) {
					    if(empty($_SESSION['customer']['cust_image'])){
					        $img='user.png';
					    }
					    else{
					        $img  = $_SESSION['customer']['cust_image'];
					    }
					    ?>
				<a href="#" class="text-white">
					<div class="pro ">
						<img src="<?=base_url('uploads/website/customer/'.$img);?>" class="rounded-circle img_60-60" alt="<?php  echo $_SESSION['customer']['cust_name'];?>">
						&nbsp; <b><?php  echo $_SESSION['customer']['cust_name'];?></b>
					</div>
					<?php  echo $_SESSION['customer']['cust_email'];?>
				</a>
				<?php
					} 
					?>
			</div>
		</li>
	</ul>
	<ul class="second-nav">
		<li class="home"><a href="index.php">Home</a></li>
		<li>
			<span>Category</span>
			<ul>
				<?php
					if(isset($mid_category2)){
					    foreach ($mid_category2 as $row1) {
					?>
				<li class="mobile">
					<a href="#"><?= $row1['mcat_name']; ?></a>
					<ul>
						<?php    
							if(isset($end_category2)){
							    foreach ($end_category2 as $row2) {
							    if($row1['mcat_id'] == $row2['mcat_id']){
							    ?>
						<li class="mobile"><a href="product_special.php?id=<?= $row2['ecat_id']; ?>&type=end-category&mid=<?= $row1['mcat_id']; ?>"><?= $row2['ecat_name']; ?></a></li>
						<?php
							}
							}
							}
							?> 
					</ul>
				</li>
				<?php }
					}
					?> 
			</ul>
		</li>
		<?php
			if(isset($_SESSION['customer'])) {
			?>
		<li class="face"><a href="my-profile.php">My Profile </a></li>
		<li><a href="orderlist.php">My Orders </a></li>
		<?php } ?>
		<li><a href="about.php">About Us </a></li>
		<li><a href="contact.php">Customer Care </a></li>
		<?php
			if(isset($_SESSION['customer'])) {
			?>
		<li><a href="customer-password-update.php">Password </a></li>
		<?php } ?>
		<li><a href="terms_and_condition.php">Terms & Condition </a></li>
		<!--<a href="#">Share </a>-->
		<!--<a href="#">Rate Us </a>-->
		<?php
			if(isset($_SESSION['customer'])) {
			?>
		<li class=""><a href="logout.php">Logout</a></li>
		<?php } ?>
	</ul>
	<!--<ul class="bottom-nav">-->
	<!--  <li class="github">-->
	<!--    <a href="#" target="_blank">-->
	<!--      <svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12"/></svg>-->
	<!--    </a>-->
	<!--  </li>-->
	<!--  <li class="email">-->
	<!--    <a href="#" target="_blank">-->
	<!--      <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M20 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm0 4l-8 5-8-5V6l8 5 8-5v2z"/><path d="M0 0h24v24H0z" fill="none"/></svg>-->
	<!--    </a>-->
	<!--  </li>-->
	<!--  <li class="ko-fi">-->
	<!--    <a href="#" target="_blank">-->
	<!--      <svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M23.881 8.948c-.773-4.085-4.859-4.593-4.859-4.593H.723c-.604 0-.679.798-.679.798s-.082 7.324-.022 11.822c.164 2.424 2.586 2.672 2.586 2.672s8.267-.023 11.966-.049c2.438-.426 2.683-2.566 2.658-3.734 4.352.24 7.422-2.831 6.649-6.916zm-11.062 3.511c-1.246 1.453-4.011 3.976-4.011 3.976s-.121.119-.31.023c-.076-.057-.108-.09-.108-.09-.443-.441-3.368-3.049-4.034-3.954-.709-.965-1.041-2.7-.091-3.71.951-1.01 3.005-1.086 4.363.407 0 0 1.565-1.782 3.468-.963 1.904.82 1.832 3.011.723 4.311zm6.173.478c-.928.116-1.682.028-1.682.028V7.284h1.77s1.971.551 1.971 2.638c0 1.913-.985 2.667-2.059 3.015z"/></svg>-->
	<!--    </a>-->
	<!--  </li>-->
	<!--</ul>-->
</nav>
<link href='https://fonts.googleapis.com/css?family=Kalam' rel='stylesheet'>
<script>
	$(document).ready(function(){
	    $('.nav-close').hide();
	});
</script>
<script>
	(function($) {
	  var $main_nav = $('#main-nav');
	  var $toggle = $('.toggle');
	
	  var defaultOptions = {
	    disableAt: false,
	    customToggle: $toggle,
	    levelSpacing: 40,
	    navTitle: '<?=$base_name;?>',
	    levelTitles: true,
	    levelTitleAsBack: true,
	    pushContent: '#container',
	    insertClose: 2
	  };
	
	  // call our plugin
	  var Nav = $main_nav.hcOffcanvasNav(defaultOptions);
	
	  // add new items to original nav
	  $main_nav.find('li.add').children('a').on('click', function() {
	    var $this = $(this);
	    var $li = $this.parent();
	    var items = eval('(' + $this.attr('data-add') + ')');
	
	    $li.before('<li class="new"><a href="#">'+items[0]+'</a></li>');
	
	    items.shift();
	
	    if (!items.length) {
	      $li.remove();
	    }
	    else {
	      $this.attr('data-add', JSON.stringify(items));
	    }
	
	    Nav.update(true);
	  });
	
	  // demo settings update
	
	  const update = (settings) => {
	    if (Nav.isOpen()) {
	      Nav.on('close.once', function() {
	        Nav.update(settings);
	        Nav.open();
	      });
	
	      Nav.close();
	    }
	    else {
	      Nav.update(settings);
	    }
	  };
	
	  $('.actions').find('a').on('click', function(e) {
	    e.preventDefault();
	
	    var $this = $(this).addClass('active');
	    var $siblings = $this.parent().siblings().children('a').removeClass('active');
	    var settings = eval('(' + $this.data('demo') + ')');
	
	    update(settings);
	  });
	
	  $('.actions').find('input').on('change', function() {
	    var $this = $(this);
	    var settings = eval('(' + $this.data('demo') + ')');
	
	    if ($this.is(':checked')) {
	      update(settings);
	    }
	    else {
	      var removeData = {};
	      $.each(settings, function(index, value) {
	        removeData[index] = false;
	      });
	
	      update(removeData);
	    }
	  });
	})(jQuery);
	
</script>
<script type="text/javascript">
	// pin code verify
	$('#pin_code').keypress(function(event){
	  if(event.keyCode == 13){
	    pin_verify();
	  }
	});
	
	function pin_verify(){
	        var pin_code = $("#pin_code").val();
	        $.ajax({
	            type: "POST",
	            url: "district.php",
	            data: {
	                pin_code: pin_code
	            },
	            success: function(data) {
	                console.log(data);
	                var obj = JSON.parse(data);
	                // alert(data);
	                if(obj.pin_count == 0){
	                    alert('Sorry We Can not Provide Delivery services this area.');
	                }
	                if(obj.pin_count == 1){
	                    $("#pin_verified").html(obj.pin_code);
	                    $("#pin_verified2").html(obj.pin_code);
	                    alert('Congrats We  Provide Delivery services this area.');
	                    window.location=window.location.href;
	                    $('#pin_modal').modal('toggle');
	                }
	            }
	        });
	    
	}
	
	$('#username').keypress(function(event){
	  if(event.keyCode == 13){
	    login_verify();
	  }
	});
	
	$('#password').keypress(function(event){
	  if(event.keyCode == 13){
	    login_verify();
	  }
	});
	
	// verify data for login user
	function login_verify(){
	        var username = $("#username").val();
	        var password = $("#password").val();
	        $.ajax({
	            type: "POST",
	            url: "<?=base_url('login');?>",
	            data: {
	                cust_email: username,
	                cust_password: password
	            },
	            success: function(data) {
	                console.log(data);
	                var obj = JSON.parse(data);
	                if(obj.log == 0){
	                    $("#error").toggle();
	                    $("#error").html(obj.error);
	                    setTimeout(function(){$("#error").hide();}, 3500);
	                }
	                if(obj.log == 1){
	                    $("#success").toggle();
	                    $("#success").html(obj.succ);
	                    setTimeout(function(){$("#success").hide();}, 3500);
	                    
	                }
	            }
	        });
	    
	}
	
	// register user
	function user_register(){
	        // $(".mobile_number").find("label").html('a');
	        var mobile_number = $("#mobile_number").val();
	        var otp = $("#otp").val();
	        var cust_name = $("#cust_name").val();
	        var cust_email = $("#cust_email").val();
	        var reg_password = $("#reg_password").val();
	        var reg_confirm_password = $("#reg_confirm_password").val();
	        var form2 = $("#form_open").val();
	        
	        if(mobile_number !='' && otp=='' && cust_name=='' && cust_email=='' && reg_password=='' && reg_confirm_password==''  && form2=='1'){
	            var form = 1;
	        $.ajax({
	            type: "POST",
	            url: "<?=base_url('Register');?>",
	            data: {
	                mobile_number: mobile_number,
	                form: form
	            },
	            success: function(data) {
	                console.log(data);
	                var obj = JSON.parse(data);
	                if(obj.log == 0){
	                    $("#error").toggle();
	                    $("#error").html(obj.error);
	                    setTimeout(function(){$("#error").hide();}, 3500);
	                }
	                if(obj.log == 1){
	                    $("#success").toggle();
	                    // alert(obj.succ);
	                    $("#success").html('OTP is Sent On Your Mobile Number.');
	                    $("#form_open").val(obj.form);
	                    $(".mobile_number").hide();
	                    $("#register_head").html("Verify OTP!!");
	                    $("#button_reg").html("Verify OTP!!");
	                    $(".resend_otp").show();
	                    $(".otp").show();
	                    setTimeout(function(){$("#success").hide();}, 3500);
	                    
	                }
	            }
	        });
	        }
	         
	        if(mobile_number !='' && otp!='' && cust_name=='' && cust_email=='' && reg_password=='' && reg_confirm_password==''  && '2'==form2){
	            var form = 2;
	        $.ajax({
	            type: "POST",
	            url: "<?=base_url('register');?>",
	            data: {
	                mobile_number: mobile_number,
	                otp: otp,
	                form: form
	            },
	            success: function(data) {
	                console.log(data);
	                var obj = JSON.parse(data);
	                if(obj.log == 0){
	                    $("#error").toggle();
	                    $("#error").html(obj.error);
	                    setTimeout(function(){$("#error").hide();}, 3500);
	                }
	                if(obj.log == 1){
	                    $("#success").toggle();
	                    $("#success").html(obj.succ);
	                    $(".mobile_number").hide();
	                    $(".otp").hide();
	                    $("#register_head").html('Enter Your Name Email && Password!!');
	                    $("#button_reg").html("Create Account!!");
	                    $("#form_open").val(obj.form);
	                    $(".cust_name").show();
	                    $(".cust_email").show();
	                    $(".reg_password").show();
	                    $(".reg_confirm_password").show();
	                    $(".resend_otp").hide();
	                    setTimeout(function(){$("#success").hide();}, 3500);
	                    
	                    
	                }
	            }
	        });
	        }
	        
	        
	        if(mobile_number !='' && otp!='' && cust_name!='' && cust_email!='' && reg_password!='' && reg_confirm_password!='' && '3'==form2){
	            var form = 3;
	        $.ajax({
	            type: "POST",
	            url: "<?=base_url('register');?>",
	            data: {
	                mobile_number: mobile_number,
	                otp: otp,
	                cust_name: cust_name,
	                cust_email: cust_email,
	                reg_password: reg_password,
	                reg_confirm_password: reg_confirm_password,
	                form: form
	            },
	            success: function(data) {
	                console.log(data);
	                var obj = JSON.parse(data);
	                if(obj.log == 0){
	                    $("#error").toggle();
	                    $("#error").html(obj.error);
	                    setTimeout(function(){$("#error").hide();}, 3500);
	                }
	                if(obj.log == 1){
	                    $("#success").toggle();
	                    $("#form_open").val(obj.form);
	                    $("#success").html(obj.succ);
	                    $(".otp").hide();
	                    setTimeout(function(){$("#success").hide();}, 3500);
	                    
	                }
	            }
	        });
	        }
	
	        
	    
	}
	        
	        
	    function resend_otp(){
	        
	        var mobile_number = $("#mobile_number").val();
	        var form = $("#form_open").val();
	                    $.ajax({
	            type: "POST",
	            url: "<?=base_url('register');?>",
	            data: {
	                mobile_number: mobile_number,
	                form: form
	            },
	            success: function(data) {
	                console.log(data);
	                var obj = JSON.parse(data);
	                if(obj.log == 0){
	                    $("#error").toggle();
	                    $("#error").html(obj.error);
	                    setTimeout(function(){$("#error").hide();}, 3500);
	                }
	                if(obj.log == 1){
	                    $("#success").toggle();
	                    // alert(obj.succ);
	                    $("#success").html('OTP is Resend Successfully.');
	                    $("#form_open").val('2');
	                    $("#register_head").html("Verify OTP!!");
	                    $("#button_reg").html("Verify OTP!!");
	                    setTimeout(function(){$("#success").hide();}, 3500);
	                    
	                }
	            }
	        });
	
	    } 
	
	
	$(document).ready(function(){
	    // $(".mobile_number").hide();
	    $(".otp").hide();
	    $(".cust_name").hide();
	    $(".cust_email").hide();
	    $(".reg_password").hide();
	    $(".reg_confirm_password").hide();
	    $(".resend_otp").hide();
	    
	    
	    $("#mobile_number").keyup(function(){
	        var mobile_number = $("#mobile_number").val();
	        if(mobile_number.length>10){
	            $("#mobile_number").val('');
	        }
	        
	        if(mobile_number.length<10){
	            $("#mobile_number").css('border','1px solid red');
	        }
	        if(mobile_number.length==10){
	            $("#mobile_number").css('border','1px solid #ccc');
	        }
	    });
	    
	    $("#otp").keyup(function(){
	        var otp = $("#otp").val();
	        if(otp.length>6){
	            $("#otp").val('');
	        }
	        if(otp.length<6){
	            $("#otp").css('border','1px solid red');
	        }
	        if(otp.length==6){
	            $("#otp").css('border','1px solid #ccc');
	        }
	    });
	    
	    
	});
	

	function block() {
	    $('#closes').css('display', 'none');
	}
	
	var timeout = setTimeout(reloadChat, 10000);
	function reloadChat() {
	    $('#closes').css('display', 'none');
	    timeout = setTimeout(reloadChat, 10000);
	}
</script>

<!-- Bootstrap core JavaScript -->
<script src="<?=base_url('site_assets/');?>vendor/bootstrap/js/bootstrap.bundle.min.js"></script>
<!-- select2 Js -->
<script src="<?=base_url('site_assets/');?>vendor/select2/js/select2.min.js"></script>
<!-- Owl Carousel -->
<script src="<?=base_url('site_assets/');?>vendor/owl-carousel/owl.carousel.js"></script>
<!-- Custom -->
<script src="<?=base_url('site_assets/');?>js/custom.js"></script>
<!-- Data Tables -->
<link href="<?=base_url('site_assets/');?>vendor/datatables/datatables.min.css" rel="stylesheet" />
<script src="<?=base_url('site_assets/');?>vendor/datatables/datatables.min.js"></script>
<script>
	$(document).ready(function() {
	    $('.datatabel').DataTable();
	} );
</script>
<script>
	function readURL(input) {
	    if (input.files && input.files[0]) {
	        var reader = new FileReader();
	        
	        reader.onload = function (e) {
	            $('#blah').attr('src', e.target.result);
	        };
	        
	        reader.readAsDataURL(input.files[0]);
	        
	        input.form.submit();
	    
	    }
	}
	
</script>
<!--cart items-->
<div id="carts">
	<div class="cart-sidebar ">
		<div class="cart-sidebar-header">
			<h5>
				My Cart <span class="text-success">(<small class="cart-value2" id="cart_quantity4">0</small> item)</span>
				<a  class="float-right" href="#"><i class="mdi mdi-close" onclick="$('body').toggleClass('toggled')"></i></a>
			</h5>
		</div>
		<input id='sonu' type="hidden" value="0">  
			
	
	
<div class ="cart-sidebar-body" id="cart_view"></div>

   <div class ="cart-sidebar-footer cart-sidebar-footer2">
            <a  <?php if(!isset($_SESSION['customer'])){?>href="javascript:void(0);" onclick='Swal.fire({title: "Alert!",html: "Please Login To Continue.",type: "warning",showConfirmButton: true,timer: 5000 });'  data-target="#bd-example-modal"  data-toggle="modal" <?php }else{?> href="<?=base_url('checkout');?>" <?php }?>>
                <button class="btn btn-secondary btn-lg btn-block text-left" type="button">
                    <span class="float-left">
                        <i class="mdi mdi-cart-outline"></i> Proceed to Checkout 
                    </span>
                        <strong>₹  <b id="to_pays"></b></strong>
                        <span class="mdi mdi-chevron-right"></span>
                    </span>
                </button>
            </a>
         </div>			
	</div>
</div>
<!--cart-->
</body>
</html>



<?php
require("localstorage.php"); ?>





<script>

    
    
 viewProduct();   
 function viewProduct()
 {
  
let Products_cart = JSON.parse(localStorage.getItem('products'));
	var myObj, i, j, x, space = "";
	sub_total = 0;
	x='';
    j=j-1;
	for (j in Products_cart) {
	   
	   if (j != 'undefined') {
			var img = Products_cart[j].image;
			var p_name = Products_cart[j].cart_p_name;
			var c_price = Products_cart[j].cart_p_current_price;
			var o_price = Products_cart[j].cart_p_old_price;
			var size_id = Products_cart[j].cart_size_id;
			var size_name = Products_cart[j].cart_size_name;
			var p_id = Products_cart[j].cart_p_id;
			var p_name = Products_cart[j].cart_p_name;
			var cart_p_qty = Products_cart[j].cart_p_qty;
            //var tot +=cart_p_qty*c_price;
			var a = ((o_price - c_price) / o_price) * 100;
			var off = a.toFixed();
			
	        a='<div class="cart-list-product" id="hidem_1">';
            b='<div class="row"><div class="col-4"><img class="img-fluid" src="<?php echo base_url(); ?>uploads/shop/product/' + img + '" ></div>';
            c='<div class="col-8"><span class="badge badge-success">' + off + '% OFF</span> <button class="btn btn-danger btn-sm btn-xs float-right mr-4" onclick="removeItem('
                +p_id+','+p_id+size_id+','+size_id+
                ')"> X </button>';
            e='<div class="mb-0 font-25" ><a href="#"><b style="font-size:12px;">' + p_name + '</b></a></div>';
            f='<p class="offer-price mb-10"><span style="font-size: 12px;color:#ff5246;">'+size_name+'</span> &nbsp; <span>₹' + c_price + '</span>';
            g='&nbsp;&nbsp;<del class="text-red-50 font-weight-normal">₹' + o_price + '</del>';
            n='<br><span>Total ₹' + c_price*cart_p_qty + '</span>';
            i='<div style="width:60%;float:left;" class="input-group input-spinner ml-auto cart-items-number">';
            
			j='<div class="input-group-prepend"><button class="btn btn-success btn-sm" type="button" id="button-plus" onclick="plus(' +p_id + ',' + p_id + size_id +')"> + </button></div>';
			
			k='<input type="text" class="form-control text-center" id="qty_' +p_id + size_id +'" qty="' + p_id + size_id +'" readonly value="'+cart_p_qty+'">';
			
			l='<div class="input-group-append"><button class="btn btn-success btn-sm" type="button" id="button-minus" onclick="minus(' +p_id + ',' + p_id + size_id + ',' + size_id +')"> − </button></div></div></div></div></div>';
		
            
            x +=a+b+c+e+f+g+n+i+j+k+l;
		
	   }
	}


  if(x!=='') { document.getElementById("cart_view").innerHTML=x;}


document.getElementById("to_pays").innerHTML=getsubtotalprice(1).toFixed(2);

$("#cart_quantity5").html(localStorage.getItem("cart"));
$("#cart_quantity6").html(localStorage.getItem("cart"));
$("#cart_quantity3").html(localStorage.getItem("cart"));
$("#cart_quantity4").html(localStorage.getItem("cart"));


var d='<div class="col-12"><img src="<?=base_url('uploads/empty-cart.png');?>" class="img-fluid" /></div><div class="col-12 text-center"><b>Cart Is Empty</b></div>';        $("#cart_quantity2").html('0');
       
 var i = localStorage.getItem("cart");
 
    if(i==null || i=='' || i==0){
        
         $("#cart_quantity5").html('0');
        $("#cart_quantity6").html('0');
        $("#cart_quantity3").html('0');
         $("#cart_quantity4").html('0');
       document.getElementById("cart_view").innerHTML=d;
    }
  
    
    
    
}
  
    
    
    
    
    

</script>
<!--end-->
<script>
/*$(document).ready(function() {
    $("img").attr('onerror','imgError(this);');
});
function imgError(image) {
    image.onerror = "";
    image.src = "<?=base_url('uploads/no-image.png');?>";
    return true;
}*/
</script>


<!-- Modal for sizes -->
<div class="modal fade login-modal-main" id="sizeModal">
	<div class="modal-dialog modal-md modal-dialog-centered" role="document">
		<div class="modal-content">
			<div class="modal-header">
				<h6 class="modal-title">Available Quantities for <b id="av_pname"></b></h6>
				<button type="button" class="close close-top-right" data-dismiss="modal" aria-label="Close">
				<span aria-hidden="true"><i class="mdi mdi-close"></i></span>
				<span class="sr-only">Close</span>
				</button>
			</div>
			<div class="modal-body">
				<div id="loop" class="text-center"></div>
			</div>
		</div>
	</div>
</div>
<script>
	function check_size(pid){
	    $('#sizeModal').modal('show');
	    var av_p_name = $('#p_name_'+pid).val();
	    $('#av_pname').html(av_p_name);
	    
	         $.ajax({
	            type: "POST",
	            url: "<?=base_url('Functions/size');?>",
	            data:{id: pid},
	            success: function(data){
	                $('#loop').html(data);
	            }
	         });
	    
	}
</script>
<script>
	function get_img(pid){
	    // url:size_other_img.php;
	}
</script>

<script>
$(document).ready(function() {

	$('[id^=hide_A]').css('display', 'none');
	$('[id^=hide_B]').css('display', 'none');

	var numItems = $('.form_value').length;
	for (i = 0; i < numItems; i++) {

		var id = parseInt($('.form_value').eq(i).attr('id2'));
		var size = $('#size_' + id).val();
		if (size) {

			var size_array = size.split(",");
			var size_id = size_array[0];
			var primaryid = id +''+ size_id;
			var size_name = size_array[4];
			var p_old_price = size_array[1];
			var p_current_price = size_array[2];
			var p_qty = size_array[3];
			
			$('#price_c_' + id).html(p_current_price);
			$('#p_current_price_' + id).val(p_current_price);
			$('#size_id_' + id).val(size_id);
			$('#size_name_' + id).val(size_name);

			$('#qty_' + id).attr('qty', parseInt(p_qty));
			$('#qty2_' + id).attr('qty', parseInt(p_qty));
			$('#price_o_' + id).html(p_old_price);
			$('#p_old_price_' + id).val(p_old_price);
			var a = ((p_old_price - p_current_price) / p_old_price) * 100;
			var off = a.toFixed();
			$('#offer_' + id).html(off + ' % off');

			var x = localStorage.getItem("cart");
			if (x == null) {
				var product_add = false;
				var x = 1;
			} else {
				// checking product in cart
				var product_add, p_qty = '';
				product_add = getval(primaryid);

				// $("#cart_quantity").html(parseInt(localStorage.getItem("cart")));
				// $("#cart_quantity2").html(parseInt(localStorage.getItem("cart")));
				$("#cart_quantity3").html(parseInt(localStorage.getItem("cart")));


			}

			if (product_add == true) {
				p_qty = getval2(primaryid);
				$('#qty_' + primaryid).val(parseInt(p_qty));
				$('#hide_A' + primaryid).css('display', 'flex');
			} else if (product_add == false) {
				$('#hide_B' + primaryid).css('display', 'inline-flex');
			}

		}
	}
});
</script>
<script>
// 		validating number entry			    
    function isNumberKey(evt){ 
    var charCode = (evt.which) ? evt.which : event.keyCode 
    if (charCode > 31 && (charCode < 48 || charCode > 57)) 
        return false; 
    return true; 
} 
</script>
<!--sizes end-->
<!-- Sweet Alerts js -->
<script src="<?= base_url();?>assets/libs/sweetalert2/sweetalert2.min.js"></script>
<!-- Sweet alert init js-->
<script src="<?= base_url();?>assets/js/pages/sweet-alerts.init.js"></script>
<?php 
	$message = $this->session->flashdata('error');
	if (isset($message)) {
	    ?>
<script>                              
	Swal.fire({title: "Alert!",html: '<?=$message;?><br>',type: "warning",showConfirmButton: true,timer: 5000 })
</script>
<?php
	}
	
	$success = $this->session->flashdata('success');
	if (isset($success)) {
	    ?>
<script>                              
	Swal.fire({
	title: "SUCCESS!",
	html: '<?=$success;?><br>',
	type: "success",
	showConfirmButton: true,
	timer: 5000
	})
</script> 
<?php
	}
	?>