<?php
include("config.php");
error_reporting(0);
include("include/functions.php");
	if($_REQUEST['command']=='delete' && $_REQUEST['pid']>0){
		remove_product($_REQUEST['pid']);}
	else if($_REQUEST['command']=='clear'){
		unset($_SESSION['cart']);}
	else if($_REQUEST['command']=='update'){
		$max=count($_SESSION['cart']); 
		for($i=0;$i<$max;$i++){
			$pid=$_SESSION['cart'][$i]['productid'];
			$q=intval($_REQUEST['product'.$pid]);
			 
			 $sett=mysql_query("select * from products where serial='$pid'");
			 $fett=mysql_fetch_array($sett);
			 $qqqtyy=$fett['quantity']; 
			if($qqqtyy>=$q)
			{
				$_SESSION['cart'][$i]['qty']=$q;
				?><script>window.location="shoppingcart.php?yes=yes";</script><?
			} else {
				?><script>window.location="shoppingcart.php?no=no";</script><?
			}}}
?>
<!DOCTYPE HTML>
<html>
	<head>
		<title><?php echo $tittle;?></title>
		<link href="css/style.css" rel='stylesheet' type='text/css' />
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<script type="application/x-javascript">
		addEventListener("load", function() { setTimeout(hideURLbar, 0); }, false); function hideURLbar(){ window.scrollTo(0,1); } </script>
		</script>
		<link href='http://fonts.googleapis.com/css?family=Open+Sans:400,300,600,700,800' rel='stylesheet' type='text/css'>
		<script src="js/jquery.min.js"></script>
		<script type="text/javascript" src="js/jquery.easy-ticker.js"></script>
		<script type="text/javascript">
		$(document).ready(function(){
			$('#demo').hide();
			$('.vticker').easyTicker();});
		</script>
		<link href="css/megamenu.css" rel="stylesheet" type="text/css" media="all" />
		<script type="text/javascript" src="js/megamenu.js"></script>
		<script>$(document).ready(function(){$(".megamenu").megamenu();});</script>
		<script src="js/menu_jquery.js"></script>
		<link rel="stylesheet" href="css/slippry.css">
		<script src="js/jquery-ui.js" type="text/javascript"></script>
		<script src="js/scripts-f0e4e0c2.js" type="text/javascript"></script>
		<script>
			  jQuery('#jquery-demo').slippry({
			  slippryWrapper: '<div class="sy-box jquery-demo" />', // wrapper to wrap everything, including pager
			  adaptiveHeight: false, // height of the sliders adapts to current slide
			  useCSS: false, // true, false -> fallback to js if no browser support
			  autoHover: false,
			  transition: 'fade'
			});
		</script>
		<script type="text/javascript" src="js/jquery-ui.min.js"></script>
		<link rel="stylesheet" type="text/css" href="css/jquery-ui.css">
		<script type="text/javascript" src="js/move-top.js"></script>
		<script type="text/javascript" src="js/easing.js"></script>
		<script type="text/javascript">
			jQuery(document).ready(function($) {
				$(".scroll").click(function(event){		
					event.preventDefault();
					$('html,body').animate({scrollTop:$(this.hash).offset().top},1200);
				});
			});
		</script>
        <script type="text/javascript">
  $(document).ready(function($){
    $('#dc_mega-menu-orange').dcMegaMenu({rowItems:'4',speed:'fast',effect:'fade'});
  });
</script>

<script language="javascript">
	function del(pid){
		if(confirm('Do you really mean to delete this item')){
			document.form1.pid.value=pid;
			document.form1.command.value='delete';
			document.form1.submit();
		}
	}
	function clear_cart(){
		if(confirm('This will empty your shopping cart, continue?')){
			document.form1.command.value='clear';
			document.form1.submit();
		}
	}
	function update_cart(){
		document.form1.command.value='update';
		document.form1.submit();
	}
</script>

	</head>
	<body>
		<!---start-wrap---->
			<!---start-header---->
			<?php include("include/header.php"); ?>
            <!---//End-header---->
		<!----start-image-slider---->
		
		<div class="clear"> </div>
		<!----//End-image-slider---->
		<!----start-price-rage--->
		<div class="wrap">
			
		</div>
		<!----//End-price-rage--->
		<!--- start-content---->
		<div class="content">
			<div class="wrap">
				<div class="content-left">
						<div class="content-left-top-grid">
							<div class="content-left-price-selection">
								
						</div>
						</div>
						<?php // include("include/left.php"); ?>
				</div>
				<div class="content-right">
                <?php
				if($_REQUEST['yes']!=NULL){
				?>
                <div style="color:#090;font-weight:bold; margin-left:50px;">Quantity has been updated successfully</div>
                <?php } if($_REQUEST['no']!=NULL){?>
                <div style="color:#F00; margin-left:50px;">Unavailable quantity you have Entered.</div>
                <?php } ?>
                
					<div class="product-grids">
						<!--- start-rate---->
						

    <div class="main">
		<div class="container">
		   
		   <div class="row content">
		   <div class="col-md-3 content_top">
		   	
            
            
		   	<div class="col-md-9" style=" margin-top:-50px; margin-left:-140px;">
		   	   <ul class="feature">
		   	   	 <h1>SELECTED PRODUCTS</h1>
		   	   </ul>
		   	   <ul class="feature_grid">
				 <form name="form1" method="post">
