<?php 
ob_start();
$PageSecurity = 4;
include('includes/session.inc');
include('includes/function_lib.php');
$data1="";
$data2="";
if($_REQUEST['ReciveAng']=='PO')
{
  
    $SQLPo=DB_query("SELECT id,purchase_ordNo FROM purchorders where site='".$_REQUEST['Branch']."' and vendorId='".$_REQUEST['supplierId']."' and final_app_status='1' and Po_recive_status='Pending' and cancel_status='0'",$db);
    //$data1.="<strong>PO No</strong>";
    $data2.="<select name='PONo' id='PONo' onchange='GetPODetails(this.value)' style='width:100%;'>";
    $data2.="<option value=''>Select PO</option>";
    while($FetchPodata=DB_fetch_array($SQLPo)){
    $data2.="<option value='".$FetchPodata['id']."'>".$FetchPodata['purchase_ordNo']."</option>";
    }
    $data2.="</select>";
    echo $data=$data2;
}
if($_REQUEST['ReciveAng']=='Indent')
{
    
    $maxAssign="select max(no_of_assignee) as numMax from conf_purch_approval where company_id='".$_SESSION['ACGCompanyId']."' and doc_type='PR'";
$maxAssignExec=DB_query($maxAssign,$db);
$maxAssignDATA=DB_fetch_array($maxAssignExec);
 $maximAss=$maxAssignDATA['numMax'];

 
 
$SQLPo=DB_query("select * FROM materialrequisitions a inner join pr_head_approval b on a.requisitionno=b.requisition_id where  a.CompanyId='".$_SESSION['ACGCompanyId']."' and a.MRN_Receive_status=0 and a.Approved_By_Purch_Head is NULL and a.po_status=0 and b.sr_no='".$maximAss."' GROUP BY Reqno",$db);

//$data1.="<strong>PR No</strong>";

$data2.="<select name='PONo' id='PONo' style='width:100%;' onchange='GetPODetails1(this.value)'>";
	$data2.="<option value=''>Select PR</option>";
	while($FetchPodata=DB_fetch_array($SQLPo))
	{
	 $poorder=$s->getField('purchorders','indentPRno',$FetchPodata['requisitionno'],'id');
	if($poorder=='')
	{	
	$data2.="<option value='".$FetchPodata['requisitionno']."'>".$FetchPodata['Reqno']."</option>";
	}
}
$data2.="</select>";

$venqry="select vendor_type from suppliers where id='".$_REQUEST['supplierId']."'";

$venExec=DB_query($venqry, $db);
$ventypedata=DB_fetch_array($venExec);

         if($ventypedata['vendor_type']=='International') {  $r='Import Order'; $o='IO'; }
         if($ventypedata['vendor_type']=='Domestic') {  $r='Domestic Order'; $o='DO'; }
$data1.="<input type='text' name='poType1' id='poType1' readonly value='".$r."' style='width:100%;'/>";
$data3.="<input type='hidden' name='poType' id='poType' readonly value='".$o."' style='width:100%;'/>";
	echo $data=$data2.'__'.$data1.'__'.$data3;
}


?>