Working on Room Management
This commit is contained in:
parent
13b7908e79
commit
221aae6c36
4 changed files with 133 additions and 12 deletions
|
|
@ -317,11 +317,26 @@ class TourController extends Controller
|
||||||
|
|
||||||
public function join_room($tour_id,$room_id) {
|
public function join_room($tour_id,$room_id) {
|
||||||
Log::info("TourController::join_room");
|
Log::info("TourController::join_room");
|
||||||
$user=Auth::user();
|
$user_id = Auth::user()->id;
|
||||||
Tour::join_room($tour_id,$user->id, $room_id);
|
Tour::join_room($tour_id,$user_id, $room_id);
|
||||||
return redirect('/tour/'.$tour_id);
|
return redirect('/tour/'.$tour_id);
|
||||||
}
|
}
|
||||||
|
public function join_room4user($tour_id,$room_id,$user_id) {
|
||||||
|
Log::info("TourController::join_room");
|
||||||
|
Tour::join_room($tour_id,$user_id, $room_id);
|
||||||
|
|
||||||
|
$tour = Tour::find($tour_id);
|
||||||
|
$tour->start = Tour::toGermanDate($tour->start);
|
||||||
|
$tour->deadline = Tour::toGermanDate($tour->deadline);
|
||||||
|
|
||||||
|
$rooms = $this->fetch_rooms($tour->id);
|
||||||
|
|
||||||
|
return view('tour.edit')
|
||||||
|
->with('tour', $tour)
|
||||||
|
->with('rooms', $rooms);
|
||||||
|
|
||||||
|
return redirect('/tour/'.$tour_id);
|
||||||
|
}
|
||||||
public function cancelBooking($tour_id) {
|
public function cancelBooking($tour_id) {
|
||||||
$user=Auth::user();
|
$user=Auth::user();
|
||||||
Booking::where('tour_id', $tour_id)->where('user_id', $user->id)->delete();
|
Booking::where('tour_id', $tour_id)->where('user_id', $user->id)->delete();
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,6 @@
|
||||||
|
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
|
|
||||||
|
|
||||||
<form style="background-color: #fff;" class="text-dark" method="post" action="/tour/{{$tour->id}}" enctype="multipart/form-data">
|
<form style="background-color: #fff;" class="text-dark" method="post" action="/tour/{{$tour->id}}" enctype="multipart/form-data">
|
||||||
|
|
||||||
@csrf
|
@csrf
|
||||||
|
|
@ -40,7 +39,7 @@
|
||||||
|
|
||||||
<div class="form-group" style="display:flex;">
|
<div class="form-group" style="display:flex;">
|
||||||
<label class="ml-2 mt-4" style="width:180px; text-align:left;font-size:18px;" for="name">Max Teilnehmer:</label>
|
<label class="ml-2 mt-4" style="width:180px; text-align:left;font-size:18px;" for="name">Max Teilnehmer:</label>
|
||||||
<input class="mt-3 mr-2 form-control" type="text" id="max_participants" style="font-size:16px;" name="max_participants" value="{{ old('max_participants') ?? $tour->max_participants }}" required >
|
<input class="mt-3 mr-2 form-control" type="text" id="max_participants" style="font-size:16px;" name="max_participants" type="number" min="1" max="99" value="{{ old('max_participants') ?? $tour->max_participants }}" required >
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -80,6 +79,52 @@
|
||||||
<button type="submit" class="btn btn-danger col-2 mb-2 float-right mr-2">Speichern</button>
|
<button type="submit" class="btn btn-danger col-2 mb-2 float-right mr-2">Speichern</button>
|
||||||
|
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
<!-- Modal Anzeige start -->
|
||||||
|
|
||||||
|
<!-- The Modal -->
|
||||||
|
<div id="myModal" class="modal">
|
||||||
|
|
||||||
|
<!-- Modal content -->
|
||||||
|
<div class="modal-content">
|
||||||
|
<span class="close">×</span>
|
||||||
|
<h2>Bitte Zimmer auswählen</h2>
|
||||||
|
<!-- Teilnehmer+Raum Anzeige/Auswahl: Nur buchbare -->
|
||||||
|
<div class="card-body">
|
||||||
|
<ul>
|
||||||
|
<!-- Intentional Assignment ! -->
|
||||||
|
@if ($room_id="") @endif
|
||||||
|
@foreach($rooms as $room)
|
||||||
|
@if( $room->room_id != 0 and $room->free_slots >0) <!-- Dont show "Ungebucht", room_id=0 and only with available slots -->
|
||||||
|
@if ($room_id != $room->room_id)
|
||||||
|
@if(strlen($room_id))
|
||||||
|
<hr/>
|
||||||
|
@endif
|
||||||
|
<p style="list-style-type: none;">[{{$room->room_id}}]
|
||||||
|
<span>{{$room->room_name}}
|
||||||
|
</span><b><a id="booking_link" href="/tour/{{$tour->id}}/join4user/{{$room->room_id}}/#USER_ID"> ==> Buchen</a></b>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<!-- Intentional Assignment ! -->
|
||||||
|
@if ($room_id=$room->room_id) @endif
|
||||||
|
@endif
|
||||||
|
|
||||||
|
@if(strlen($room->user_name))
|
||||||
|
<li> {{ $room->user_name}}
|
||||||
|
</li>
|
||||||
|
@endif
|
||||||
|
@endif
|
||||||
|
@endforeach
|
||||||
|
<li>Ungebucht / Kein Raum</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<!--Modal Anzeige end -->
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -99,7 +144,7 @@
|
||||||
@endif
|
@endif
|
||||||
<p><b>[{{$room->room_id}}] {{$room->room_name}}</b>
|
<p><b>[{{$room->room_id}}] {{$room->room_name}}</b>
|
||||||
@if($room->room_id>0) <!-- Delete link only for real room ids -->
|
@if($room->room_id>0) <!-- Delete link only for real room ids -->
|
||||||
<a class="text-primary ts_tooltip" href="/tour/{{$tour->id}}/delete_room/{{$room->room_id}}">
|
<a id="room_booking_link" class="text-primary ts_tooltip" href="/tour/{{$tour->id}}/delete_room/{{$room->room_id}}">
|
||||||
(X) <span class="ts_tooltiptext">Raum Löschen</span>
|
(X) <span class="ts_tooltiptext">Raum Löschen</span>
|
||||||
</a>
|
</a>
|
||||||
@endif
|
@endif
|
||||||
|
|
@ -113,8 +158,12 @@
|
||||||
<li style="list-style:none"> {{ $room->user_name}}
|
<li style="list-style:none"> {{ $room->user_name}}
|
||||||
@if(Auth::user()->role=="ADMIN")
|
@if(Auth::user()->role=="ADMIN")
|
||||||
<a href="/tour/{{$tour->id}}/cancelBookingAdmin/{{$room->user_id}}" class="text-primary ts_tooltip">
|
<a href="/tour/{{$tour->id}}/cancelBookingAdmin/{{$room->user_id}}" class="text-primary ts_tooltip">
|
||||||
<span class="ts_tooltiptext">Stornieren</span>
|
(-)
|
||||||
|
<span class="ts_tooltiptext">Ḱein Raum</span>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
|
<a href="#" data-user_id="{{$room->user_id}}" id="myBtn" class="float-left">(Zimmer->)</a>
|
||||||
|
|
||||||
@endif
|
@endif
|
||||||
</li>
|
</li>
|
||||||
@endif
|
@endif
|
||||||
|
|
@ -152,6 +201,66 @@
|
||||||
'format':'dd.mm.yyyy',
|
'format':'dd.mm.yyyy',
|
||||||
'language':'de'
|
'language':'de'
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////
|
||||||
|
// Get the modal
|
||||||
|
var modal = document.getElementById("myModal");
|
||||||
|
|
||||||
|
// Get the button that opens the modal
|
||||||
|
//var btn = document.getElementById("myBtn");
|
||||||
|
var btns=document.querySelectorAll("#myBtn");
|
||||||
|
for (let i = 0; i < btns.length; ++i) {
|
||||||
|
//btns[i].user_id=
|
||||||
|
btns[i].onclick = function(e) {
|
||||||
|
|
||||||
|
console.log("** CLICK **")
|
||||||
|
console.log(this)
|
||||||
|
let user_id = this.dataset.user_id
|
||||||
|
|
||||||
|
// Jetzt die Links
|
||||||
|
var elems = document.querySelectorAll("#booking_link")
|
||||||
|
for (var i = 0; i < elems.length; i++) {
|
||||||
|
console.log("Before: ")
|
||||||
|
console.log(elems[i].href)
|
||||||
|
elems[i].href = elems[i].href.replace("#USER_ID", user_id)
|
||||||
|
console.log("After:")
|
||||||
|
console.log(elems[i].href)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// When the user clicks on the button, open the modal
|
||||||
|
e.preventDefault();
|
||||||
|
modal.style.display = "block";
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the <span> element that closes the modal
|
||||||
|
var span = document.getElementsByClassName("close")[0];
|
||||||
|
|
||||||
|
|
||||||
|
// When the user clicks on <span> (x), close the modal, restore the links
|
||||||
|
span.onclick = function(e) {
|
||||||
|
e.preventDefault();
|
||||||
|
modal.style.display = "none";
|
||||||
|
|
||||||
|
// Jetzt die Links
|
||||||
|
var elems = document.querySelectorAll("#booking_link")
|
||||||
|
for (var i = 0; i < elems.length; i++) {
|
||||||
|
arr = elems[i].href.split("/")
|
||||||
|
arr.pop()
|
||||||
|
str = arr.join("/")+"/#USER_ID"
|
||||||
|
elems[i].href=str
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// When the user clicks anywhere outside of the modal, close it
|
||||||
|
window.onclick = function(event) {
|
||||||
|
if (event.target == modal) {
|
||||||
|
modal.style.display = "none";
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@endsection
|
@endsection
|
||||||
|
|
|
||||||
|
|
@ -93,11 +93,6 @@
|
||||||
<!-- Modal Anzeige start -->
|
<!-- Modal Anzeige start -->
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!-- The Modal -->
|
<!-- The Modal -->
|
||||||
<div id="myModal" class="modal">
|
<div id="myModal" class="modal">
|
||||||
|
|
||||||
|
|
@ -138,8 +133,8 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!--Modal Anzeige end -->
|
<!--Modal Anzeige end -->
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -49,10 +49,12 @@ Route::post('/tour/upload_gallery/{tour_id}', 'TourController@upload_gallery');
|
||||||
Route::resource('/tour', TourController::class)->middleware('auth');
|
Route::resource('/tour', TourController::class)->middleware('auth');
|
||||||
|
|
||||||
Route::get('/tour/{tour_id}/join/{room_id}', 'TourController@join_room')->middleware('auth');
|
Route::get('/tour/{tour_id}/join/{room_id}', 'TourController@join_room')->middleware('auth');
|
||||||
|
Route::get('/tour/{tour_id}/join4user/{room_id}/{user_id}', 'TourController@join_room4user')->middleware('auth');
|
||||||
Route::get('/tour/{tour_id}/cancelBooking', 'TourController@cancelBooking')->middleware('auth');
|
Route::get('/tour/{tour_id}/cancelBooking', 'TourController@cancelBooking')->middleware('auth');
|
||||||
Route::get('/tour/{tour_id}/cancelBookingAdmin/{user_id}', 'TourController@cancelBookingAdmin')->middleware('auth');
|
Route::get('/tour/{tour_id}/cancelBookingAdmin/{user_id}', 'TourController@cancelBookingAdmin')->middleware('auth');
|
||||||
Route::get('/tour/{tour_id}/create_room/{capacity}', 'TourController@create_room')->middleware('auth');
|
Route::get('/tour/{tour_id}/create_room/{capacity}', 'TourController@create_room')->middleware('auth');
|
||||||
Route::get('/tour/{tour_id}/delete_room/{room_id}', 'TourController@delete_room')->middleware('auth');
|
Route::get('/tour/{tour_id}/delete_room/{room_id}', 'TourController@delete_room')->middleware('auth');
|
||||||
|
Route::get('/tour/{tour_id}/assign_room_for_user/{user_id}', 'TourController@delete_room')->middleware('auth');
|
||||||
|
|
||||||
Route::get('/img_storage/{category}/{imageName}','ImageController@getImage'); // no middleware auth needed, its checked in Controller
|
Route::get('/img_storage/{category}/{imageName}','ImageController@getImage'); // no middleware auth needed, its checked in Controller
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue