<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<?php
$_SESSION['current_page']  = "production";
include ("../navigation/header.php");
$page_name = "Stores-main";
include ("../navigation/access.php");

if ($permission_num==1) {
	include ("../navigation/store_sidebar.php");
?>

<!--style sheets-->
<!--reference to main.css removed-->
<link rel="stylesheet" type="text/css" href="../css/tooltip.css" />

<script language="JavaScript" src="../jscript/tooltip.js"  type="text/javascript"></script>  
</head>

<body>
<?php 

$product_item_id = $_GET['product_item_id'];
$table_name = $_SESSION['db_prefix']."_product_store";
$item_query = "SELECT * FROM $table_name WHERE product_item_id ='".$product_item_id."'";
$item_result = $con->query($item_query);
while($row = $item_result->fetch_assoc()) {
	$f1=$row["item_name"];
	$f2=$row["supplier_id"];
	$f3=$row["category"];
	$f4=$row["subCategory"];
	$f5=$row["unit"];
	$f6=$row["returnable"];
	$f7=$row["quantity"];
	$f8=$row["price"];
	$f10=$row["date"];
	$f11=$row["product_item_id"];
	$f12=$row["location"];
	$f13=$row["minimumStock"];
	$f14=$row["productSpecs"];
	$f15=$row["purchase_price"];
	
}
		
	$table_name2 = $_SESSION['db_prefix']."_suppliers";
	if($f2!=0) {
    $suppliers_query = "SELECT account_name, post_address, post_place, phone, contact1, cell1 FROM $table_name2 WHERE supplier_id = '".$f2."' ";
	$suppliers_result = $con->query($suppliers_query);
    $suppliers_num = mysqli_num_rows($suppliers_result);
	if ($suppliers_num!=0) {
	   while($row = $suppliers_result->fetch_assoc()) {
       $a1 = $row["account_name"];
	   $a2 = $row["post_address"];
	   $a3 = $row["post_place"];
	   $a4 = $row["phone"];
	   $a5 = $row["contact1"];
	   $a6 = $row["cell1"];
	   }
	}
	else {
		$a1='';
		$a2='';
		$a3='';
		$a4='';
		$a5='';
		$a6='';
	}
	}
	else {
		$a1='';
		$a2='';
		$a3='';
		$a4='';
		$a5='';
		$a6='';
	}
	
	
	$supplierTT =
		   "<table id=table_tool_tip width=250 ><tr><td  width=75>Name:</td><td width=175>".$a1."</td></tr><tr><td>Address:</td><td>".$a2."</td></tr><tr><td></td><td>".$a3."</td></tr><tr><td>Contact:</td><td>".$a5."</td></tr><tr><td>Phone:</td><td>".$a4."</td></tr><tr><td>Cell:</td><td>".$a6."</td></tr></table><br><b>Click for details</b>";
		   

?>
<!--reference to main.css removed-->

 
<div class="main_frame">
<div class="page_head_frame">
	<label class="label_page_head">Store Item Details</label>
    &nbsp;&nbsp;&nbsp;&nbsp;
<label class="label_page_head_2"><?php echo $f1 ?></label>
  </div>
<table width="700" align="left" id="tableMain"> <!--begin of tableMain-->
    <tr>
      <td valign="top" ><br />
        <br />


<div class="page_middle_frame">
<table width="649" align="left"  id="table_display">
      <tr>
        <td width="137">Item Name:</td>
        <td colspan="3">
          <a href="product_item_history.php?product_item_id=<?php echo $product_item_id ?>&date=0" onMouseover="ddrivetip('<?php           
			$table_name3 = $_SESSION['db_prefix']."_product_history";
			$history_query = "SELECT entry, quantity, total, date FROM $table_name3 WHERE product_item_id = '".$product_item_id."' ORDER BY history_id DESC LIMIT 10";
			$history_result = $con->query($history_query);
		?><b>Recent history:</b><br><br><table id=table_tool_tip width=250 border=1 cellspacing=0 cellpadding=0><tr><td width=75>date</td><td width=75>action</td><td width=50>qty</td><td width=50>stock qty</td></tr><?php
            $h2="0";
			$h2a="";
			while($row = $history_result->fetch_assoc()) {
				$h1 = $row["date"];
		  		$h2 = $row["entry"];
				
		  		if ($h2=="5") {$h2a='stock count';}
		  		if ($h2=="10") {$h2a='new';}
		 		if ($h2=="20") {$h2a='received';}
		  		if ($h2=="30") {$h2a='delivered';}
		  		$h3 = $row["quantity"];
		  		$h4 = $row["total"];
			
         ?><tr><td><?php echo date("d-m-Y", strtotime($h1)) ?></td><td><?php echo $h2a ?></td><td><?php echo $h3 ?></td><td><?php echo $h4 ?></td><?php }?></tr></table><br><b>Click for full history</b>', 260)"; onMouseout="hideddrivetip()"><?php echo $f1; ?>
        </a>  
        </td>
        </tr>
      <tr>
        <td>Location:</td>
        <td width="223">
          <?php echo $f12?>
          </td>
        <td width="126">Suppliers Name:</td>
        <td width="143"><a href="displaySupplier.php?supplier_id=<?php echo $f2 ?>" onMouseover="ddrivetip('<?php echo $supplierTT ?>', 200)"; onMouseout="hideddrivetip()"><?php echo $a1; ?></a></td>
      </tr>
      <tr>
        <td>Category:</td>
        <td><a href="store_items_list.php?subCatSelect=<?php echo $f4;?>" onMouseOver="ddrivetip('Click to see stores list for <?php echo $f4;?>', 200)"; onMouseOut="hideddrivetip()"><?php echo $f3;?></a></td>
        <td>Sub category:</td>
        <td><a href="store_items_list.php?subCatSelect=<?php echo $f4;?>" onMouseOver="ddrivetip('Click to see stores list for <?php echo $f4;?>', 200)"; onMouseOut="hideddrivetip()"><?php echo $f4;?></a></td>
      </tr>
      <tr>
        <td>Unit:</td>
        <td><?php echo $f5; ?></td>
        <td>Returnable:</td>
        <td><?php echo $f6; ?></td>
      </tr>
      <tr>
        <td>Quantity in stock: </td>
        <td><?php echo number_format($f7); ?></td>
        <td>Minimum Stock:</td>
        <td>
        <?=number_format($f13)?>
        </td>
      </tr>
      <tr>
        <td>Price:</td>
        <td><?php echo number_format($f8, 2, '.', ','); ?></td>
        <td>Last purchase price:</td>
        <td><?php echo number_format($f15, 2, '.', ','); ?></td>
      </tr>
      <tr>
        <td>Date added:</td>
        <td><?php echo date("d-m-Y", strtotime($f10 )); ?></td>
        <td>&nbsp;</td>
        <td></td>
      </tr>
      <tr>
        <td>Product specifications</td>
        <td colspan="3"><?php echo $f14; ?></td>
        </tr>
    </table>
    
    <br />
    
    	
</div>




    </td>
</tr>

</table><!--end of tableMain-->


</div>
</body>
<?php } else { ?>
<script> needToConfirm = false; </script>
<?php
$_SESSION['denied_return'] = $_SESSION['location'];	
include ("../navigation/store_sidebar.php");?>
	<body onLoad="accessdenied(); return false">
	</body>
<?php }
?>

<?php include ('../navigation/side_bar.php'); ?>


</html>
