Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

Select current day

38 views
Skip to first unread message

Nacho Mestre

unread,
Oct 28, 2024, 7:02:34 PM10/28/24
to Easy!Appointments - Support Group
Hi, I'm trying to get the date selection calendar to only enable the current day. I don't want it to let me select the previous day or the next day.

any script or way to configure

select current day

thanks
calendar date.jpg

The Bat

unread,
Oct 29, 2024, 9:52:28 AM10/29/24
to Easy!Appointments - Support Group
you have to edit booking.php

Nacho Mestre

unread,
Oct 29, 2024, 11:38:25 AM10/29/24
to Easy!Appointments - Support Group
What configuration do I have to make?   In that file only the following is displayed 
select-date.png

The Bat

unread,
Oct 29, 2024, 12:51:21 PM10/29/24
to Easy!Appointments - Support Group
application/controllers/Booking.php

Nacho Mestre

unread,
Oct 30, 2024, 9:02:18 AM10/30/24
to Easy!Appointments - Support Group
Hi, make these changes on the line 673 booking.php

public function get_unavailable_dates(): void
{
    try {
        $disable_booking = setting('disable_booking');

        if ($disable_booking) {
            abort(403);
        }

        $provider_id = request('provider_id');
        $service_id = request('service_id');
        $appointment_id = request('appointment_id');
        $manage_mode = filter_var(request('manage_mode'), FILTER_VALIDATE_BOOLEAN);
        $selected_date_string = date('Y-m-d');  // Usar la fecha actual
        $current_date = new DateTime($selected_date_string);
        $unavailable_dates = [];

        $provider_ids = $provider_id === ANY_PROVIDER
            ? $this->search_providers_by_service($service_id)
            : [$provider_id];

        $exclude_appointment_id = $manage_mode ? $appointment_id : null;

        // Obtener el servicio especificado
        $service = $this->services_model->find($service_id);

        // Comprobar la disponibilidad solo para el día actual
        foreach ($provider_ids as $current_provider_id) {
            $provider = $this->providers_model->find($current_provider_id);

            $available_hours = $this->availability->get_available_hours(
                $current_date->format('Y-m-d'),
                $service,
                $provider,
                $exclude_appointment_id
            );

            if (!empty($available_hours)) {
                // Si hay disponibilidad, termina el ciclo
                break;
            }
        }

        // Si no hay disponibilidad para el día actual
        if (empty($available_hours)) {
            $unavailable_dates[] = $current_date->format('Y-m-d');
        }

        json_response($unavailable_dates);
    } catch (Throwable $e) {
        json_exception($e);
    }
}


But in the flatpickr calendar it keeps enabling later and earlier days

Alex Tselegidis

unread,
Nov 5, 2024, 6:36:04 AM11/5/24
to Easy!Appointments - Support Group
Hello! 

It seems that you will need to return only the current date as available from the get_unavailable_dates callback that is located in the Booking.php controller. 

If that method returns all dates as unavailable except from the current one, then only the current one will be selectable during booking. 


Alex Tselegidis, Easy!Appointments Creator
Need a customization? Get a free quote!



Reply all
Reply to author
Forward
0 new messages