query("SELECT * FROM delivery JOIN delivery_tank ON delivery.tank_group_id=delivery_tank.delivery_id");
// print_r("
// Action |
// Message |
// id |
// Tank |
// Status |
// Start |
// End |
//
");
$json_data=[];
function dateFormatChanger($datetime) {
$getDateTime = $datetime;
$date = explode(' ', $getDateTime);
$newDate = date("d-M-Y", strtotime($date[0]));
$timezone = explode('+', $date[1]);
$time = explode('.', $timezone[0]);
return($newDate." ".$time[0]);
}
while ($row = $selectDelivery1->fetchArray()) {
print_r($row);
// print_r(
// "
"
// ."".$row['type']." | "
// ."".$row['type']." | "
// ."".$row['id']." | "
// ."".$row['tank_id']." | "
// ."".$row['status']." | "
// ."".$row['start']." | "
// ."".$row['end']." | "
// ."
"
// );
$details = [
"Action" => $row['type'],
"Message" => $row['type'],
"Id" => $row['id'],
"Tank" => $row['tank_id'],
"Status" => $row['status'],
"Start" => dateFormatChanger($row['start']),
"End" => dateFormatChanger($row['end']),
"Product" => $row['product'],
"SupplierId" => $row['supplier_id'],
"SupplierName" => $row['product'],
"DeliveryCarNumber" => $row['car_number'],
"OrderPrice" => $row['order_price'],
"OrderVolume" => $row['order_vol'],
"DeliverVolume" => $row['deliver_vol'],
"FuelPoints" => $row['fp_group'],
"TankGroup" => $row['tank_group_id'],
];
//here pushing the values in to an array
array_push($json_data,$details);
}
$json_data_all = ["data" => $json_data];
$myfile = fopen("api/v1/Deliveries/deliveryDetails.txt", "w+") or die("Unable to open file!");;
fwrite($myfile,json_encode($json_data_all, JSON_PRETTY_PRINT));
fclose($myfile);
?>