Fix manage-booking time slots; align modify email with original

- getAvailableTimes() takes optional exclude_booking_id so a guest's
  own booking isn't counted as a conflict when editing — original time
  now reappears when extending services
- Manage-booking AJAX passes manage_token; server resolves to booking_id
- manage_booking_process uses the new param instead of the date-swap
  workaround (removes a small race-condition risk)
- Modify-booking emails (no/en/hu) now include Name/Email/Phone rows
  and the 24h cancellation policy, matching the original booking email
This commit is contained in:
Ubuntu
2026-05-10 13:18:07 +00:00
parent 1e32a146a7
commit e24e68f603
3 changed files with 68 additions and 26 deletions
+28 -11
View File
@@ -396,7 +396,7 @@ class Service_model extends CI_Model {
}
public function getAvailableTimes($worker_id, $selectedDate, $servicelength) {
public function getAvailableTimes($worker_id, $selectedDate, $servicelength, $exclude_booking_id = null) {
$this->load->database();
// múltbeli napra ne lehessen foglalni
@@ -490,10 +490,17 @@ class Service_model extends CI_Model {
$allBookings = [];
if ($lunchRequired) {
$allBookings = $this->db->query("
SELECT booking_start_time, booking_finish_time FROM bookings
WHERE booking_date = ? AND worker_id = ?
", array($selectedDate, $worker_id))->result();
if ($exclude_booking_id !== null) {
$allBookings = $this->db->query("
SELECT booking_start_time, booking_finish_time FROM bookings
WHERE booking_date = ? AND worker_id = ? AND booking_id != ?
", array($selectedDate, $worker_id, $exclude_booking_id))->result();
} else {
$allBookings = $this->db->query("
SELECT booking_start_time, booking_finish_time FROM bookings
WHERE booking_date = ? AND worker_id = ?
", array($selectedDate, $worker_id))->result();
}
}
$interval = new DateInterval('PT15M');
@@ -508,12 +515,22 @@ class Service_model extends CI_Model {
$startTimeStr = $current->format('H:i:s');
$endTimeStr = $slotEnd->format('H:i:s');
$bookingQuery = $this->db->query("
SELECT * FROM bookings
WHERE booking_date = ?
AND worker_id = ?
AND booking_start_time < ? AND booking_finish_time > ?
", array($selectedDate, $worker_id, $endTimeStr, $startTimeStr));
if ($exclude_booking_id !== null) {
$bookingQuery = $this->db->query("
SELECT * FROM bookings
WHERE booking_date = ?
AND worker_id = ?
AND booking_id != ?
AND booking_start_time < ? AND booking_finish_time > ?
", array($selectedDate, $worker_id, $exclude_booking_id, $endTimeStr, $startTimeStr));
} else {
$bookingQuery = $this->db->query("
SELECT * FROM bookings
WHERE booking_date = ?
AND worker_id = ?
AND booking_start_time < ? AND booking_finish_time > ?
", array($selectedDate, $worker_id, $endTimeStr, $startTimeStr));
}
if ($bookingQuery->num_rows() > 0) continue; // already booked