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

	$s = $_GET['s'];
	$p = $_GET['p'];
	$_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['type'] = $_GET['type_group'];
		$_SESSION['cust_id'] = $_GET['comp_name_select'];
		$_SESSION['job_cash'] = $job_cash;
					
					
		$table_name = $_SESSION['db_prefix']."_customer";
		$name_query = "SELECT comp_name FROM $table_name WHERE cust_id = '".$_SESSION['cust_id']."' ";
		$name_result = mySQL_query($name_query);
		$_SESSION['cust_name'] = mysql_result($name_result, 0, "comp_name");
		
		
		
			 if ($_SESSION['type']=='client') {
				    
				 	$table_name = $_SESSION['db_prefix']."_customer";
					$name_query = "SELECT comp_name FROM $table_name WHERE cust_id = '".$_SESSION['cust_id']."' ";
					$name_result = mySQL_query($name_query);
					$_SESSION['cust_name'] = mysql_result($name_result, 0, "comp_name");
			 }
			 
			  if ($_SESSION['type']=='contact') {
	               	$comp_name = $_GET['comp_name_text'];
					$table_name = $_SESSION['db_prefix']."_customer";
					$cust_query="SELECT cust_id FROM $table_name WHERE comp_name = '".$comp_name."' ";
	
    				$cust_result = mySQL_query($cust_query) or die ("Error in query:   $query . * ". mySQL_error());
					$num = mysql_num_rows($cust_result);
					$_SESSION['cust_name'] = $comp_name;
		
					if ($num!=0)
							{  
								$_SESSION['error']=2;
								$_SESSION['p']=1;
								//$_SESSION['type'] = "";	
								$_SESSION['sort'] = "";	
								$_SESSION['cust_name'] = $comp_name;
	
		
						?>
		<script language="javascript" type="text/javascript">
       						needToConfirm = false;
	 						// window.location="quoteRequestWizbase.php?s=0&p=1";
        		        </script>
		<?php
						}
	
					else {
							$status = "new";
							$account_type = $_GET['sort_group'];
							$_SESSION['sort'] = $account_type;
							$name = trim($_GET['comp_name_text']);
							$name_2 = trim($_GET['name_2_text']);
	
							$bag_box = trim($_GET['bag_box_select']);
							$box_number = trim($_GET['box_number_text']);
							$post_place = trim($_GET['post_place_select']);
							$phone = trim($_GET['phone_text']);
							$fax = trim($_GET['fax_text']);
							$email = trim($_GET['email_text']);
							$_SESSION['name'] = $name;
	
							$table_name = $_SESSION['db_prefix']."_customer";
	
	
    						$contact_query = "INSERT INTO $table_name (`account_type`,`status`, `comp_name`, `name_2`,`bag_box`, `box_no`, `postal_place`, `phone`, `fax`, `email_1`) VALUES ('".$account_type."', '".$status."',  '".$name."', '".$name_2."', '".$bag_box."', '".$box_number."', '".$post_place."', '".$phone."', '".$fax."', '".$email."') ";
   							execsql($contact_query);
	
							$table_name = $_SESSION['db_prefix']."_customer";
    						$id_query = "SELECT  cust_id  FROM $table_name WHERE comp_name  = '".$name."'  ";
	
							$id_result = mySQL_query($id_query);
    						$_SESSION['cust_id'] = mysql_result($id_result, 0, "cust_id");
	
	
							}
							}
			     
	};
	
	if($s==2) {
		$_SESSION['supply_date'] = $_GET['supply_date'];
		
		if ($_SESSION['list2']==0) { 
		      $_SESSION['error2']=1;
			  ?>
			  <script>
			    needToConfirm = false;
			    window.location='supplyOrderWizbase.php?p=2&s=';
				
			</script>
            
            <?php
		} 
		else {
			$_SESSION['error2']=0;
			
		}
	 
	}
	
	if($s==3) {
	   
	 
	};
	
	if($s==4) {
	 
	}
	
	if($s==10) {
		$store_item_id = $_GET['store_item_select'];
		$quantity = $_GET['quantity_text'];
				
		$table_name = $_SESSION['db_prefix']."_supply_customer_temp";
		$supply_query = "INSERT INTO $table_name ( `job_no`, `truss_type`, `store_item_id`, `quantity`, `user`) VALUES ('".$_SESSION['job_no']."', 'Cash', '".$store_item_id."', '".$quantity."', '".$_SESSION['username']."' ) ";
		execsql($supply_query);
		
		if (isset($_GET['next_add_button']) )
	   { 
	    $_SESSION['screen']=1;
		?>
		<script>
	   editwindow=dhtmlmodal.open('editBox', 'iframe', '../edit_windows/job_supply_add.php?category=&sub_category=', 'Add item', 'width=500px,height=250px,center=1,resize=0,scrolling=0')
needToConfirm = false;
		</script>
		<?php		 
	   }
		
	}
	
	if($s==11) {
		$supply_id = $_GET['supply_id'];
		$quantity = $_GET['quantity_text'];
		
				
		$table_name = $_SESSION['db_prefix']."_supply_customer_temp";
		
		
		$supply_edit_query = "UPDATE $table_name SET quantity='".$quantity."' WHERE supply_id = '".$supply_id."' ";
		execsql($supply_edit_query);
	}
	
	if($s==12) {
		$supply_id = $_GET['supply_id'];
		
		$table_name = $_SESSION['db_prefix']."_supply_customer_temp";
		$delete_query = "DELETE FROM $table_name WHERE supply_id = '".$supply_id."' "; 
		execsql($delete_query);
	}
	
	?>
		<!--style sheets-->
		<link rel="stylesheet" type="text/css" href="../css/wizard.css" />
		<!--reference to main.css removed-->
		<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 type="text/javascript" src="../window/dhtmlwindow.js"></script>
		<script type="text/javascript" src="../window/modal.js"></script>
		<script language="JavaScript" src="../jscript/jquery1.4.2.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>
		<script language="JavaScript" src="../jscript/show_hide_layers.js"  type="text/javascript"></script>

		<body>
<div class="main_frame" style="height:auto; min-height:550px;">
          <table id="tableMain" width="595">
    <!--begin of tableMain-->
    <tr>
              <td ><div class="page_head_frame">
                  <label class="label_page_head">Cash sale </label>
                  &nbsp;&nbsp;
                  <label class="label_page_head_2"><?php echo $_SESSION['cust_name'] ?></label>
                </div>
        <br />
        <br />
        <br />
        <br />
        <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</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</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 />
                          Items</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 />
                          Items</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 />
                          Finish</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 />
                          Finish</div>
              </div>
                      <?php } ?></td>
          </tr>
                </table>
                </div>
                </td>
              <!--center of tableMain--> 
            </tr>
    <tr>
              <td><!--center of tableMain-->
        
        <?php 
	if ($_SESSION['p']==1) { include("supplyOrderWiz1.php"); }
	if ($_SESSION['p']==2) { include("supplyOrderWiz2.php"); }
	if ($_SESSION['p']==3) { include("supplyOrderWiz4.php"); }
	//if ($_SESSION['p']==4) { include("supplyOrderWiz4.php"); }
//	if ($_SESSION['p']==5) { include("supplyOrderWiz5.php"); }
    ?></td>
            </tr>
  </table>
        </div>
<?php include ('../navigation/side_bar.php'); ?>

		</body>
