
   <div class="row">
   
	 <div class="table-responsive">
		
<div class="panel panel-default" data-collapsed="0">
        	
			<div class="panel-body">
		
  
     <div class="col-md-4">
	 
	<div class="post-info">
					 <?php
if(!isset($_SESSION)){
    session_start();
}

$status="";
if (isset($_POST['code']) && $_POST['code']!=""){
//$code = $_POST['code'];
//$result = mysqli_query($con,"SELECT * FROM `products` WHERE `code`='$code'");
//$row = mysqli_fetch_assoc($result);
$name = $_POST['name'];
$code = $_POST['code'];
$price = $_POST['price'];
$image = $_POST['image'];
$quantity = $_POST['quantity'];

$cartArray = array(
	$code=>array(
	'name'=>$name,
	'code'=>$code,
	'price'=>$price,
	'quantity'=>$quantity,
	'image'=>$image)
);

if(empty($_SESSION["shopping_cart"])) {
	$_SESSION["shopping_cart"] = $cartArray;
	$status = "<div class='box'>Product is added to your cart!</div>";
						redirect("viewitem?randomitemidentifier=".$itemid);

		return false;	
	
}else{
	$array_keys = array_keys($_SESSION["shopping_cart"]);
	if(in_array($code,$array_keys)) {
		$status = "<div class='box' style='color:red;'>
		Product is already added to your cart!</div>";	
	} else {
	$_SESSION["shopping_cart"] = array_merge($_SESSION["shopping_cart"],$cartArray);
	$status = "<div class='box'>Product is added to your cart!</div>";
		redirect("viewitem?randomitemidentifier=".$itemid);

		return false;	
	}

	}
}




















   
	   //echo $this->input->cookie('customerid');
        

$cookie = array(
 'name' => 'customerid',
 			'domain ' => base_url(), 		   

 'value' => '',
 'expire' => '-2592000',
 );

	
//delete_cookie($cookie);
//delete_cookie("customerid");
					
			
			//	if(!isset($_COOKIE[$cookie_name])) {
    // echo "Cookie named '" . $cookie_name . "' is not set!";
//} else {
  //  echo "Cookie '" . $cookie_name . "' is set!<br>";
   //  echo "Value is: " . $_COOKIE[$cookie_name];
//}
	 
					 
					 
					 
					 ?>
			
					 <?php
					 
	 $products = $this->usermodel->populateallarray('products','code',$viewproducts[0]["code"]);

	 $productcategory = $this->usermodel->populateallarray('productcategory','id',$viewproducts[0]["category"]);


						 $img_id=$products[0]['imgid'];	
						$usr_result= $this->usermodel->populatepostimages($img_id);
						$img1='photoimghod/';
						if($usr_result==FALSE){
						?>
						<a href="#" >
						<img  style="height:300px" src="<?php echo base_url(); ?>images/img/default.jpg"></a>
						<?php
						}else{
						$img=$usr_result[0]->name;
						$url = base_url().$img1.$img;
						 ?>
						<a href="#" ><img src="<?php echo $url ?>" style="height:300px" ></a>         
						<?PHP
						}
						?>

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

		
	

<p class="text-center">





<h1><b>More details of the item/product selected</b></h1>
</br>
	<h1><?php echo"Product/Item Name: ". $products[0]["name"];
	if($products[0]["description"]!=""){
			echo "-".$products[0]["description"];

	}
	

	?></br>
	<?php echo "Category: " .$productcategory[0]["name"]; ?></br>
								
								<span><a href="#" style="color:black"><?php echo "Price :". $currencysymbol." ". $products[0]["sellingprice"]; ?></a></span>
				        				
	</h1>	
			 					  <form method='post' action=''>

  <input type='hidden' name='code' value="<?php echo set_value('code',$products[0]["code"]); ?>" />
  <input type='hidden' name='price' value="<?php echo set_value('sellingprice',$products[0]["sellingprice"]); ?>" />
    <input type='hidden' name='name' value="<?php echo set_value('name',$products[0]["name"]); ?>" />
	    <input type='hidden' name='image' value="<?php echo set_value('name',$img_id); ?>" />
	    <input type='hidden' name='quantity' value="<?php echo set_value('quantity',1); ?>" />




			 <a  id="more" href="<?php echo base_url();echo    $page; ?>" class="btn btn-primary" >
Go back to products </a>	


	
</p>



</div>



		<?php echo form_close();?>
		
	
			
</div>		
</div>	
</div>

	
	

</div>