<?php $PageSecurity = 11;
 //echo $_SERVER['QUERY_STRING'];exit;
 include('includes/SQL_CommonFunctions.inc');
 include('includes/function_lib.php');
 include('includes/session.inc');
 global $db;
 if($_REQUEST['receipt']=='PO')
 {
	  $q=$_GET['q'];
	  $site=$_GET['site'];
	  $sql_po= "select * from venderquotations Where mst_supplierno='".$q."'";
	  $result=DB_query($sql_po,$db);
	  $PurchaseOrder=$_REQUEST['PurchaseOrder'];
	
	
	if(DB_num_rows($result)>0)
	{
	
	$list=array();
	while($myrow=DB_fetch_array($result))
	{
	  $list[]=$myrow['id'];
	 // $myrow['id'];
	} 
	
	if(count($list)>0)
	{
	$listrec=implode(',',$list);
	//echo "select * from purchorders Where Po_recive_status='Pending'  and  mst_vendor_quotesid in(".$listrec.") and sitecode='".$site."'";
   	$sql=DB_query("select * from purchorders Where Po_recive_status='Pending'  and  mst_vendor_quotesid in(".$listrec.") and sitecode='".$site."'",$db);?>
 	<select  name="Purchase_Order" id="Purchase_Order"   onchange="FiendPurchasenumber(this.value)" style="width:100%;" > 
	<option value="000">---Select---</option>
	<?php 
	
		while ($rsdesig=DB_fetch_array($sql)){
			
	?>
	<option value="<?php  echo $rsdesig['orderno'];?>" <?php echo ($PurchaseOrder==$rsdesig['orderno']?'selected':'')?>><?php echo $rsdesig['PO_Orderno'];?></option>
	<?php }?> 
	</select>
<?php }	}
         else{?>
 	<select  name="PO" id="PurchaseOrder" > 
	<option value="000">--No Record--</option>
	</select>
	<?php }}
else if($_REQUEST['receipt']=='DirectPOOrder')
  {

	 $q=$_GET['q'];
	  $site=$_GET['site'];
	
   	$sql=DB_query("select * from direct_po Where vender_id='".$_REQUEST['q']."' and recive_status='Pending' and cancel_issue=0  and cancel_issue_approv=0 and site='".$site."' and Approval_status='1'",$db);
   	$num=DB_num_rows($sql);
   	if($num>0)
   	{
   		?>
 	<select  name="Purchase_Order" id="Purchase_Order" onchange="getOrderDate(this.value)"   style="width:100%;" > 
	<option value="">---Select---</option>
	<?php 
	



		while ($rsdesig=DB_fetch_array($sql)){
			
	?>
	<option value="<?php  echo $rsdesig['id'];?>" <?php echo ($PurchaseOrder==$rsdesig['id']?'selected':'')?>><?php echo $rsdesig['pr_no'];?></option>
	<?php }?> 
	</select>
<?php }	
         else{?>
 	<select  name="PO" id="PurchaseOrder" > 
	<option value="000">--No Record--</option>
	</select>
	

 <?php  } }?>