<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<?php 
include ("../navigation/header.php");

$page_name = "Stores-main";
include ("../navigation/access.php");

if ($permission_num==1) {

	 include ("../navigation/store_sidebar.php");
				  
		$subCat = $_GET['sub_cat'];
								
		$subCatText = $subCat;	
		$table_name2 = $_SESSION['db_prefix']."_store_items"; 		 
		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 = '".$subCat."'  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);
    	$i = 0;
    	$items_num = mysql_num_rows($items_result);
		
		if ($items_num==0) {
		  $message="No records to show";
		  }
		else {
		  $message="End of list";
		  }
?>
<!--style sheets-->
<!--reference to main.css removed-->
<link rel="stylesheet" type="text/css" href="../css/tooltip.css" />
<link href="../css/main.css" rel="stylesheet" type="text/css">
<link rel="stylesheet" type="text/css" href="../css/scroll_table.css" />

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

</head>

<body>
<div class="main_frame">
  <!--reference to main.css removed-->
  <div class="page_head_frame">
    <label class="label_page_head">Store Items Price Edit <?php echo $subCatText ?></label>
  </div>
<div class="page_inside_frame" style="width:700px;">
  <form action="store_items_price_edit_save.php" method="post">
  <input type="hidden" name="subCat" id="subCat" value="<?php echo $subCat?>">
<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": "450px",
					"bPaginate": false,
					"bScrollCollapse": true,
					"aaSorting": [[ 0, "asc" ]],
					"aoColumns": [
								{"bSortable": true},
								{"bSortable": true},
								{"bSortable": true},
								{"bSortable": true},
								{"bSortable": true},
								{"bSortable": true}
								 ]
				} );
			} );
		</script>
    <table width="662" id="scroll_table_1" class="data_display">
      <thead>
        <tr>
          <th width="226">Product Name</th>
          <th width="76" >Sub category</th>
          <th width="76" >Location</th>
          <th width="56" >Unit</th>
          <th width="92" >Cost Price</th>
          <th width="92" >Sales price</th>
        </tr>
      </thead>
      <tbody>
        <?php 

    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, "price");
		   $b8 = mysql_result($items_result, $i, "unit");
		   $b9 = mysql_result($items_result, $i, "supplier_id");
		   $b10 = mysql_result($items_result, $i, "price_2");
		   $b11 = mysql_result($items_result, $i, "prereserved");
		   $b12 = mysql_result($items_result, $i, "reserved");
		   $b13 = mysql_result($items_result, $i, "class");
		   
		   $table_name2 = $_SESSION['db_prefix']."_suppliers";
           $suppliers_query = "SELECT account_name   FROM $table_name2 WHERE supplier_id = '".$b9."' ";
           $suppliers_result = mySQL_query($suppliers_query);
		   $suppliers_num = mysql_num_rows($suppliers_result);
           if ($suppliers_num!=0) {
		   $b9a = mysql_result($suppliers_result, 0, "account_name");
		   }
		   else {
			   $b9a="";
		   }
		          		   
		   $itemTT =
		   "<img src=../images/view.png  width=20 height=16><table id=table_tool_tip width=250 ><tr><td  width=75>Item name:</td><td width=175>".$b2."</td></tr><tr><td>Supplier:</td><td>".$b9a."</td></tr></table><br><b>Click for details</b>";
		   
		      
    ?>
        <tr class="alt">
          <td align="left"><?php echo $b2 ?></a>
          <input type="hidden" name="store_item_id<?php echo $i?>" id="store_item_id<?php echo $i?>" value="<?php echo $b1?>"></td>
          <td align="left"><?php echo $b4?></td>
          <td align="left"><?php echo $b3 ?></td>
          <td align="left"><?php echo $b8 ?></td>
          
          <td align="right"><input name="price_text<?php echo $i?>" id="price_text<?php echo $i?>" type="hidden" value="<?php echo $b7?>"><input name="price_edit<?php echo $i?>" type="text" class="text60" id="price_edit<?php echo $i?>" value="<?php echo $b7?>" autocomplete="off" onKeyPress="return isNumberKey(event)" onKeyUp=" this.value = this.value.replace (/(\...).*/, '$1')" style="text-align:right" onfocus = "this.select();"></td>
          <td align="right"><input name="price2_text<?php echo $i?>" id="price_text2<?php echo $i?>" type="hidden" value="<?php echo $b10?>">            <input name="price2_edit<?php echo $i?>" type="text" class="text60" id="price2_edit<?php echo $i?>" value="<?php echo $b10?>" autocomplete="off" onKeyPress="return isNumberKey(event)" onKeyUp=" this.value = this.value.replace (/(\...).*/, '$1')" style="text-align:right" onfocus = "this.select();"></td>
        </tr>
        <?php 
		$i++;
    	}
		?>
		
    	
      </tbody>
    </table>
    <input name="list_num" type="hidden" value="<?php echo $i ?>">
</div>   
 <div class="page_middle_frame">
  <table width="660" border="0">
    <tr>
      <td width="20"></td>
      <td width="615" align="right">
        <input name="button2" type="button" class="imagebutton" id="button2" onClick="cancel_confirmation(3, '../production/production_main.php');" value="Close"/>
        <input name="save_button"  id="save_button" type="submit" class="imagebutton" value="Save " onClick="needToConfirm = false; confirmRefresh();" />
        <input name="save_close_button"  id="save_close_button" type="submit" class="imagebutton" value="Save &amp; Close" onClick="needToConfirm = false; confirmRefresh();" /></td>
    </tr>
  </table>
  </form>  
</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'); ?>
