Skip to content

Commit

Permalink
Allow working plan exceptions to be defined as non-working days (#1383).
Browse files Browse the repository at this point in the history
  • Loading branch information
alextselegidis committed Jul 10, 2023
1 parent 81e8b88 commit 5473544
Show file tree
Hide file tree
Showing 38 changed files with 206 additions and 58 deletions.
5 changes: 5 additions & 0 deletions application/controllers/Calendar.php
Expand Up @@ -444,6 +444,11 @@ public function save_working_plan_exception()

$working_plan_exception = request('working_plan_exception');

if ( ! $working_plan_exception)
{
$working_plan_exception = NULL;
}

$provider_id = request('provider_id');

$this->providers_model->save_working_plan_exception($provider_id, $date, $working_plan_exception);
Expand Down
2 changes: 2 additions & 0 deletions application/language/arabic/translations_lang.php
Expand Up @@ -434,4 +434,6 @@
$lang['week_short'] = 'Wk';
$lang['scroll_to_increment'] = 'Scroll To Increment';
$lang['year'] = 'Year';
$lang['make_non_working_day'] = 'This provider will not be available for work on the selected day.';
$lang['no_breaks'] = 'No Breaks';
// End
2 changes: 2 additions & 0 deletions application/language/bulgarian/translations_lang.php
Expand Up @@ -434,4 +434,6 @@
$lang['week_short'] = 'Wk';
$lang['scroll_to_increment'] = 'Scroll To Increment';
$lang['year'] = 'Year';
$lang['make_non_working_day'] = 'This provider will not be available for work on the selected day.';
$lang['no_breaks'] = 'No Breaks';
// End
2 changes: 2 additions & 0 deletions application/language/catalan/translations_lang.php
Expand Up @@ -434,4 +434,6 @@
$lang['week_short'] = 'Wk';
$lang['scroll_to_increment'] = 'Scroll To Increment';
$lang['year'] = 'Year';
$lang['make_non_working_day'] = 'This provider will not be available for work on the selected day.';
$lang['no_breaks'] = 'No Breaks';
// End
2 changes: 2 additions & 0 deletions application/language/chinese/translations_lang.php
Expand Up @@ -434,4 +434,6 @@
$lang['week_short'] = 'Wk';
$lang['scroll_to_increment'] = 'Scroll To Increment';
$lang['year'] = 'Year';
$lang['make_non_working_day'] = 'This provider will not be available for work on the selected day.';
$lang['no_breaks'] = 'No Breaks';
// End
2 changes: 2 additions & 0 deletions application/language/croatian/translations_lang.php
Expand Up @@ -434,4 +434,6 @@
$lang['week_short'] = 'Tjed';
$lang['scroll_to_increment'] = 'Skrolajte za inkrementaciju';
$lang['year'] = 'Godina';
$lang['make_non_working_day'] = 'This provider will not be available for work on the selected day.';
$lang['no_breaks'] = 'No Breaks';
// End
2 changes: 2 additions & 0 deletions application/language/czech/translations_lang.php
Expand Up @@ -434,4 +434,6 @@
$lang['week_short'] = 'Wk';
$lang['scroll_to_increment'] = 'Scroll To Increment';
$lang['year'] = 'Year';
$lang['make_non_working_day'] = 'This provider will not be available for work on the selected day.';
$lang['no_breaks'] = 'No Breaks';
// End
2 changes: 2 additions & 0 deletions application/language/danish/translations_lang.php
Expand Up @@ -434,4 +434,6 @@
$lang['week_short'] = 'Wk';
$lang['scroll_to_increment'] = 'Scroll To Increment';
$lang['year'] = 'Year';
$lang['make_non_working_day'] = 'This provider will not be available for work on the selected day.';
$lang['no_breaks'] = 'No Breaks';
// End
2 changes: 2 additions & 0 deletions application/language/dutch/translations_lang.php
Expand Up @@ -434,4 +434,6 @@
$lang['week_short'] = 'Wk';
$lang['scroll_to_increment'] = 'Scroll To Increment';
$lang['year'] = 'Year';
$lang['make_non_working_day'] = 'This provider will not be available for work on the selected day.';
$lang['no_breaks'] = 'No Breaks';
// End
2 changes: 2 additions & 0 deletions application/language/english/translations_lang.php
Expand Up @@ -434,4 +434,6 @@
$lang['week_short'] = 'Wk';
$lang['scroll_to_increment'] = 'Scroll To Increment';
$lang['year'] = 'Year';
$lang['make_non_working_day'] = 'This provider will not be available for work on the selected day.';
$lang['no_breaks'] = 'No Breaks';
// End
2 changes: 2 additions & 0 deletions application/language/estonian/translations_lang.php
Expand Up @@ -434,4 +434,6 @@
$lang['week_short'] = 'Wk';
$lang['scroll_to_increment'] = 'Scroll To Increment';
$lang['year'] = 'Year';
$lang['make_non_working_day'] = 'This provider will not be available for work on the selected day.';
$lang['no_breaks'] = 'No Breaks';
// End
2 changes: 2 additions & 0 deletions application/language/finnish/translations_lang.php
Expand Up @@ -434,4 +434,6 @@
$lang['week_short'] = 'Wk';
$lang['scroll_to_increment'] = 'Scroll To Increment';
$lang['year'] = 'Year';
$lang['make_non_working_day'] = 'This provider will not be available for work on the selected day.';
$lang['no_breaks'] = 'No Breaks';
// End
2 changes: 2 additions & 0 deletions application/language/french/translations_lang.php
Expand Up @@ -434,4 +434,6 @@
$lang['week_short'] = 'Se';
$lang['scroll_to_increment'] = 'Faire défiler pour incrémenter';
$lang['year'] = 'Année';
$lang['make_non_working_day'] = 'This provider will not be available for work on the selected day.';
$lang['no_breaks'] = 'No Breaks';
// End
2 changes: 2 additions & 0 deletions application/language/german/translations_lang.php
Expand Up @@ -434,4 +434,6 @@
$lang['week_short'] = 'Wo';
$lang['scroll_to_increment'] = 'Scrollen Sie zu Inkrement';
$lang['year'] = 'Jahr';
$lang['make_non_working_day'] = 'This provider will not be available for work on the selected day.';
$lang['no_breaks'] = 'No Breaks';
// End
2 changes: 2 additions & 0 deletions application/language/greek/translations_lang.php
Expand Up @@ -434,4 +434,6 @@
$lang['week_short'] = 'Wk';
$lang['scroll_to_increment'] = 'Scroll To Increment';
$lang['year'] = 'Year';
$lang['make_non_working_day'] = 'This provider will not be available for work on the selected day.';
$lang['no_breaks'] = 'No Breaks';
// End
2 changes: 2 additions & 0 deletions application/language/hebrew/translations_lang.php
Expand Up @@ -434,4 +434,6 @@
$lang['week_short'] = 'Wk';
$lang['scroll_to_increment'] = 'Scroll To Increment';
$lang['year'] = 'Year';
$lang['make_non_working_day'] = 'This provider will not be available for work on the selected day.';
$lang['no_breaks'] = 'No Breaks';
// End
2 changes: 2 additions & 0 deletions application/language/hindi/translations_lang.php
Expand Up @@ -434,4 +434,6 @@
$lang['week_short'] = 'Wk';
$lang['scroll_to_increment'] = 'Scroll To Increment';
$lang['year'] = 'Year';
$lang['make_non_working_day'] = 'This provider will not be available for work on the selected day.';
$lang['no_breaks'] = 'No Breaks';
// End
2 changes: 2 additions & 0 deletions application/language/hungarian/translations_lang.php
Expand Up @@ -434,4 +434,6 @@
$lang['week_short'] = 'Wk';
$lang['scroll_to_increment'] = 'Scroll To Increment';
$lang['year'] = 'Year';
$lang['make_non_working_day'] = 'This provider will not be available for work on the selected day.';
$lang['no_breaks'] = 'No Breaks';
// End
2 changes: 2 additions & 0 deletions application/language/italian/translations_lang.php
Expand Up @@ -434,4 +434,6 @@
$lang['week_short'] = 'Wk';
$lang['scroll_to_increment'] = 'Scroll To Increment';
$lang['year'] = 'Year';
$lang['make_non_working_day'] = 'This provider will not be available for work on the selected day.';
$lang['no_breaks'] = 'No Breaks';
// End
2 changes: 2 additions & 0 deletions application/language/japanese/translations_lang.php
Expand Up @@ -434,4 +434,6 @@
$lang['week_short'] = 'Wk';
$lang['scroll_to_increment'] = 'Scroll To Increment';
$lang['year'] = 'Year';
$lang['make_non_working_day'] = 'This provider will not be available for work on the selected day.';
$lang['no_breaks'] = 'No Breaks';
// End
2 changes: 2 additions & 0 deletions application/language/luxembourgish/translations_lang.php
Expand Up @@ -434,4 +434,6 @@
$lang['week_short'] = 'Wk';
$lang['scroll_to_increment'] = 'Scroll To Increment';
$lang['year'] = 'Year';
$lang['make_non_working_day'] = 'This provider will not be available for work on the selected day.';
$lang['no_breaks'] = 'No Breaks';
// End
2 changes: 2 additions & 0 deletions application/language/marathi/translations_lang.php
Expand Up @@ -434,4 +434,6 @@
$lang['week_short'] = 'Wk';
$lang['scroll_to_increment'] = 'Scroll To Increment';
$lang['year'] = 'Year';
$lang['make_non_working_day'] = 'This provider will not be available for work on the selected day.';
$lang['no_breaks'] = 'No Breaks';
// End
2 changes: 2 additions & 0 deletions application/language/persian/translations_lang.php
Expand Up @@ -434,4 +434,6 @@
$lang['week_short'] = 'Wk';
$lang['scroll_to_increment'] = 'Scroll To Increment';
$lang['year'] = 'Year';
$lang['make_non_working_day'] = 'This provider will not be available for work on the selected day.';
$lang['no_breaks'] = 'No Breaks';
// End
2 changes: 2 additions & 0 deletions application/language/polish/translations_lang.php
Expand Up @@ -434,4 +434,6 @@
$lang['week_short'] = 'Wk';
$lang['scroll_to_increment'] = 'Scroll To Increment';
$lang['year'] = 'Year';
$lang['make_non_working_day'] = 'This provider will not be available for work on the selected day.';
$lang['no_breaks'] = 'No Breaks';
// End
2 changes: 2 additions & 0 deletions application/language/portuguese-br/translations_lang.php
Expand Up @@ -434,4 +434,6 @@
$lang['week_short'] = 'Wk';
$lang['scroll_to_increment'] = 'Scroll To Increment';
$lang['year'] = 'Year';
$lang['make_non_working_day'] = 'This provider will not be available for work on the selected day.';
$lang['no_breaks'] = 'No Breaks';
// End
2 changes: 2 additions & 0 deletions application/language/portuguese/translations_lang.php
Expand Up @@ -434,4 +434,6 @@
$lang['week_short'] = 'Wk';
$lang['scroll_to_increment'] = 'Scroll To Increment';
$lang['year'] = 'Year';
$lang['make_non_working_day'] = 'This provider will not be available for work on the selected day.';
$lang['no_breaks'] = 'No Breaks';
// End
2 changes: 2 additions & 0 deletions application/language/romanian/translations_lang.php
Expand Up @@ -434,4 +434,6 @@
$lang['week_short'] = 'Wk';
$lang['scroll_to_increment'] = 'Scroll To Increment';
$lang['year'] = 'Year';
$lang['make_non_working_day'] = 'This provider will not be available for work on the selected day.';
$lang['no_breaks'] = 'No Breaks';
// End
2 changes: 2 additions & 0 deletions application/language/russian/translations_lang.php
Expand Up @@ -434,4 +434,6 @@
$lang['week_short'] = 'Нед';
$lang['scroll_to_increment'] = 'Прокрутка для увеличения';
$lang['year'] = 'Год';
$lang['make_non_working_day'] = 'This provider will not be available for work on the selected day.';
$lang['no_breaks'] = 'No Breaks';
// End
2 changes: 2 additions & 0 deletions application/language/serbian/translations_lang.php
Expand Up @@ -434,4 +434,6 @@
$lang['week_short'] = 'Wk';
$lang['scroll_to_increment'] = 'Scroll To Increment';
$lang['year'] = 'Year';
$lang['make_non_working_day'] = 'This provider will not be available for work on the selected day.';
$lang['no_breaks'] = 'No Breaks';
// End
2 changes: 2 additions & 0 deletions application/language/slovak/translations_lang.php
Expand Up @@ -434,4 +434,6 @@
$lang['week_short'] = 'Wk';
$lang['scroll_to_increment'] = 'Scroll To Increment';
$lang['year'] = 'Year';
$lang['make_non_working_day'] = 'This provider will not be available for work on the selected day.';
$lang['no_breaks'] = 'No Breaks';
// End
2 changes: 2 additions & 0 deletions application/language/spanish/translations_lang.php
Expand Up @@ -434,4 +434,6 @@
$lang['week_short'] = 'Wk';
$lang['scroll_to_increment'] = 'Scroll To Increment';
$lang['year'] = 'Year';
$lang['make_non_working_day'] = 'This provider will not be available for work on the selected day.';
$lang['no_breaks'] = 'No Breaks';
// End
2 changes: 2 additions & 0 deletions application/language/swedish/translations_lang.php
Expand Up @@ -434,4 +434,6 @@
$lang['week_short'] = 'Wk';
$lang['scroll_to_increment'] = 'Scroll To Increment';
$lang['year'] = 'Year';
$lang['make_non_working_day'] = 'This provider will not be available for work on the selected day.';
$lang['no_breaks'] = 'No Breaks';
// End
2 changes: 2 additions & 0 deletions application/language/turkish/translations_lang.php
Expand Up @@ -434,4 +434,6 @@
$lang['week_short'] = 'Wk';
$lang['scroll_to_increment'] = 'Scroll To Increment';
$lang['year'] = 'Year';
$lang['make_non_working_day'] = 'This provider will not be available for work on the selected day.';
$lang['no_breaks'] = 'No Breaks';
// End
10 changes: 5 additions & 5 deletions application/models/Providers_model.php
Expand Up @@ -582,7 +582,7 @@ protected function save_service_ids(int $provider_id, array $service_ids)
* @throws InvalidArgumentException
* @throws Exception
*/
public function save_working_plan_exception(int $provider_id, string $date, array $working_plan_exception)
public function save_working_plan_exception(int $provider_id, string $date, array $working_plan_exception = NULL)
{
// Validate the working plan exception data.
$start = date('H:i', strtotime($working_plan_exception['start']));
Expand Down Expand Up @@ -610,7 +610,7 @@ public function save_working_plan_exception(int $provider_id, string $date, arra
// Store the working plan exception.
$working_plan_exceptions = json_decode($provider['settings']['working_plan_exceptions'], TRUE);

if ( ! isset($working_plan_exception['breaks']))
if ( is_array($working_plan_exception) && ! isset($working_plan_exception['breaks']))
{
$working_plan_exception['breaks'] = [];
}
Expand Down Expand Up @@ -643,7 +643,7 @@ public function delete_working_plan_exception(int $provider_id, string $date)

unset($working_plan_exceptions[$date]);

$provider['settings']['working_plan_exceptions'] = empty($working_plan_exceptions) ? new stdClass() : $working_plan_exceptions;
$provider['settings']['working_plan_exceptions'] = empty($working_plan_exceptions) ? '{}' : $working_plan_exceptions;

$this->update($provider);
}
Expand Down Expand Up @@ -1015,10 +1015,10 @@ public function api_decode(array &$provider, array $base = NULL)

/**
* Quickly check if a service is assigned to a provider.
*
*
* @param int $provider_id
* @param int $service_id
*
*
* @return bool
*/
public function is_service_supported(int $provider_id, int $service_id): bool
Expand Down
29 changes: 21 additions & 8 deletions application/views/components/working_plan_exceptions_modal.php
@@ -1,5 +1,5 @@
<div class="modal" id="working-plan-exceptions-modal">
<div class="modal-dialog modal-dialog-centered modal-dialog-scrollable">
<div class="modal-dialog modal-dialog-centered modal-dialog-scrollable modal-lg">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title"><?= lang('working_plan_exception') ?></h5>
Expand All @@ -11,14 +11,27 @@
<input class="form-control" id="working-plan-exceptions-date">
</div>

<div class="mb-3">
<label class="form-label" for="working-plan-exceptions-start"><?= lang('start') ?></label>
<input class="form-control" id="working-plan-exceptions-start">
<div class="form-check form-switch mb-3">
<input class="form-check-input" type="checkbox" id="working-plan-exceptions-is-non-working-day">
<label class="form-check-label" for="working-plan-exceptions-is-non-working-day">
<?= lang('make_non_working_day') ?>
</label>
</div>

<div class="mb-3">
<label class="form-label" for="working-plan-exceptions-end"><?= lang('end') ?></label>
<input class="form-control" id="working-plan-exceptions-end">
<div class="row">
<div class="col-sm-6">
<div class="mb-3">
<label class="form-label" for="working-plan-exceptions-start"><?= lang('start') ?></label>
<input class="form-control" id="working-plan-exceptions-start">
</div>
</div>

<div class="col-sm-6">
<div class="mb-3">
<label class="form-label" for="working-plan-exceptions-end"><?= lang('end') ?></label>
<input class="form-control" id="working-plan-exceptions-end">
</div>
</div>
</div>

<h3><?= lang('breaks') ?></h3>
Expand All @@ -28,7 +41,7 @@
</p>

<div>
<button type="button" class="btn btn-primary working-plan-exceptions-add-break">
<button type="button" class="btn btn-outline-primary btn-sm working-plan-exceptions-add-break">
<i class="fas fa-plus-square me-2"></i>
<?= lang('add_break') ?>
</button>
Expand Down

0 comments on commit 5473544

Please sign in to comment.