<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<?php
include('../include/session.php');
$quote_no = $_GET['quote_no'];
	
$table_name2 = $_SESSION['db_prefix']."_quotations";
$quote_query = "SELECT cust_id, type, seller, status, request_date, company_contact, contact_phone, seller, project, project_no, project_description, required_date, project_area, project_place FROM $table_name2 WHERE quote_no ='".$quote_no."' ";
$quote_result = mySQL_query($quote_query);
$quote_num = mysql_num_rows($quote_result);


$a1 = mysql_result($quote_result, 0, "cust_id");
$a2 = mysql_result($quote_result, 0, "type");
$a3 = mysql_result($quote_result, 0, "seller");
$a4 = mysql_result($quote_result, 0, "status");
$a5 = mysql_result($quote_result, 0, "request_date");
$a6 = mysql_result($quote_result, 0, "company_contact");
$a7 = mysql_result($quote_result, 0, "contact_phone");
$a8 = mysql_result($quote_result, 0, "project_no");
$a9 = mysql_result($quote_result, 0, "project_description");
$a10 = mysql_result($quote_result, 0, "project");
$a11 = mysql_result($quote_result, 0, "project_area");
$a12 = mysql_result($quote_result, 0, "project_place");

$cust_id = $a1;

$table_name3 = $_SESSION['db_prefix']."_customer";
$customer_query = "SELECT account_type, comp_name, name_2, title, bag_box, box_no, postal_place, phone, contact_1, email_1, cell_1, status FROM $table_name3 WHERE cust_id = '".$a1."' ";
$customer_result = mySQL_query($customer_query);
$c0 = mysql_result($customer_result, 0, "account_type");
if ($c0=="corporate") { $c1 = mysql_result($customer_result, 0, "comp_name"); } else { $c1 = mysql_result($customer_result, 0, "title")." ".mysql_result($customer_result, 0, "name_2")." ".mysql_result($customer_result, 0, "comp_name"); }
$c2 = mysql_result($customer_result, 0, "bag_box");
$c3 = mysql_result($customer_result, 0, "box_no");
$c4 = mysql_result($customer_result, 0, "postal_place");
$c5 = mysql_result($customer_result, 0, "phone");
$c6 = mysql_result($customer_result, 0, "contact_1");
$c7 = mysql_result($customer_result, 0, "email_1");
$c8 = mysql_result($customer_result, 0, "status");
$c9 = mysql_result($customer_result, 0, "cell_1");

$table_name = $_SESSION['db_prefix']."_list_sellers";
$sellers_query = "SELECT item_name FROM $table_name  ORDER BY item_name ASC";
	$sellers_result = execsql($sellers_query);
	$sellers_num = mysql_num_rows($sellers_result);
	$w = 0;
	$arrId2 = array ();
	$arrName2 = array ();
	while ($w < $sellers_num) {
		$arrId2[$w] = mysql_result($sellers_result, $w, "item_name");
		$arrName2[$w] = mysql_result($sellers_result, $w, "item_name");
		$w++;
	}
	
$table_name = $_SESSION['db_prefix']."_list_places";
    $position_query = "SELECT item_name FROM $table_name ORDER BY item_name ASC";
	$arrId3 = array ();
	$arrName3 = array ();
	$position_result = execsql($position_query);
	if ($position_result!="") {
	$position_num = mysql_num_rows($position_result);
	$b = 0;
	while ($b < $position_num) {
		$arrId3[$b] = mysql_result($position_result, $b, "item_name");
		$arrName3[$b] = mysql_result($position_result, $b, "item_name");
		$b++;
	}
	}
	
$table_name = $_SESSION['db_prefix']."_list_area";
    $position_query = "SELECT item_name FROM $table_name ORDER BY item_name ASC";
	$arrId5 = array ();
	$arrName5 = array ();
	$position_result = execsql($position_query);
	if ($position_result!="") {
	$position_num = mysql_num_rows($position_result);
	$b = 0;
	while ($b < $position_num) {
		$arrId5[$b] = mysql_result($position_result, $b, "item_name");
		$arrName5[$b] = mysql_result($position_result, $b, "item_name");
		$b++;
	}
	}

?>
<!--<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 type="text/javascript" src="../jscript/tablesort.js"></script>

</head>

<body>
<?php
include ("../navigation/header.php");
$page_name = "Sales-main";
include ("../navigation/access.php");

if ($permission_num==1) {
	include ("../navigation/sales_sidebar.php");
?>

<div class="main_frame" >
  <div class="page_head_frame">
     <table width="690" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="556"><label class="label_page_head">Edit enquiry<b></b>&nbsp;&nbsp;</label>              
              <label class="label_page_head_2"><?php echo $c1 ?></label></td>
            <td width="124"><label class="label_quote_no"><?php echo "Q".$quote_no ?></label></td>
            </tr>
        </table>
      </div>
<form action="quotation_request_edit_save.php" method="post">
<div class="page_middle_frame">
  <div class="page_inside_frame" style="width:680px;"> Quotation details:
    <table width="650" id="table_details_display">
      <tr>
        <td width="123">Sales person:</td>
        <td colspan="3"><select name="seller_select" id="seller_select" class="select300" tabindex="8">
          <option value="<?php echo $a3?>" selected="selected"><?php echo $a3?></option>
          <?php 
    	for ($w = 0; $w < count($arrId2); $w++) {
		echo "<option value=\"".$arrId2[$w] . "\"" . ">" . $arrName2[$w] . "</option>";	
	    }
     ?>
        </select></td>
        </tr>
      <tr>
        <td>Quote no.:</td>
        <td width="205"><?php echo "Q".$quote_no ?></td>
        <td width="109">Enquiry  date:</td>
        <td width="213"><?php echo date("d-m-Y", strtotime($a5)) ?></td>
      </tr>
    </table>
  </div>

<div class="page_inside_frame" style="width:680px;"> Quotation requested by:
<?php 
		include ('../include/customer_block.php');
		?>

</div>


<div class="page_inside_frame" style="width:680px;"> Quotation project
  <table width="650" id="table_details_display">
    <tr>
      <td width="108">Enquiry date:</td>
      <td colspan="5"><?php echo date("d-m-Y", strtotime($a5)) ?></td>
      </tr>
    <tr>
      <td>Project:</td>
      <td colspan="5"><select name="project_select" id="project_select" class="select160" tabindex="3">
        <option value="<?php echo $a10 ?>"><?php echo $a10 ?></option>
        <option value="Manase 358">Manase 358</option>
        <option value="Diamond mesh">Diamond mesh</option>
        <option value="Electric fencing">Electric fencing</option>
        <option value="Farm fence">Farm fence</option>
        <option value="Free standing electric fence">Free standing electric fence</option>
        <option value="Gate">Gate</option>
        <option value="Gate motor">Gate motor</option>
        <option value="Miscelaneous">Miscelaneous</option>
        <option value="Palisade standard">Palisade standard</option>
        <option value="Palisade fencing">Palisade fencing</option>
        <option value="Pool fence">Pool fence</option>
        <option value="Razor wire">Razor wire</option>
        <option value="Wall spikes">Wall spikes</option>
      </select></td>
      </tr>
    <tr>
      <td>Project no:</td>
      <td width="206"><input name="project_no_text" type="text" class="text100" id="project_no_text" onkeyup="ToLower(this)" onblur="capitalize(this)" value="<?php echo $a8?>" tabindex="4" /></td>
      <td width="36">Area:</td>
      <td width="56"><select name="project_area_select" class="select120" tabindex="5" >
        <option value="<?php echo $a11 ?>" selected="selected"><?php echo $a11 ?></option>
        <?php
        	for ($j = 0; $j < count($arrId5); $j++) {
    		echo "<option value=" . "\"" . $arrId5[$j] . "\"" . ">" . $arrName5[$j] . "</option>";
	}
?>
      </select></td>
      <td width="76">Place:</td>
      <td width="140"><select name="project_place_select" class="select120" tabindex="6" >
        <option value="<?php echo $a12 ?>" selected="selected"><?php echo $a12 ?></option>
        <?php
        	for ($j = 0; $j < count($arrId3); $j++) {
    		echo "<option value=" . "\"" . $arrId3[$j] . "\"" . ">" . $arrName3[$j] . "</option>";
	}
?>
      </select></td>
    </tr>
    <tr>
      <td>Project description:</td>
      <td colspan="5"><textarea name="project_description_text" class="text_box" cols="80" rows="3"><?php echo $a9 ?></textarea></td>
      </tr>
  </table>
</div>

<div class="page_inside_frame">
  <table width="645" border="0">
    <tr>
      <td width="20"></td>
      <td width="615" align="right">
        <input type="hidden" name="quote_no_text" id="quote_no_text" value="<?php echo $quote_no ?>" />
        <input name="button2" type="button" class="imagebutton" id="button2" onclick="cancel_confirmation(3, '../sales/sales_main.php?date=0');" value="Close"/>
        <input name="save_button"  id="save_button" type="submit" class="imagebutton" value="Save" onclick="needToConfirm = false; confirmRefresh();" />
        <input name="save_close_button"  id="save_close_button" type="submit" class="imagebutton" value="Save &amp; Close" onclick="needToConfirm = false; confirmRefresh();" /></td>
    </tr>
  </table>
</div>  
</div>
</form>
</div>
</body>  
<?php include ('../navigation/side_bar.php'); ?>

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