selectDeliveryVw.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. require "connectionDb.php";
  3. $selectDelivery1 = $db->query("SELECT * FROM delivery JOIN delivery_tank ON delivery.id=delivery_tank.delivery_id");
  4. $json_data=[];
  5. while ($row = $selectDelivery1->fetchArray()) {
  6. // print_r($row);
  7. $details = [
  8. "Action" => $row['type'],
  9. "Message" => $row['type'],
  10. "Id" => $row['id'],
  11. "Tank" => $row['tank_id'],
  12. "Status" => $row['status'],
  13. "Start" => dateFormatChanger($row['start']),
  14. "End" => dateFormatChanger($row['end']),
  15. "Product" => $row['product'],
  16. "SupplierId" => $row['supplier_id'],
  17. "SupplierName" => $row['product'],
  18. "DeliveryCarNumber" => $row['car_number'],
  19. "OrderPrice" => $row['order_price'],
  20. "OrderVolume" => $row['order_vol'],
  21. "DeliverVolume" => $row['deliver_vol'],
  22. "FuelPoints" => $row['fp_group'],
  23. "TankGroup" => $row['tank_group_id'],
  24. ];
  25. //here pushing the values in to an array
  26. array_push($json_data,$details);
  27. }
  28. $json_data_all = ["data" => $json_data];
  29. $myfile = fopen("api/v1/Deliveries/deliveryDetails.txt", "w+") or die("Unable to open file!");;
  30. fwrite($myfile,json_encode($json_data_all, JSON_PRETTY_PRINT));
  31. fclose($myfile);
  32. ?>