<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<?php 
include('../include/session.php');
	
				  
		$subCat = $_GET['subCatSelect'];
								
		$subCatText = $subCat;	
		$table_name2 = $_SESSION['db_prefix']."_store_items"; 
		
		$tip_reserved_text='';
		$reservedTT='';		 
		if ($subCat=="Complete") {
		$items_query = "SELECT * FROM $table_name2 WHERE category!='Old' ORDER BY item_name ASC";	
		}
		else
		 {
		$items_query = "SELECT * FROM $table_name2 WHERE subCategory = '".$subCatText."' ORDER BY item_name ASC";
		}
		
		if ($subCat=="Old") {
		$items_query = "SELECT * FROM $table_name2 WHERE category='Old' ORDER BY item_name ASC";	
		}
		
		$items_result = execsql($items_query);
    	$items_num = mysql_num_rows($items_result);
		
		    	
?>
<!--style sheets-->
<link rel="stylesheet" type="text/css" href="../css/tooltip.css" />
<link rel="stylesheet" type="text/css" href="../css/scroll_table.css" />
<link href="../css/main.css" rel="stylesheet" type="text/css">

</head>

<body>
<?php
include ("../navigation/header.php");
$page_name = "Stores-main";
include ("../navigation/access.php");
if ($permission_num==1) {
	 include ("../navigation/store_sidebar.php");
	 ?>
<div class="main_frame">
 
  <div class="page_head_frame">
    <label class="label_page_head">Cost Store Items List <?php echo $subCatText ?></label>
  </div>
 

<div class="page_inside_frame">
<!--jscript-->
<script language="JavaScript" src="../jscript/tooltip.js"  type="text/javascript"></script>
<script type="text/javascript" language="javascript" src="../jscript/jquery.dataTables.js"></script> 
<script type="text/javascript" charset="utf-8">
			$(document).ready(function() {
				$('#scroll_table_1').dataTable( {
					"sScrollY": "410px",
					"bPaginate": false,
					"bScrollCollapse": true,
					"aaSorting": [[ 0, "asc" ]],
					"aoColumns": [
								{"bSortable": true},
								{"bSortable": true},
								{"bSortable": true},
								{"bSortable": true},
                             	{"bSortable": true},
								{"bSortable": true}
								
								 ]
				} );
			} );
		</script>
  <table width="655" id="scroll_table_1" class="data_display">
      <thead>
        <tr>
          <th>Product Name</th>
          <th width="106">Group</th>
          <th width="76">Stock<br>qty</th>
          <th width="56">Unit</th>
          <th width="66">Price</th>
          <th width="112">Total</th>
        </tr>
      </thead>
      <tbody>
        <?php 
    $i=0;
	$b12tot=0;
    while($i < $items_num){
	       $b1 = mysql_result($items_result, $i, "store_item_id");
	       $b2 = mysql_result($items_result, $i, "item_name");
	       $b3 = mysql_result($items_result, $i, "location");
		   $b4 = mysql_result($items_result, $i, "subCategory");
	       $b5 = mysql_result($items_result, $i, "quantity");
	       $b6 = mysql_result($items_result, $i, "minimumStock");
	       $b7 = mysql_result($items_result, $i, "maximumStock");
		   $b8 = mysql_result($items_result, $i, "price");
		   $b9 = mysql_result($items_result, $i, "supplier_id");
		   $b10 = mysql_result($items_result, $i, "unit");
		   
		   
		   	$b12=$b5*$b8;	
			$b12tot= $b12tot + $b12;
			   
		     
			$itemTT = "<table id=table_tool_tip width=250 ><tr><td  width=75>Item name:</td><td width=175>".$b2."</td></tr><tr><td>Group</td><td>".$b4."</td></tr><tr><td>Location:</td><td>".$b3."</td></tr><tr><td>Min. stock</td><td>".$b6."</td></tr><tr><td>Max. stock</td><td>".$b7."</td></tr></table><br><b>Click for details</b>";
			
			
		      
    ?>
        <tr class="alt">
          <td width="211" align="left"><a href="store_item_display.php?store_item_id=<?php echo $b1 ?> " onMouseover="ddrivetip('<?php echo $itemTT ?>', 260)"; onMouseout="hideddrivetip()"><?php echo $b2 ?></a></td>
          <td align="left"><?php echo $b4 ?>&nbsp;</td>
          <td align="center"><?php if ($b10!='no') {echo number_format($b5, 2, '.', ',');} else { echo number_format($b5); }?></td>
          <td align="center"><?php echo $b10 ?>&nbsp;</td>
          <td align="right"><?php echo number_format($b8, 2, '.', ',') ?></td>
          <td align="right"><?php echo number_format($b12, 2, '.', ',') ?></td>
        </tr>
         <?php 
		$i++;
    	}
    	?>
        <tfoot>
        <tr >
          <td colspan="5" align="right">All total:&nbsp;&nbsp;</td>
          <td align="right"><?php echo number_format($b12tot, 2, '.', ',') ?>&nbsp;</td>
        </tr>
        </tfoot>
       
      </tbody>
    </table>
  </div>  
  </div>
</div>
</body>
<?php } else { 
    $_SESSION['denied_return'] = "store/store_main.php";	?>
<body onLoad="accessdenied(); return false">
</body>
<?php }
?>
<?php include ('../navigation/side_bar.php'); ?>
