CraigT543 / EasyBlue

Modifications for Easy!Appointments
21 stars 23 forks source link

waiting list shows more than real available times #9

Open bullmoose20 opened 7 years ago

bullmoose20 commented 7 years ago

Set up an appointment in backend as 480 minutes Setup an availability in the store with less than 480 minutes Try to find available time slots in the week, none will be found as expected. Add yourself to the waiting list. When you get the email, a bunch of availabilities show which is the bug.

CraigT543 commented 7 years ago

Ok, the problem was with the diff function which always returns a positive and then makes the loop infinite because it never falls below the condition. 480 minutes should register a significant negative on the diff (with the intval set to 60 we would end up with -420). But instead it inverts the negative and now you have a significant positive of 420 and so on. So the fix is to put a break in the loop. These are the changes I am making:

`

            //$openspot is the default duration to search for availability
            $openspot = 60;

            while (($diff->h * $openspot + $diff->i) >= intval($openspot)) {
                if ($time_format == '24HR') {
                    $available_hours[] = $current_hour->format('H:i');
                }else{
                    $available_hours[] = $current_hour->format('g:i a');
                }
                $current_hour->add(new DateInterval("PT".$openspot."M"));
                $diff = $current_hour->diff($end_hour);
                //Break here added by Craig Tucker
                $diff = $current_hour->diff($end_hour);
                if ($diff->invert == 1) {  
                 break;
                }
                //end break Craig Tucker                    
            }

` I will add this on github after I have made some other changes. I really appreciate the addition of the HTML. It looks great. You see I am also adding a variable for $openspot. That should be a back end setting I think. I will add that so that the user can select any amount they want to show up as the basic availability searched for. I am going to take out some lines that are associated with the appointment stuff so that it basically just shows something like

Update: John Doe has availability on the following dates and times: 05/08/2017, Monday: 9:00am, 10:00, 11:00, 12:00pm, 1:00, 3:00, 4:00, 5:00

I will also change some formatting of the text so it fits better. I think that will do that. Give me any thoughts you have on this.

Another way to go is to have the waiting list based upon the length of a specific appointment the client is seeking (that would probably be best). However, that would take more coding time than I have so I will not be going there.

bullmoose20 commented 7 years ago

I think that a service has a designated duration and hence that is what the user needs to look for. The first available spot is based on the duration of the service, the availability of the provider of that service, and the overall hours of operation. A store that closes at 5pm should not offer availability to a user at 430pm if the service is a 31 minute or greater service as this would go into "overtime".

Nick

CraigT543 commented 7 years ago

I found the problem and fixed it.