<?php
include("php_conation.php");

require("PHPExcel/PHPExcel.php");
$excel= new PHPExcel();

$excel->setActiveSheetIndex()
->setCellValue("A1","Order number")
->setCellValue("B1","Waybill number")
->setCellValue("C1","Contact Name")
->setCellValue("D1","Delivery Address")
->setCellValue("E1","Order Description")
->setCellValue("F1","Destination")
->setCellValue("G1","Customer Phone")
->setCellValue("H1","COD Amount");

$row_count=2;

$qury=mysqli_query($conation,"SELECT * FROM order_details WHERE AssignDate BETWEEN '$_GET[form_date]' and '$_GET[to_date]' and RiderID='$_GET[Shop]' and asign_display='No' ORDER BY City ASC");
while($resalt=mysqli_fetch_array($qury)){
	
	$amount=0;
	$item="";
	$amount_qury=mysqli_query($conation,"SELECT * FROM order_item WHERE OrderNumber='$resalt[OrderNumber]'");
	while($amount_resalt=mysqli_fetch_array($amount_qury)){
		$amount=$amount+$amount_resalt['ProductPrice'];
		$item=$item.$amount_resalt['product_id']." ";
	}

$excel->setActiveSheetIndex()
->setCellValue("A".$row_count,"$resalt[OrderNumber]")
->setCellValue("B".$row_count,"$resalt[map_bar]")
->setCellValue("C".$row_count,"$resalt[Name]")
->setCellValue("D".$row_count,"$resalt[Address]")
->setCellValue("E".$row_count,"$item")
->setCellValue("F".$row_count,"$resalt[City]")
->setCellValue("G".$row_count,"$resalt[ContactNumber]")
->setCellValue("H".$row_count,"$amount");
$row_count++;
}




header('content-Type:Application.openxmlformats-officedocument.spreadsheetml.sheet');
header('content-Disposition:attachment; filename="Simplex_UploadFile.xlsx"');
header('cache-Control: max-age=0');

	
$file=PHPExcel_IOFactory::CreateWriter($excel,'Excel2007');
$file->save('php://output');
?>