forked from mirrors/easyappointments
All the user roles with access to the backend calendar page can filter by service (#956).
This commit is contained in:
parent
d4d7fd13d0
commit
97f98c5118
2 changed files with 14 additions and 20 deletions
|
@ -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']);
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in a new issue