<?php 
header("Content-type:application/octet-stream");

header("Content-type: application/x-msdownload"); 
header("Content-Disposition: attachment; filename=excel_requisition.xls"); 
header("Pragma: no-cache"); 
header("Expires: 0"); 
error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED);
?>
<?php 
include('includes/config/config.php');
include('includes/functions.php')
//include('pop_up_top.php');
?>

<body>

<table border="1" width="100%">
<?php 

	$sql=base64_decode($filterkey);
	//echo $sql;
$result = mysqli_query($conn,$sql);


  ?>
  <strong><tr bgcolor="#eeeeee"><td align="left" width="2%" >Sr.</td><td  align="left" width="10%">Requisition No.</td><td  align="left" width="10%">Requisition Date</td><td  align="left" width="10%">OHC Location</td><td  valign="top"  align="left" width="25%">Item Desc</td><td width="10%"  valign="top"  align="left">Approval Status</td>
  <td  valign="top"  align="left" width="15%">Remarks</td></strong></tr>
  
  <?php 
$count=0;

while ($row1= mysqli_fetch_assoc($result)){
 extract($row1);
 $issue_ref_no="";
$item_desc="";
$item_unit_id="";
$item_unit="";
$ohc_type="";
$status="";
?> 
<?php 

   
 
// $issue_date = getTableFieldValue('stock_issue','issue_date','stock_issue_id',$row_req['stock_issue_id']);
   $ohc_type = getTableFieldValue('ohc_type','ohc_type_name','ohc_type_id',$row1['ohc_location_id']);
   //ec  ho $ohc_type;  
	$item_desc="";
//$item_qty="";

$sql_req_items="select * from requisition_items where req_id='".$row1['req_id']."'";
$results_req_items = mysqli_query($conn,$sql_req_items);
while ($row_req_items= mysqli_fetch_assoc($results_req_items)) {

 $item_desc = $item_desc.' <p> '.getTableFieldValue('tbl_items','item_name','item_id',$row_req_items['item_id'])."  ";
  //$item_desc = $item_desc.getTableFieldValue('tbl_items','item_name','item_id',$row_req_items['item_id'])."<br/>";
  $item_unit_id=getTableFieldValue('tbl_items','unit_id','item_id',$row_req_items['item_id']);
   $item_unit =getTableFieldValue(' unit_master','unit_name','unit_id',$item_unit_id);
  $item_desc=$item_desc.'<b> Qty: '.$row_req_items['qty'].' '.$item_unit.'</b>';
  $item_desc=$item_desc."</p>";
  
}
		$status=($row1['status']=='Y'?'<b>Approved</b>':'Rejected');
		
   $count=$count+1;
  ?>
	
		
  
  <tr><td><?php  echo $count?></td><td><?php  echo  $row1['req_ref_no']?></td><td align="left"><?php  echo date_format(date_create($row1['req_date']),"d-M-Y ")?></td><td><?php  echo $ohc_type?></td><td><?php  echo $item_desc?></td><td><?php  echo $status?></td><td><?php  echo $row1['remarks']?></td></tr>
	<?php 

 

	
	


}
?>
</table>
</body>