diff --git a/config/routes.php b/config/routes.php
index f0200db4..6c44bb1a 100644
--- a/config/routes.php
+++ b/config/routes.php
@@ -163,14 +163,14 @@ $route->addGroup(
}
);
- // Rooms
+ // Locations
$route->addGroup(
- '/rooms',
+ '/locations',
function (RouteCollector $route): void {
- $route->get('', 'Admin\\RoomsController@index');
- $route->post('', 'Admin\\RoomsController@delete');
- $route->get('/edit[/{room_id:\d+}]', 'Admin\\RoomsController@edit');
- $route->post('/edit[/{room_id:\d+}]', 'Admin\\RoomsController@save');
+ $route->get('', 'Admin\\LocationsController@index');
+ $route->post('', 'Admin\\LocationsController@delete');
+ $route->get('/edit[/{location_id:\d+}]', 'Admin\\LocationsController@edit');
+ $route->post('/edit[/{location_id:\d+}]', 'Admin\\LocationsController@save');
}
);
diff --git a/db/factories/RoomFactory.php b/db/factories/LocationFactory.php
similarity index 76%
rename from db/factories/RoomFactory.php
rename to db/factories/LocationFactory.php
index 0a06959b..775fda96 100644
--- a/db/factories/RoomFactory.php
+++ b/db/factories/LocationFactory.php
@@ -4,13 +4,13 @@ declare(strict_types=1);
namespace Database\Factories\Engelsystem\Models;
-use Engelsystem\Models\Room;
+use Engelsystem\Models\Location;
use Illuminate\Database\Eloquent\Factories\Factory;
-class RoomFactory extends Factory
+class LocationFactory extends Factory
{
/** @var string */
- protected $model = Room::class; // phpcs:ignore
+ protected $model = Location::class; // phpcs:ignore
public function definition(): array
{
diff --git a/db/factories/Shifts/NeededAngelTypeFactory.php b/db/factories/Shifts/NeededAngelTypeFactory.php
index ee07e534..0b4ab3bc 100644
--- a/db/factories/Shifts/NeededAngelTypeFactory.php
+++ b/db/factories/Shifts/NeededAngelTypeFactory.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
namespace Database\Factories\Engelsystem\Models\Shifts;
use Engelsystem\Models\AngelType;
-use Engelsystem\Models\Room;
+use Engelsystem\Models\Location;
use Engelsystem\Models\Shifts\NeededAngelType;
use Engelsystem\Models\Shifts\Shift;
use Illuminate\Database\Eloquent\Factories\Factory;
@@ -17,11 +17,11 @@ class NeededAngelTypeFactory extends Factory
public function definition(): array
{
- $forRoom = $this->faker->boolean();
+ $forLocation = $this->faker->boolean();
return [
- 'room_id' => $forRoom ? Room::factory() : null,
- 'shift_id' => $forRoom ? null : Shift::factory(),
+ 'location_id' => $forLocation ? Location::factory() : null,
+ 'shift_id' => $forLocation ? null : Shift::factory(),
'angel_type_id' => AngelType::factory(),
'count' => $this->faker->numberBetween(1, 5),
];
diff --git a/db/factories/Shifts/ShiftFactory.php b/db/factories/Shifts/ShiftFactory.php
index 6bf2f796..8364ce73 100644
--- a/db/factories/Shifts/ShiftFactory.php
+++ b/db/factories/Shifts/ShiftFactory.php
@@ -4,7 +4,7 @@ declare(strict_types=1);
namespace Database\Factories\Engelsystem\Models\Shifts;
-use Engelsystem\Models\Room;
+use Engelsystem\Models\Location;
use Engelsystem\Models\Shifts\Shift;
use Engelsystem\Models\Shifts\ShiftType;
use Engelsystem\Models\User\User;
@@ -25,7 +25,7 @@ class ShiftFactory extends Factory
'start' => $start,
'end' => $this->faker->dateTimeInInterval($start, '+3 hours'),
'shift_type_id' => ShiftType::factory(),
- 'room_id' => Room::factory(),
+ 'location_id' => Location::factory(),
'transaction_id' => $this->faker->optional()->uuid(),
'created_by' => User::factory(),
'updated_by' => $this->faker->optional(.3)->boolean() ? User::factory() : null,
diff --git a/db/migrations/2023_10_13_000000_rename_rooms_to_locations.php b/db/migrations/2023_10_13_000000_rename_rooms_to_locations.php
new file mode 100644
index 00000000..f71a10d1
--- /dev/null
+++ b/db/migrations/2023_10_13_000000_rename_rooms_to_locations.php
@@ -0,0 +1,69 @@
+schema->rename('rooms', 'locations');
+
+ $this->schema->table('shifts', function (Blueprint $table): void {
+ $table->renameColumn('room_id', 'location_id');
+ });
+
+ $this->schema->table('needed_angel_types', function (Blueprint $table): void {
+ $table->renameColumn('room_id', 'location_id');
+ });
+
+ $db = $this->schema->getConnection();
+ $db->table('privileges')->where('name', 'admin_rooms')->update([
+ 'name' => 'admin_locations',
+ 'description' => 'Manage locations',
+ ]);
+ $db->table('privileges')->where('name', 'view_rooms')->update([
+ 'name' => 'view_locations',
+ 'description' => 'User can view locations',
+ ]);
+ $db->table('privileges')->where('name', 'schedule.import')->update([
+ 'description' => 'Import locations and shifts from schedule.xml',
+ ]);
+ }
+
+ /**
+ * Reverse the migration
+ */
+ public function down(): void
+ {
+ $this->schema->rename('locations', 'rooms');
+
+ $this->schema->table('shifts', function (Blueprint $table): void {
+ $table->renameColumn('location_id', 'room_id');
+ });
+
+ $this->schema->table('needed_angel_types', function (Blueprint $table): void {
+ $table->renameColumn('location_id', 'room_id');
+ });
+
+ $db = $this->schema->getConnection();
+ $db->table('privileges')->where('name', 'admin_locations')->update([
+ 'name' => 'admin_rooms',
+ 'description' => 'Räume administrieren',
+ ]);
+ $db->table('privileges')->where('name', 'view_locations')->update([
+ 'name' => 'view_rooms',
+ 'description' => 'User can view rooms',
+ ]);
+ $db->table('privileges')->where('name', 'schedule.import')->update([
+ 'description' => 'Import rooms and shifts from schedule.xml',
+ ]);
+ }
+}
diff --git a/includes/controller/angeltypes_controller.php b/includes/controller/angeltypes_controller.php
index 2d9e2813..f239649e 100644
--- a/includes/controller/angeltypes_controller.php
+++ b/includes/controller/angeltypes_controller.php
@@ -2,7 +2,7 @@
use Engelsystem\Helpers\Carbon;
use Engelsystem\Models\AngelType;
-use Engelsystem\Models\Room;
+use Engelsystem\Models\Location;
use Engelsystem\Models\UserAngelType;
use Engelsystem\ShiftsFilter;
use Engelsystem\ShiftsFilterRenderer;
@@ -243,13 +243,13 @@ function angeltype_controller_shiftsFilterDays(AngelType $angeltype)
function angeltype_controller_shiftsFilter(AngelType $angeltype, $days)
{
$request = request();
- $roomIds = Room::query()
+ $locationIds = Location::query()
->select('id')
->pluck('id')
->toArray();
$shiftsFilter = new ShiftsFilter(
auth()->can('user_shifts_admin'),
- $roomIds,
+ $locationIds,
[$angeltype->id]
);
$selected_day = date('Y-m-d');
diff --git a/includes/controller/rooms_controller.php b/includes/controller/locations_controller.php
similarity index 58%
rename from includes/controller/rooms_controller.php
rename to includes/controller/locations_controller.php
index 2136565a..9dff1cf4 100644
--- a/includes/controller/rooms_controller.php
+++ b/includes/controller/locations_controller.php
@@ -1,29 +1,29 @@
can('view_rooms')) {
+ if (!auth()->can('view_locations')) {
throw_redirect(page_link_to());
}
$request = request();
- $room = load_room();
+ $location = load_location();
- $all_shifts = $room->shifts->sortBy('start');
+ $all_shifts = $location->shifts->sortBy('start');
$days = [];
foreach ($all_shifts as $shift) {
$day = $shift->start->format('Y-m-d');
@@ -34,7 +34,7 @@ function room_controller(): array
$shiftsFilter = new ShiftsFilter(
true,
- [$room->id],
+ [$location->id],
AngelType::query()->get('id')->pluck('id')->toArray()
);
$selected_day = date('Y-m-d');
@@ -53,17 +53,17 @@ function room_controller(): array
$shiftCalendarRenderer = shiftCalendarRendererByShiftFilter($shiftsFilter);
return [
- $room->name,
- Room_view($room, $shiftsFilterRenderer, $shiftCalendarRenderer),
+ $location->name,
+ location_view($location, $shiftsFilterRenderer, $shiftCalendarRenderer),
];
}
/**
- * Dispatch different room actions.
+ * Dispatch different location actions.
*
* @return array
*/
-function rooms_controller(): array
+function locations_controller(): array
{
$request = request();
$action = $request->input('action');
@@ -72,36 +72,36 @@ function rooms_controller(): array
}
return match ($action) {
- 'view' => room_controller(),
- 'list' => throw_redirect(page_link_to('admin/rooms')),
- default => throw_redirect(page_link_to('admin/rooms')),
+ 'view' => location_controller(),
+ 'list' => throw_redirect(page_link_to('admin/locations')),
+ default => throw_redirect(page_link_to('admin/locations')),
};
}
/**
- * @param Room $room
+ * @param Location $location
* @return string
*/
-function room_link(Room $room)
+function location_link(Location $location)
{
- return page_link_to('rooms', ['action' => 'view', 'room_id' => $room->id]);
+ return page_link_to('locations', ['action' => 'view', 'location_id' => $location->id]);
}
/**
- * Loads room by request param room_id
+ * Loads location by request param location_id
*
- * @return Room
+ * @return Location
*/
-function load_room()
+function load_location()
{
- if (!test_request_int('room_id')) {
+ if (!test_request_int('location_id')) {
throw_redirect(page_link_to());
}
- $room = Room::find(request()->input('room_id'));
- if (!$room) {
+ $location = Location::find(request()->input('location_id'));
+ if (!$location) {
throw_redirect(page_link_to());
}
- return $room;
+ return $location;
}
diff --git a/includes/controller/public_dashboard_controller.php b/includes/controller/public_dashboard_controller.php
index 59ddc2b9..04fefbb6 100644
--- a/includes/controller/public_dashboard_controller.php
+++ b/includes/controller/public_dashboard_controller.php
@@ -1,8 +1,8 @@
get('filtered')) {
- $requestRooms = check_request_int_array('rooms');
+ $requestLocations = check_request_int_array('locations');
$requestAngelTypes = check_request_int_array('types');
- if (!$requestRooms && !$requestAngelTypes) {
+ if (!$requestLocations && !$requestAngelTypes) {
$sessionFilter = collect(session()->get('shifts-filter', []));
- $requestRooms = $sessionFilter->get('rooms', []);
+ $requestLocations = $sessionFilter->get('locations', []);
$requestAngelTypes = $sessionFilter->get('types', []);
}
$angelTypes = collect(unrestricted_angeltypes());
- $rooms = $requestRooms ?: Room::orderBy('name')->get()->pluck('id')->toArray();
+ $locations = $requestLocations ?: Location::orderBy('name')->get()->pluck('id')->toArray();
$angelTypes = $requestAngelTypes ?: $angelTypes->pluck('id')->toArray();
$filterValues = [
'userShiftsAdmin' => false,
'filled' => [],
- 'rooms' => $rooms,
+ 'locations' => $locations,
'types' => $angelTypes,
'startTime' => null,
'endTime' => null,
@@ -87,7 +87,7 @@ function public_dashboard_controller_free_shift(Shift $shift, ShiftsFilter $filt
'duration' => round(($shift->end->timestamp - $shift->start->timestamp) / 3600),
'shifttype_name' => $shift->shiftType->name,
'title' => $shift->title,
- 'room_name' => $shift->room->name,
+ 'location_name' => $shift->location->name,
'needed_angels' => public_dashboard_needed_angels($shift->neededAngels, $filter),
];
diff --git a/includes/controller/shift_entries_controller.php b/includes/controller/shift_entries_controller.php
index ccb0515c..2fd08d68 100644
--- a/includes/controller/shift_entries_controller.php
+++ b/includes/controller/shift_entries_controller.php
@@ -120,10 +120,10 @@ function shift_entry_create_controller_admin(Shift $shift, ?AngelType $angeltype
}
$angeltypes_select = $angeltypes->pluck('name', 'id')->toArray();
- $room = $shift->room;
+ $location = $shift->location;
return [
ShiftEntry_create_title(),
- ShiftEntry_create_view_admin($shift, $room, $angeltype, $angeltypes_select, $signup_user, $users_select),
+ ShiftEntry_create_view_admin($shift, $location, $angeltype, $angeltypes_select, $signup_user, $users_select),
];
}
@@ -167,10 +167,10 @@ function shift_entry_create_controller_supporter(Shift $shift, AngelType $angelt
$users_select[$u->id] = $u->displayName;
}
- $room = $shift->room;
+ $location = $shift->location;
return [
ShiftEntry_create_title(),
- ShiftEntry_create_view_supporter($shift, $room, $angeltype, $signup_user, $users_select),
+ ShiftEntry_create_view_supporter($shift, $location, $angeltype, $signup_user, $users_select),
];
}
@@ -250,10 +250,10 @@ function shift_entry_create_controller_user(Shift $shift, AngelType $angeltype):
throw_redirect(shift_link($shift));
}
- $room = $shift->room;
+ $location = $shift->location;
return [
ShiftEntry_create_title(),
- ShiftEntry_create_view_user($shift, $room, $angeltype, $comment),
+ ShiftEntry_create_view_user($shift, $location, $angeltype, $comment),
];
}
diff --git a/includes/controller/shifts_controller.php b/includes/controller/shifts_controller.php
index 14eba99a..f6ce2ad4 100644
--- a/includes/controller/shifts_controller.php
+++ b/includes/controller/shifts_controller.php
@@ -1,8 +1,8 @@
get() as $room) {
- $rooms[$room->id] = $room->name;
+ $locations = [];
+ foreach (Location::orderBy('name')->get() as $location) {
+ $locations[$location->id] = $location->name;
}
$angeltypes = AngelType::all()->pluck('name', 'id')->toArray();
$shifttypes = ShiftType::all()->pluck('name', 'id')->toArray();
@@ -84,7 +84,7 @@ function shift_edit_controller()
$shifttype_id = $shift->shift_type_id;
$title = $shift->title;
$description = $shift->description;
- $rid = $shift->room_id;
+ $rid = $shift->location_id;
$start = $shift->start;
$end = $shift->end;
@@ -97,7 +97,7 @@ function shift_edit_controller()
if (
$request->has('rid')
&& preg_match('/^\d+$/', $request->input('rid'))
- && isset($rooms[$request->input('rid')])
+ && isset($locations[$request->input('rid')])
) {
$rid = $request->input('rid');
} else {
@@ -154,7 +154,7 @@ function shift_edit_controller()
$shift->shift_type_id = $shifttype_id;
$shift->title = $title;
$shift->description = $description;
- $shift->room_id = $rid;
+ $shift->location_id = $rid;
$shift->start = $start;
$shift->end = $end;
$shift->updatedBy()->associate(auth()->user());
@@ -210,7 +210,7 @@ function shift_edit_controller()
form([
form_select('shifttype_id', __('Shifttype'), $shifttypes, $shifttype_id),
form_text('title', __('title.title'), $title),
- form_select('rid', __('Location:'), $rooms, $rid),
+ form_select('rid', __('Location:'), $locations, $rid),
form_text('start', __('Start:'), $start->format('Y-m-d H:i')),
form_text('end', __('End:'), $end->format('Y-m-d H:i')),
form_textarea('description', __('Additional description'), $description),
@@ -255,7 +255,7 @@ function shift_delete_controller()
'name' => $shift->shiftType->name,
'title' => $shift->title,
'type' => $entry->angelType->name,
- 'room' => $shift->room,
+ 'location' => $shift->location,
'freeloaded' => $entry->freeloaded,
]);
}
@@ -312,7 +312,7 @@ function shift_controller()
}
$shifttype = $shift->shiftType;
- $room = $shift->room;
+ $location = $shift->location;
/** @var AngelType[] $angeltypes */
$angeltypes = AngelType::all();
$user_shifts = Shifts_by_user($user->id);
@@ -344,7 +344,7 @@ function shift_controller()
return [
$shift->shiftType->name,
- Shift_view($shift, $shifttype, $room, $angeltypes, $shift_signup_state),
+ Shift_view($shift, $shifttype, $location, $angeltypes, $shift_signup_state),
];
}
diff --git a/includes/helper/shift_helper.php b/includes/helper/shift_helper.php
index 0452079e..153c628d 100644
--- a/includes/helper/shift_helper.php
+++ b/includes/helper/shift_helper.php
@@ -5,7 +5,7 @@ namespace Engelsystem\Events\Listener;
use Carbon\Carbon;
use Engelsystem\Helpers\Shifts;
use Engelsystem\Mail\EngelsystemMailer;
-use Engelsystem\Models\Room;
+use Engelsystem\Models\Location;
use Engelsystem\Models\User\User;
use Engelsystem\Models\Worklog;
use Psr\Log\LoggerInterface;
@@ -25,7 +25,7 @@ class Shift
string $name,
string $title,
string $type,
- Room $room,
+ Location $location,
bool $freeloaded
): void {
if ($freeloaded || $start > Carbon::now()) {
@@ -44,7 +44,7 @@ class Shift
$name,
$title,
$type,
- $room->name,
+ $location->name,
$start->format(__('Y-m-d H:i')),
$end->format(__('Y-m-d H:i'))
);
@@ -63,7 +63,7 @@ class Shift
string $name,
string $title,
string $type,
- Room $room,
+ Location $location,
bool $freeloaded
): void {
if (!$user->settings->email_shiftinfo) {
@@ -79,7 +79,7 @@ class Shift
'title' => $title,
'start' => $start,
'end' => $end,
- 'room' => $room,
+ 'location' => $location,
'freeloaded' => $freeloaded,
'username' => $user->displayName,
]
diff --git a/includes/includes.php b/includes/includes.php
index 41f76c8a..877bcb4b 100644
--- a/includes/includes.php
+++ b/includes/includes.php
@@ -24,7 +24,7 @@ $includeFiles = [
__DIR__ . '/../includes/view/AngelTypes_view.php',
__DIR__ . '/../includes/view/EventConfig_view.php',
__DIR__ . '/../includes/view/PublicDashboard_view.php',
- __DIR__ . '/../includes/view/Rooms_view.php',
+ __DIR__ . '/../includes/view/Locations_view.php',
__DIR__ . '/../includes/view/ShiftCalendarLane.php',
__DIR__ . '/../includes/view/ShiftCalendarRenderer.php',
__DIR__ . '/../includes/view/ShiftCalendarShiftRenderer.php',
@@ -40,7 +40,7 @@ $includeFiles = [
__DIR__ . '/../includes/controller/angeltypes_controller.php',
__DIR__ . '/../includes/controller/event_config_controller.php',
__DIR__ . '/../includes/controller/public_dashboard_controller.php',
- __DIR__ . '/../includes/controller/rooms_controller.php',
+ __DIR__ . '/../includes/controller/locations_controller.php',
__DIR__ . '/../includes/controller/shift_entries_controller.php',
__DIR__ . '/../includes/controller/shifts_controller.php',
__DIR__ . '/../includes/controller/shifttypes_controller.php',
diff --git a/includes/mailer/shifts_mailer.php b/includes/mailer/shifts_mailer.php
index ce037e54..56e02090 100644
--- a/includes/mailer/shifts_mailer.php
+++ b/includes/mailer/shifts_mailer.php
@@ -11,8 +11,8 @@ function mail_shift_change(Shift $old_shift, Shift $new_shift)
$shiftEntries = $old_shift->shiftEntries()
->with(['user', 'user.settings'])
->get();
- $old_room = $old_shift->room;
- $new_room = $new_shift->room;
+ $old_location = $old_shift->location;
+ $new_location = $new_shift->location;
$noticeable_changes = false;
@@ -51,8 +51,8 @@ function mail_shift_change(Shift $old_shift, Shift $new_shift)
$noticeable_changes = true;
}
- if ($old_shift->room_id != $new_shift->room_id) {
- $message .= sprintf(__('* Shift Location changed from %s to %s'), $old_room->name, $new_room->name) . "\n";
+ if ($old_shift->location_id != $new_shift->location_id) {
+ $message .= sprintf(__('* Shift Location changed from %s to %s'), $old_location->name, $new_location->name) . "\n";
$noticeable_changes = true;
}
@@ -67,7 +67,7 @@ function mail_shift_change(Shift $old_shift, Shift $new_shift)
$message .= $new_shift->shiftType->name . "\n";
$message .= $new_shift->title . "\n";
$message .= $new_shift->start->format(__('Y-m-d H:i')) . ' - ' . $new_shift->end->format(__('H:i')) . "\n";
- $message .= $new_room->name . "\n\n";
+ $message .= $new_location->name . "\n\n";
$message .= url('/shifts', ['action' => 'view', 'shift_id' => $new_shift->id]) . "\n";
foreach ($shiftEntries as $shiftEntry) {
@@ -89,13 +89,11 @@ function mail_shift_assign(User $user, Shift $shift)
return;
}
- $room = $shift->room;
-
$message = __('You have been assigned to a Shift:') . "\n";
$message .= $shift->shiftType->name . "\n";
$message .= $shift->title . "\n";
$message .= $shift->start->format(__('Y-m-d H:i')) . ' - ' . $shift->end->format(__('H:i')) . "\n";
- $message .= $room->name . "\n\n";
+ $message .= $shift->location->name . "\n\n";
$message .= url('/shifts', ['action' => 'view', 'shift_id' => $shift->id]) . "\n";
engelsystem_email_to_user($user, __('Assigned to Shift'), $message, true);
@@ -107,13 +105,11 @@ function mail_shift_removed(User $user, Shift $shift)
return;
}
- $room = $shift->room;
-
$message = __('You have been removed from a Shift:') . "\n";
$message .= $shift->shiftType->name . "\n";
$message .= $shift->title . "\n";
$message .= $shift->start->format(__('Y-m-d H:i')) . ' - ' . $shift->end->format(__('H:i')) . "\n";
- $message .= $room->name . "\n";
+ $message .= $shift->location->name . "\n";
engelsystem_email_to_user($user, __('Removed from Shift'), $message, true);
}
diff --git a/includes/model/NeededAngelTypes_model.php b/includes/model/NeededAngelTypes_model.php
index fb051df2..3ef2d06b 100644
--- a/includes/model/NeededAngelTypes_model.php
+++ b/includes/model/NeededAngelTypes_model.php
@@ -23,19 +23,19 @@ function NeededAngelTypes_by_shift($shiftId)
FROM `needed_angel_types`
JOIN `angel_types` ON `angel_types`.`id` = `needed_angel_types`.`angel_type_id`
WHERE `shift_id` = ?
- ORDER BY `room_id` DESC',
+ ORDER BY `location_id` DESC',
[$shiftId]
);
- // Use settings from room
+ // Use settings from location
if (count($needed_angeltypes_source) == 0) {
$needed_angeltypes_source = Db::select('
SELECT `needed_angel_types`.*, `angel_types`.`name`, `angel_types`.`restricted`
FROM `needed_angel_types`
JOIN `angel_types` ON `angel_types`.`id` = `needed_angel_types`.`angel_type_id`
- JOIN `shifts` ON `shifts`.`room_id` = `needed_angel_types`.`room_id`
+ JOIN `shifts` ON `shifts`.`location_id` = `needed_angel_types`.`location_id`
WHERE `shifts`.`id` = ?
- ORDER BY `room_id` DESC
+ ORDER BY `location_id` DESC
', [$shiftId]);
}
diff --git a/includes/model/ShiftEntry_model.php b/includes/model/ShiftEntry_model.php
index 21ec0921..3f8dd3b5 100644
--- a/includes/model/ShiftEntry_model.php
+++ b/includes/model/ShiftEntry_model.php
@@ -15,7 +15,7 @@ function ShiftEntry_onCreate(ShiftEntry $shiftEntry): void
'User ' . User_Nick_render($shiftEntry->user, true)
. ' signed up for shift ' . $shiftEntry->shift->title
. ' (' . $shift->shiftType->name . ')'
- . ' at ' . $shift->room->name
+ . ' at ' . $shift->location->name
. ' from ' . $shift->start->format('Y-m-d H:i')
. ' to ' . $shift->end->format('Y-m-d H:i')
. ' as ' . $shiftEntry->angelType->name
@@ -33,14 +33,14 @@ function ShiftEntry_onDelete(ShiftEntry $shiftEntry)
$signout_user = $shiftEntry->user;
$shift = Shift($shiftEntry->shift);
$shifttype = $shift->shiftType;
- $room = $shift->room;
+ $location = $shift->location;
$angeltype = $shiftEntry->angelType;
engelsystem_log(
'Shift signout: ' . User_Nick_render($signout_user, true)
. ' from shift ' . $shift->title
. ' (' . $shifttype->name . ')'
- . ' at ' . $room->name
+ . ' at ' . $location->name
. ' from ' . $shift->start->format('Y-m-d H:i')
. ' to ' . $shift->end->format('Y-m-d H:i')
. ' as ' . $angeltype->name
diff --git a/includes/model/ShiftsFilter.php b/includes/model/ShiftsFilter.php
index bb75ed7e..4d31a22f 100644
--- a/includes/model/ShiftsFilter.php
+++ b/includes/model/ShiftsFilter.php
@@ -44,10 +44,10 @@ class ShiftsFilter
* ShiftsFilter constructor.
*
* @param bool $user_shifts_admin
- * @param int[] $rooms
+ * @param int[] $locations
* @param int[] $angelTypes
*/
- public function __construct($user_shifts_admin = false, private $rooms = [], $angelTypes = [])
+ public function __construct($user_shifts_admin = false, private $locations = [], $angelTypes = [])
{
$this->types = $angelTypes;
@@ -68,7 +68,7 @@ class ShiftsFilter
return [
'userShiftsAdmin' => $this->userShiftsAdmin,
'filled' => $this->filled,
- 'rooms' => $this->rooms,
+ 'locations' => $this->locations,
'types' => $this->types,
'startTime' => $this->startTime,
'endTime' => $this->endTime,
@@ -80,12 +80,12 @@ class ShiftsFilter
*/
public function sessionImport($data)
{
- $this->userShiftsAdmin = $data['userShiftsAdmin'];
- $this->filled = $data['filled'];
- $this->rooms = $data['rooms'];
- $this->types = $data['types'];
- $this->startTime = $data['startTime'];
- $this->endTime = $data['endTime'];
+ $this->userShiftsAdmin = $data['userShiftsAdmin'] ?? false;
+ $this->filled = $data['filled'] ?? [];
+ $this->locations = $data['locations'] ?? [];
+ $this->types = $data['types'] ?? [];
+ $this->startTime = $data['startTime'] ?? null;
+ $this->endTime = $data['endTime'] ?? null;
}
/**
@@ -163,20 +163,20 @@ class ShiftsFilter
/**
* @return int[]
*/
- public function getRooms()
+ public function getLocations()
{
- if (count($this->rooms) == 0) {
+ if (count($this->locations) == 0) {
return [0];
}
- return $this->rooms;
+ return $this->locations;
}
/**
- * @param int[] $rooms
+ * @param int[] $locations
*/
- public function setRooms($rooms)
+ public function setLocations($locations)
{
- $this->rooms = $rooms;
+ $this->locations = $locations;
}
/**
diff --git a/includes/model/Shifts_model.php b/includes/model/Shifts_model.php
index a2ec4451..09a1add1 100644
--- a/includes/model/Shifts_model.php
+++ b/includes/model/Shifts_model.php
@@ -29,7 +29,7 @@ function Shifts_by_angeltype(AngelType $angeltype)
UNION
SELECT DISTINCT `shifts`.* FROM `shifts`
- JOIN `needed_angel_types` ON `needed_angel_types`.`room_id` = `shifts`.`room_id`
+ JOIN `needed_angel_types` ON `needed_angel_types`.`location_id` = `shifts`.`location_id`
LEFT JOIN schedule_shift AS s on shifts.id = s.shift_id
WHERE `needed_angel_types`.`angel_type_id` = ?
AND NOT s.shift_id IS NULL
@@ -60,7 +60,7 @@ function Shifts_free($start, $end, ShiftsFilter $filter = null)
AND (SELECT SUM(`count`) FROM `needed_angel_types` WHERE `needed_angel_types`.`shift_id`=`shifts`.`id`' . ($filter ? ' AND needed_angel_types.angel_type_id IN (' . implode(',', $filter->getTypes()) . ')' : '') . ')
> (SELECT COUNT(*) FROM `shift_entries` WHERE `shift_entries`.`shift_id`=`shifts`.`id` AND shift_entries.`freeloaded`=0' . ($filter ? ' AND shift_entries.angel_type_id IN (' . implode(',', $filter->getTypes()) . ')' : '') . ')
AND s.shift_id IS NULL
- ' . ($filter ? 'AND shifts.room_id IN (' . implode(',', $filter->getRooms()) . ')' : '') . '
+ ' . ($filter ? 'AND shifts.location_id IN (' . implode(',', $filter->getLocations()) . ')' : '') . '
UNION
@@ -68,10 +68,10 @@ function Shifts_free($start, $end, ShiftsFilter $filter = null)
FROM `shifts`
LEFT JOIN schedule_shift AS s on shifts.id = s.shift_id
WHERE (`end` > ? AND `start` < ?)
- AND (SELECT SUM(`count`) FROM `needed_angel_types` WHERE `needed_angel_types`.`room_id`=`shifts`.`room_id`' . ($filter ? ' AND needed_angel_types.angel_type_id IN (' . implode(',', $filter->getTypes()) . ')' : '') . ')
+ AND (SELECT SUM(`count`) FROM `needed_angel_types` WHERE `needed_angel_types`.`location_id`=`shifts`.`location_id`' . ($filter ? ' AND needed_angel_types.angel_type_id IN (' . implode(',', $filter->getTypes()) . ')' : '') . ')
> (SELECT COUNT(*) FROM `shift_entries` WHERE `shift_entries`.`shift_id`=`shifts`.`id` AND `freeloaded`=0' . ($filter ? ' AND shift_entries.angel_type_id IN (' . implode(',', $filter->getTypes()) . ')' : '') . ')
AND NOT s.shift_id IS NULL
- ' . ($filter ? 'AND shifts.room_id IN (' . implode(',', $filter->getRooms()) . ')' : '') . '
+ ' . ($filter ? 'AND shifts.location_id IN (' . implode(',', $filter->getLocations()) . ')' : '') . '
) AS `tmp`
ORDER BY `tmp`.`start`
', [
@@ -97,32 +97,32 @@ function Shifts_by_ShiftsFilter(ShiftsFilter $shiftsFilter)
{
$sql = '
SELECT * FROM (
- SELECT DISTINCT `shifts`.*, `shift_types`.`name`, `rooms`.`name` AS `room_name`
+ SELECT DISTINCT `shifts`.*, `shift_types`.`name`, `locations`.`name` AS `location_name`
FROM `shifts`
- JOIN `rooms` ON `shifts`.`room_id` = `rooms`.`id`
+ JOIN `locations` ON `shifts`.`location_id` = `locations`.`id`
JOIN `shift_types` ON `shift_types`.`id` = `shifts`.`shift_type_id`
JOIN `needed_angel_types` ON `needed_angel_types`.`shift_id` = `shifts`.`id`
LEFT JOIN schedule_shift AS s on shifts.id = s.shift_id
- WHERE `shifts`.`room_id` IN (' . implode(',', $shiftsFilter->getRooms()) . ')
+ WHERE `shifts`.`location_id` IN (' . implode(',', $shiftsFilter->getLocations()) . ')
AND `start` BETWEEN ? AND ?
AND `needed_angel_types`.`angel_type_id` IN (' . implode(',', $shiftsFilter->getTypes()) . ')
AND s.shift_id IS NULL
UNION
- SELECT DISTINCT `shifts`.*, `shift_types`.`name`, `rooms`.`name` AS `room_name`
+ SELECT DISTINCT `shifts`.*, `shift_types`.`name`, `locations`.`name` AS `location_name`
FROM `shifts`
- JOIN `rooms` ON `shifts`.`room_id` = `rooms`.`id`
+ JOIN `locations` ON `shifts`.`location_id` = `locations`.`id`
JOIN `shift_types` ON `shift_types`.`id` = `shifts`.`shift_type_id`
- JOIN `needed_angel_types` ON `needed_angel_types`.`room_id`=`shifts`.`room_id`
+ JOIN `needed_angel_types` ON `needed_angel_types`.`location_id`=`shifts`.`location_id`
LEFT JOIN schedule_shift AS s on shifts.id = s.shift_id
- WHERE `shifts`.`room_id` IN (' . implode(',', $shiftsFilter->getRooms()) . ')
+ WHERE `shifts`.`location_id` IN (' . implode(',', $shiftsFilter->getLocations()) . ')
AND `start` BETWEEN ? AND ?
AND `needed_angel_types`.`angel_type_id` IN (' . implode(',', $shiftsFilter->getTypes()) . ')
AND NOT s.shift_id IS NULL
) AS tmp_shifts
- ORDER BY `room_name`, `start`
+ ORDER BY `location_name`, `start`
';
$shiftsData = Db::select(
@@ -161,7 +161,7 @@ function NeededAngeltypes_by_ShiftsFilter(ShiftsFilter $shiftsFilter)
JOIN `needed_angel_types` ON `needed_angel_types`.`shift_id`=`shifts`.`id`
JOIN `angel_types` ON `angel_types`.`id`= `needed_angel_types`.`angel_type_id`
LEFT JOIN schedule_shift AS s on shifts.id = s.shift_id
- WHERE `shifts`.`room_id` IN (' . implode(',', $shiftsFilter->getRooms()) . ')
+ WHERE `shifts`.`location_id` IN (' . implode(',', $shiftsFilter->getLocations()) . ')
AND shifts.`start` BETWEEN ? AND ?
AND s.shift_id IS NULL
@@ -175,10 +175,10 @@ function NeededAngeltypes_by_ShiftsFilter(ShiftsFilter $shiftsFilter)
`angel_types`.`restricted`,
`angel_types`.`shift_self_signup`
FROM `shifts`
- JOIN `needed_angel_types` ON `needed_angel_types`.`room_id`=`shifts`.`room_id`
+ JOIN `needed_angel_types` ON `needed_angel_types`.`location_id`=`shifts`.`location_id`
JOIN `angel_types` ON `angel_types`.`id`= `needed_angel_types`.`angel_type_id`
LEFT JOIN schedule_shift AS s on shifts.id = s.shift_id
- WHERE `shifts`.`room_id` IN (' . implode(',', $shiftsFilter->getRooms()) . ')
+ WHERE `shifts`.`location_id` IN (' . implode(',', $shiftsFilter->getLocations()) . ')
AND shifts.`start` BETWEEN ? AND ?
AND NOT s.shift_id IS NULL
';
@@ -228,7 +228,7 @@ function NeededAngeltype_by_Shift_and_Angeltype(Shift $shift, AngelType $angelty
`angel_types`.`restricted`,
`angel_types`.`shift_self_signup`
FROM `shifts`
- JOIN `needed_angel_types` ON `needed_angel_types`.`room_id`=`shifts`.`room_id`
+ JOIN `needed_angel_types` ON `needed_angel_types`.`location_id`=`shifts`.`location_id`
JOIN `angel_types` ON `angel_types`.`id`= `needed_angel_types`.`angel_type_id`
LEFT JOIN schedule_shift AS s on shifts.id = s.shift_id
WHERE `shifts`.`id`=?
@@ -252,7 +252,7 @@ function ShiftEntries_by_ShiftsFilter(ShiftsFilter $shiftsFilter)
{
return ShiftEntry::with('user')
->join('shifts', 'shifts.id', 'shift_entries.shift_id')
- ->whereIn('shifts.room_id', $shiftsFilter->getRooms())
+ ->whereIn('shifts.location_id', $shiftsFilter->getLocations())
->whereBetween('start', [$shiftsFilter->getStart(), $shiftsFilter->getEnd()])
->get();
}
@@ -510,8 +510,8 @@ function Shifts_by_user($userId, $include_freeloaded_comments = false)
$shiftsData = Db::select(
'
SELECT
- `rooms`.*,
- `rooms`.name AS Name,
+ `locations`.*,
+ `locations`.name AS Name,
`shift_types`.`id` AS `shifttype_id`,
`shift_types`.`name`,
`shift_entries`.`id` as shift_entry_id,
@@ -525,7 +525,7 @@ function Shifts_by_user($userId, $include_freeloaded_comments = false)
FROM `shift_entries`
JOIN `shifts` ON (`shift_entries`.`shift_id` = `shifts`.`id`)
JOIN `shift_types` ON (`shift_types`.`id` = `shifts`.`shift_type_id`)
- JOIN `rooms` ON (`shifts`.`room_id` = `rooms`.`id`)
+ JOIN `locations` ON (`shifts`.`location_id` = `locations`.`id`)
WHERE shift_entries.`user_id` = ?
ORDER BY `start`
',
diff --git a/includes/model/Stats.php b/includes/model/Stats.php
index afd5cb60..06eb30cf 100644
--- a/includes/model/Stats.php
+++ b/includes/model/Stats.php
@@ -24,7 +24,7 @@ function stats_currently_working(ShiftsFilter $filter = null)
)) AS `count`
FROM `shifts`
WHERE (`end` >= NOW() AND `start` <= NOW())
- ' . ($filter ? 'AND shifts.room_id IN (' . implode(',', $filter->getRooms()) . ')' : '')
+ ' . ($filter ? 'AND shifts.location_id IN (' . implode(',', $filter->getLocations()) . ')' : '')
);
return $result['count'] ?: '-';
@@ -49,18 +49,18 @@ function stats_hours_to_work(ShiftsFilter $filter = null)
LEFT JOIN schedule_shift AS s on shifts.id = s.shift_id
WHERE `shifts`.`end` >= NOW()
AND s.shift_id IS NULL
- ' . ($filter ? 'AND shifts.room_id IN (' . implode(',', $filter->getRooms()) . ')' : '') . '
+ ' . ($filter ? 'AND shifts.location_id IN (' . implode(',', $filter->getLocations()) . ')' : '') . '
UNION ALL
SELECT
- (SELECT SUM(`count`) FROM `needed_angel_types` WHERE `needed_angel_types`.`room_id`=`shifts`.`room_id`' . ($filter ? ' AND needed_angel_types.angel_type_id IN (' . implode(',', $filter->getTypes()) . ')' : '') . ')
+ (SELECT SUM(`count`) FROM `needed_angel_types` WHERE `needed_angel_types`.`location_id`=`shifts`.`location_id`' . ($filter ? ' AND needed_angel_types.angel_type_id IN (' . implode(',', $filter->getTypes()) . ')' : '') . ')
* TIMESTAMPDIFF(MINUTE, `shifts`.`start`, `shifts`.`end`) / 60 AS `count`
FROM `shifts`
LEFT JOIN schedule_shift AS s on shifts.id = s.shift_id
WHERE shifts.`end` >= NOW()
AND NOT s.shift_id IS NULL
- ' . ($filter ? 'AND shifts.room_id IN (' . implode(',', $filter->getRooms()) . ')' : '') . '
+ ' . ($filter ? 'AND shifts.location_id IN (' . implode(',', $filter->getLocations()) . ')' : '') . '
) AS `tmp`
'
);
@@ -103,7 +103,7 @@ function stats_angels_needed_three_hours(ShiftsFilter $filter = null)
LEFT JOIN schedule_shift AS s on shifts.id = s.shift_id
WHERE shifts.`end` > NOW() AND shifts.`start` < ?
AND s.shift_id IS NULL
- ' . ($filter ? 'AND shifts.room_id IN (' . implode(',', $filter->getRooms()) . ')' : '') . '
+ ' . ($filter ? 'AND shifts.location_id IN (' . implode(',', $filter->getLocations()) . ')' : '') . '
UNION ALL
@@ -114,7 +114,7 @@ function stats_angels_needed_three_hours(ShiftsFilter $filter = null)
FROM `needed_angel_types`
JOIN `angel_types` ON `angel_types`.`id`=`needed_angel_types`.`angel_type_id`
WHERE `angel_types`.`show_on_dashboard`=TRUE
- AND `needed_angel_types`.`room_id`=`shifts`.`room_id`
+ AND `needed_angel_types`.`location_id`=`shifts`.`location_id`
' . ($filter ? 'AND needed_angel_types.angel_type_id IN (' . implode(',', $filter->getTypes()) . ')' : '') . '
) - (
SELECT COUNT(*)
@@ -131,7 +131,7 @@ function stats_angels_needed_three_hours(ShiftsFilter $filter = null)
LEFT JOIN schedule_shift AS s on shifts.id = s.shift_id
WHERE `end` > NOW() AND `start` < ?
AND NOT s.shift_id IS NULL
- ' . ($filter ? 'AND shifts.room_id IN (' . implode(',', $filter->getRooms()) . ')' : '') . '
+ ' . ($filter ? 'AND shifts.location_id IN (' . implode(',', $filter->getLocations()) . ')' : '') . '
) AS `tmp`', [
$in3hours,
$in3hours,
@@ -185,7 +185,7 @@ function stats_angels_needed_for_nightshifts(ShiftsFilter $filter = null)
LEFT JOIN schedule_shift AS s on shifts.id = s.shift_id
WHERE shifts.`end` > ? AND shifts.`start` < ?
AND s.shift_id IS NULL
- ' . ($filter ? 'AND shifts.room_id IN (' . implode(',', $filter->getRooms()) . ')' : '') . '
+ ' . ($filter ? 'AND shifts.location_id IN (' . implode(',', $filter->getLocations()) . ')' : '') . '
UNION ALL
@@ -196,7 +196,7 @@ function stats_angels_needed_for_nightshifts(ShiftsFilter $filter = null)
FROM `needed_angel_types`
JOIN `angel_types` ON `angel_types`.`id`=`needed_angel_types`.`angel_type_id`
WHERE `angel_types`.`show_on_dashboard`=TRUE
- AND `needed_angel_types`.`room_id`=`shifts`.`room_id`
+ AND `needed_angel_types`.`location_id`=`shifts`.`location_id`
' . ($filter ? 'AND angel_types.id IN (' . implode(',', $filter->getTypes()) . ')' : '') . '
) - (
SELECT COUNT(*) FROM `shift_entries`
@@ -212,7 +212,7 @@ function stats_angels_needed_for_nightshifts(ShiftsFilter $filter = null)
LEFT JOIN schedule_shift AS s on shifts.id = s.shift_id
WHERE `end` > ? AND `start` < ?
AND NOT s.shift_id IS NULL
- ' . ($filter ? 'AND shifts.room_id IN (' . implode(',', $filter->getRooms()) . ')' : '') . '
+ ' . ($filter ? 'AND shifts.location_id IN (' . implode(',', $filter->getLocations()) . ')' : '') . '
) AS `tmp`', [
$night_start,
$night_end,
diff --git a/includes/pages/admin_shifts.php b/includes/pages/admin_shifts.php
index b4c32830..0c5cebf1 100644
--- a/includes/pages/admin_shifts.php
+++ b/includes/pages/admin_shifts.php
@@ -4,7 +4,7 @@ use Engelsystem\Database\Db;
use Engelsystem\Helpers\Carbon;
use Engelsystem\Http\Exceptions\HttpForbidden;
use Engelsystem\Models\AngelType;
-use Engelsystem\Models\Room;
+use Engelsystem\Models\Location;
use Engelsystem\Models\Shifts\NeededAngelType;
use Engelsystem\Models\Shifts\Schedule;
use Engelsystem\Models\Shifts\Shift;
@@ -44,8 +44,8 @@ function admin_shifts()
$shift_over_midnight = true;
// Locations laden
- $rooms = Room::orderBy('name')->get();
- $room_array = $rooms->pluck('name', 'id')->toArray();
+ $locations = Location::orderBy('name')->get();
+ $location_array = $locations->pluck('name', 'id')->toArray();
// Load angeltypes
/** @var AngelType[] $types */
@@ -85,14 +85,14 @@ function admin_shifts()
// Auswahl der sichtbaren Locations für die Schichten
if (
- $request->has('rid')
- && preg_match('/^\d+$/', $request->input('rid'))
- && isset($room_array[$request->input('rid')])
+ $request->has('lid')
+ && preg_match('/^\d+$/', $request->input('lid'))
+ && isset($location_array[$request->input('lid')])
) {
- $rid = $request->input('rid');
+ $lid = $request->input('lid');
} else {
$valid = false;
- $rid = $rooms->first()->id;
+ $lid = $locations->first()->id;
error(__('Please select a location.'));
}
@@ -208,7 +208,7 @@ function admin_shifts()
// Alle Eingaben in Ordnung
if ($valid) {
if ($angelmode == 'location') {
- $needed_angel_types = NeededAngelType::whereRoomId($rid)
+ $needed_angel_types = NeededAngelType::whereLocationId($lid)
->pluck('count', 'angel_type_id')
->toArray() + $needed_angel_types;
}
@@ -218,7 +218,7 @@ function admin_shifts()
$shifts[] = [
'start' => $start,
'end' => $end,
- 'room_id' => $rid,
+ 'location_id' => $lid,
'title' => $title,
'shift_type_id' => $shifttype_id,
'description' => $description,
@@ -238,7 +238,7 @@ function admin_shifts()
$shifts[] = [
'start' => $shift_start,
'end' => $shift_end,
- 'room_id' => $rid,
+ 'location_id' => $lid,
'title' => $title,
'shift_type_id' => $shifttype_id,
'description' => $description,
@@ -299,7 +299,7 @@ function admin_shifts()
$shifts[] = [
'start' => $interval_start,
'end' => $interval_end,
- 'room_id' => $rid,
+ 'location_id' => $lid,
'title' => $title,
'shift_type_id' => $shifttype_id,
'description' => $description,
@@ -330,7 +330,7 @@ function admin_shifts()
. ''
. ', ' . round($end->copy()->diffInMinutes($start) / 60, 2) . 'h'
. '
'
- . Room_name_render(Room::find($shift['room_id'])),
+ . location_name_render(Location::find($shift['location_id'])),
'title' =>
ShiftType_name_render(ShiftType::find($shifttype_id))
. ($shift['title'] ? '
' . $shift['title'] : ''),
@@ -367,7 +367,7 @@ function admin_shifts()
form_hidden('shifttype_id', $shifttype_id),
form_hidden('description', $description),
form_hidden('title', $title),
- form_hidden('rid', $rid),
+ form_hidden('lid', $lid),
form_hidden('start', $request->input('start')),
form_hidden('end', $request->input('end')),
form_hidden('mode', $mode),
@@ -434,9 +434,9 @@ function admin_shifts()
$session->remove('admin_shifts_types');
}
- $rid = null;
- if ($request->has('rid')) {
- $rid = $request->input('rid');
+ $lid = null;
+ if ($request->has('lid')) {
+ $lid = $request->input('lid');
}
$angel_types = '';
foreach ($types as $type) {
@@ -467,7 +467,7 @@ function admin_shifts()
div('col-md-6 col-xl-5', [
form_select('shifttype_id', __('Shifttype'), $shifttypes, $shifttype_id),
form_text('title', __('title.title'), $title),
- form_select('rid', __('Location'), $room_array, $rid),
+ form_select('lid', __('Location'), $location_array, $lid),
]),
div('col-md-6 col-xl-7', [
form_textarea('description', __('Additional description'), $description),
@@ -599,7 +599,7 @@ function admin_shifts_history(): string
'name' => $shift->shiftType->name,
'title' => $shift->title,
'type' => $entry->angelType->name,
- 'room' => $shift->room,
+ 'location' => $shift->location,
'freeloaded' => $entry->freeloaded,
]);
}
diff --git a/includes/pages/schedule/ImportSchedule.php b/includes/pages/schedule/ImportSchedule.php
index 679bc179..4d146bd7 100644
--- a/includes/pages/schedule/ImportSchedule.php
+++ b/includes/pages/schedule/ImportSchedule.php
@@ -16,7 +16,7 @@ use Engelsystem\Helpers\Schedule\XmlParser;
use Engelsystem\Helpers\Uuid;
use Engelsystem\Http\Request;
use Engelsystem\Http\Response;
-use Engelsystem\Models\Room as RoomModel;
+use Engelsystem\Models\Location;
use Engelsystem\Models\Shifts\Schedule as ScheduleUrl;
use Engelsystem\Models\Shifts\ScheduleShift;
use Engelsystem\Models\Shifts\Shift;
@@ -179,7 +179,7 @@ class ImportSchedule extends BaseController
[
'schedule_id' => $scheduleUrl->id,
'schedule' => $schedule,
- 'rooms' => [
+ 'locations' => [
'add' => $newRooms,
],
'shifts' => [
@@ -218,15 +218,15 @@ class ImportSchedule extends BaseController
$this->log('Started schedule "{name}" import', ['name' => $scheduleUrl->name]);
foreach ($newRooms as $room) {
- $this->createRoom($room);
+ $this->createLocation($room);
}
- $rooms = $this->getAllRooms();
+ $locations = $this->getAllLocations();
foreach ($newEvents as $event) {
$this->createEvent(
$event,
$shiftType,
- $rooms
+ $locations
->where('name', $event->getRoom()->getName())
->first(),
$scheduleUrl
@@ -237,7 +237,7 @@ class ImportSchedule extends BaseController
$this->updateEvent(
$event,
$shiftType,
- $rooms
+ $locations
->where('name', $event->getRoom()->getName())
->first()
);
@@ -255,11 +255,11 @@ class ImportSchedule extends BaseController
return redirect($this->url, 303);
}
- protected function createRoom(Room $room): void
+ protected function createLocation(Room $room): void
{
- $roomModel = new RoomModel();
- $roomModel->name = $room->getName();
- $roomModel->save();
+ $location = new Location();
+ $location->name = $room->getName();
+ $location->save();
$this->log('Created schedule location "{location}"', ['location' => $room->getName()]);
}
@@ -269,12 +269,12 @@ class ImportSchedule extends BaseController
$shiftEntries = $this->db
->table('shift_entries')
->select([
- 'shift_types.name', 'shifts.title', 'angel_types.name AS type', 'rooms.id AS room_id',
+ 'shift_types.name', 'shifts.title', 'angel_types.name AS type', 'locations.id AS location_id',
'shifts.start', 'shifts.end', 'shift_entries.user_id', 'shift_entries.freeloaded',
])
->join('shifts', 'shifts.id', 'shift_entries.shift_id')
->join('schedule_shift', 'shifts.id', 'schedule_shift.shift_id')
- ->join('rooms', 'rooms.id', 'shifts.room_id')
+ ->join('locations', 'locations.id', 'shifts.location_id')
->join('angel_types', 'angel_types.id', 'shift_entries.angel_type_id')
->join('shift_types', 'shift_types.id', 'shifts.shift_type_id')
->where('schedule_shift.guid', $event->getGuid())
@@ -288,13 +288,13 @@ class ImportSchedule extends BaseController
'name' => $shiftEntry->name,
'title' => $shiftEntry->title,
'type' => $shiftEntry->type,
- 'room' => RoomModel::find($shiftEntry->room_id),
+ 'location' => Location::find($shiftEntry->location_id),
'freeloaded' => $shiftEntry->freeloaded,
]);
}
}
- protected function createEvent(Event $event, int $shiftTypeId, RoomModel $room, ScheduleUrl $scheduleUrl): void
+ protected function createEvent(Event $event, int $shiftTypeId, Location $location, ScheduleUrl $scheduleUrl): void
{
$user = auth()->user();
$eventTimeZone = Carbon::now()->timezone;
@@ -304,7 +304,7 @@ class ImportSchedule extends BaseController
$shift->shift_type_id = $shiftTypeId;
$shift->start = $event->getDate()->copy()->timezone($eventTimeZone);
$shift->end = $event->getEndDate()->copy()->timezone($eventTimeZone);
- $shift->room()->associate($room);
+ $shift->location()->associate($location);
$shift->url = $event->getUrl() ?? '';
$shift->transaction_id = Uuid::uuidBy($scheduleUrl->id, '5c4ed01e');
$shift->createdBy()->associate($user);
@@ -319,7 +319,7 @@ class ImportSchedule extends BaseController
'Created schedule shift "{shift}" in "{location}" ({from} {to}, {guid})',
[
'shift' => $shift->title,
- 'location' => $shift->room->name,
+ 'location' => $shift->location->name,
'from' => $shift->start->format(DateTimeInterface::RFC3339),
'to' => $shift->end->format(DateTimeInterface::RFC3339),
'guid' => $scheduleShift->guid,
@@ -327,7 +327,7 @@ class ImportSchedule extends BaseController
);
}
- protected function updateEvent(Event $event, int $shiftTypeId, RoomModel $room): void
+ protected function updateEvent(Event $event, int $shiftTypeId, Location $location): void
{
$user = auth()->user();
$eventTimeZone = Carbon::now()->timezone;
@@ -339,7 +339,7 @@ class ImportSchedule extends BaseController
$shift->shift_type_id = $shiftTypeId;
$shift->start = $event->getDate()->copy()->timezone($eventTimeZone);
$shift->end = $event->getEndDate()->copy()->timezone($eventTimeZone);
- $shift->room()->associate($room);
+ $shift->location()->associate($location);
$shift->url = $event->getUrl() ?? '';
$shift->updatedBy()->associate($user);
$shift->save();
@@ -348,7 +348,7 @@ class ImportSchedule extends BaseController
'Updated schedule shift "{shift}" in "{location}" ({from} {to}, {guid})',
[
'shift' => $shift->title,
- 'location' => $shift->room->name,
+ 'location' => $shift->location->name,
'from' => $shift->start->format(DateTimeInterface::RFC3339),
'to' => $shift->end->format(DateTimeInterface::RFC3339),
'guid' => $scheduleShift->guid,
@@ -367,7 +367,7 @@ class ImportSchedule extends BaseController
'Deleted schedule shift "{shift}" in {location} ({from} {to}, {guid})',
[
'shift' => $shift->title,
- 'location' => $shift->room->name,
+ 'location' => $shift->location->name,
'from' => $shift->start->format(DateTimeInterface::RFC3339),
'to' => $shift->end->format(DateTimeInterface::RFC3339),
'guid' => $scheduleShift->guid,
@@ -377,7 +377,7 @@ class ImportSchedule extends BaseController
/**
* @param Request $request
- * @return Event[]|Room[]|RoomModel[]
+ * @return Event[]|Room[]|Location[]
* @throws ErrorException
*/
protected function getScheduleData(Request $request)
@@ -420,10 +420,10 @@ class ImportSchedule extends BaseController
protected function newRooms(array $scheduleRooms): array
{
$newRooms = [];
- $allRooms = $this->getAllRooms();
+ $allLocations = $this->getAllLocations();
foreach ($scheduleRooms as $room) {
- if ($allRooms->where('name', $room->getName())->count()) {
+ if ($allLocations->where('name', $room->getName())->count()) {
continue;
}
@@ -456,7 +456,7 @@ class ImportSchedule extends BaseController
$scheduleEvents = [];
/** @var Event[] $deleteEvents */
$deleteEvents = [];
- $rooms = $this->getAllRooms();
+ $locations = $this->getAllLocations();
$eventTimeZone = Carbon::now()->timezone;
foreach ($schedule->getDay() as $day) {
@@ -480,16 +480,16 @@ class ImportSchedule extends BaseController
foreach ($existingShifts as $shift) {
$guid = $shift->guid;
/** @var Shift $shift */
- $shift = Shift::with('room')->find($shift->shift_id);
+ $shift = Shift::with('location')->find($shift->shift_id);
$event = $scheduleEvents[$guid];
- $room = $rooms->where('name', $event->getRoom()->getName())->first();
+ $location = $locations->where('name', $event->getRoom()->getName())->first();
if (
$shift->title != $event->getTitle()
|| $shift->shift_type_id != $shiftType
|| $shift->start != $event->getDate()
|| $shift->end != $event->getEndDate()
- || $shift->room_id != ($room->id ?? '')
+ || $shift->location_id != ($location->id ?? '')
|| $shift->url != ($event->getUrl() ?? '')
) {
$changeEvents[$guid] = $event;
@@ -514,13 +514,13 @@ class ImportSchedule extends BaseController
protected function eventFromScheduleShift(ScheduleShift $scheduleShift): Event
{
/** @var Shift $shift */
- $shift = Shift::with('room')->find($scheduleShift->shift_id);
+ $shift = Shift::with('location')->find($scheduleShift->shift_id);
$duration = $shift->start->diff($shift->end);
return new Event(
$scheduleShift->guid,
0,
- new Room($shift->room->name),
+ new Room($shift->location->name),
$shift->title,
'',
'n/a',
@@ -534,11 +534,11 @@ class ImportSchedule extends BaseController
}
/**
- * @return RoomModel[]|Collection
+ * @return Location[]|Collection
*/
- protected function getAllRooms(): Collection
+ protected function getAllLocations(): Collection
{
- return RoomModel::all();
+ return Location::all();
}
/**
diff --git a/includes/pages/user_myshifts.php b/includes/pages/user_myshifts.php
index f20b8aea..67751795 100644
--- a/includes/pages/user_myshifts.php
+++ b/includes/pages/user_myshifts.php
@@ -51,7 +51,7 @@ function user_myshifts()
/** @var ShiftEntry $shiftEntry */
$shiftEntry = ShiftEntry::where('id', $shift_entry_id)
->where('user_id', $shifts_user->id)
- ->with(['shift', 'shift.shiftType', 'shift.room', 'user'])
+ ->with(['shift', 'shift.shiftType', 'shift.location', 'user'])
->first();
if (!empty($shiftEntry)) {
$shift = $shiftEntry->shift;
@@ -97,7 +97,7 @@ function user_myshifts()
return ShiftEntry_edit_view(
$shifts_user,
$shift->start->format(__('Y-m-d H:i')) . ', ' . shift_length($shift),
- $shift->room->name,
+ $shift->location->name,
$shift->shiftType->name,
$shiftEntry->angelType->name,
$shiftEntry->user_comment,
diff --git a/includes/pages/user_shifts.php b/includes/pages/user_shifts.php
index d2e4765a..0755dd68 100644
--- a/includes/pages/user_shifts.php
+++ b/includes/pages/user_shifts.php
@@ -3,7 +3,7 @@
use Engelsystem\Database\Db;
use Engelsystem\Helpers\Carbon;
use Engelsystem\Models\AngelType;
-use Engelsystem\Models\Room;
+use Engelsystem\Models\Location;
use Engelsystem\Models\Shifts\NeededAngelType;
use Engelsystem\Models\Shifts\Shift;
use Engelsystem\Models\UserAngelType;
@@ -107,40 +107,40 @@ function update_ShiftsFilter(ShiftsFilter $shiftsFilter, $user_shifts_admin, $da
{
$shiftsFilter->setUserShiftsAdmin($user_shifts_admin);
$shiftsFilter->setFilled(check_request_int_array('filled', $shiftsFilter->getFilled()));
- $shiftsFilter->setRooms(check_request_int_array('rooms', $shiftsFilter->getRooms()));
+ $shiftsFilter->setLocations(check_request_int_array('locations', $shiftsFilter->getLocations()));
$shiftsFilter->setTypes(check_request_int_array('types', $shiftsFilter->getTypes()));
update_ShiftsFilter_timerange($shiftsFilter, $days);
}
/**
- * @return Room[]|Collection
+ * @return Location[]|Collection
*/
-function load_rooms(bool $onlyWithActiveShifts = false)
+function load_locations(bool $onlyWithActiveShifts = false)
{
- $rooms = Room::orderBy('name');
+ $locations = Location::orderBy('name');
if ($onlyWithActiveShifts) {
- $roomIdsFromAngelType = NeededAngelType::query()
- ->whereNotNull('room_id')
- ->select('room_id');
+ $locationIdsFromAngelType = NeededAngelType::query()
+ ->whereNotNull('location_id')
+ ->select('location_id');
- $roomIdsFromShift = Shift::query()
+ $locationIdsFromShift = Shift::query()
->leftJoin('needed_angel_types', 'shifts.id', 'needed_angel_types.shift_id')
->whereNotNull('needed_angel_types.shift_id')
- ->select('shifts.room_id');
+ ->select('shifts.location_id');
- $rooms->whereIn('id', $roomIdsFromAngelType)
- ->orWhereIn('id', $roomIdsFromShift);
+ $locations->whereIn('id', $locationIdsFromAngelType)
+ ->orWhereIn('id', $locationIdsFromShift);
}
- $rooms = $rooms->get();
+ $locations = $locations->get();
- if ($rooms->isEmpty()) {
+ if ($locations->isEmpty()) {
error(__('The administration has not configured any locations yet.'));
throw_redirect(page_link_to('/'));
}
- return $rooms;
+ return $locations;
}
/**
@@ -233,7 +233,7 @@ function view_user_shifts()
$session = session();
$days = load_days();
- $rooms = load_rooms(true);
+ $locations = load_locations(true);
$types = load_types();
$ownAngelTypes = [];
@@ -250,8 +250,8 @@ function view_user_shifts()
}
if (!$session->has('shifts-filter')) {
- $room_ids = $rooms->pluck('id')->toArray();
- $shiftsFilter = new ShiftsFilter(auth()->can('user_shifts_admin'), $room_ids, $ownAngelTypes);
+ $location_ids = $locations->pluck('id')->toArray();
+ $shiftsFilter = new ShiftsFilter(auth()->can('user_shifts_admin'), $location_ids, $ownAngelTypes);
$session->set('shifts-filter', $shiftsFilter->sessionExport());
}
@@ -297,10 +297,10 @@ function view_user_shifts()
view(__DIR__ . '/../../resources/views/pages/user-shifts.html', [
'title' => shifts_title(),
'add_link' => auth()->can('admin_shifts') ? $link : '',
- 'room_select' => make_select(
- $rooms,
- $shiftsFilter->getRooms(),
- 'rooms',
+ 'location_select' => make_select(
+ $locations,
+ $shiftsFilter->getLocations(),
+ 'locations',
icon('pin-map-fill') . __('Locations')
),
'start_select' => html_select_key(
diff --git a/includes/sys_menu.php b/includes/sys_menu.php
index 2be8cd84..9e5a0fbd 100644
--- a/includes/sys_menu.php
+++ b/includes/sys_menu.php
@@ -1,7 +1,7 @@
['Answer questions', 'question.edit'],
'shifttypes' => 'Shifttypes',
'admin_shifts' => 'Create shifts',
- 'admin/rooms' => ['room.rooms', 'admin_rooms'],
+ 'admin/locations' => ['location.locations', 'admin_locations'],
'admin_groups' => 'Grouprights',
'admin/schedule' => ['schedule.import', 'schedule.import'],
'admin/logs' => ['log.log', 'admin_log'],
@@ -142,31 +142,36 @@ function menu_is_allowed(string $page, $options)
}
/**
- * Adds room navigation to the given menu.
+ * Adds location navigation to the given menu.
*
* @param string[] $menu Rendered menu
* @return string[]
*/
-function make_room_navigation($menu)
+function make_location_navigation($menu)
{
- if (!auth()->can('view_rooms')) {
+ if (!auth()->can('view_locations')) {
return $menu;
}
- // Get a list of all rooms
- $rooms = Room::orderBy('name')->get();
- $room_menu = [];
- if (auth()->can('admin_rooms')) {
- $room_menu[] = toolbar_dropdown_item(page_link_to('admin/rooms'), __('Manage locations'), false, 'list');
+ // Get a list of all locations
+ $locations = Location::orderBy('name')->get();
+ $location_menu = [];
+ if (auth()->can('admin_locations')) {
+ $location_menu[] = toolbar_dropdown_item(
+ page_link_to('admin/locations'),
+ __('Manage locations'),
+ false,
+ 'list'
+ );
}
- if (count($room_menu) > 0) {
- $room_menu[] = toolbar_dropdown_item_divider();
+ if (count($location_menu) > 0) {
+ $location_menu[] = toolbar_dropdown_item_divider();
}
- foreach ($rooms as $room) {
- $room_menu[] = toolbar_dropdown_item(room_link($room), $room->name, false, 'pin-map-fill');
+ foreach ($locations as $location) {
+ $location_menu[] = toolbar_dropdown_item(location_link($location), $location->name, false, 'pin-map-fill');
}
- if (count($room_menu) > 0) {
- $menu[] = toolbar_dropdown(__('Locations'), $room_menu);
+ if (count($location_menu) > 0) {
+ $menu[] = toolbar_dropdown(__('Locations'), $location_menu);
}
return $menu;
}
diff --git a/includes/view/Rooms_view.php b/includes/view/Locations_view.php
similarity index 53%
rename from includes/view/Rooms_view.php
rename to includes/view/Locations_view.php
index e6873d49..dc0d4502 100644
--- a/includes/view/Rooms_view.php
+++ b/includes/view/Locations_view.php
@@ -1,17 +1,17 @@
user();
@@ -21,33 +21,33 @@ function Room_view(Room $room, ShiftsFilterRenderer $shiftsFilterRenderer, Shift
}
$description = '';
- if ($room->description) {
+ if ($location->description) {
$description = '
' . Room_name_render($room) . '
', + '' . location_name_render($location) . '
', ]), ]); } @@ -109,16 +109,21 @@ function Shift_signup_button_render(Shift $shift, AngelType $angeltype) /** * @param Shift $shift * @param ShiftType $shifttype - * @param Room $room + * @param Location $location * @param AngelType[]|Collection $angeltypes_source * @param ShiftSignupState $shift_signup_state * @return string */ -function Shift_view(Shift $shift, ShiftType $shifttype, Room $room, $angeltypes_source, ShiftSignupState $shift_signup_state) -{ +function Shift_view( + Shift $shift, + ShiftType $shifttype, + Location $location, + $angeltypes_source, + ShiftSignupState $shift_signup_state +) { $shift_admin = auth()->can('admin_shifts'); $user_shift_admin = auth()->can('user_shifts_admin'); - $admin_rooms = auth()->can('admin_rooms'); + $admin_locations = auth()->can('admin_locations'); $admin_shifttypes = auth()->can('shifttypes'); $parsedown = new Parsedown(); @@ -166,12 +171,12 @@ function Shift_view(Shift $shift, ShiftType $shifttype, Room $room, $angeltypes_ } $buttons = []; - if ($shift_admin || $admin_shifttypes || $admin_rooms) { + if ($shift_admin || $admin_shifttypes || $admin_locations) { $buttons = [ $shift_admin ? button(shift_edit_link($shift), icon('pencil') . __('edit')) : '', $shift_admin ? button(shift_delete_link($shift), icon('trash') . __('delete')) : '', $admin_shifttypes ? button(shifttype_link($shifttype), $shifttype->name) : '', - $admin_rooms ? button(room_link($room), icon('pin-map-fill') . $room->name) : '', + $admin_locations ? button(location_link($location), icon('pin-map-fill') . $location->name) : '', ]; } $buttons[] = button( @@ -180,7 +185,7 @@ function Shift_view(Shift $shift, ShiftType $shifttype, Room $room, $angeltypes_ ); $content[] = buttons($buttons); - $content[] = Shift_view_header($shift, $room); + $content[] = Shift_view_header($shift, $location); $content[] = div('row', [ div('col-sm-6', [ '