<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />


<?php
include ("../navigation/header.php");
include ("../navigation/store_sidebar.php");
?>


<?php 
	
	$s = $_GET['s'];
	$p = $_GET['p'];
	$error = $_SESSION['error'];
	$_SESSION['p']=$p;
	$_SESSION['s']=$s;
	
	
	if (isset($_GET['prev_button']) )
	   {
		 $_SESSION['p']= $_SESSION['p']-1;
	   }
		 
	if (isset($_GET['next_button']) )
	  {
		$_SESSION['p']=$_SESSION['p']+1;
	  }
	
		
	
	if ($s==1) {
		
			
	}
		
		
	if($s==2) {
		$i=0;
		while ($i<$_SESSION['line_no3']) {
			$_SESSION['timber_no'.$i] = $_POST['timber_no_text'.$i];
			$store_item_id = $_POST['timber_id'.$i];
			$table_name = $_SESSION['db_prefix']."_store_items";
			$check_query = "SELECT quantity FROM $table_name WHERE store_item_id = '".$store_item_id."'  ";
			$check_result = mySQL_query($check_query);
			$quantity = mysql_result($check_result, 0, "quantity");
			if ($quantity<0) {$quantity=0;}
			if ($_SESSION['timber_no'.$i]>$quantity) {
				$_SESSION['error2']='yes';
				$_SESSION['timber_no'.$i]=$quantity;
				$_SESSION['timber_error'.$i]='yes';
			}
						
			$i++;
		}
		if ($_SESSION['error2']=='yes') {
			?>
                <script language="javascript" type="text/javascript">
	                     window.location="cutJobWizbase.php?p=2&s=&all=";
                </script>
               <?php
			}
	}
	
	if($s==3) {
		$i=0;
		while ($i<$_SESSION['line_no5']) {
			
			$_SESSION['plates_no'.$i] = $_POST['plates_no_text'.$i];
			$store_item_id = $_POST['plate_id'.$i];
			$table_name = $_SESSION['db_prefix']."_store_items";
			$check_query = "SELECT quantity FROM $table_name WHERE store_item_id = '".$store_item_id."'  ";
			$check_result = mySQL_query($check_query);
			$quantity = mysql_result($check_result, 0, "quantity");
			
			if ($_SESSION['plates_no'.$i]>$quantity) {
				$_SESSION['error3']='yes';
				$_SESSION['plates_no'.$i]=$quantity;
				$_SESSION['plates_error'.$i]='yes';
			}
						
			$i++;
		}
		if ($_SESSION['error3']=='yes') {
			?>
                <script language="javascript" type="text/javascript">
	                     window.location="cutJobWizbase.php?p=3&s=&all2=";
                </script>
               <?php
			}
		
		}
	

	?>

<!--style sheets-->
<link rel="stylesheet" type="text/css" href="../css/wizard.css" />
<!--reference to main.css removed-->
<link rel="stylesheet" type="text/css" href="../css/wait.css" />
<link rel="stylesheet" href="../window/dhtmlwindow.css" type="text/css" />
<link rel="stylesheet" href="../window/modal.css" type="text/css" />

<!--jscript-->
<script type="text/javascript" src="../window/dhtmlwindow.js"></script>
<script type="text/javascript" src="../window/modal.js"></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>  
<script language="JavaScript" src="../jscript/show_hide_layers.js"  type="text/javascript"></script>  




</head>

<body>


<div class="main_frame" style="height:auto;min-height:550px; " >
  <table width="595" align="left" id="tableMain">
  <!--begin of tableMain-->
  <tr>
    <td >
    <div class="page_head_frame">
      <table width="681" border="0">
        <tr>
          <td width="548"><label class="label_page_head">Supply  cutting bill </label>&nbsp;<label class="label_page_head_2"><?php echo $_SESSION['name']?></label>&nbsp;</td>
          <td width="122">
            <label style="font-size:24px; color:#FB6808;"><?php echo "J".$_SESSION['job_no']; ?></label></td>
        </tr>
      </table>
      </div>
      <br /><br /><br /><br />

      <div class="wizard_paging_frame">
      <table align="left">
      <tr>
      <td width="56">
      <?php if ($_SESSION['p']==1) { ?>
      <div class="active_step_frame"><div class="active_step_head_label">&nbsp;1</div>
      <div class="active_step_label"><br /><br /><br />
      Job details</div></div>
      <?php } else { ?>
      <div class="de_active_step_frame"><div class="de_active_step_head_label">&nbsp;1</div>
      <div class="de_active_step_label"><br /><br /><br />
      Job details</div></div>
      <?php } ?>
      
      </td>
     
      <td width="68">
      <?php if ($_SESSION['p']==2) { ?>
      <div class="active_step_frame"><div class="active_step_head_label">&nbsp;2</div>
      <div class="active_step_label"><br /><br /><br />
      Timber</div></div>
      <?php } else { ?>
      <div class="de_active_step_frame"><div class="de_active_step_head_label">&nbsp;2</div>
      <div class="de_active_step_label"><br /><br /><br />
      Timber</div></div>
      <?php } ?>
      </td>
      <td width="68">
      <?php if ($_SESSION['p']==3) { ?>
      <div class="active_step_frame"><div class="active_step_head_label">&nbsp;3</div>
      <div class="active_step_label"><br /><br /><br />
      Plates</div></div>
      <?php } else { ?>
      <div class="de_active_step_frame"><div class="de_active_step_head_label">&nbsp;3</div>
      <div class="de_active_step_label"><br /><br /><br />
      Plates</div></div>
      <?php } ?>
      </td>
      <td width="68">
      <?php if ($_SESSION['p']==4) { ?>
      <div class="active_step_frame"><div class="active_step_head_label">&nbsp;4</div>
      <div class="active_step_label"><br /><br /><br />
      Finish</div></div>
      <?php } else { ?>
      <div class="de_active_step_frame"><div class="de_active_step_head_label">&nbsp;4</div>
      <div class="de_active_step_label"><br /><br /><br />
      Finish</div></div>
      <?php } ?>
      </td>
      
      </tr>
      </table>
      </div>
      </td>
          </tr>
          <tr>
            <td><?php 
	if ($_SESSION['p']==1) { include("cutJobWiz1.php"); }
	if ($_SESSION['p']==2) { include("cutJobWiz2.php"); }
	if ($_SESSION['p']==3) { include("cutJobWiz3.php"); }
	if ($_SESSION['p']==4) { include("cutJobWiz4.php"); }
	if ($_SESSION['p']==5) { include("cutJobWiz5.php"); }
	
		
    ?></td>
          </tr>
    </table>
    </div>
    </td>
  </tr>
</table>

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


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