<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<?php
include('../include/session.php');
include ("../navigation/header.php");
include ("../navigation/orders_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) {
		$_SESSION['quote_note'] = $_GET['notes_text'];
		$_SESSION['project_no'] = $_GET['project_no_text'];
		$_SESSION['project_place'] = $_GET['project_place_select'];
		$_SESSION['project_area'] = $_GET['project_area_select'];
		$_SESSION['start_date'] = date('Y-m-d', strtotime($_GET['start_date_text']));
		$_SESSION['end_date'] = date('Y-m-d', strtotime($_GET['end_date_text']));
		
	}
		
	if($s==2) {
		
	 $_SESSION['forman']=$_GET['forman_select'];
	 	$table_name2 = $_SESSION['db_prefix']."_employee";
		$employee_query = "SELECT emp_first_name, emp_last_name FROM $table_name2 WHERE emp_id ='".$_SESSION['forman']."' ";
		$employee_result = mySQL_query($employee_query);
		$employee_num = mysql_num_rows($employee_result);	
		$_SESSION['forman_name'] = mysql_result($employee_result, 0, "emp_first_name").' '.mysql_result($employee_result, 0, "emp_last_name"); 
	 $_SESSION['labour']=$_GET['labour_text'];
	 $_SESSION['travel']=$_GET['travel_text'];
	 $_SESSION['accomodation']=$_GET['accomodation_text'];
	 if (isset($_GET['mworks_checkbox']) ) {
	   $_SESSION['mworks']='yes' ;
	   $_SESSION['mworks_charge']=$_GET['mworks_text'];
	 }
	 else {
		$_SESSION['mworks']='';  
		$_SESSION['mworks_charge']='';
	 }
	};
	
	if($s==3) {
		$table_name = $_SESSION['db_prefix']."_order_job_lines_temp";
		$delete_query = "DELETE FROM $table_name WHERE  user_name = '".$_SESSION['username']."'   "; 
		execsql($delete_query);
		
$line_num = $_POST['line_num'];
$i=0;
while ($i<$line_num) {
if (isset($_POST['line_checkbox'.$i])) {
//$_SESSION['category'.$i] =	$_POST['category'.$i];
$_SESSION['index'.$i] =	$_POST['index'.$i];
$store_item_id = $_POST['store_item_id'.$i];
if ($store_item_id<100000) {
		$table_name = $_SESSION['db_prefix']."_store_items";
		$name_query = "SELECT item_name, price FROM $table_name WHERE store_item_id = '".$store_item_id."'  ";
		$name_result = mySQL_query($name_query);
		$store_item_name = mysql_result($name_result, 0, "item_name");
		$price = mysql_result($name_result, 0, "price");
		$quantity = $_POST['quantity_text'.$i];
}
if ($store_item_id>100000) {
	
	    $store_item_id = $_POST['store_item_id'.$i];	
		$table_name = $_SESSION['db_prefix']."_store_items_special";
		$special_query = "SELECT item_name, quantity, price  FROM $table_name WHERE special_store_item_id = '".$store_item_id."'  ";
		$special_result = mySQL_query($special_query);
		$store_item_name = mysql_result($special_result, 0, "item_name");
		$quantity = mysql_result($special_result, 0, "quantity");
		$price = mysql_result($special_result, 0, "price");
}


$table_name = $_SESSION['db_prefix']."_order_job_lines_temp";
$receive_query = "INSERT INTO $table_name ( store_item_id, item_name, quantity,  price, user_name) VALUES ('".$store_item_id."', '".$store_item_name."', '".$quantity."', '".$price."', '".$_SESSION['username']."' ) ";
execsql($receive_query);

};
$i++;
}

$line_num2 = $_POST['line_num2'];
$i=0;
while ($i<$line_num2) {
if (isset($_POST['line_checkbox7'.$i])) {
$item_name = $_POST['item_text7'.$i];

$quantity2 = $_POST['quantity_text7'.$i];
$price2 = $_POST['amount_text7'.$i];

if(isset($_POST['line_checkbox7'.$i]) ) {
$table_name = $_SESSION['db_prefix']."_order_job_lines_temp";
$receive_query = "INSERT INTO $table_name ( store_item_id, item_name, quantity,  price, user_name) VALUES ('0', '".$item_name."', '".$quantity2."', '".$price2."', '".$_SESSION['username']."' ) ";
execsql($receive_query);
}
};
$i++;
}
	 
}
	

	
	?>

<!--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" />
<link href="../css/tooltip.css" rel="stylesheet" type="text/css">

<!--jscript-->
<script language="JavaScript" src="../jscript/gen_validatorv4.js"  type="text/javascript" xml:space="preserve"></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/alert_message.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>
<script language="JavaScript" src="../jscript/numbers_only.js"  type="text/javascript"></script>  
<script language="JavaScript" src="../jscript/numbers_only_decimal.js"  type="text/javascript"></script>  
<script language="JavaScript" src="../jscript/tooltip.js"  type="text/javascript"></script> 


<div class="main_frame">

<div class="page_head_frame">
                <label class="label_page_head">Compile </label>
                &nbsp;
                <label class="label_page_head_2">job card:&nbsp;&nbsp;<?php echo $_SESSION['job_card_no'] ?>&nbsp;&nbsp;<?php echo $_SESSION['name'] ?></label>
</div>               
       <table >
     	<tr>
      	<td >         
        <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>
                <div class="active_step_label">
                  Job details
              </div>
              <?php } else { ?>
              <div class="de_active_step_frame">
                <div class="de_active_step_head_label">&nbsp;1</div></div>
                <div class="de_active_step_label">
                  Job details
              </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>
                <div class="active_step_label">
                  Charges
              </div>
              <?php } else { ?>
              <div class="de_active_step_frame">
                <div class="de_active_step_head_label">&nbsp;2</div></div>
                <div class="de_active_step_label">
                  Charges
              </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>
                <div class="active_step_label">
                 Item list
              </div>
              <?php } else { ?>
              <div class="de_active_step_frame">
                <div class="de_active_step_head_label">&nbsp;3</div></div>
                <div class="de_active_step_label">
                   Item list
              </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>
                <div class="active_step_label">
                   Finish
              </div>
              <?php } else { ?>
              <div class="de_active_step_frame">
                <div class="de_active_step_head_label">&nbsp;4</div></div>
                <div class="de_active_step_label">
                  Finish
              </div>
              <?php } ?></td>
             
          </tr>
        </table>
        </div>
        </td>
    </tr>
    <tr>
      <td><?php 
	if ($_SESSION['p']==1) { include("compileJobWiz1.php"); }
	if ($_SESSION['p']==2) { include("compileJobWiz2.php"); }
	if ($_SESSION['p']==3) { include("compileJobWiz3.php"); }
	if ($_SESSION['p']==4) { include("compileJobWiz4.php"); }
	if ($_SESSION['p']==5) { include("compileJobWiz5.php"); }
	if ($_SESSION['p']==6) { include("compileJobWiz6.php"); }
    ?></td>
    </tr>
  </table>
</div>

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