<!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/sales_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['type'] = $_GET['type_text'];	
  $_SESSION['sort'] = $_GET['sort_group'];	
  
  
  if ($_SESSION['type']=="client") {
	
	$cust_id = $_GET['comp_name_select'];	
	$_SESSION['id'] = $cust_id;
	$table_name = $_SESSION['db_prefix']."_customer";
	$cust_query="SELECT account_type, comp_name, contact_1, cell_1, name_2, title FROM $table_name WHERE cust_id = '".$cust_id."' ";
	$cust_result = mySQL_query($cust_query) or die ("Error in query:   $query . * ". mySQL_error());
	$c0 = mysql_result($cust_result, 0, "account_type");
    
	if ($c0=="corporate") { 
			$_SESSION['company_name'] = mysql_result($cust_result, 0, "comp_name"); } 
	else { 
			$_SESSION['company_name'] = mysql_result($cust_result, 0, "title")." ".mysql_result($cust_result, 0, "name_2")." ".mysql_result($cust_result, 0, "comp_name"); 
		}
		
	$_SESSION['comp_contact'] = mysql_result($cust_result, 0, "contact_1");
	$_SESSION['contact_phone'] = mysql_result($cust_result, 0, "cell_1");
	$num = mysql_num_rows($cust_result);
	
	if ($num==0)
	{ 
	$_SESSION['error']=1;
	$_SESSION['p']=1;
	$_SESSION['type'] = "";	
	$_SESSION['sort'] = "";	
	?>
    <script language="javascript" type="text/javascript">
        <!--
		needToConfirm = false;
	    window.location="quoteRequestWizbase.php?s=0&p=1";
        -->
     </script>
	
	<?php
	}
	
		$_SESSION['comp_contact'] = mysql_result($cust_result, 0, "contact_1");
		$_SESSION['contact_phone'] = mysql_result($cust_result, 0, "cell_1");
	
		
		
}

if ($_SESSION['type']=="contact") {
	
	$comp_name = $_GET['comp_name_text'];
	$name_2 = $_GET['name_2_text'];
	$table_name = $_SESSION['db_prefix']."_customer";
	$cust_query="SELECT cust_id FROM $table_name WHERE comp_name = '".$comp_name."' AND name_2 = '".$name_2."' ";
	
    $cust_result = mySQL_query($cust_query) or die ("Error in query:   $query . * ". mySQL_error());
	$num = mysql_num_rows($cust_result);
	
	$_SESSION['company_name'] = $name_2.' '.$comp_name ;
		
	if (($num!=0))
	{  
	$_SESSION['error']=2;
	$_SESSION['p']=1;
	$_SESSION['type'] = "";	
	$_SESSION['sort'] = "";	
	$_SESSION['company_name'] = $name_2.' '.$comp_name ;
	
	}
	
	else {
	$status = "new";
	$account_type = $_GET['sort_group'];
	$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['id'] = mysql_result($id_result, 0, "cust_id");
	
	
}
	}
	
	}
		
	if($s==2) {
		$_SESSION['receive_date']  = $_GET['receive_date'];
		$_SESSION['comp_contact']  = $_GET['comp_contact_text'];
		$_SESSION['contact_phone']  = $_GET['contact_phone_text'];
		$_SESSION['project_no']  = $_GET['project_no_text'];
		$_SESSION['project_place']  = $_GET['project_place_select'];
		$_SESSION['description']  = $_GET['description_text'];
		$_SESSION['require_date']  = $_GET['require_date'];
		$_SESSION['seller']  = $_GET['seller_select'];
		$_SESSION['designer']  = $_GET['designer_select'];
		
	  
 	};
	
	if($s==3) {
	 
	 
	};
	
	if($s==4) {
	 
		 
	}
	
	if($s==15) {
	 $_SESSION['reference'] = $_GET['reference'];
	 
	}
			
	?>

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


</head>


<body>


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

<div class="page_head_frame">
  <label class="label_page_head">Enquiry</label>&nbsp;&nbsp;<label class="label_page_head_2"><?php echo $_SESSION['company_name'] ?></label></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 />
      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>
      </tr>
      <tr>
      <td><?php 
	if ($_SESSION['p']==1) { include("quoteRequestWiz1.php"); }
	if ($_SESSION['p']==2) { include("quoteRequestWiz2.php"); }
	if ($_SESSION['p']==3) { include("quoteRequestWiz5.php"); }
	
    ?></td>
    </tr>
    </table>
    </div>

</div>

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