selectDeliveryVw.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. require "connectionDb.php";
  3. $selectDelivery1 = $db->query("SELECT * FROM delivery JOIN delivery_tank ON delivery.id=delivery_tank.delivery_id");
  4. // print_r("<thead><tr>
  5. // <th>Action</th>
  6. // <th>Message</th>
  7. // <th>id</th>
  8. // <th>Tank</th>
  9. // <th>Status</th>
  10. // <th>Start</th>
  11. // <th>End</th>
  12. // </tr></thead> ");
  13. $json_data=[];
  14. function dateFormatChanger($datetime) {
  15. $getDateTime = $datetime;
  16. $date = explode(' ', $getDateTime);
  17. $newDate = date("d-M-Y", strtotime($date[0]));
  18. $timezone = explode('+', $date[1]);
  19. $time = explode('.', $timezone[0]);
  20. return($newDate." ".$time[0]);
  21. }
  22. while ($row = $selectDelivery1->fetchArray()) {
  23. //print_r($row);
  24. // print_r(
  25. // "<tr>"
  26. // ."<td>".$row['type']."</td>"
  27. // ."<td>".$row['type']."</td>"
  28. // ."<td>".$row['id']."</td>"
  29. // ."<td>".$row['tank_id']."</td>"
  30. // ."<td>".$row['status']."</td>"
  31. // ."<td>".$row['start']."</td>"
  32. // ."<td>".$row['end']."</td>"
  33. // ."</tr>"
  34. // );
  35. $details = [
  36. "Action" => $row['type'],
  37. "Message" => $row['type'],
  38. "Id" => $row['id'],
  39. "Tank" => $row['tank_id'],
  40. "Status" => $row['status'],
  41. "Start" => dateFormatChanger($row['start']),
  42. "End" => dateFormatChanger($row['end']),
  43. "Product" => $row['product'],
  44. "SupplierId" => $row['supplier_id'],
  45. "SupplierName" => $row['product'],
  46. "DeliveryCarNumber" => $row['car_number'],
  47. "OrderPrice" => $row['order_price'],
  48. "OrderVolume" => $row['order_vol'],
  49. "DeliverVolume" => $row['deliver_vol'],
  50. "FuelPoints" => $row['fp_group'],
  51. "TankGroup" => $row['tank_group_id'],
  52. ];
  53. //here pushing the values in to an array
  54. array_push($json_data,$details);
  55. }
  56. $json_data_all = ["data" => $json_data];
  57. $myfile = fopen("api/v1/Deliveries/deliveryDetails.txt", "w+") or die("Unable to open file!");;
  58. fwrite($myfile,json_encode($json_data_all, JSON_PRETTY_PRINT));
  59. fclose($myfile);
  60. ?>