Tour Room UI update

This commit is contained in:
Torsten 2023-01-11 20:45:29 +01:00
parent 221aae6c36
commit 134ac6478f
5 changed files with 489 additions and 130 deletions

View file

@ -162,7 +162,7 @@ class TourController extends Controller
qry.free_slots,
COALESCE(qry.room_name,'Ungebucht') as room_name,
COALESCE(qry.room_name,'ZZZZZZZZZ') as room_sort_order
COALESCE(qry.room_id,'ZZZZZZZZZ') as room_sort_order
FROM
(
SELECT
@ -173,15 +173,16 @@ class TourController extends Controller
b.user_id,
(SELECT tr.capacity - count(*) from bookings where tour_id=tr.tour_id and room_id=tr.id) as free_slots
FROM
tour_rooms tr
LEFT JOIN bookings as b
ON b.tour_id = tr.tour_id AND b.room_id = tr.id
tour_rooms tr LEFT JOIN bookings as b
ON b.tour_id = tr.tour_id AND b.room_id = tr.id
WHERE
tr.tour_id= ".$tour_id."
) qry
LEFT JOIN users as u
ON qry.user_id = u.id
UNION
-- unbooked tour users
@ -205,7 +206,7 @@ class TourController extends Controller
b.user_id = u.id
AND
capacity is null
ORDER BY room_name, user_name
ORDER BY room_sort_order, user_name
;
";
@ -219,6 +220,7 @@ class TourController extends Controller
public function edit(Tour $tour)
{
if (Auth::user()->role != 'ADMIN') {return redirect('/tour');}
error_log("Tour:edit");
if ($tour->start<Carbon::now()) {
return view('tour.edit_old')->with('tour', $tour);
@ -229,6 +231,8 @@ class TourController extends Controller
$rooms = $this->fetch_rooms($tour->id);
return view('tour.edit')
->with('tour', $tour)
->with('rooms', $rooms);
@ -361,7 +365,7 @@ class TourController extends Controller
Log::info("create_room Controller started");
$user=Auth::user();
Booking::where('tour_id', $tour_id)->where('room_id', $room_id)->delete();
DB::update("UPDATE bookings SET room_id=0 WHERE room_id=".$room_id);
DB::delete("DELETE FROM tour_rooms WHERE tour_id = ? AND id = ?",[$tour_id, $room_id]);
return redirect('tour/'.$tour_id.'/edit');
}