This topic is locked

Reservations Project - Not allow already booked

6/29/2016 5:53:44 PM
ASPRunnerPro General questions
B
blalor author

Hi Sergey... I'm building an online motorpool reservation system using ASPRunner 9.1. I have a reservations table which has a [PickUpDate] field, a [PickUpTime] field, a [ReturnDate] field and a [ReturnTime] field.
I am struggling trying to figure out a way that if a user tries to select a vehicle for a date/time that is already booked to either have a pop up alert saying that the vehicle is not available or someway to filter the vehicle drop-down to not show vehicles booked at that date/time.
Any ideas?
Thanks, Bill

admin 6/30/2016

This can be done but definitely some custom coding will be required. The best option is to run a select query in event like BeforeAdd to pick all reservations that may overlap with selected date range.
You can see some ideas at http://stackoverflow.com/questions/19743829/mysql-check-if-two-date-range-overlap-with-input but it can be more complicated if you also include reservation time in consideration. It will be also more complicated if besides overlapping ranges you need to account for range that are fully inside or fully outside of selected range.
For instance, client wants to reserve the vehicle from July 2rd to July 10th. Previous reservations like July 3rd-Juky 9th or July 1st - July 15th need to be accounted for. You might need to write some ASP code as well besides the SQL query alone.