1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- <?php
- require "connectionDb.php";
- if (isset($_POST['find'])) {
-
- $date = $_POST['selectDateToFind'];
- $date = str_replace('-', '_', $date);
- $shiftnum = $_POST['shiftNumber'];
- if ($_POST['fuelGrade']=='ALL') {
- $customers = $db->query("SELECT * FROM shift_tank_vw WHERE date='$date' AND number='$shiftnum' ");
- }else {
- $fuelgrade = $_POST['fuelGrade'];
- $customers = $db->query("SELECT * FROM shift_tank_vw WHERE date='$date' AND number='$shiftnum' AND product_text='$fuelgrade' ");
- }
- $json_data=[];
- while ($row = $customers->fetchArray()) {
- //print_r($row);
- $details = [
- "Shift_Id" => $row['shift_id'],
- "Date" => $row['date'],
- "Number" => $row['number'],
- "Open_Date" => date('Y-M-d h:i:s A',$row['open_date']),
- "Close_Date" => date('Y-M-d h:i:s A',$row['close_date']),
- "Tank_Id" => $row['tank_id'],
- "Product_Text" => $row['product_text'],
- "Open_Vol" => $row['open_vol'],
- "Close_Vol" => $row['close_vol'],
- "Open_Water_Vol" => $row['open_water_vol'],
- "Close_Water_Vol" => $row['close_water_vol'],
- "Open_Level" => $row['open_level'],
- "Close_Level" => $row['close_level'],
- ];
- //here pushing the values in to an array
- array_push($json_data,$details);
- }
- $json_data_all = ["data" => $json_data];
- $myfile = fopen("api/v1/ShiftTankReport/shiftTankData.txt", "w+") or die("Unable to open file!");;
- fwrite($myfile,json_encode($json_data_all, JSON_PRETTY_PRINT));
- fclose($myfile);
- }
- ?>
|