<?php 
ob_start();
$PageSecurity = 4;
$PageName = 'Purchase Requisition';
include('includes/DefinePOClass.php');
include('includes/session.inc');
include('includes/SQL_CommonFunctions.inc');
include('includes/DefineSuppTransClass.php');?>

<form id="myform" name="AsignVendor" action="" method="post" onsubmit="return validateForm()" >
<input type="hidden" name="ReqiAId1" id="ReqiAId1" value="<?php echo $_REQUEST['VendorId']; ?>" />
<input type="hidden" name="mapindenid" id="mapindenid" value="<?php echo $_REQUEST['id']; ?>" />
<table width="100%" border="0" style="border:1px solid #333333;" align="right" cellspacing="0" cellpadding="3">
<tr style="height:30px;">
	<td style="border-bottom:1px solid #FF0000;"><strong>SrNo.</strong></td>
	<td style="border-bottom:1px solid #FF0000;"><strong>Vendor.</strong></td>
	<td style="border-bottom:1px solid #FF0000;"><strong>Select.</strong></td>
</tr>
<?php 
$SQLmappedVenderList=DB_query("SELECT * FROM indentpr_mapping WHERE indentPrno='".$_REQUEST['VendorId']."' and id='".$_REQUEST['id']."' order by id desc limit 0,1",$db);
if(DB_num_rows($SQLmappedVenderList)>0)
{
	while($GetMappedvendor=DB_fetch_array($SQLmappedVenderList)){
		$mappedVenArr[]=$GetMappedvendor['recieve_quots_vendors'];
		
}



$FinalMappedVendorList=implode(",",$mappedVenArr);
$FinalMappedVendorList1=explode(",",$FinalMappedVendorList);
}
else
{
$FinalMappedVendorList1='';
}


$SQLmappedVenderList2=DB_query("SELECT * FROM indentpr_mapping WHERE indentPrno='".$_REQUEST['VendorId']."'
 and id='".$_REQUEST['id']."' order by id desc limit 0,1",$db);
if(DB_num_rows($SQLmappedVenderList2)>0)
{
	
		$GetMappedvendor2=DB_fetch_array($SQLmappedVenderList2);
		$mappedVenArr1=$GetMappedvendor2['mapped_vendor'];
		$FinalMappedVendorList2=explode(",",$mappedVenArr1);
}
else
{
$FinalMappedVendorList2='';
}


//print_r($FinalMappedVendorList2);

$z=0;
$sqlVendor=DB_query("SELECT * FROM suppliers where CompanyId='".$_SESSION['ACGCompanyId']."'",$db);
while($GetVendor=DB_fetch_array($sqlVendor)){
if(!empty($FinalMappedVendorList1))
if(in_array($GetVendor['id'],$FinalMappedVendorList1))
{
	$disabled='disabled';
}
else
{
	$disabled='';
}
//echo $GetVendor['id'];
if(!empty($FinalMappedVendorList2))
if(in_array($GetVendor['id'],$FinalMappedVendorList2))
{
	$checked='checked';
}
else
{
	$checked='';
}
?>
<tr style="height:25px;">
	<td ><?php echo $z+1; ?></td>
	<td><?php echo $GetVendor['vendor_name']; ?>	</td>
	<td ><input type="checkbox" name="vendorId[]" id="vendorId_<?php echo $z; ?>" <?php echo $disabled; ?> <?php echo $checked; ?> value="<?php echo $GetVendor['id']; ?>"  /></td>
</tr>
<?php $z++;} ?>
</table>
</form>