updateCell.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. require('auth-validate.php');
  3. require('../../db.php');
  4. $id_user = $_SESSION['id_user'];
  5. $id_file_row = isset($_REQUEST['id_file_row']) ? $_REQUEST['id_file_row'] : null;
  6. //example: 06-09-2016 2:32 AM
  7. $time_pickup = isset($_REQUEST['time_pickup']) ? $_REQUEST['time_pickup'] : null;
  8. $time_depart = isset($_REQUEST['time_depart']) ? $_REQUEST['time_depart'] : null;
  9. $bol_delivered = isset($_REQUEST['bol_delivered']) ? $_REQUEST['bol_delivered'] : null;
  10. $stmt = $dbh->prepare(
  11. "INSERT INTO file_row_update
  12. (id_user, id_file_row, time_pickup, time_depart, bol_delivered)
  13. VALUES
  14. (:id_user, :id_file_row,
  15. STR_TO_DATE(:time_pickup, '%m/%d/%Y %h:%i %p'),
  16. STR_TO_DATE(:time_depart, '%m/%d/%Y %h:%i %p'),
  17. STR_TO_DATE(:bol_delivered, '%m/%d/%Y %h:%i %p')
  18. )");
  19. try
  20. {
  21. $ret = $stmt->execute(array(
  22. ':id_user' => $id_user,
  23. ':id_file_row' => $id_file_row,
  24. ':time_pickup' => $time_pickup,
  25. ':time_depart' => $time_depart,
  26. ':bol_delivered' => $bol_delivered
  27. ));
  28. }
  29. catch(Exception $e)
  30. {
  31. http_response_code(500);
  32. //TODO: probably shouldn't report this internal exception message to the user
  33. echo $e->getMessage();
  34. return;
  35. }
  36. echo 'OK';
  37. ?>