<?php include("../../include/dbconnect.php");
// Get all _POST VALUES HERE..

foreach($_POST as $p=>$t)
{
	$_POST[$p] = trim($t);
}
$myCustomer = $_POST['Customer'];
foreach($_POST as $q=>$r)
{
	$_POST[$q] = trim($r);
}
$myProduct = $_POST['Product'];

?>
<title>Enquiry View</title>
<body background=blater01.gif  topmargin=0>
<center> 
<table cellpadding=0 cellspacing=4 width=590>
<tr> 
<td style="padding:3px;" colspan=2 bgcolor="#93BEE2"><font face="Verdana, Arial, Helvetica, sans-serif"><b><b>View and Edit Enquiry</b></font></td>
</tr>
<tr valign="top"> 
<td colspan=2> <font >&nbsp;</font> </td>
</tr>
</table>
 
 <table border=0 width="602">
 <tr> 
<td width="139" height="31" align="left" ><font color="#003366" size="2" face="Verdana, Arial, Helvetica, sans-serif"><b>1. Customer Name
  &nbsp;</b></font></td>
  <td>
<?

// Pull all the data from Customer master & populate it
$stQuery = mysql_query("select distinct enquiry.bcode,buy.name,unit,buy.buyertype from enquiry, buy  where enquiry.bcode = buy.bcode order by buy.name")or die( mysql_error() );

?>
 <form name='myForm01' method='POST' action='<?=$_SERVER[PHP_SELF]?>'>
  <SELECT name='Customer' onChange="javascript:submit();">
    <?
echo "<option selected value=\" 0\"> Select Customer";
while($row = mysql_fetch_row($stQuery))
{
	   if($row[3]== 'LABOUR')
	   {
		   	$type='------>>'.$row[3];
		}
		elseif($row[3]!= 'LABOUR')
		{
			$type ='';
		}	
	$temp = $row[1].'&nbsp;&nbsp;'.$row[2].$type;
	if(isset($myCustomer) && eregi("$myCustomer",$row[0]))
	{
		echo "<option selected value=\"$row[0]\">$temp";
	}
	else{
		echo "<option value=\"$row[0]\">$temp";
	}
}
?>
  </SELECT></td></tr>
  
<tr>
<td width="139" height="31" align="right" ><div align="left"><font color="#003366" size="2" face="Verdana, Arial, Helvetica, sans-serif"><b>2. Product Name
  &nbsp;</b></font></div></td>
<td width="174">
<SELECT name="Product"  onChange="javascript:submit();">
<?
$bkquery = "SELECT  prodname,drawing_no,prodcode FROM product WHERE bcode ='$myCustomer' order by prodname,drawing_no ";
    $bkquery=stripslashes($bkquery);
    $result=mysql_query($bkquery) or       die( mysql_error() );
   echo "<option selected value=' '> Select Product";
   while($row1 = mysql_fetch_row($result))
{
          //echo "<option value='$row1[2]'>";
          //echo ($row1[0].'&nbsp;&nbsp;Dr. No:'.$row1[1]);
		  	$temp = $row1[0].'&nbsp;&nbsp;'.$row1[1].$type;
  	if(isset($Product) && eregi("$Product",$row1[2]))
	{
		echo "<option selected value=\"$row1[2]\">$temp";
	}
	else{
		echo "<option value=\"$row1[2]\">$temp";
	}


}
?>
</SELECT></td>
</tr>


</form>
<form name="form1" method="POST"  action="update.php">


<?
//echo "cust   " . "$myCustomer";
//echo "cat    " . "$myCat";
//echo "prod   " . "$Product";
// Pull all Customers from Customer  based on Selected Customer id and populate it.

