<?php
    ob_start();error_reporting(0);
session_name('CAKEPHP'); session_start();
include("reportconfig.php");
$data=''; 
$data.="<table width='100%' border='0' cellspacing='1' cellpadding='2'>";
$data.="<tr>";
$data.="<th scope='col'>RETURN SLIP   NO. </th>";
$data.=" <th scope='col'>PARTY CHALLAN  NO. </th>";
$data.="<th scope='col'>RETURN DATE  </th>";
$data.="<th scope='col'>VENDOR</th>";
$data.="<th scope='col'>TOTAL QUANTITY </th>";
$data.=" </tr>";
$sql1=$_SESSION['data'];
$result1 = mysqli_query($con, $sql1);
if(mysqli_num_rows($result1)>0){
	while($row1=mysqli_fetch_array($result1))
	{

$data.="<tr bgcolor='#FFFFFF'> ";
$data.=" <td>";
$data.=$row1['returnSlipNo']."====".$row1['id'];
$data.="</td>";
$data.=" <td>";
$data.=$row1['partyChallanNo'];
$data.="</td>";
$data.=" <td>";
$data.=$row1['returnDate'];
$data.=" <td>";
if($_SESSION['vendor']!=''){
$vendorname1=mysqli_query($con, "Select vendor_name from suppliers where vendor_code='".$_SESSION['vendor']."'");

$vendorrow=mysqli_fetch_array($vendorname1);

$data.=$vendorrow['vendor_name'];
$data.="</td>";
$data.="<td>";
if($_SESSION['item']!='')

	  {$data.=$row1['receivedQty'];}
	  else if($_SESSION['sub_group']!='0' || $_SESSION['main_group']!='0' && $_SESSION['site']=='')
	  {$data.= $row1['receivedQty'];}
	  else if($_SESSION['site']!='' &&($_SESSION['sub_group']!='0' || $_SESSION['main_group']!='0' || $_SESSION['item']!=''))
	  {$data.= $row1['sum(receivedQty)'];}
	  else{$data.= $row1['totalReceivedQty'];}
$data.="</td>";
$data.="    </tr>";
} 
	}
}
	else
	{
$data.="<tr>";
$data.="<td colspan='5'><font color='#FF0000'><strong>No Record Found</strong></font></td>";

$data.="</tr>";
	}
$data.="</table>";

header("Content-type: application/x-msdownload"); 
header("Content-Disposition: attachment; filename=data1.xls"); 
header("Pragma: no-cache"); 
header("Expires: 0"); 
print "$header\n$data"; 

?>