2014-12-22 17:55:20 +01:00
|
|
|
<?php
|
2017-12-25 23:12:52 +01:00
|
|
|
|
2023-10-15 19:25:55 +02:00
|
|
|
use Engelsystem\Models\Location;
|
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
|
|
|
*
|
2023-10-15 19:25:55 +02:00
|
|
|
* @param Location $location
|
2017-12-25 23:12:52 +01:00
|
|
|
* @param ShiftsFilterRenderer $shiftsFilterRenderer
|
|
|
|
* @param ShiftCalendarRenderer $shiftCalendarRenderer
|
2017-01-03 03:22:48 +01:00
|
|
|
* @return string
|
|
|
|
*/
|
2023-10-15 19:25:55 +02:00
|
|
|
function location_view(Location $location, 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
|
|
|
|
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) {
|
2023-12-22 11:08:39 +01:00
|
|
|
$assignNotice = info(render_user_arrived_hint(), true);
|
2017-08-31 12:25:06 +02:00
|
|
|
}
|
2017-12-25 23:12:52 +01:00
|
|
|
|
2017-12-10 15:02:37 +01:00
|
|
|
$description = '';
|
2023-10-15 19:25:55 +02:00
|
|
|
if ($location->description) {
|
2023-10-02 16:15:25 +02:00
|
|
|
$description = '<h3>' . __('general.description') . '</h3>';
|
2017-12-10 15:02:37 +01:00
|
|
|
$parsedown = new Parsedown();
|
2023-12-06 19:03:12 +01:00
|
|
|
$description .= $parsedown->parse(htmlspecialchars($location->description));
|
2017-12-10 15:02:37 +01:00
|
|
|
}
|
2017-12-25 23:12:52 +01:00
|
|
|
|
2023-12-29 13:40:01 +01:00
|
|
|
$neededAngelTypes = '';
|
2023-12-29 15:21:38 +01:00
|
|
|
if (auth()->can('admin_shifts') && $location->neededAngelTypes->isNotEmpty()) {
|
2023-12-29 13:40:01 +01:00
|
|
|
$neededAngelTypes .= '<h3>' . __('location.required_angels') . '</h3><ul>';
|
|
|
|
foreach ($location->neededAngelTypes as $neededAngelType) {
|
|
|
|
if ($neededAngelType->count) {
|
|
|
|
$neededAngelTypes .= '<li><a href="'
|
|
|
|
. url('angeltypes', ['action' => 'view', 'angeltype_id' => $neededAngelType->angelType->id])
|
|
|
|
. '">' . $neededAngelType->angelType->name
|
|
|
|
. '</a>: '
|
|
|
|
. $neededAngelType->count
|
|
|
|
. '</li>';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$neededAngelTypes .= '</ul>';
|
|
|
|
}
|
|
|
|
|
2022-10-18 17:34:08 +02:00
|
|
|
$dect = '';
|
2023-10-15 19:25:55 +02:00
|
|
|
if (config('enable_dect') && $location->dect) {
|
2022-10-18 17:34:08 +02:00
|
|
|
$dect = heading(__('Contact'), 3)
|
2023-12-06 19:03:12 +01:00
|
|
|
. description([__('general.dect') => sprintf(
|
|
|
|
'<a href="tel:%s">%1$s</a>',
|
|
|
|
htmlspecialchars($location->dect)
|
|
|
|
)]);
|
2022-10-18 17:34:08 +02:00
|
|
|
}
|
|
|
|
|
2017-12-10 15:02:37 +01:00
|
|
|
$tabs = [];
|
2023-10-15 19:25:55 +02:00
|
|
|
if ($location->map_url) {
|
|
|
|
$tabs[__('location.map_url')] = 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>',
|
2023-12-06 19:03:12 +01:00
|
|
|
htmlspecialchars($location->map_url)
|
2017-12-25 23:12:52 +01:00
|
|
|
);
|
2017-12-10 15:02:37 +01:00
|
|
|
}
|
2017-12-25 23:12:52 +01:00
|
|
|
|
2024-03-24 15:05:24 +01:00
|
|
|
$tabs[__('general.shifts')] = div('first', [
|
2023-11-13 16:56:52 +01:00
|
|
|
$shiftsFilterRenderer->render(url('/locations', [
|
2017-12-25 23:12:52 +01:00
|
|
|
'action' => 'view',
|
2023-10-15 19:25:55 +02:00
|
|
|
'location_id' => $location->id,
|
|
|
|
]), ['locations' => [$location->id]]),
|
2023-02-05 18:03:00 +01:00
|
|
|
$shiftCalendarRenderer->render(),
|
2017-01-02 15:43:36 +01:00
|
|
|
]);
|
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
|
|
|
|
2023-12-21 13:08:29 +01:00
|
|
|
$link = button(url('/admin/locations'), icon('chevron-left'), 'btn-sm', '', __('general.back'));
|
2023-11-03 15:02:54 +01:00
|
|
|
return page_with_title(
|
2023-10-15 19:25:55 +02:00
|
|
|
(auth()->can('admin_locations') ? $link . ' ' : '') .
|
2023-12-06 19:03:12 +01:00
|
|
|
icon('pin-map-fill') . htmlspecialchars($location->name),
|
2023-11-03 15:02:54 +01:00
|
|
|
[
|
2017-12-10 15:02:37 +01:00
|
|
|
$assignNotice,
|
2023-10-15 19:25:55 +02:00
|
|
|
auth()->can('admin_locations') ? buttons([
|
2020-09-12 23:14:38 +02:00
|
|
|
button(
|
2023-11-13 16:56:52 +01:00
|
|
|
url('/admin/locations/edit/' . $location->id),
|
2023-12-21 13:08:29 +01:00
|
|
|
icon('pencil'),
|
|
|
|
'',
|
|
|
|
'',
|
|
|
|
__('form.edit')
|
2020-09-12 23:14:38 +02:00
|
|
|
),
|
|
|
|
]) : '',
|
2022-10-18 17:34:08 +02:00
|
|
|
$dect,
|
2021-09-10 14:30:16 +02:00
|
|
|
$description,
|
2023-12-29 13:40:01 +01:00
|
|
|
$neededAngelTypes,
|
2020-09-12 23:14:38 +02:00
|
|
|
tabs($tabs, $selected_tab),
|
2023-11-03 15:02:54 +01:00
|
|
|
],
|
|
|
|
true
|
|
|
|
);
|
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
|
|
|
*
|
2023-10-15 19:25:55 +02:00
|
|
|
* @param Location $location
|
2017-01-03 03:22:48 +01:00
|
|
|
* @return string
|
|
|
|
*/
|
2023-10-15 19:25:55 +02:00
|
|
|
function location_name_render(Location $location)
|
2017-01-02 03:57:23 +01:00
|
|
|
{
|
2023-10-15 19:25:55 +02:00
|
|
|
if (auth()->can('view_locations')) {
|
2023-12-06 19:03:12 +01:00
|
|
|
return '<a href="' . location_link($location) . '">'
|
|
|
|
. icon('pin-map-fill') . htmlspecialchars($location->name)
|
|
|
|
. '</a>';
|
2017-01-02 03:57:23 +01:00
|
|
|
}
|
2017-12-25 23:12:52 +01:00
|
|
|
|
2023-12-06 19:03:12 +01:00
|
|
|
return icon('pin-map-fill') . htmlspecialchars($location->name);
|
2014-12-22 17:55:20 +01:00
|
|
|
}
|