| 12345678910111213141516171819202122232425262728293031323334353637383940 |
- <?php
- // Include Database connection
- include_once "../../include/DB.php";
- // Include SimpleXLSXGen library
- include_once "../../include/SimpleXLSXGen.php";
- $id = 0;
- $fromDate="";
- $toDate="";
- $swapSqlfilter="";
- $swapCountSqlfilter="";
- $swaps = [
- ['#', 'Rider ID', 'DEID', 'Return Batter ID', 'Swapped Batter ID', 'Is Free Swap', 'Swap Created At', 'Swap UpdatedAt']
- ];
- $swapCount = [
- ['#', 'Date', 'Count']
- ];
- if (isset($_GET["fromDate"]) && !empty($_GET["fromDate"]) && isset($_GET["toDate"]) && !empty($_GET["toDate"])) {
- $fromDate=$_GET["fromDate"];
- $toDate=$_GET["toDate"];
- $swapSqlfilter="AND (swap.CreatedDate BETWEEn '$fromDate' AND '$toDate')";
- $swapCountSqlfilter ="AND (swap.CreatedDate BETWEEn '$fromDate' AND '$toDate')";
- }
- if (isset($_GET["RiderID"]) && !empty($_GET["RiderID"])) {
- $RiderID=$_GET["RiderID"];
- $swapSqlfilter .=" AND swap.RiderID='$RiderID'";
- $swapCountSqlfilter .=" AND swap.RiderID='$RiderID'";
- }
- include 'swap_report.php';
- $xlsx = SimpleXLSXGen::fromArray($swaps,'Swap')->addSheet($swapCount,'Swap Count');
- $xlsx->downloadAs('swap_report.xlsx'); // This will download the file to your local system
- // $xlsx->saveAs('swap_report.xlsx'); // This will save the file to your server
- echo "<pre>";
- print_r($swaps);
- print_r($swapCount);
|