<!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" />
        
        <!--style sheets-->
		<link rel="stylesheet" type="text/css" href="../css/wizard.css" />
		<link href="../css/wait.css" rel="stylesheet" type="text/css">
        <link rel="stylesheet" href="../window/dhtmlwindow.css" type="text/css" />
		<link rel="stylesheet" href="../window/modal.css" type="text/css" />

		<!--jscript-->
		<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>
        <script type="text/javascript" src="../window/dhtmlwindow.js"></script>
		<script type="text/javascript" src="../window/modal.js"></script>
        
        
		<?php
include ("../navigation/header.php");
include ("../navigation/sales_sidebar.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) {
	  $line2 = $_GET['line2'];
	  $i = 0;
	  	$table_name = $_SESSION['db_prefix']."_cash_authorisation_lines_temp";
		$delete_query = "DELETE FROM $table_name WHERE job_no = '".$_SESSION['job_no']."' AND truss_item = 'Timber' AND user_name = '".$_SESSION['username']."' "; 
		execsql($delete_query);
	  	  
	  while ($i<$line2) {
	  	$store_item_id = $_GET['store_item_id'.$i];
	  	$quantity = $_GET['quantity_text_'.$i];
	  
	  	$table_name = $_SESSION['db_prefix']."_cash_authorisation_lines_temp";
		$timber_query = "INSERT INTO $table_name (job_no, store_item_id, truss_item, quantity, user_name) VALUES ('".$_SESSION['job_no']."', '".$store_item_id."', 'Timber', '".$quantity."', '".$_SESSION['username']."' ) ";
		
		execsql($timber_query);
		
		$i++;
	}
	 
	};
	
	if($s==3) {
		$line3 = $_GET['line3'];
	  $i = 0;
	  	$table_name = $_SESSION['db_prefix']."_cash_authorisation_lines_temp";
		$delete_query = "DELETE FROM $table_name WHERE job_no = '".$_SESSION['job_no']."' AND truss_item = 'Mitek' AND user_name = '".$_SESSION['username']."' "; 
		execsql($delete_query);
	  	  
	  while ($i<$line3) {
	  	$store_item_id = $_GET['store_item_id'.$i];
	  	$quantity = $_GET['quantity_text_'.$i];
	  
	  	$table_name = $_SESSION['db_prefix']."_cash_authorisation_lines_temp";
		$mitek_query = "INSERT INTO $table_name (job_no, store_item_id, truss_item, quantity, user_name) VALUES ('".$_SESSION['job_no']."', '".$store_item_id."', 'Mitek', '".$quantity."', '".$_SESSION['username']."' ) ";
		execsql($mitek_query);
		
		$i++;
	}
	}
	
	if($s==4) {
	$line4 = $_GET['line4'];
	  $i = 0;
	  	$table_name = $_SESSION['db_prefix']."_cash_authorisation_lines_temp";
		$delete_query = "DELETE FROM $table_name WHERE job_no = '".$_SESSION['job_no']."' AND truss_item = 'Sundries' AND user_name = '".$_SESSION['username']."' "; 
		execsql($delete_query);
	  	  
	  while ($i<$line4) {
	  	$store_item_id = $_GET['store_item_id'.$i];
	  	$quantity = $_GET['quantity_text_'.$i];
	  
	  	$table_name = $_SESSION['db_prefix']."_cash_authorisation_lines_temp";
		$sundries_query = "INSERT INTO $table_name (job_no, store_item_id, truss_item, quantity, user_name) VALUES ('".$_SESSION['job_no']."', '".$store_item_id."', 'Sundries', '".$quantity."', '".$_SESSION['username']."' ) ";
		execsql($sundries_query);
		
		$i++;
	}
	}
	
	?>
<!--jscript-->		
 <script language="JavaScript" src="../jscript/alert_message.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="671" border="0">
                  <tr>
                      <td width="548"><label class="label_page_head">Authorise cash sale</label>
                      &nbsp;&nbsp;&nbsp;
                      <label class="label_page_head_2"><?php echo $_SESSION['name']?></label></td>
                      <td width="113"><label style="font-size:24px; color:#FB6808;"><?php echo "J".$_SESSION['job_no']; ?></label></td>
                    </tr>
                </table>
                  &nbsp;</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 />
                          Cash Sale 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 />
                          Cash Sale Details</div>
              </div>
                      <?php } ?></td>
            <td width="72"><?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 />
                          Eco products</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 />
                          Eco products</div>
              </div>
                      <?php } ?></td>
            <td width="59"><?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 />
                          Sundries</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 />
                          Sundries</div>
              </div>
                      <?php } ?></td>
            <td width="30"><?php if ($_SESSION['p']==5) { ?>
                      <div class="active_step_frame">
                <div class="active_step_head_label">&nbsp;5</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;5</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("cash_authorisationWiz1.php"); }
	if ($_SESSION['p']==2) { include("cash_authorisationWiz2.php"); }
	if ($_SESSION['p']==3) { include("cash_authorisationWiz3.php"); }
	if ($_SESSION['p']==4) { include("cash_authorisationWiz4.php"); }
	if ($_SESSION['p']==5) { include("cash_authorisationWiz5.php"); }
	
	
	
    ?></td>
            </tr>
  </table>
        </div>
</td>
</tr>
</table>
</td>
</tr>
</table>
<!--end of tableMain-->

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