|
|
@ -5,6 +5,9 @@ namespace Engelsystem;
|
|
|
|
use Engelsystem\Models\Room;
|
|
|
|
use Engelsystem\Models\Room;
|
|
|
|
use Engelsystem\Models\User\User;
|
|
|
|
use Engelsystem\Models\User\User;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
use function config;
|
|
|
|
|
|
|
|
use function theme_type;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Renders a single shift for the shift calendar
|
|
|
|
* Renders a single shift for the shift calendar
|
|
|
|
*/
|
|
|
|
*/
|
|
|
@ -23,7 +26,7 @@ class ShiftCalendarShiftRenderer
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$info_text = '';
|
|
|
|
$info_text = '';
|
|
|
|
if ($shift['title'] != '') {
|
|
|
|
if ($shift['title'] != '') {
|
|
|
|
$info_text = icon('info') . $shift['title'] . '<br>';
|
|
|
|
$info_text = icon('info-circle') . $shift['title'] . '<br>';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
list($shift_signup_state, $shifts_row) = $this->renderShiftNeededAngeltypes(
|
|
|
|
list($shift_signup_state, $shifts_row) = $this->renderShiftNeededAngeltypes(
|
|
|
|
$shift,
|
|
|
|
$shift,
|
|
|
@ -48,10 +51,10 @@ class ShiftCalendarShiftRenderer
|
|
|
|
. ($blocks * ShiftCalendarRenderer::BLOCK_HEIGHT - ShiftCalendarRenderer::MARGIN)
|
|
|
|
. ($blocks * ShiftCalendarRenderer::BLOCK_HEIGHT - ShiftCalendarRenderer::MARGIN)
|
|
|
|
. 'px;',
|
|
|
|
. 'px;',
|
|
|
|
div(
|
|
|
|
div(
|
|
|
|
'shift panel panel-' . $class,
|
|
|
|
'shift card bg-' . $class,
|
|
|
|
[
|
|
|
|
[
|
|
|
|
$this->renderShiftHead($shift, $class, $shift_signup_state->getFreeEntries()),
|
|
|
|
$this->renderShiftHead($shift, $class, $shift_signup_state->getFreeEntries()),
|
|
|
|
div('panel-body', [
|
|
|
|
div('card-body ' . $this->classBg(), [
|
|
|
|
$info_text,
|
|
|
|
$info_text,
|
|
|
|
Room_name_render($room)
|
|
|
|
Room_name_render($room)
|
|
|
|
]),
|
|
|
|
]),
|
|
|
@ -79,7 +82,7 @@ class ShiftCalendarShiftRenderer
|
|
|
|
case ShiftSignupState::NOT_ARRIVED:
|
|
|
|
case ShiftSignupState::NOT_ARRIVED:
|
|
|
|
case ShiftSignupState::NOT_YET:
|
|
|
|
case ShiftSignupState::NOT_YET:
|
|
|
|
case ShiftSignupState::SHIFT_ENDED:
|
|
|
|
case ShiftSignupState::SHIFT_ENDED:
|
|
|
|
return 'default';
|
|
|
|
return 'light';
|
|
|
|
|
|
|
|
|
|
|
|
case ShiftSignupState::ANGELTYPE:
|
|
|
|
case ShiftSignupState::ANGELTYPE:
|
|
|
|
case ShiftSignupState::COLLIDES:
|
|
|
|
case ShiftSignupState::COLLIDES:
|
|
|
@ -133,7 +136,7 @@ class ShiftCalendarShiftRenderer
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (auth()->can('user_shifts_admin')) {
|
|
|
|
if (auth()->can('user_shifts_admin')) {
|
|
|
|
$html .= '<li class="list-group-item">';
|
|
|
|
$html .= '<li class="list-group-item d-flex align-items-center ' . $this->classBg() . '">';
|
|
|
|
$html .= button(shift_entry_create_link_admin($shift),
|
|
|
|
$html .= button(shift_entry_create_link_admin($shift),
|
|
|
|
icon('plus-lg') . __('Add more angels'),
|
|
|
|
icon('plus-lg') . __('Add more angels'),
|
|
|
|
'btn-sm'
|
|
|
|
'btn-sm'
|
|
|
@ -143,7 +146,7 @@ class ShiftCalendarShiftRenderer
|
|
|
|
if ($html != '') {
|
|
|
|
if ($html != '') {
|
|
|
|
return [
|
|
|
|
return [
|
|
|
|
$shift_signup_state,
|
|
|
|
$shift_signup_state,
|
|
|
|
'<ul class="list-group">' . $html . '</ul>'
|
|
|
|
'<ul class="list-group list-group-flush">' . $html . '</ul>'
|
|
|
|
];
|
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -167,8 +170,8 @@ class ShiftCalendarShiftRenderer
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$entry_list = [];
|
|
|
|
$entry_list = [];
|
|
|
|
foreach ($shift_entries as $entry) {
|
|
|
|
foreach ($shift_entries as $entry) {
|
|
|
|
$style = $entry['freeloaded'] ? ' text-decoration: line-through;' : '';
|
|
|
|
$class = $entry['freeloaded'] ? 'text-decoration-line-through' : '';
|
|
|
|
$entry_list[] = '<span style="' . $style . '">' . User_Nick_render($entry) . '</span>';
|
|
|
|
$entry_list[] = '<span class="text-nowrap ' . $class . '">' . User_Nick_render($entry) . '</span>';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$shift_signup_state = Shift_signup_allowed(
|
|
|
|
$shift_signup_state = Shift_signup_allowed(
|
|
|
|
$user,
|
|
|
|
$user,
|
|
|
@ -186,14 +189,14 @@ class ShiftCalendarShiftRenderer
|
|
|
|
case ShiftSignupState::ADMIN:
|
|
|
|
case ShiftSignupState::ADMIN:
|
|
|
|
case ShiftSignupState::FREE:
|
|
|
|
case ShiftSignupState::FREE:
|
|
|
|
// When admin or free display a link + button for sign up
|
|
|
|
// When admin or free display a link + button for sign up
|
|
|
|
$entry_list[] = '<a href="'
|
|
|
|
$entry_list[] = '<a class="me-1 text-nowrap" href="'
|
|
|
|
. shift_entry_create_link($shift, $angeltype)
|
|
|
|
. shift_entry_create_link($shift, $angeltype)
|
|
|
|
. '">'
|
|
|
|
. '">'
|
|
|
|
. $inner_text
|
|
|
|
. $inner_text
|
|
|
|
. '</a> '
|
|
|
|
. '</a> '
|
|
|
|
. button(
|
|
|
|
. button(
|
|
|
|
shift_entry_create_link($shift, $angeltype),
|
|
|
|
shift_entry_create_link($shift, $angeltype),
|
|
|
|
__('Sign up'), 'btn-sm btn-primary d-print-none'
|
|
|
|
__('Sign up'), 'btn-sm btn-primary text-nowrap d-print-none'
|
|
|
|
);
|
|
|
|
);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
@ -240,8 +243,8 @@ class ShiftCalendarShiftRenderer
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$shifts_row = '<li class="list-group-item">';
|
|
|
|
$shifts_row = '<li class="list-group-item d-flex flex-wrap align-items-center ' . $this->classBg() . '">';
|
|
|
|
$shifts_row .= '<strong>' . AngelType_name_render($angeltype) . ':</strong> ';
|
|
|
|
$shifts_row .= '<strong class="me-1">' . AngelType_name_render($angeltype) . ':</strong> ';
|
|
|
|
$shifts_row .= join(', ', $entry_list);
|
|
|
|
$shifts_row .= join(', ', $entry_list);
|
|
|
|
$shifts_row .= '</li>';
|
|
|
|
$shifts_row .= '</li>';
|
|
|
|
return [
|
|
|
|
return [
|
|
|
@ -250,6 +253,20 @@ class ShiftCalendarShiftRenderer
|
|
|
|
];
|
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Return the corresponding bg class
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @return string
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
private function classBg(): string
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (theme_type() === 'light') {
|
|
|
|
|
|
|
|
return 'bg-white';
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return 'bg-dark';
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Renders the shift header
|
|
|
|
* Renders the shift header
|
|
|
|
*
|
|
|
|
*
|
|
|
@ -261,16 +278,16 @@ class ShiftCalendarShiftRenderer
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$header_buttons = '';
|
|
|
|
$header_buttons = '';
|
|
|
|
if (auth()->can('admin_shifts')) {
|
|
|
|
if (auth()->can('admin_shifts')) {
|
|
|
|
$header_buttons = '<div class="float-end d-print-none">' . table_buttons([
|
|
|
|
$header_buttons = '<div class="ms-auto d-print-none">' . table_buttons([
|
|
|
|
button(
|
|
|
|
button(
|
|
|
|
page_link_to('user_shifts', ['edit_shift' => $shift['SID']]),
|
|
|
|
page_link_to('user_shifts', ['edit_shift' => $shift['SID']]),
|
|
|
|
icon('pencil'),
|
|
|
|
icon('pencil'),
|
|
|
|
"btn-$class btn-sm"
|
|
|
|
"btn-$class btn-sm border-light"
|
|
|
|
),
|
|
|
|
),
|
|
|
|
button(
|
|
|
|
button(
|
|
|
|
page_link_to('user_shifts', ['delete_shift' => $shift['SID']]),
|
|
|
|
page_link_to('user_shifts', ['delete_shift' => $shift['SID']]),
|
|
|
|
icon('trash'),
|
|
|
|
icon('trash'),
|
|
|
|
"btn-$class btn-sm"
|
|
|
|
"btn-$class btn-sm border-light"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
]) . '</div>';
|
|
|
|
]) . '</div>';
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -279,11 +296,11 @@ class ShiftCalendarShiftRenderer
|
|
|
|
. $shift['name'];
|
|
|
|
. $shift['name'];
|
|
|
|
|
|
|
|
|
|
|
|
if ($needed_angeltypes_count > 0) {
|
|
|
|
if ($needed_angeltypes_count > 0) {
|
|
|
|
$shift_heading = '<span class="badge">' . $needed_angeltypes_count . '</span> ' . $shift_heading;
|
|
|
|
$shift_heading = '<span class="badge bg-light text-danger me-1">' . $needed_angeltypes_count . '</span> ' . $shift_heading;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return div('panel-heading', [
|
|
|
|
return div('card-header d-flex align-items-center', [
|
|
|
|
'<a href="' . shift_link($shift) . '">' . $shift_heading . '</a>',
|
|
|
|
'<a class="d-flex align-items-center text-white" href="' . shift_link($shift) . '">' . $shift_heading . '</a>',
|
|
|
|
$header_buttons
|
|
|
|
$header_buttons
|
|
|
|
]);
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|