index.php 1.0 KB

12345678910111213141516171819202122232425262728293031
  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. $serviceSqlfilter="";
  10. $services = [
  11. ['#', 'Service History ID', 'Asset ID', 'is Serviced', 'In Ward', 'out Ward', 'Service Created At', 'Service Updated At']
  12. ];
  13. if (isset($_GET["fromDate"]) && !empty($_GET["fromDate"]) && isset($_GET["toDate"]) && !empty($_GET["toDate"])) {
  14. $fromDate=$_GET["fromDate"];
  15. $toDate=$_GET["toDate"];
  16. $serviceSqlfilter="AND (servicehistory.CreatedDate BETWEEN '$fromDate' AND '$toDate')";
  17. }
  18. if (isset($_GET["AssetID"]) && !empty($_GET["AssetID"])) {
  19. $AssetID=$_GET["AssetID"];
  20. $serviceSqlfilter .="AND servicehistory.AssetID='$AssetID'";
  21. }
  22. include 'service_report.php';
  23. $xlsx = SimpleXLSXGen::fromArray($services,'Service');
  24. $xlsx->downloadAs('service_report.xlsx'); // This will download the file to your local system
  25. // $xlsx->saveAs('service_report.xlsx'); // This will save the file to your server
  26. echo "<pre>";
  27. print_r($services);