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

$page_name = "Sales-price edit";
include ("../navigation/access.php");

if ($permission_num==1) {

	 include ("../navigation/sales_sidebar.php");
	
				  
		
		$table_name2 = $_SESSION['db_prefix']."_store_items"; 		 
		$items_query = "SELECT * FROM $table_name2 WHERE subCategory = 'Timber' AND (class='S5' OR class='S7') AND category<>'Old' ORDER BY item_name ASC";	
		$items_result = execsql($items_query);
    	
    	$items_num = mysql_num_rows($items_result);
		
		$table_name2 = $_SESSION['db_prefix']."_store_items"; 		 
		$loose_query = "SELECT * FROM $table_name2 WHERE subCategory = 'Timber' AND class<>'S5' AND class<>'S7' AND category<>'Old' ORDER BY item_name ASC";
		$loose_result = execsql($loose_query);
    	$loose_num = mysql_num_rows($loose_result);
		
		$table_name = $_SESSION['db_prefix']."_timber_meter_price";
		$price_query = "SELECT * FROM $table_name ";
		$price_result = mySQL_query($price_query);
		$price_num = mysql_num_rows($price_result);
		$p=0;
		while ($p<$price_num) {
		${'price'.$p} = mysql_result($price_result, $p, "price");
		${'price_s'.$p} = mysql_result($price_result, $p, "price_2");
		$p++;
		}
		
		
			
    	
?>
<!--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">

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

</head>
<body>


<div class="main_frame" style="height:auto; min height:540px;">

 <input type="hidden" name="subCat" id="subCat" value="<?php echo 'Timber' ?>">
  <!--reference to main.css removed-->
  <div class="page_head_frame">
    <label class="label_page_head">Timber Items Sales Price Edit </label>
  </div>
  <div class="page_middle_frame">
  <form action="timber_sales_price_edit_save.php" method="POST">
  
  
    <label class="label_std">Update meter prices:</label>
    <table width="700" border="0" id="table_display">
  <tr>
    <td colspan="11" align="center">class S5 (treated)</td>
    </tr>
  <tr>
    <td width="43" align="left">size:</td>
    <td width="81" align="center">38x38</td>
    <td width="67" align="center">38x50</td>
    <td width="67" align="center">38x76</td>
    <td width="67" align="center">38x114</td>
    <td width="67" align="center">38x152</td>
    <td width="67" align="center">38x228</td>
    <td width="67" align="center">50x76</td>
    <td width="67" align="center">50x152</td>
    <td width="67" align="center">50x228</td>
    <td width="75" align="center">70x330</td>
  </tr>
  <tr>
    <td align="left">cost:</td>
    <td align="center"><input name="3838_text" type="text" class="text40" id="3838_text" style="text-align:right; border:hidden; background-color:transparent; color:#999;" value="<?php echo $price0?>"  readonly="readonly"></td>
    <td align="center"><input name="3850_text" type="text" class="text40" id="3850_text" style="text-align:right; border:hidden; background-color:transparent; color:#999;" value="<?php echo $price1?>"  readonly="readonly"></td>
    <td align="center"><input name="3876_text" type="text" class="text40" id="3876_text" style="text-align:right; border:hidden; background-color:transparent; color:#999;" value="<?php echo $price2?>"  readonly="readonly"></td>
    <td align="center"><input name="38114_text" type="text" class="text40" id="38114_text" style="text-align:right; border:hidden; background-color:transparent; color:#999;" value="<?php echo $price3?>"  readonly="readonly"></td>
    <td align="center"><input name="38152_text" type="text" class="text40" id="38152_text" style="text-align:right; border:hidden; background-color:transparent; color:#999;" value="<?php echo $price4?>"  readonly="readonly"></td>
    <td align="center"><input name="38228_text" type="text" class="text40" id="38228_text" style="text-align:right; border:hidden; background-color:transparent; color:#999;" value="<?php echo $price5?>"  readonly="readonly"></td>
    <td align="center"><input name="5076_text" type="text" class="text40" id="5076_text" style="text-align:right; border:hidden; background-color:transparent; color:#999;" value="<?php echo $price6?>"  readonly="readonly"></td>
    <td align="center"><input name="50152_text" type="text" class="text40" id="50152_text" style="text-align:right; border:hidden; background-color:transparent; color:#999;" value="<?php echo $price10?>"  readonly="readonly"></td>
    <td align="center"><input name="50228_text" type="text" class="text40" id="50228_text" style="text-align:right; border:hidden; background-color:transparent; color:#999;" value="<?php echo $price11?>"  readonly="readonly"></td>
    <td align="center"><input name="70330_text" type="text" class="text40" id="70330_text" style="text-align:right; border:hidden; background-color:transparent; color:#999;" value="<?php echo $price12?>"  readonly="readonly"></td>
  </tr>
<tr>
  <td align="left">sale:</td>
    <td align="center"><input name="3838_sale_text" type="text" class="text40" id="3838_sale_text" onKeyPress="return isNumberKey(event)" onKeyUp=" this.value = this.value.replace (/(\...).*/, '$1')" style="text-align:right" value="<?php echo $price_s0?>" onfocus = "this.select();"></td>
    <td align="center"><input name="3850_sale_text" type="text" class="text40" id="3850_sale_text" onKeyPress="return isNumberKey(event)" onKeyUp=" this.value = this.value.replace (/(\...).*/, '$1')" style="text-align:right" value="<?php echo $price_s1?>" onfocus = "this.select();"></td>
    <td align="center"><input name="3876_sale_text" type="text" class="text40" id="3876_sale_text" onKeyPress="return isNumberKey(event)" onKeyUp=" this.value = this.value.replace (/(\...).*/, '$1')" style="text-align:right" value="<?php echo $price_s2?>" onfocus = "this.select();"></td>
    <td align="center"><input name="38114_sale_text" type="text" class="text40" id="38114_sale_text" onKeyPress="return isNumberKey(event)" onKeyUp=" this.value = this.value.replace (/(\...).*/, '$1')" style="text-align:right" value="<?php echo $price_s3?>" onfocus = "this.select();"></td>
    <td align="center"><input name="38152_sale_text" type="text" class="text40" id="38152_sale_text" onKeyPress="return isNumberKey(event)" onKeyUp=" this.value = this.value.replace (/(\...).*/, '$1')" style="text-align:right" value="<?php echo $price_s4?>" onfocus = "this.select();"></td>
    <td align="center"><input name="38228_sale_text" type="text" class="text40" id="38228_sale_text" onKeyPress="return isNumberKey(event)" onKeyUp=" this.value = this.value.replace (/(\...).*/, '$1')" style="text-align:right" value="<?php echo $price_s5?>" onfocus = "this.select();"></td>
    <td align="center"><input name="5076_sale_text" type="text" class="text40" id="5076_sale_text" onKeyPress="return isNumberKey(event)" onKeyUp=" this.value = this.value.replace (/(\...).*/, '$1')" style="text-align:right" value="<?php echo $price_s6?>" onfocus = "this.select();"></td>
    <td align="center"><input name="50152_sale_text" type="text" class="text40" id="50152_sale_text" onKeyPress="return isNumberKey(event)" onKeyUp=" this.value = this.value.replace (/(\...).*/, '$1')" style="text-align:right" value="<?php echo $price_s10?>" onfocus = "this.select();"></td>
    <td align="center"><input name="50228_sale_text" type="text" class="text40" id="50228_sale_text" onKeyPress="return isNumberKey(event)" onKeyUp=" this.value = this.value.replace (/(\...).*/, '$1')" style="text-align:right" value="<?php echo $price_s11?>" onfocus = "this.select();"></td>
    <td align="center"><input name="70330_sale_text" type="text" class="text40" id="70330_sale_text" onKeyPress="return isNumberKey(event)" onKeyUp=" this.value = this.value.replace (/(\...).*/, '$1')" style="text-align:right" value="<?php echo $price_s12?>" onfocus = "this.select();"></td>
  </tr>
<tr align="center">
  <td colspan="11">class S7 (treated)</td>
  </tr>
<tr>
  <td align="left">size:</td>
  <td align="center">38x114</td>
  <td align="center">38x152</td>
  <td align="center">38x228</td>
  <td align="center">&nbsp;</td>
  <td align="center">&nbsp;</td>
  <td align="center">&nbsp;</td>
  <td align="center">&nbsp;</td>
  <td align="center">&nbsp;</td>
  <td align="center">&nbsp;</td>
  <td align="center">&nbsp;</td>
</tr>
<tr>
  <td align="left">cost:</td>
  <td align="center"><input name="38114_text2" type="text" class="text40" id="38114_text2" style="text-align:right; border:hidden; background-color:transparent; color:#999;" value="<?php echo $price7?>"  readonly="readonly"></td>
  <td align="center"><input name="38152_text2" type="text" class="text40" id="38152_text2" style="text-align:right; border:hidden; background-color:transparent; color:#999;" value="<?php echo $price8?>"  readonly="readonly"></td>
  <td align="center"><input name="38228_text2" type="text" class="text40" id="38228_text2" style="text-align:right; border:hidden; background-color:transparent; color:#999;" value="<?php echo $price9?>"  readonly="readonly"></td>
  <td align="center">&nbsp;</td>
  <td align="center">&nbsp;</td>
  <td align="center">&nbsp;</td>
  <td align="center">&nbsp;</td>
  <td align="center">&nbsp;</td>
  <td align="center">&nbsp;</td>
  <td align="center">&nbsp;</td>
</tr>
<tr>
  <td align="left">sale:</td>
  <td align="center"><input name="38114_sale_text2" type="text" class="text40" id="38114_sale_text2" onKeyPress="return isNumberKey(event)" onKeyUp=" this.value = this.value.replace (/(\...).*/, '$1')" style="text-align:right" value="<?php echo $price_s7?>" onfocus = "this.select();"></td>
  <td align="center"><input name="38152_sale_text2" type="text" class="text40" id="38152_sale_text2" onKeyPress="return isNumberKey(event)" onKeyUp=" this.value = this.value.replace (/(\...).*/, '$1')" style="text-align:right" value="<?php echo $price_s8?>" onfocus = "this.select();"></td>
  <td align="center"><input name="38228_sale_text2" type="text" class="text40" id="38228_sale_text2" onKeyPress="return isNumberKey(event)" onKeyUp=" this.value = this.value.replace (/(\...).*/, '$1')" style="text-align:right" value="<?php echo $price_s9?>" onfocus = "this.select();"></td>
  <td align="center">&nbsp;</td>
  <td align="center">&nbsp;</td>
  <td align="center">&nbsp;</td>
  <td align="center">&nbsp;</td>
  <td align="center">&nbsp;</td>
  <td align="center">&nbsp;</td>
  <td align="center">&nbsp;</td>
</tr> 
    </table>

    <div align="right">
      <input name="update_button" type="submit" class="imagebutton" id="update_button" value="Update prices" onClick="needToConfirm = false;">
      <input name="update_close_button" type="submit" class="imagebutton" id="update_close_button" value="Update prices & close" onClick="needToConfirm = false;">
      <input name="close_button" type="button" class="imagebutton" id="close_button" onClick="cancel_confirmation(3, '../store/store_main.php');" value="Close"/>
    </div>
    Scroll down to edit prices for loose timbers.
  
  </form>

<div class="scroll_frame_long" style="height:300px;">
  <table width="650" id="table_details_display" class="sortable-onload-0 rowstyle-alt no-arrow "  >
      <thead>
        <tr>
          <th width="226" class="sortable-text">
          Product Name</th>
          <th width="76" class=\"sortable-text">Sub category</th>
          <th width="76" class=\"sortable-text">Location</th>
          <th width="56" class=\"sortable-text">Unit</th>
          <th width="92" class=\"sortable-numeric"><span class="sortable-numeric">Cost Price</span></th>
          <th width="92" class=\"sortable-numeric">Sales price</th>
        </tr>
      </thead>
      <tbody>
        <?php 
	$i=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, "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 ?>
          <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"><label style="color:#999;"><?php echo $b7?></label></td>
          <td align="right"><?php echo $b10?></td>
        </tr>
        <?php 
		$i++;
    	}
		?>
		<input name="list_num" type="hidden" value="<?php echo $i ?>">   	
      </tbody>
    </table>
    
