shiftSaleData.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. require "connectionDb.php";
  3. if (isset($_POST['find'])) {
  4. $date = $_POST['selectDateToFind'];
  5. $date = str_replace('-', '_', $date);
  6. $shiftnum = $_POST['shiftNumber'];
  7. $fuelgrade = $_POST['fuelGrade'];
  8. $customers = $db->query("SELECT * FROM shift_sale_vw WHERE date='$date' AND number='$shiftnum' AND grade_name='$fuelgrade' ");
  9. $json_data=[];
  10. while ($row = $customers->fetchArray()) {
  11. // print_r($row);
  12. $details = [
  13. "Shift_Id" => $row['shift_id'],
  14. "Date" => $row['date'],
  15. "Number" => $row['number'],
  16. "Open_Date" => date('Y-M-d h:i:s A',$row['open_date']),
  17. "Close_Date" => date('Y-M-d h:i:s A',$row['close_date']),
  18. "Fp_Id" => $row['fp_id'],
  19. "Grade_Name" => $row['grade_name'],
  20. "Price" => $row['price'],
  21. "Volume" => $row['volume'],
  22. "Amount" => $row['amount'],
  23. ];
  24. //here pushing the values in to an array
  25. array_push($json_data,$details);
  26. }
  27. $json_data_all = ["data" => $json_data];
  28. $myfile = fopen("api/v1/ShiftSaleReport/shiftSaleData.txt", "w+") or die("Unable to open file!");;
  29. fwrite($myfile,json_encode($json_data_all, JSON_PRETTY_PRINT));
  30. fclose($myfile);
  31. }
  32. ?>