<!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('../include/session.php');
include ("../navigation/header.php");
$page_name = "Customer-edit";
include ("../navigation/access.php");
?>

<link href="../css/main.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../jscript/jquery.1.4.2.js"></script>
</head>
<?php
if ($permission_num==1) {
	include ("../navigation/sales_sidebar.php");

$page = $_GET['page'];

if ($page=='enquiry') {
$reference='quotation_request_edit.php?quote_no=';	
$page_name='Edit enquiry.';
$table_name = $_SESSION['db_prefix']."_quotations";
$quoteQuery = "SELECT quote_no, cust_id, project FROM $table_name WHERE status = 'request' ORDER BY quote_no DESC";
$quoteResult = execsql($quoteQuery);
$quoteNum = mysql_num_rows($quoteResult);
	$w = 0;
	$arrId4 = array ();
	$arrName4 = array ();
	while ($w < $quoteNum) {
		$cust_id = mysql_result($quoteResult, $w, "cust_id");
		$table_name = $_SESSION['db_prefix']."_customer";
		$name_query = "SELECT comp_name FROM $table_name WHERE cust_id = '".$cust_id."' ";
		$name_result = mySQL_query($name_query);
		$name_num = mysql_num_rows($name_result);
		if ($name_num!=0) {
			$name = mysql_result($name_result, 0, "comp_name");
		}
		else {
			$name = '';
		}
			
		$arrId4[$w] = mysql_result($quoteResult, $w, 'quote_no');
		$arrName4[$w] = "Q".mysql_result($quoteResult, $w, 'quote_no').' - '.$name.'('.mysql_result($quoteResult, $w, 'project').')';
		$w++;
	}
}
	
if ($page=='quotation') {
$reference='quotation_details_edit.php?quote_no=';	
$page_name='Edit quotation.';
$table_name = $_SESSION['db_prefix']."_quotations";
$quoteQuery = "SELECT quote_no, cust_id, project FROM $table_name WHERE status = 'quoted' ORDER BY quote_no DESC";
$quoteResult = execsql($quoteQuery);
$quoteNum = mysql_num_rows($quoteResult);
	$w = 0;
	$arrId4 = array ();
	$arrName4 = array ();
	while ($w < $quoteNum) {
		$cust_id = mysql_result($quoteResult, $w, "cust_id");
		$table_name = $_SESSION['db_prefix']."_customer";
		$name_query = "SELECT comp_name FROM $table_name WHERE cust_id = '".$cust_id."' ";
		$name_result = mySQL_query($name_query);
		$name_num = mysql_num_rows($name_result);
		if ($name_num!=0) {
			$name = mysql_result($name_result, 0, "comp_name");
		}
		else {
			$name = '';
		}
			
		$arrId4[$w] = mysql_result($quoteResult, $w, 'quote_no');
		$arrName4[$w] = "Q".mysql_result($quoteResult, $w, 'quote_no').' - '.$name.'('.mysql_result($quoteResult, $w, 'project').')';
		$w++;
	}
}

if ($page=='customer') {
$reference='customer_details_edit.php';
$page_name='Customer details';
?>
<!--style sheets-->
<link rel="stylesheet" type="text/css" href="../css/jquery.autocomplete.css" />

<!--jscript-->
<script type="text/javascript" src="../jscript/jquery.autocomplete.js"></script>
<script type="text/javascript">
 $(document).ready(function(){
  $("#customer_name_text").autocomplete("customer_autocomplete.php", {
        selectFirst: true
  });
 });
</script>

<?php

}

?>
<body>

<div class="main_frame">
<table width="630" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td height="52" colspan="4" align="left" valign="top"><div class="page_head_frame">
        <table width="630" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="385"><label class="label_page_head">Select to edit</label></td>
            <td align="right">&nbsp;</td>
          </tr>
        </table>
      </div>
<?php
if ($page=='customer') {
?>
<div class="page_middle_frame"><br />
  <label class="label_std" style="font-size:16px;"><?php echo $page_name?></label>
  <br />
  <br />
  <form action="customer_details_edit.php" method="get">
  <div class="wizard_frame">
    <label class="label_std"> Select customer to edit <?php echo $page_name?>: &nbsp;&nbsp;</label>
    <input name="customer_name_text" type="text" id="customer_name_text" class="text300" value=""  "this.value='';" onBlur="capitalize(this)"/>
    <input type="hidden" name="cust_id" id="cust_id" value=""/>
  </div>
  
  <br />
  <input type="submit" name="next_button" class="imagebutton" value="Next"  onclick="needToConfirm = false; MM_showHideLayers('wait','','show');" />
  <br />
</form>
<br />
<br />
<br />

</div>
<?php	      
}
else {
	?>
      
<div class="page_middle_frame"><br />
  <label class="label_std" style="font-size:16px;"><?php echo $page_name?></label>
  <br />
  <br />
  <form action="" method="get">
  <div class="wizard_frame">
    <label class="label_std"> Select job to edit <?php echo $page_name?>: &nbsp;&nbsp;</label>
    <select name="job_no_select" autofocus="autofocus" class="selectbox300" id="job_no_select" onchange="window.location.href= this.form.job_no_select.options[this.form.job_no_select.selectedIndex].value"> 
      <option value=" " selected="selected" >&nbsp;</option>
      <?php
    	for ($j = 0; $j < count($arrId4); $j++) {
			echo "<option value=".$reference.$arrId4[$j].">".$arrName4[$j]."</option>";	
		}
     ?>
    </select>
  </div>
  </form>
  <br />
  <br />
<br />
<br />
<br />

</div>
<?php
}
?>
    </td>
    </tr>
    </table>
</div>

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


<?php } else {
    $_SESSION['denied_return'] = "sales/sales_main.php?date=";	
    include ("../navigation/sales_sidebar.php");?>
    <?php include ('../navigation/side_bar.php'); ?>
	<body onLoad="accessdenied(); return false">	
	</body>
<?php }
?>
</html>
</body>