Force gap between bookings
Normally to force a gap between bookings you just create timeslots with gaps between them like..
- 9:00-9:45
- 10:00-10:45
- etc.
When using Service based duration to offer variable length bookings, this technique does not work as bookings are not constrained by timeslot boundaries.
This How-to shows how to hard code the validation to fail unless there is a gap.
Essentially, a 'gap of x minutes between bookings' = 'do not allow a booking which start or ends less than x minutes before the next booking'.
Note: This is a validation change, it does not change the way bookings are displayed so the customer will not be told they have a conflict until they hit submit (or add to cart).
Edit file: \components\com_rsappt_pro3\fe_val.php
Around line 221 look for:
$mystartdatetime = "STR_TO_DATE('".$startdate ." ". $starttime ."', '%Y-%m-%d %T')+ INTERVAL 1 SECOND";
$myenddatetime = "STR_TO_DATE('".$enddate ." ". $endtime ."', '%Y-%m-%d %T')- INTERVAL 1 SECOND";
This code is looking for other bookings in conflict with the new one.
By changing the INTERVAL you can expand the range it see as a conflict.
Example:
Say you want a 15 min gap left after every booking.
The INTERVAL is in seconds so 15 minutes = 900 seconds (15x60)
Change the code to be:
$mystartdatetime = "STR_TO_DATE('".$startdate ." ". $starttime ."', '%Y-%m-%d %T') - INTERVAL 899 SECOND";
$myenddatetime = "STR_TO_DATE('".$enddate ." ". $endtime ."', '%Y-%m-%d %T')+ INTERVAL 899 SECOND";
Note: you are changing the sign and changing the number from 1 to your desired gap -1.
Now the attempt to book a timeslot will not be allowed if there is already a booking within 15 min of the start/end of this one.