shiftSaleData.php 1.2 KB

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