2014-12-22 17:55:20 +01:00
|
|
|
<?php
|
2017-12-25 23:12:52 +01:00
|
|
|
|
2016-10-05 22:28:39 +02:00
|
|
|
use Engelsystem\ShiftCalendarRenderer;
|
2017-01-02 15:43:36 +01:00
|
|
|
use Engelsystem\ShiftsFilterRenderer;
|
2016-10-05 18:56:50 +02:00
|
|
|
|
2017-01-03 03:22:48 +01:00
|
|
|
/**
|
2017-12-10 15:02:37 +01:00
|
|
|
*
|
2017-12-25 23:12:52 +01:00
|
|
|
* @param array $room
|
|
|
|
* @param ShiftsFilterRenderer $shiftsFilterRenderer
|
|
|
|
* @param ShiftCalendarRenderer $shiftCalendarRenderer
|
2017-01-03 03:22:48 +01:00
|
|
|
* @return string
|
|
|
|
*/
|
2017-01-02 03:57:23 +01:00
|
|
|
function Room_view($room, ShiftsFilterRenderer $shiftsFilterRenderer, ShiftCalendarRenderer $shiftCalendarRenderer)
|
|
|
|
{
|
2018-10-31 12:48:22 +01:00
|
|
|
$user = auth()->user();
|
2017-12-25 23:12:52 +01:00
|
|
|
|
2017-08-31 12:25:06 +02:00
|
|
|
$assignNotice = '';
|
2018-10-08 21:15:56 +02:00
|
|
|
if (config('signup_requires_arrival') && !$user->state->arrived) {
|
2017-08-31 12:25:06 +02:00
|
|
|
$assignNotice = info(render_user_arrived_hint(), true);
|
|
|
|
}
|
2017-12-25 23:12:52 +01:00
|
|
|
|
2017-12-10 15:02:37 +01:00
|
|
|
$description = '';
|
2017-12-25 23:12:52 +01:00
|
|
|
if (!empty($room['description'])) {
|
2018-08-29 21:55:32 +02:00
|
|
|
$description = '<h3>' . __('Description') . '</h3>';
|
2017-12-10 15:02:37 +01:00
|
|
|
$parsedown = new Parsedown();
|
|
|
|
$description .= '<div class="well">' . $parsedown->parse($room['description']) . '</div>';
|
|
|
|
}
|
2017-12-25 23:12:52 +01:00
|
|
|
|
2017-12-10 15:02:37 +01:00
|
|
|
$tabs = [];
|
2017-12-25 23:12:52 +01:00
|
|
|
if (!empty($room['map_url'])) {
|
2018-08-29 21:55:32 +02:00
|
|
|
$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>',
|
|
|
|
$room['map_url']
|
|
|
|
);
|
2017-12-10 15:02:37 +01:00
|
|
|
}
|
2017-12-25 23:12:52 +01:00
|
|
|
|
2018-08-29 21:55:32 +02: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',
|
2017-12-10 15:02:37 +01:00
|
|
|
'room_id' => $room['RID']
|
2017-11-24 12:01:19 +01:00
|
|
|
])),
|
2017-01-02 15:43:36 +01:00
|
|
|
$shiftCalendarRenderer->render()
|
|
|
|
]);
|
2017-12-25 23:12:52 +01:00
|
|
|
|
2017-12-10 15:02:37 +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
|
|
|
|
2017-12-10 15:02:37 +01:00
|
|
|
return page_with_title(glyph('map-marker') . $room['Name'], [
|
|
|
|
$assignNotice,
|
|
|
|
$description,
|
|
|
|
tabs($tabs, $selected_tab)
|
|
|
|
]);
|
2016-10-05 18:56:50 +02:00
|
|
|
}
|
2014-12-22 17:55:20 +01:00
|
|
|
|
2017-01-03 03:22:48 +01:00
|
|
|
/**
|
2017-12-10 15:02:37 +01:00
|
|
|
*
|
2017-12-25 23:12:52 +01:00
|
|
|
* @param array $room
|
2017-01-03 03:22:48 +01:00
|
|
|
* @return string
|
|
|
|
*/
|
2017-01-02 03:57:23 +01:00
|
|
|
function Room_name_render($room)
|
|
|
|
{
|
2018-11-12 14:41:23 +01:00
|
|
|
if (auth()->can('view_rooms')) {
|
2017-01-02 03:57:23 +01:00
|
|
|
return '<a href="' . room_link($room) . '">' . glyph('map-marker') . $room['Name'] . '</a>';
|
|
|
|
}
|
2017-12-25 23:12:52 +01:00
|
|
|
|
2017-01-02 03:57:23 +01:00
|
|
|
return glyph('map-marker') . $room['Name'];
|
2014-12-22 17:55:20 +01:00
|
|
|
}
|