$result = mysql_query("select distinct enquiry.record, enquiry.bcode, enquiry.prodcode, enquiry.drawing_no, enquiry.enquiry_refno, enquiry.enquiry_refdt, enquiry.qty, enquiry.sample, enquiry.tools, enquiry.feasible, enquiry.enquiry_open, enquiry.tools_cost, enquiry.quot_sub_dt, enquiry.quot_refno, enquiry.quot_refdt, enquiry.quot_rev_by, enquiry.order_sub_dt, enquiry.diff_order_quot, enquiry.Details_cus, enquiry.order_refno, enquiry.sample_give_dt, enquiry.approv_by, enquiry.amend_dt, enquiry.amend_details, enquiry.amend_comm
 FROM enquiry, product WHERE (enquiry.bcode ='$myCustomer') and  enquiry.prodcode= '$myProduct'  group by enquiry.record order by enquiry_refno,enquiry_refdt ") or die(mysql_error());

//and (enquiry.prodcode=product.prodcode and product.bcode = '$myCustomer')
?>


<?php 

 $row1=mysql_fetch_row($result);

// echo "cust  " . "$myCustomer";
// echo "product  "."$myProduct";
// echo "cat " . "$myCat";
if (empty($row1))
{
// echo 'The Customer is not having any Enquiry ' ;
}
?>

<input type="hidden" name="record" value="<? echo($row1[0]); ?>">

<tr > 
  <td width="418" height="31" align="left" ><font color="#003366" size="2" face="Verdana, Arial, Helvetica, sans-serif"><b>Enquiry Ref No  &nbsp;</b></font></td>
  <td>
<input type="text"    onKeyPress="return event.keyCode!=13"   size='20' name="enquiry_refno" value = <?php echo("'$row1[4]'");?>>  </td></tr>

<SCRIPT LANGUAGE="JavaScript" src="../../include/CalendarPopup.js"></SCRIPT>
<SCRIPT LANGUAGE="JavaScript">
var cal = new CalendarPopup();
</SCRIPT>

<?
if ($row1[5]==0)
{
//echo "z";
  $sdt=substr($row1[5],8,2).'/'.substr($row1[5],5,2).'/'.substr($row1[5],0,4);
}
else
{
//echo "y";
$refdt = $row1[5];
$sdt = substr($refdt,8,2).'/'.substr($refdt,5,2).'/'.substr($refdt,0,4);
//echo "xxx" . "$enqrefdt";
}
?>
<tr>
<td width="418" height="31" align="right" ><div align="left"><font color="#003366" size="2" face="Verdana, Arial, Helvetica, sans-serif"><b>Enquiry Ref Date &nbsp;</b></font></div></td>
<td>
<INPUT NAME="sdt" TYPE="text" class="text_box_button" VALUE="<?=$sdt?>" SIZE="15" readonly  >
 <A HREF="#" onClick="cal.select(document.form1.sdt,'anchor1','dd/MM/yyyy'); return false;"NAME="anchor1" ID="anchor1"><img  src="../../images/cal.gif" border="0"></A> <BR>
 </td>
</tr>


<tr > 
  <td width="418" height="31" align="left" ><font color="#003366" size="2" face="Verdana, Arial, Helvetica, sans-serif"><b>3. Quantity  &nbsp;</b></font></td>
  <td>
<input type="text"    onKeyPress="return event.keyCode!=13"   size='20' name="qty" value = <?php echo ("$row1[6]") ?> >  </td></tr>

<tr > 
  <td width="418" height="31" align="left" ><font color="#003366" size="2" face="Verdana, Arial, Helvetica, sans-serif"><b>4. Sample / Drawings given by customer [Drawing / Tools] &nbsp;</b></font></td>
  <td>
<input type="text"    onKeyPress="return event.keyCode!=13"   size='20' name="sample" value = <?php echo ("$row1[7]") ?> >  </td></tr>

<tr > 
  <td width="418" height="31" align="left" ><font color="#003366" size="2" face="Verdana, Arial, Helvetica, sans-serif"><b>5. Tools given by customer &nbsp;</b></font></td>
  <td>
<input type="text"    onKeyPress="return event.keyCode!=13"   size='20' name="tools" value = <?php echo ("$row1[8]") ?> >  </td></tr>

<tr > 
  <td width="418" height="31" align="left" ><font color="#003366" size="2" face="Verdana, Arial, Helvetica, sans-serif"><b>6. Tools Developed by Wilson &nbsp;</b></font></td>
  <td>
<input type="text"    onKeyPress="return event.keyCode!=13"   size='20' name="tools_cost" value = <?php echo ("$row1[11]") ?> >  </td></tr>

<?
if ($row1[12]==0)
{
  $qsubdt=strftime ("%d/%m/%Y", mktime (0,0,0,date("m"),date("d"),date("Y"))); 
  //$qsubdt=substr($row1[12],8,2).'/'.substr($row1[12],5,2).'/'.substr($row1[12],0,4);
}
else
{
$qdt = $row1[12];
$qsubdt = substr($qdt,8,2).'/'.substr($qdt,5,2).'/'.substr($qdt,0,4);
}
?>

<tr><td  width="418" height="31" align="left"><font color ="#003366" size="2" face="Verdana, Arial, Helvetica, sans-serif"><b>7. Quotation to be Submitted on(date) </b></font></td>
<td>
<INPUT NAME="qsubdt" TYPE="text" class="text_box_button" VALUE="<?=$qsubdt?>" SIZE="15" readonly  >
 <A HREF="#" onClick="cal.select(document.form1.qsubdt,'anchor1','dd/MM/yyyy'); return false;"NAME="anchor1" ID="anchor1"><img  src="../../images/cal.gif" border="0"></A> <BR>
 </td>
</tr>

<tr><td  width="418" height="31" align="left"><font color ="#003366" size="2" face="Verdana, Arial, Helvetica, sans-serif"><b>8. Feasible to supply </b></font></td>
<td><input type="text"    onKeyPress="return event.keyCode!=13"   size='20' name="feasible" value = <?php echo ("$row1[9]")?> ></td></tr>

<?
if ($row1[14]==0)
{
 $qrefdt =strftime ("%d/%m/%Y", mktime (0,0,0,date("m"),date("d"),date("Y"))); 
}
else
{
$qdt = $row1[14];
$qrefdt = substr($qdt,8,2).'/'.substr($qdt,5,2).'/'.substr($qdt,0,4);
}
?>
</table>
<body>
<hr align = center width = 600 >
</hr>
</body>
<table border=0 width="602">
<tr><td  width="300" height="31" align="left"><font color ="#003366" size="2" face="Verdana, Arial, Helvetica, sans-serif"><b>9. Quotation Ref No. & Date</b> </font></td>
<td>
<INPUT NAME="qrefdt" TYPE="text" class="text_box_button" VALUE="<?=$qrefdt?>" SIZE="15" readonly  >
 <A HREF="#" onClick="cal.select(document.form1.qrefdt,'anchor1','dd/MM/yyyy'); return false;"NAME="anchor1" ID="anchor1"><img  src="../../images/cal.gif" border="0"></A> <BR>
 </td>
</tr>


<tr><td  width="139" height="31" align="left"><font color ="#003366" size="2" face="Verdana, Arial, Helvetica, sans-serif"><b>10. Reviewed By</b> </font></td><td>
<input type="text"    onKeyPress="return event.keyCode!=13"   size='20' name="quot_rev_by" value = <?php echo("'$row1[15]'");?>>  </td></tr>

</table>
<body>
<hr align = center width = 600 >
</hr>
</body>
<table border=0 width="602">

<?
if ($row1[16]==0)
{
 $odt =strftime ("%d/%m/%Y", mktime (0,0,0,date("m"),date("d"),date("Y"))); 
}
else
{
$oodt = $row1[16];
$odt = substr($oodt,8,2).'/'.substr($oodt,5,2).'/'.substr($oodt,0,4);
}
?>
<tr><td  width="139" height="31" align="left"><font color ="#003366" size="2" face="Verdana, Arial, Helvetica, sans-serif"><b>11. Order Acceptance received on</b> </font></td>
<td>
<INPUT NAME="odt" TYPE="text" class="text_box_button" VALUE="<?=$odt?>" SIZE="15" readonly  >
 <A HREF="#" onClick="cal.select(document.form1.odt,'anchor1','dd/MM/yyyy'); return false;"NAME="anchor1" ID="anchor1"><img  src="../../images/cal.gif" border="0"></A> <BR>
 </td>
</tr>


<tr><td  width="139" height="31" align="left"><font color ="#003366" size="2" face="Verdana, Arial, Helvetica, sans-serif"><b>12. Difference between order / Quotation</b> </font></td><td>
<input type="text"    onKeyPress="return event.keyCode!=13"   size='20' name="diff_order_quot" value = <?php echo("'$row1[17]'");?>>  </td></tr>

<tr><td  width="300" height="31" align="left"><font color ="#003366" size="2" face="Verdana, Arial, Helvetica, sans-serif"><b>13. Details of resolution with customer (regret)</b> </font></td><td><input type="text"    onKeyPress="return event.keyCode!=13"   size='20' name="details_cus" value = <?php echo("'$row1[18]'");?>>  </td></tr>

<tr><td  width="139" height="31" align="left"><font color ="#003366" size="2" face="Verdana, Arial, Helvetica, sans-serif"><b>14. Order.ref </b></font></td><td>
<input type="text"    onKeyPress="return event.keyCode!=13"   size='20' name="order_refno" value = <?php echo("'$row1[19]'");?>>  </td></tr>

<?
if ($row1[20]==0)
{
 $srefdt =strftime ("%d/%m/%Y", mktime (0,0,0,date("m"),date("d"),date("Y"))); 
}
else
{
$sdt = $row1[20];
$srefdt = substr($sdt,8,2).'/'.substr($sdt,5,2).'/'.substr($sdt,0,4);
}
?>

<tr><td  width="139" height="31" align="left"><font color ="#003366" size="2" face="Verdana, Arial, Helvetica, sans-serif"><b>15. Sample should be given on </b></font></td>
<td>
<INPUT NAME="srefdt" TYPE="text" class="text_box_button" VALUE="<?=$srefdt?>" SIZE="15" readonly  >
 <A HREF="#" onClick="cal.select(document.form1.srefdt,'anchor1','dd/MM/yyyy'); return false;"NAME="anchor1" ID="anchor1"><img  src="../../images/cal.gif" border="0"></A> <BR>
 </td>
</tr>

<tr><td  width="139" height="31" align="left"><font color ="#003366" size="2" face="Verdana, Arial, Helvetica, sans-serif"><b>16. Reviewed and Approved by </b></font></td><td>
<input type="text"    onKeyPress="return event.keyCode!=13"   size='20' name="approv_by" value = <?php echo("'$row1[21]'");?>>  </td></tr>
</table>
<body>
<hr align = center width = 600 >
</hr>
</body>
<table border=0 width="602">
<h3> AMEDEMENT DETAILS </h3>

<?
if ($row1[22]==0)
{
 $amddt = date(d).'/'.date(m).'/'.date(Y); 
}
else
{
$adt = $row1[22];
$amddt = substr($adt,8,2).'/'.substr($adt,5,2).'/'.substr($adt,0,4);
}
?>
<table>

<table border=1 cellpadding="10"  width="602">
<tr><td><font color ="#003366" size="2" face="Verdana, Arial, Helvetica, sans-serif"><b>Date</b> </font></td>
<td ><font color ="#003366" size="2" face="Verdana, Arial, Helvetica, sans-serif"><b>Details of Amendment</b> </font></td>
<td ><font color ="#003366" size="2" face="Verdana, Arial, Helvetica, sans-serif"><b>Communicated to</b> </font></td>

</tr>
<tr>
<td>
  <textarea name="amddt" cols="20" onKeyPress="return event.keyCode!=13"><?php echo("$amddt");?></textarea>  </td>
<td><textarea name="amend_details" cols="20" onKeyPress="return event.keyCode!=13"><?php echo("$row1[23]");?></textarea>  </td>
<td><textarea name="amend_comm" cols="20" onKeyPress="return event.keyCode!=13"><?php echo("$row1[24]");?></textarea>  </td>
</tr>
</table>

<table border=0 width="602">

<tr> 
<td align="right" ><font color="#003366" size="2" face="Verdana, Arial, Helvetica, sans-serif"><b>Accepted</b></font></td>
<td> <input type="radio"    onKeyPress="return event.keyCode!=13"   name="enquiry_open" value = "No" checked> <font color="#003366" size="2" face="Verdana, Arial, Helvetica, sans-serif"><b>No</b></font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <input type="radio"    onKeyPress="return event.keyCode!=13"   name="enquiry_open" value = "Yes"> <font color="#003366" size="2" face="Verdana, Arial, Helvetica, sans-serif"><b>Yes </b></font>&nbsp;</td>
</tr>  
</table>
<table>
<tr>
<blockquote>  
<? //echo "$enqrefdt";?>
<td><input  type =submit name=submit value = "Update"></td> 
<td><input type =submit name=submit value = "Delete"></td>
<td><input type =submit name=submit value = "Print"></td>
</blockquote>
</table>


<br><br><font size=1><center><a href= "index.html">Return to index page</a></center></font>
</body></form>