<input type="hidden" name="pid" />
<input type="hidden" name="command" />
	<div style="margin:0px auto; width:900px; margin-left:0px;" >
    <div style="padding-bottom:10px">
    <!--<a href="index.php"><img src="images/contt.jpg" width="150" height="35" title="Continue Shopping"></a>-->
    </div>

    <table width="100%" border="1" cellpadding="9" class="shoppilist">
     
      <tr bgcolor="59ad3e" style="color:#FFF;">
      <td>S.NO</td>
     <!---<th>CAT</th>
      <th>SUB-CAT</th>
      <th>SUB-SUB-CAT</th>-->
      <td>NAME</td>
       <td>IMAGE</td>
      <td>PRICE</td>
      <td>QTY</td>
      <td>AMOUNT</td>
      <td>DELETE</td>
      </tr>
     
          <?php
			if(is_array($_SESSION['cart'])){
            	
				$max=count($_SESSION['cart']);
				for($i=0;$i<$max;$i++){
					$pid=$_SESSION['cart'][$i]['productid'];
					$q=$_SESSION['cart'][$i]['qty'];
					$pname=get_product_name($pid);
					if($q==0) continue;
					$qur="select * from products where `serial` ='$pid' order by serial desc "; 

	              	     $result = mysql_query($qur)or die('Have an error in viewing data'.mysql_error());
		                 while ($row_section = mysql_fetch_array($result)) 
		 	{				$small_jpg= $row_section['small_jpg'];
							 $quantity= $row_section['quantity'];
			?>
       
      
        <tr>
          <td><?php echo $i+1?></td>
          <!---<th><?php echo $row_section['category'];?></th>
          <th><?php echo $row_section['sub_category'];?></th>
          <th><?php echo $row_section['sub_sub_cat'];?></th>--->
          <td><?php echo $pname?></td>
          <td><img src="CryoM@dmin/<?php echo $small_jpg; ?>" width="200"></td>
          <td><?php echo get_price($pid)?></td>
          <td><a href="#" alt="Available Stock <?php echo $quantity; ?>" class="tool">
          <input type="text" name="product<?php echo $pid; ?>" value="<?php echo $q?>" maxlength="3" size="2" /></a></td>
          <td><?php echo number_format(get_price($pid)*$q,2)?></td>
          <td>
          <a href="javascript:del(<?php echo $pid?>)"><img src="images/remove.jpg" width="50" title="Remove Your cart"></a>
          </td>
        </tr>
        <?php }} ?>
        <?php } else{
	    echo "<div style='color:#E40F15'>There are no items in your shopping cart!</div>";}?>
      </table>
       
       
       
            <div style="width:400px; margin-top:10px;">
            <font size="+2" style=" color:#00679B;font-weight:bold; font-family:Tahoma, Geneva, sans-serif;">Order Total&nbsp;&nbsp;:&nbsp;&nbsp;<?php echo $corrrency; ?> &nbsp; <?php echo number_format(get_order_total(),2)?></font>
            </div>
            <div style="clear:both;"></div>
            
            <table border="0" st style="margin-top:10px;" align="right" cellpadding="8">
            <tr>
            <td><button onClick="clear_cart()" id="clearcart_butt">Clear Cart</button></td>
            <td><button onClick="update_cart()" id="updatecart_butt">Update Qty</button></td>
            <td> <?php 
 			if($_SESSION['username']!=NULL)
  			{?>
	        <a href="ship_address.php"><div id="CheckOutcart_butt" style="text-align:center;width:90px;">Check Out</div></a>
  			<?php } else{?>
 		    <a href="login.php"><div id="CheckOutcart_butt" style="text-align:center;width:90px;">Check Out</div></a>
  			<?php } 	?></td>
            </tr>
            </table>
            
    </div>
    </div>
</form>
		   	   </ul>
		   	   
</div>
</div>		    
 </div>
       			</div>
       			<div class="clear"> </div>
       		</div>
			</div>
			</div>
			<div class="clear"> </div>
			</div>
		</div>
        </div>
		<?php include("include/footer.php"); ?>
        
        
       <style type="text/css">
.shoppilist{font-family:Tahoma, Geneva, sans-serif; color:#000;}
.shoppilist td {border: 1px solid black;}
#clearcart_butt{background:#F00;width:90px;padding:10px;border:0px;color:#FFF;font-size:16px;cursor:pointer;border-radius:10px 6px;font-family:Tahoma, Geneva, sans-serif;}
#updatecart_butt{background:#090;padding:10px;width:120px;border:0px;color:#FFF;font-size:16px;cursor:pointer;border-radius:10px 6px;font-family:Tahoma, Geneva, sans-serif;}
#CheckOutcart_butt{background:#FC3;padding:10px;width:120px;border:0px;color:#000;font-size:16px;cursor:pointer;border-radius:10px 6px;font-family:Tahoma, Geneva, sans-serif;}


  .tool
        {
            display: inline;
            position: relative;
            text-decoration: none;
            top: 0px;
            left: 4px;
        }
        .tool:hover:after
        {
            background: #333;
            background: rgba(0,0,0,.8);
            border-radius: 5px;
            top: -5px;
            color: #fff;
            content: attr(alt);
            left: 50px;
            padding: 5px 15px;
            position: absolute;
            z-index: 98;
            width: 150px;
        }
        .tool:hover:before
        {
            border: solid;
            border-color: transparent black;
            border-width: 6px 6px 6px 0;
            bottom: 20px;
            content: "";
            left: 45px;
            position: absolute;
            z-index: 99;
            top: 3px;
        }
</style>