diff --git a/application/controllers/Calendar.php b/application/controllers/Calendar.php index 7773796f..541036e0 100644 --- a/application/controllers/Calendar.php +++ b/application/controllers/Calendar.php @@ -98,6 +98,20 @@ class Calendar extends EA_Controller { $available_providers = $this->providers_model->get_available_providers(); + if ($role_slug === DB_SLUG_PROVIDER) + { + $available_providers = array_filter($available_providers, function ($available_provider) use ($user_id) { + return (int)$available_provider['id'] === (int)$user_id; + }); + } + + if ($role_slug === DB_SLUG_SECRETARY) + { + $available_providers = array_filter($available_providers, function ($available_provider) use ($secretary_providers) { + return in_array($available_provider['id'], $secretary_providers); + }); + } + $available_services = $this->services_model->get_available_services(); $calendar_view = request('view', $user['settings']['calendar_view']); diff --git a/assets/js/utils/calendar_default_view.js b/assets/js/utils/calendar_default_view.js index 07ffb3a8..b666cce3 100755 --- a/assets/js/utils/calendar_default_view.js +++ b/assets/js/utils/calendar_default_view.js @@ -1580,26 +1580,6 @@ App.Utils.CalendarDefaultView = (function () { .find('optgroup:eq(0)') .find('option[value="' + vars('user_id') + '"]') .prop('selected', true); - $selectFilterItem.prop('disabled', true); - } - - if (vars('role_slug') === App.Layouts.Backend.DB_SLUG_SECRETARY) { - // Remove the providers that are not connected to the secretary. - $selectFilterItem.find('optgroup:eq(1)').remove(); - - $selectFilterItem.find('option[type="provider"]').each((index, option) => { - const provider = vars('secretary_providers').find( - (secretaryProviderId) => Number($(option).val()) === Number(secretaryProviderId) - ); - - if (!provider) { - $(option).remove(); - } - }); - - if (!$selectFilterItem.find('option[type="provider"]').length) { - $selectFilterItem('optgroup[type="providers-group"]').remove(); - } } // Add the page event listeners.