index.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. // Include Database connection
  3. include_once "../../include/DB.php";
  4. // Include SimpleXLSXGen library
  5. include_once "../../include/SimpleXLSXGen.php";
  6. $id = 0;
  7. $fromDate="";
  8. $toDate="";
  9. $swapSqlfilter="";
  10. $swapCountSqlfilter="";
  11. $swaps = [
  12. ['#', 'Rider ID', 'DEID', 'Return Batter ID', 'Swapped Batter ID', 'Is Free Swap', 'Swap Created At', 'Swap UpdatedAt']
  13. ];
  14. $swapCount = [
  15. ['#', 'Date', 'Count']
  16. ];
  17. if (isset($_GET["fromDate"]) && !empty($_GET["fromDate"]) && isset($_GET["toDate"]) && !empty($_GET["toDate"])) {
  18. $fromDate=$_GET["fromDate"];
  19. $toDate=$_GET["toDate"];
  20. $swapSqlfilter="AND (swap.CreatedDate BETWEEn '$fromDate' AND '$toDate')";
  21. $swapCountSqlfilter ="AND (swap.CreatedDate BETWEEn '$fromDate' AND '$toDate')";
  22. }
  23. if (isset($_GET["RiderID"]) && !empty($_GET["RiderID"])) {
  24. $RiderID=$_GET["RiderID"];
  25. $swapSqlfilter .=" AND swap.RiderID='$RiderID'";
  26. $swapCountSqlfilter .=" AND swap.RiderID='$RiderID'";
  27. }
  28. include 'swap_report.php';
  29. $xlsx = SimpleXLSXGen::fromArray($swaps,'Swap')->addSheet($swapCount,'Swap Count');
  30. $xlsx->downloadAs('swap_report.xlsx'); // This will download the file to your local system
  31. // $xlsx->saveAs('swap_report.xlsx'); // This will save the file to your server
  32. echo "<pre>";
  33. print_r($swaps);
  34. print_r($swapCount);