<?php
ob_start();
session_name('CAKEPHP'); session_start();
include('exportconfig.php');
$data .= "<table width='90%' border='0' cellspacing='2' cellpadding='2'>";
$data .= "<tr>";
$data .= "<th>Branch</th>";
$data .= "<th>Advice No.</th>";
$data .= "<th>Dispatch Date</th>";
$data .= "<th>Total Dispatch Qty</th>";
$data .= "</tr>";


//$purchsql=$_SESSION['purch_reg'];
$sql_dispatch = "select * from dispatch";
$exec_dispatch = mysqli_query($db, $sql_dispatch);
$i = 1;
//$site=$_SESSION['sitesession'];
//$item=$_SESSION['itemsession'];
//$name= $_SESSION['itemsession'];
while ($dispatchrow = mysqli_fetch_array($exec_dispatch)) {
  $data .= "<tr>";
  $data .= "<td>" . $i . "</td>";
  $data .= "<td>" . $dispatchrow['site'] . "</td>";
  $data .= "<td>" . $dispatchrow['adviceNo'] . "</td>";
  $data .= "<td>" . $dispatchrow['dispatchDate'] . "</td>";
  $data .= "<td>" . $dispatchrow['totalDispatch'] . "</td>";
  $data .= "</tr>";
  $i++;
}
echo "</table>";


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