index.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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. $userSqlfilter="";
  10. $userCountSqlfilter="";
  11. $users = [
  12. ['#', 'User ID', 'Rider ID', 'DEID', 'User Name', 'Phone Number', 'User Created At', 'User UpdatedAt']
  13. ];
  14. $userCount = [
  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. $userSqlfilter ="AND user.CreatedDate BETWEEn '$fromDate' AND '$toDate'";
  21. $userCountSqlfilter ="AND (user.CreatedDate BETWEEn '$fromDate' AND '$toDate')";
  22. }
  23. if (isset($_GET["RiderID"]) && !empty($_GET["RiderID"])) {
  24. $RiderID=$_GET["RiderID"];
  25. $userSqlfilter .=" AND user.RiderID='$RiderID'";
  26. $userCountSqlfilter .=" AND user.RiderID='$RiderID'";
  27. }
  28. include 'user_report.php';
  29. $xlsx = SimpleXLSXGen::fromArray($users,'Users')->addSheet($userCount,'User Count');
  30. $xlsx->downloadAs('users_report.xlsx'); // This will download the file to your local system
  31. // $xlsx->saveAs('users_report.xlsx'); // This will save the file to your server
  32. echo "<pre>";
  33. print_r($users);
  34. print_r($userCount);