</div>
</div>  
<div class="page_middle_frame">
<form action="timber_loose_sales_price_edit_save.php" method="post">
  <input type="hidden" name="subCat" id="subCat" value="<?php echo 'Timber' ?>">
<link rel="stylesheet" type="text/css" href="../css/scroll_table.css" />
<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>
<label class="label_std" style="font-size:18px;">Timber other</label>         
    <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 
	$i=0;
    while($i < $loose_num){
	       $b1 = mysql_result($loose_result, $i, "store_item_id");
	       $b2 = mysql_result($loose_result, $i, "item_name");
	       $b3 = mysql_result($loose_result, $i, "location");
		   $b4 = mysql_result($loose_result, $i, "subCategory");
	       $b5 = mysql_result($loose_result, $i, "quantity");
	       $b6 = mysql_result($loose_result, $i, "minimumStock");
	       $b7 = mysql_result($loose_result, $i, "price");
		   $b8 = mysql_result($loose_result, $i, "unit");
		   $b9 = mysql_result($loose_result, $i, "supplier_id");
		   $b10 = mysql_result($loose_result, $i, "price_2");
		   $b11 = mysql_result($loose_result, $i, "prereserved");
		   $b12 = mysql_result($loose_result, $i, "reserved");
		   $b13 = mysql_result($loose_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 ?>
          <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?>2" type="text" class="text60" id="price_edit<?php echo $i?>2" value="<?php echo $b10?>" autocomplete="off" readonly style="text-align:right; border:hidden; background-color:transparent; color:#999;" ></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 class="page_middle_frame" style="width:680px; border:hidden;">
  <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>
  </div>
<?php include ('../navigation/side_bar.php'); ?>  
</body>
<?php } else {
$_SESSION['denied_return'] = "sales/sales_main.php?date=";	
include ("../navigation/sales_sidebar.php");?>
	<body onload="accessdenied(); return false">
    <?php include ('../navigation/side_bar.php'); ?>
	</body>
<?php }
?>
</html>

