swap_report.php 1.0 KB

123456789101112131415161718192021222324252627282930
  1. <?php
  2. $swapsSql = "SELECT *,
  3. user.DEID,
  4. swap.CreatedAt AS SwapCreatedAt,
  5. swap.UpdatedAt AS SwapUpdatedAt
  6. FROM swap swap
  7. JOIN rider rider ON rider.RiderID=swap.RiderID
  8. JOIN user user ON user.UserID=rider.UserID
  9. WHERE swap.IsActive='1' $swapSqlfilter";
  10. $swapsRes = mysqli_query($conn, $swapsSql);
  11. if ($swapsRes->num_rows > 0) {
  12. $id = 0;
  13. foreach ($swapsRes as $swaprow) {
  14. $id++;
  15. $swaps = array_merge($swaps, array(array($id, $swaprow['RiderID'], $swaprow['DEID'], $swaprow['ReturnBatterID'], $swaprow['SwappedBatterID'], $swaprow['IsFreeSwap'], $swaprow['SwapCreatedAt'], $swaprow['SwapUpdatedAt'])));
  16. }
  17. }
  18. $swapCountSql = "SELECT swap.CreatedDate, count(swap.SwapID) AS ContData
  19. from swap swap
  20. WHERE swap.IsActive='1' $swapCountSqlfilter
  21. GROUP BY swap.CreatedDate";
  22. $swapCountRes = mysqli_query($conn, $swapCountSql);
  23. if ($swapCountRes->num_rows > 0) {
  24. $id = 0;
  25. foreach ($swapCountRes as $swapCountrow) {
  26. $id++;
  27. $swapCount = array_merge($swapCount, array(array($id, $swapCountrow['CreatedDate'], $swapCountrow['ContData'])));
  28. }
  29. }