<?php ob_start();
session_name('CAKEPHP'); session_start();
include("reportconfig.php");
$data='';
$data.="<table width='100%' border='0' cellspacing='2' cellpadding='2'>";
$data.="<tr>";
$data.="<th colspan='10'>Job Work Receipt Register Report</th>";
$data.="</tr>";
$data.="<tr>";
$data.="<th width='6%'>CHALLAN NO. </th>";
$data.="<th width='9%'>CHALLAN DATE </th>";
$data.="<th width='6%'>VENDOR </th>";
$data.="<th width='9%'>JOB WORK NO.</th>";
$data.="<th width='8%'>TOTAL QUANTITY </th>";
$data.="</tr>"; 
$data5= $_SESSION['query'];
  $result=mysqli_query($con, $data5);
			
		$num=mysqli_affected_rows($con);
		if($num>0)
	{
		$flag=1;
				$i=0;
			    $totalamount=0;
				while($item_row=mysqli_fetch_array($result))
				{					
				$data.="<tr bgcolor='#FFFFFF'>"; 
      $data.="<td>".$item_row['challanNumber'].'===='.$item_row['id']."</td>";  
	  $data.="<td>".$item_row['challanDate']."</td>";  
      $data.="<td>".$vendorname=$s->getField('suppliers','vendor_code',$item_row['vendor'],'vendor_name')."</td>";
      $data.="<td>".$jobcode=$s->getField('job_work','id',$item_row['jobNumber'],'jobNumber')."</td>";
	  $data.="<td>";
	  	 if($_REQUEST['site']!=''){
	  $data.=$item_row['sum(quantity)'];
	  	}
else  if($_REQUEST['item']!='')
      {
	$data.=$item_row['quantity'];
       }
else {	  
	 $data.=$item_row['quantity'];
	  }
	  	
	  	
	  	"</td>";
    $data.="</tr>";
  $i++;
  }
  }
  $data.="</table>";
  //echo $data;
 $header='';  		
 header("Content-type: application/x-msdownload"); 
header("Content-Disposition: attachment; filename=data.xls"); 
header("Pragma: no-cache"); 
header("Expires: 0"); 
print "$header\n$data";  
  ?>
  