<?php ob_start();
error_reporting(0);
session_name('CAKEPHP'); session_start();

include("reportconfig.php");
$data = '';
$data .= "<table border='0' cellpadding='1' cellspacing='2' colspan='7' WIDTH=100%>";
$data .= "<tr><th colspan='2'><strong>CHALLAN</strong></th>";
$data .= "<th colspan='2'><strong>ORDER</strong></th>";
$data .= "<th>&nbsp;</th>";
$data .= "<th colspan='3'><strong>ITEM</strong></tr>";
$data .= "<tr>";
$data .= "<th><strong>Number</strong></th>";
$data .= "<th><strong>Date</strong></th>";
$data .= "<th><strong>Number</strong></th>";
$data .= "<th><strong>Date</strong></th>";
$data .= "<th><strong>Vendor</strong></th>";
$data .= "<th><strong>Code</strong></th>";
$data .= "<th><strong>Description</strong></th>";
$data .= "<th><strong>Quantity</strong></th>";
$data .= "</tr>";
$sql = $_SESSION['data1'];
$result = mysqli_query($con, $sql);


while ($myrow = mysqli_fetch_array($result)) {
	$data .= "<tr >";
	$data .= "<td>" . $myrow['BillNo'] . "</td>";
	$data .= "<td>" . $myrow['BillDate'] . "</td>";
	$data .= "<td>" . $myrow['PO_WO_MTO'] . "</td>";
	$data .= "<td>" . $myrow['OrderDate'] . "</td>";
	$data .= "<td>";

	if ($myrow['ReceivedAgainst'] == 'PO' || $myrow['ReceivedAgainst'] == 'Direct') {
		$vendor_sql = "select vendor_name from suppliers where vendor_code='" . $myrow['ReceivedFrom'] . "' ";
		$vendor_res = mysqli_query($con, $vendor_sql);
		$vendor_row = mysqli_fetch_array($vendor_res);
		$data .= $vendor_row['vendor_name'];
	} else if ($myrow['ReceivedAgainst'] == 'APCM') {
		$pc_sql = "select pc_name from pcopening where id='" . $myrow['ReceivedFrom'] . "' ";
		$pc_result = mysqli_query($con, $pc_sql);
		$pc_row = mysqli_fetch_array($pc_result);
		$data .= $pc_row['pc_name'];
	}



	$data .= "</td>";
	$data .= "<td>" . $myrow['itemcode'] . "</td>";

	$data .= "<td>" . $myrow['description'] . "</td>";
	$data .= "<td>" . $myrow['reciveqty'] . "</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";
