<?php
$PageSecurity = 5;
include('includes/session.inc');
?>
<script>
function validate()
{
for(var i=0;i<final_Quot[i].length;i++)
{
	if(document.getElementById('final_Quot').checked==false) 
		{
 			alert('Plese Select Any one Quotation Number !');
			document.getElementById('final_Quot').focus;
			return true
 		}
}

}
</script>
<?php
$title = _('Comparative Vendor Quotation');
include('includes/header.inc');
include('includes/SQL_CommonFunctions.inc');
$RequisitionNo = $_REQUEST['RequisitionNo'];
 ?>
    <form action="PO_Header.php?" method="post" name="finalqt" id="finalqt">
	
	
	
	<table  WIDTH=100% cellpadding="2" cellspacing="2" >
	<tr class="EvenTableRows">
	        <td width="2%">&nbsp;</td>
	            <td width="5%">Vendor Quot. No</td>
		       <td width="16%">Site Name</td>
				<td width="6%">Quot. Entry No</td>
				<td width="7%">Quot. Date</td>
				<td width="11%">Vendor Name</td>
				<td width="5%">Vendor ID</th>
				<td width="6%">Quot. Catagory</td>
			    <td width="5%">Basis</td>
				<td width="5%">Remarks</td>
				<td width="7%">Product Code</td>
			    <td width="6%">Product Name</td>
				<td width="4%">Quantity</td>
				<td width="3%">Rate	</td>
				<td width="6%">Created by</td>
				<td width="6%">Requisition No.</td>
	                 
      </tr>
	   <?php 
	           $sqlvend="SELECT id FROM venderquotations WHERE pr_no='".$RequisitionNo."'";
				$resultvand=DB_query($sqlvend,$db);
				while($vendorid=DB_fetch_array($resultvand))
				{
				//echo"Amit Kumar"; $vendorid['pr_no'];
	  ?>
			<tr class="OddTableRows">
              <td width="2%" align="center" ><input name="final_Quot" id="final_Quot[]" type="radio" value="<?php echo $vendorid['id']; ?>" onClick="FinalQuotation(this.value)"/></td>
<!--                  <td width="47%" colspan="14"><div align="left">Check Final Quot</div></td>
-->				  <td align="left" colspan="15">
		  
		  <table width="100%" border="0">
		  <?php 
		 
			 $sql='SELECT venderquotations.id, 
		                  venderquotations.sitecode,
						  venderquotations.site, 
						  venderquotations.quotationentryno, 
						  venderquotations.date1, 
						  suppliers.suppname, 
						  suppliers.supplierid, 
						  venderquotations.vendercode, 
						  venderquotations.quotationcategory, 
						  venderquotations.basis, 
						  venderquotations.remarks,
						  vendorquotationdetails.quotation_id, 
						  vendorquotationdetails. prod_id, 
						  vendorquotationdetails.prod_dec, 
						  vendorquotationdetails.quantity, 
						  vendorquotationdetails.rate, 
						  venderquotations.delivery_by, 
						  venderquotations.pr_no FROM  venderquotations
						  INNER JOIN suppliers ON suppliers.supplierid=venderquotations.vendercode 
						  INNER JOIN vendorquotationdetails ON vendorquotationdetails.quotation_no=venderquotations.id 
						  WHERE venderquotations.pr_no='.$RequisitionNo. ' and id='.$vendorid['id']; 
			  $result=DB_query($sql,$db);
			  $j = 1;
			  $k=0; //row colour counter
			 while($myrow=DB_fetch_array($result))
			 {	
			 
				if ($k==1){ /*alternate bgcolour of row for highlighting */
					echo '<tr class="OddTableRows">';
					$k=0;
				} else {
					echo '<tr class="EvenTableRows">';
					$k++;
				}
               ?>
			<td width="5%"><?php echo $myrow['id']; ?>
			<input type="hidden" name="Vendorqtnid" id="Vendorqtnid" value="<?php echo $myrow['id']; ?>"  /></td>
			<td width="16%"><?php echo $myrow['site']; ?>
			  <input type="hidden" name="sitecode" id="sitecode" value="<?php echo $myrow['sitecode']; ?>"  />
			<input type="hidden" name="sitename" id="sitename" value="<?php echo $myrow['site']; ?>"  /></td>
			<td width="6%"><?php  ?></td>
			<td width="8%"><?php echo ConvertSQLDate($myrow['date1']); ?></td>
			<td width="10%"><?php  echo $myrow['suppname']; ?>
			<input type="hidden" name="suppid" id="suppid"  value="<?php echo $myrow['supplierid']; ?>" /></td>
			<td width="6%"><?php echo $myrow['vendercode']; ?>
			<input type="hidden" name="vendername" id="vendername" value="<?php echo $myrow['suppname']; ?>" />
			<input type="hidden" name="vendercode" id="vendercode" value="<?php echo $myrow['supplierid']; ?>"  /></td>
			<td width="6%"><?php echo $myrow['quotationcategory']; ?></td>
			<td width="5%"><?php echo $myrow['basis']; ?></td>
			<td width="6%"><?php echo $myrow['remarks']; ?></td>
			<td width="7%"><?php echo $myrow['prod_id']; ?>
			<input type="hidden" name="prod_id"  value="<?php echo $myrow['prod_id']; ?>" /></td>
			<td width="6%"><?php echo $myrow['prod_dec']; ?></td>
			<td width="4%"><?php echo $myrow['quantity']; ?></td>
			<td width="4%"><?php echo $myrow['rate']; ?></td>
			<td width="5%"><?php echo $myrow['delivery_by']; ?></td>
			<td width="6%"><?php echo $myrow['pr_no']; ?> 
			<input type="hidden" name="reqno" id="reqno"  value="<?php echo $myrow['pr_no']; ?>" /></td>
		  </tr>
		  <?php } ?>
</table>
		</td>
	    </tr>	
<tr><td colspan="30">&nbsp;</td></tr>
<?php } ?>
</table>
    
    </form>



<script type="text/javascript">


function FinalQuotation(str)
	{ 
	   xmlHttp=GetXmlHttpObject();
			if (xmlHttp==null)
			  {
				alert ("Your browser does not support AJAX!");
				return;
			  } 
		var url="FinalQuot.php";
		url=url+"?FinalQuot="+str;
		//alert(url);
		xmlHttp.onreadystatechange=NumberChanged1;
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
	}
	
  function NumberChanged1() 
	{ 
		if (xmlHttp.readyState==4)
		{ 
		   document.getElementById("FinalQuot").innerHTML=xmlHttp.responseText;
		}
	}    
   
   
  function GetXmlHttpObject()
  {
	var xmlHttp=null;
	try
	  {
	  // Firefox, Opera 8.0+, Safari
	  xmlHttp=new XMLHttpRequest();
	  }
	catch (e)
	  {
	  // Internet Explorer
	  try
		{
		xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
	  catch (e)
		{
		xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	  }
	return xmlHttp;
  }  
   
</script>   