<?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]);
$loc=base64_decode($_REQUEST['other']);
$product=base64_decode($_REQUEST['pro']);
$status=base64_decode($_REQUEST['sta']);
$location=getAccessLocation($_SESSION['userid'],$link1);
if($status=='' )
{
	$status='1';
}

else
{
	$status="(b.status='".$status."') ";
}
if($product=='' )
{
	$product_code='1';
}

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

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

else
{
	$from_party="(b.po_from='".$from_loc."') ";
}*/
if($loc=='' )
{
	$to_party="b.po_from in (".$location.")";
}

else
{
	$to_party="(b.po_from='".$loc."') ";
}



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 purchase_order_data a inner join purchase_order_master b on a.po_no=b.po_no where  $to_party  and $sql_date and $product_code and $status  ")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>Invoice Date</strong></td>
<td><strong>HO Name</strong></td>
<td><strong>HO City</strong></td>
<td><strong>HO State</strong></td>
<td><strong>HO Address</strong></td>
<td><strong>HO 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>Product Code</strong></td>
<td><strong>Product Name</strong></td>
<td><strong>Require Qty</strong></td>
<td><strong>Dispatch qty</strong></td>
<td><strong>Price</strong></td>
<td><strong>Value</strong></td>
<td><strong>Status</strong></td>
<td><strong>Aging</strong></td>
<td><strong>TAT</strong></td>
</tr>
<?php
$i=1;
while($row_loc = mysqli_fetch_array($sql)){
$other=explode("~",getLocationDetails($row_loc['po_to'],"name,city,state,addrs,phone",$link1));
$location=explode("~",getLocationDetails($row_loc['po_from'],"name,city,state,phone",$link1));
$product_name=explode("~",getProductDetails($row_loc['prod_code'],"productname",$link1));
$value=$row_loc[po_price]*$row_loc[qty];
 ?>
<tr>
<td align="left"><?=$i?></td>
<td align="left"><?=$row_loc[po_no]?></td>
<td align="left"><?=$row_loc[requested_date]?></td>
<td align="left"><?=$row_loc[challan_date]?></td>
<td align="left"><?=$other[0]?></td>
<td align="left"><?=$other[1]?></td>
<td align="left"><?=$other[2]?></td>
<td align="right"><?=$other[3]?></td>
<td align="right"><?=$other[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="left"><?=$row_loc[prod_code]?></td>
<td align="left"><?=$product_name[0]?></td>
<td align="right"><?=$row_loc[req_qty]?></td>
<td align="right"><?=$row_loc[qty]?></td>
<td align="right"><?=$row_loc[po_price]?></td>
<td align="right"><?=$value?></td>
<td align="left"><?=$row_loc[status]?></td>
<td align="right"><?php if($row_loc['challan_date']=="0000-00-00"){ echo daysDifference($today,$row_loc['requested_date']);}?></td>
<td align="right"><?php if($row_loc['challan_date']!="0000-00-00"){ echo daysDifference($row_loc['challan_date'],$row_loc['requested_date']);}?></td>
</tr>
<?php
$i+=1;		
}
?>
</table>