1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- <?php
- require "connectionDb.php";
- $selectDelivery1 = $db->query("SELECT * FROM delivery JOIN delivery_tank ON delivery.id=delivery_tank.delivery_id");
- // print_r("<thead><tr>
- // <th>Action</th>
- // <th>Message</th>
- // <th>id</th>
- // <th>Tank</th>
- // <th>Status</th>
- // <th>Start</th>
- // <th>End</th>
- // </tr></thead> ");
- $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(
- // "<tr>"
- // ."<td>".$row['type']."</td>"
- // ."<td>".$row['type']."</td>"
- // ."<td>".$row['id']."</td>"
- // ."<td>".$row['tank_id']."</td>"
- // ."<td>".$row['status']."</td>"
- // ."<td>".$row['start']."</td>"
- // ."<td>".$row['end']."</td>"
- // ."</tr>"
- // );
- $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);
- ?>
|