<!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");

	$d="";
	$s = $_GET['s'];
	$p = $_GET['p'];
	if ($_SESSION['p'] >= 4) {$d=1;}
	$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['cust_id'] = $_GET['account_select'];
	
	$table_name2 = $_SESSION['db_prefix']."_customer";
	$account_query = "SELECT comp_name, phys_address, phys_place, contact_1, phone FROM $table_name2 WHERE cust_id ='".$_SESSION['cust_id']."' ";
	$account_result = $con->query($account_query);
	$account_num = mysqli_num_rows($account_result);
	$row = mysqli_fetch_assoc($account_result);
	$_SESSION['comp_name'] = $row["comp_name"];
	$_SESSION['project_no'] = $row["phys_address"];
	$_SESSION['project_place'] = $row["phys_place"];
	$_SESSION['deliver_contact'] = $row["contact_1"];
	$_SESSION['deliver_phone'] = $row["phone"];
	
	$_SESSION['project_no_original'] = $row["phys_address"];
	$_SESSION['project_place_original'] = $row["phys_place"];
				
	
	
	}
		
	if($s==2) {
		$_SESSION['deliver_collect'] = $_GET['deliver_group'];
		$_SESSION['order_no'] = $_GET['order_no_text'];
		$_SESSION['order_date']	= $_GET['order_date'];
				
		$_SESSION['deliver_contact'] = $_GET['deliver_contact_text'];
		$_SESSION['deliver_phone'] = $_GET['deliver_phone_text'];
		$_SESSION['project_no'] = $_GET['deliver_project_no_text'];
	 	$_SESSION['project_place'] = $_GET['deliver_project_place_select'];
		
		
				
		$_SESSION['additional_info'] = $_GET['additional_info_text'];
		
		$_SESSION['tba_deliver'] = $_GET['del_date_group'];
		if ($_SESSION['tba_deliver']=='del_date') {
		   		$_SESSION['delivery_date'] = $_GET['delivery_date'];
		}
		else {
				$_SESSION['delivery_date'] = '2000-01-01';
		}
	  
 	};
	
	if($s==3) {
		
$table_name = $_SESSION['db_prefix']."_order_lines_temp";
$delete_query = "DELETE FROM $table_name WHERE  user_name = '".$_SESSION['username']."'   "; 
$delete_result = $con->query($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];
$product_item_id = $_POST['product_item_id'.$i];

				$table_name = $_SESSION['db_prefix']."_product_store";
				$name_query = "SELECT item_name, subCategory, item_type, price FROM $table_name WHERE product_item_id = '".$product_item_id."'  ";
				$name_result = $con->query($name_query);
				while($row = $name_result->fetch_assoc()) {
					$_SESSION['store_item_name'] = $row["item_name"];
					$price = $row["price"];
					$sub_category = $row["subCategory"];
					$item_type = $row["item_type"];
				}
				$_SESSION['product_item_id'] = $product_item_id;
				
$quantity = $_POST['quantity_text'.$i];

$table_name = $_SESSION['db_prefix']."_order_lines_temp";
$receive_query = "INSERT INTO $table_name ( product_item_id, sub_category, item_type, quantity,  price, user_name) VALUES ('".$product_item_id."', '".$sub_category."', '".$item_type."', '".$quantity."', '".$price."',  '".$_SESSION['username']."' ) ";
$receive_result = $con->query($receive_query);

};
$i++;
}

$_SESSION['pallets'] = $_POST['pallets_text'];
	
	
	};
	
	if($s==4) {
	 
		 
	}
				
	?>

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

<!--jscript-->
<script type="text/javascript" src="../jscript/jquery.1.4.2.js"></script>
<script type="text/javascript" src="../window/dhtmlwindow.js"></script>
<script type="text/javascript" src="../window/modal.js"></script>
<script language="JavaScript" src="../jscript/gen_validatorv4.js"  type="text/javascript" xml:space="preserve"></script>
<script language="JavaScript" src="../jscript/cancel_confirmation.js"  type="text/javascript"></script>
<script language="JavaScript" src="../jscript/confirm_exit.js"  type="text/javascript"></script>
<script language="JavaScript" src="../jscript/show_hide_layers.js"  type="text/javascript"></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/alert_message.js"  type="text/javascript"></script>

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

</head>


<body>


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

<div class="page_head_frame">
  
<table width="678" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td width="547"><label class="label_page_head">Order 
              <?php  echo $_SESSION['comp_name'] ?>
          </label>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </td>
          <td width="131" align="center"><b>&nbsp;</b></td>
        </tr>
    </table>
 </div>     
      <div class='wizard_paging_frame'>
       <table align="left">
      <tr>
      <td>
      <?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 />
        Customer 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 />
      Customer details</div></div>
      <?php } ?>
      
      </td>
      <td>
      <?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 />
      Details</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 />
      Details</div></div>
      <?php } ?>
     </td>
     <td>
      <?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 />
      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 />
      Products</div></div>
      <?php } ?>
     </td>
     <td>
      <?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("newOrderWiz1.php"); }
	if ($_SESSION['p']==2) { include("newOrderWiz2.php"); }
	if ($_SESSION['p']==3) { include("newOrderWiz3.php"); }
	if ($_SESSION['p']==4) { include("newOrderWiz5.php"); }
	
    ?></td>
    </tr>
    </table>
    </div>

</div>

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