<?php 
print("\n");
print("\n");
////// filters value/////
//// extract all encoded variables

$from_date=base64_decode($_REQUEST[fdate]);
$to_date=base64_decode($_REQUEST[tdate]);
$from_loc=base64_decode($_REQUEST[loc]);
$vendordetail=base64_decode($_REQUEST[ven]);
$product=base64_decode($_REQUEST[pro]);
$alllocation=getAccessLocation($_SESSION[userid],$link1);
if($product=='' )
{
	$product_code='1';
}

else
{
	$product_code="(a.prod_code='".$product."') ";
}

if($from_loc=='' )
{
	$from_party="b.po_from in (".$alllocation.")";
}

else
{
	$from_party="(b.po_from='".$from_loc."') ";
}
if($vendordetail=='' )
{
	$to_party='1';
}

else
{
	$to_party="(b.po_to='".$vendordetail."') ";
}



if($from_date=='' || $to_date=='')
{
	$sql_date='1';
}

else
{
	$sql_date="(b.requested_date>='".$from_date."' and b.requested_date<='".$to_date."')";
}

//////End filters value/////

$sql=mysqli_query($link1,"Select * from vendor_order_data a inner join vendor_order_master b on a.po_no=b.po_no where $from_party and $to_party  and $sql_date and $product_code   ")or die("er1".mysqli_error($link1));
?>
<table width="100%" border="1" cellpadding="2" cellspacing="1" bordercolor="#000000">
<tr align="left" style="background-color:#396; color:#FFFFFF;font-size:13px;font-family:Verdana, Arial, Helvetica, sans-serif;font-weight:normal;vertical-align:central">
<td height="25"><strong>S.No.</strong></td>
<td><strong>PO No.</strong></td>
<td><strong>PO Date</strong></td>
<td><strong>Vendor Name</strong></td>
<td><strong>Vendor City</strong></td>
<td><strong>Vendor State</strong></td>
<td><strong>Vendor Address</strong></td>
<td><strong>Vendor Phone No.</strong></td>
<td><strong>Location Name</strong></td>
<td><strong>Location City</strong></td>
<td><strong>Location State</strong></td>
<td><strong>Location Phone</strong></td>
<td><strong>Sub Total</strong></td>
<td><strong>Tax Type</strong></td>
<td><strong>Tax %</strong></td>
<td><strong>Tax Amount</strong></td>
<td><strong>Total Amount</strong></td>
<td><strong>Status</strong></td>
<td><strong>Vendor Invoice Number</strong></td>
<td><strong>Receive Date</strong></td>
<td><strong>Receive By</strong></td>
<td><strong>Receive Remark</strong></td>
</tr>
<?php
$i=1;
while($row_loc = mysqli_fetch_array($sql)){
$vendor=explode("~",getVendorDetails($row_loc['po_to'],"name,city,state,address,phone",$link1));
$location=explode("~",getLocationDetails($row_loc['po_from'],"name,city,state,phone",$link1));
$product_name=explode("~",getProductDetails($row_loc['prod_code'],"productname",$link1));
$admin_detail=explode("~",getAdminDetails($row_loc['receive_by'],"name",$link1));
if($row_loc[taxtype]=="NONE")
{
	$tax_amt=$row_loc[po_value];
}
else{
	$tax_amt=$row_loc[po_value]+$row_loc[taxamount];
}
 ?>
<tr>
<td align="center"><?=$i?></td>
<td align="left"><?=$row_loc[po_no]?></td>
<td align="left"><?=$row_loc[requested_date]?></td>
<td align="left"><?=$vendor[0]?></td>
<td align="left"><?=$vendor[1]?></td>
<td align="left"><?=$vendor[2]?></td>
<td align="left"><?=$vendor[3]?></td>
<td align="right"><?=$vendor[4]?></td>
<td align="left"><?=$location[0]?></td>
<td align="left"><?=$location[1]?></td>
<td align="left"><?=$location[2]?></td>
<td align="right"><?=$location[3]?></td>
<td align="right"><?=$row_loc[po_value]?></td>
<td align="left"><?=$row_loc[taxtype]?></td>
<td align="right"><?=$row_loc[taxper]?></td>
<td align="right"><?=$row_loc[taxamount]?></td>
<td align="right"><?=$tax_amt?></td>
<td align="right"><?=$row_loc[status]?></td>
<td align="right"><?=$row_loc[invoice_no]?></td>
<td align="right"><?=$row_loc[receive_date]?></td>
<td align="right"><?=$admin_detail[0]?></td>
<td align="right"><?=$row_loc[receive_remark]?></td>
</tr>
<?php
$i+=1;		
}
?>
</table>