Provider and secretary users can only add unavailabilities for their authorized users (#1214)

This commit is contained in:
Alex Tselegidis 2022-02-23 12:00:39 +01:00
parent cc697fc09e
commit 617222ae2a
2 changed files with 11 additions and 3 deletions

View file

@ -85,12 +85,22 @@ class Backend extends EA_Controller {
{
$secretary = $this->secretaries_model->get_row($this->session->userdata('user_id'));
$view['secretary_providers'] = $secretary['providers'];
$view['available_providers'] = array_values(array_filter($view['available_providers'], function ($available_provider) use ($secretary) {
return in_array($available_provider['id'], $secretary['providers']);
}));
}
else
{
$view['secretary_providers'] = [];
}
if ($this->session->userdata('role_slug') === DB_SLUG_PROVIDER)
{
$view['available_providers'] = array_values(array_filter($view['available_providers'], function ($available_provider) use ($user_id) {
return $available_provider['id'] === $user_id;
}));
}
$results = $this->appointments_model->get_batch(['hash' => $appointment_hash]);
if ($appointment_hash !== '' && count($results) > 0)

View file

@ -110,9 +110,7 @@ window.BackendCalendarUnavailabilityEventsModal = window.BackendCalendarUnavaila
if ($('.calendar-view').length === 0) {
$dialog.find('#unavailable-provider')
.val($('#select-filter-item').val())
.closest('.form-group')
.hide();
.val($('#select-filter-item').val());
}
$dialog.find('#unavailable-start').val(GeneralFunctions.formatDate(start, GlobalVariables.dateFormat, true));