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

View file

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

View file

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

View file

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

View file

@ -88,8 +88,7 @@
<!-- Page Components --> <!-- Page Components -->
<?php <?php component(
component(
'appointments_modal', 'appointments_modal',
'', '',
[ [
@ -103,19 +102,16 @@
'require_city' => vars('require_city'), 'require_city' => vars('require_city'),
'require_zip_code' => vars('require_zip_code') 'require_zip_code' => vars('require_zip_code')
] ]
) ) ?>
?>
<?php <?php component(
component(
'unavailabilities_modal', 'unavailabilities_modal',
'', '',
[ [
'timezones' => vars('timezones'), 'timezones' => vars('timezones'),
'timezone' => vars('timezone') 'timezone' => vars('timezone')
] ]
) ) ?>
?>
<?php component('select_google_calendar_modal') ?> <?php component('select_google_calendar_modal') ?>

View file

@ -161,7 +161,9 @@
<?= lang('timezone') ?> <?= lang('timezone') ?>
<span class="text-danger">*</span> <span class="text-danger">*</span>
</label> </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>
<div class="mb-3"> <div class="mb-3">

View file

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

View file

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