Currently I'm using html time picker, but wouldn't mind using Javascript/Jquery/Ajax instead. The problem I'm trying to solve is this:
you are a customer, you ordered x from an employee. that x has a duration (start_time - end_time). The time form data is saved in $customer_time
. Note that I had to store the days as varchar. but my issue is not with date, it's with time.
The sql query I have is this (feel free to make it better if you could)
SELECT employee_id, product_start_time, product_end_time, date FROM orders
WHERE NOT (
employee_id ='$employee_id'
AND res_date = '$res_date'
AND $customer_time =TIMEDIFF ('product_start_time','product_end_time')
)
I guess I wrote timediff right, if not please correct it as I have never used it before, the idea is
$customer_time = start_time - end_time
Anyhow, if the employee is free, then the customer can proceed with the reservation, otherwise, the time_ picker field should be disabled. I need a time picker like the html one, but one that I can work with and disable the time. I don't want a time picker where I select default time from a list of intervals.
So please
- Check if my mysql query is correct
- Recommend a time picker
- An example implantation is highly appreciated
Update
Perhaps a better version of my query is to use INTERVAL instead of timediff, since every product has a duration in minutes, few have durations in hours, but mostly minutes.
My initial idea was to create a time field that keeps checking for availability, like you check for available usernames, in a username field using ajax, don't know if that would work though.