engelsystem/includes/view/Rooms_view.php

93 lines
2.5 KiB
PHP
Raw Normal View History

2014-12-22 17:55:20 +01:00
<?php
2017-12-25 23:12:52 +01:00
2020-09-06 23:50:36 +02:00
use Engelsystem\Models\Room;
use Engelsystem\ShiftCalendarRenderer;
2017-01-02 15:43:36 +01:00
use Engelsystem\ShiftsFilterRenderer;
2017-01-03 03:22:48 +01:00
/**
*
2020-09-06 23:50:36 +02:00
* @param Room $room
2017-12-25 23:12:52 +01:00
* @param ShiftsFilterRenderer $shiftsFilterRenderer
* @param ShiftCalendarRenderer $shiftCalendarRenderer
2017-01-03 03:22:48 +01:00
* @return string
*/
2020-09-06 23:50:36 +02:00
function Room_view(Room $room, ShiftsFilterRenderer $shiftsFilterRenderer, ShiftCalendarRenderer $shiftCalendarRenderer)
2017-01-02 03:57:23 +01:00
{
2018-10-31 12:48:22 +01:00
$user = auth()->user();
2017-12-25 23:12:52 +01:00
$assignNotice = '';
2018-10-08 21:15:56 +02:00
if (config('signup_requires_arrival') && !$user->state->arrived) {
$assignNotice = info(render_user_arrived_hint(), true);
}
2017-12-25 23:12:52 +01:00
$description = '';
2020-09-06 23:50:36 +02:00
if ($room->description) {
$description = '<h3>' . __('Description') . '</h3>';
$parsedown = new Parsedown();
$description .= $parsedown->parse($room->description);
}
2017-12-25 23:12:52 +01:00
2022-10-18 17:34:08 +02:00
$dect = '';
if (config('enable_dect') && $room->dect) {
$dect = heading(__('Contact'), 3)
. description([__('DECT') => sprintf('<a href="tel:%s">%1$s</a>', $room->dect)]);
}
$tabs = [];
2020-09-06 23:50:36 +02:00
if ($room->map_url) {
$tabs[__('Map')] = sprintf(
2017-12-25 23:12:52 +01:00
'<div class="map">'
2017-12-26 12:45:35 +01:00
. '<iframe style="width: 100%%; min-height: 400px; border: 0 none;" src="%s"></iframe>'
2017-12-25 23:12:52 +01:00
. '</div>',
2020-09-06 23:50:36 +02:00
$room->map_url
2017-12-25 23:12:52 +01:00
);
}
2017-12-25 23:12:52 +01:00
$tabs[__('Shifts')] = div('first', [
2017-11-24 12:01:19 +01:00
$shiftsFilterRenderer->render(page_link_to('rooms', [
2017-12-25 23:12:52 +01:00
'action' => 'view',
2020-09-06 23:50:36 +02:00
'room_id' => $room->id
2020-11-24 01:18:05 +01:00
]), ['rooms' => [$room->id]]),
2017-01-02 15:43:36 +01:00
$shiftCalendarRenderer->render()
]);
2017-12-25 23:12:52 +01:00
$selected_tab = 0;
$request = request();
if ($request->has('shifts_filter_day')) {
$selected_tab = count($tabs) - 1;
}
2017-12-25 23:12:52 +01:00
return page_with_title(icon('geo-alt') . $room->name, [
$assignNotice,
2020-09-12 23:14:38 +02:00
auth()->can('admin_rooms') ? buttons([
button(
page_link_to('admin_rooms', ['show' => 'edit', 'id' => $room->id]),
__('edit'),
'btn'
),
button(
page_link_to('admin_rooms', ['show' => 'delete', 'id' => $room->id]),
__('delete'),
'btn'
)
]) : '',
2022-10-18 17:34:08 +02:00
$dect,
2021-09-10 14:30:16 +02:00
$description,
2020-09-12 23:14:38 +02:00
tabs($tabs, $selected_tab),
2019-12-14 10:35:42 +01:00
], true);
}
2014-12-22 17:55:20 +01:00
2017-01-03 03:22:48 +01:00
/**
*
2020-09-06 23:50:36 +02:00
* @param Room $room
2017-01-03 03:22:48 +01:00
* @return string
*/
2020-09-06 23:50:36 +02:00
function Room_name_render(Room $room)
2017-01-02 03:57:23 +01:00
{
if (auth()->can('view_rooms')) {
return '<a href="' . room_link($room) . '">' . icon('geo-alt') . $room->name . '</a>';
2017-01-02 03:57:23 +01:00
}
2017-12-25 23:12:52 +01:00
return icon('geo-alt') . $room->name;
2014-12-22 17:55:20 +01:00
}