The timezone component must not use the global vars when rendering.

This commit is contained in:
Alex Tselegidis 2022-01-18 10:32:30 +01:00
parent 837bcab4fc
commit 65d2836911
8 changed files with 44 additions and 39 deletions

View file

@ -58,7 +58,6 @@ class Providers extends EA_Controller {
return;
}
$role_slug = session('role_slug');
$services = $this->services_model->get();
@ -84,7 +83,7 @@ class Providers extends EA_Controller {
'page_title' => lang('providers'),
'active_menu' => PRIV_USERS,
'user_display_name' => $this->accounts->get_user_display_name($user_id),
'timezones' => $this->timezones->to_array(),
'timezones' => $this->timezones->to_grouped_array(),
'privileges' => $this->roles_model->get_permissions_by_slug($role_slug),
'services' => $this->services_model->get(),
]);

View file

@ -83,7 +83,7 @@ class Secretaries extends EA_Controller {
'page_title' => lang('secretaries'),
'active_menu' => PRIV_USERS,
'user_display_name' => $this->accounts->get_user_display_name($user_id),
'timezones' => $this->timezones->to_array(),
'timezones' => $this->timezones->to_grouped_array(),
'privileges' => $this->roles_model->get_permissions_by_slug($role_slug),
'providers' => $this->providers_model->get(),
]);

View file

@ -26,12 +26,10 @@ function render_timezone_dropdown(string $attributes = ''): string
$timezones = $CI->timezones->to_grouped_array();
html_vars([
return $CI->load->view('components/timezone_dropdown', [
'attributes' => $attributes,
'timezones' => $timezones
]);
return $CI->load->view('components/timezone_dropdown', html_vars(), TRUE);
], TRUE);
}
/**

View file

@ -1,5 +1,11 @@
<select <?= vars('attributes') ?>>
<?php foreach (vars('timezones') as $continent => $entries): ?>
<?php
/**
* @var string $attributes
* @var array $timezones
*/
?>
<select <?= $attributes ?>>
<?php foreach ($timezones as $continent => $entries): ?>
<optgroup label="<?= $continent ?>">
<?php foreach ($entries as $value => $name): ?>
<option value="<?= $value ?>"><?= $name ?></option>

View file

@ -88,34 +88,30 @@
<!-- Page Components -->
<?php
component(
'appointments_modal',
'',
[
'available_services' => vars('available_services'),
'timezones' => vars('timezones'),
'require_first_name' => vars('require_first_name'),
'require_last_name' => vars('require_last_name'),
'require_email' => vars('require_email'),
'require_phone_number' => vars('require_phone_number'),
'require_address' => vars('require_address'),
'require_city' => vars('require_city'),
'require_zip_code' => vars('require_zip_code')
]
)
?>
<?php component(
'appointments_modal',
'',
[
'available_services' => vars('available_services'),
'timezones' => vars('timezones'),
'require_first_name' => vars('require_first_name'),
'require_last_name' => vars('require_last_name'),
'require_email' => vars('require_email'),
'require_phone_number' => vars('require_phone_number'),
'require_address' => vars('require_address'),
'require_city' => vars('require_city'),
'require_zip_code' => vars('require_zip_code')
]
) ?>
<?php
component(
'unavailabilities_modal',
'',
[
'timezones' => vars('timezones'),
'timezone' => vars('timezone')
]
)
?>
<?php component(
'unavailabilities_modal',
'',
[
'timezones' => vars('timezones'),
'timezone' => vars('timezone')
]
) ?>
<?php component('select_google_calendar_modal') ?>

View file

@ -161,7 +161,9 @@
<?= lang('timezone') ?>
<span class="text-danger">*</span>
</label>
<?php component('timezone_dropdown', 'id="timezone" class="form-control required"') ?>
<?php component('timezone_dropdown', 'id="timezone" class="form-control required"', [
'timezones' => vars('timezones')
]) ?>
</div>
<div class="mb-3">

View file

@ -198,7 +198,9 @@
<?= lang('timezone') ?>
<span class="text-danger">*</span>
</label>
<?= render_timezone_dropdown('id="timezone" class="form-control required"') ?>
<?php component('timezone_dropdown', 'id="timezone" class="form-control required"', [
'timezones' => vars('timezones')
]) ?>
</div>
<br>

View file

@ -176,7 +176,9 @@
<?= lang('timezone') ?>
<span class="text-danger">*</span>
</label>
<?= render_timezone_dropdown('id="timezone" class="form-control required"') ?>
<?php component('timezone_dropdown', 'id="timezone" class="form-control required"', [
'timezones' => vars('timezones')
]) ?>
</div>
<br>