Tour-Überbuchung verhindern

This commit is contained in:
Torsten 2023-01-12 13:50:48 +01:00
parent 134ac6478f
commit 4253194117
6 changed files with 621 additions and 560 deletions

View file

@ -1,12 +1,14 @@
<?php
namespace App\Http\Controllers;
namespace App\Http\Controllers;
use App\Page;
use Illuminate\Http\Request;
use App\Page;
use Illuminate\Support\Facades\Auth;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log;
class PageController extends Controller
{
class PageController extends Controller
{
/**
* Display a listing of the resource.
*
@ -84,20 +86,26 @@ class PageController extends Controller
}
public function page_home() {
$page=Page::where('name','home')->first();
$content=$page->content;
public function page_home()
{
$page = Page::where('name', 'home')->first();
$content = $page->content;
$content = rtrim(ltrim($content,'"'),'"');
$content = rtrim(ltrim($content, '"'), '"');
return view('home')->with('content',$content);
$user = Auth::user();
if ($user) {
Log::info("Home page display for user " . $user->name . "[" . $user->id . "]");
}
public function page_activities() {
$page=Page::where('name','activities')->first();
$content=$page->content;
return view('activities')->with('content',$content);
return view('home')->with('content', $content);
}
}
public function page_activities()
{
$page = Page::where('name', 'activities')->first();
$content = $page->content;
return view('activities')->with('content', $content);
}
}

View file

@ -1,21 +1,21 @@
<?php
namespace App\Http\Controllers;
namespace App\Http\Controllers;
use App\Tour;
use App\Booking;
use App\User;
use Carbon\Carbon;
use Illuminate\Http\Request;
use Illuminate\Http\File;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Storage;
use Intervention\Image\Facades\Image;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB;
use App\Tour;
use App\Booking;
use App\User;
use Carbon\Carbon;
use Illuminate\Http\Request;
use Illuminate\Http\File;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Storage;
use Intervention\Image\Facades\Image;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB;
class TourController extends Controller
{
class TourController extends Controller
{
/**
* Display a listing of the resource.
*
@ -24,33 +24,33 @@ class TourController extends Controller
public function index()
{
error_log("Tour:index");
$tours=Tour::where('start','>',Carbon::now())->orderBy('start')->get();
$participantCount=array();
foreach($tours as $key => $tour) {
$tours = Tour::where('start', '>', Carbon::now())->orderBy('start')->get();
$participantCount = array();
foreach ($tours as $key => $tour) {
$result = DB::select('select count(*) as cnt from bookings where tour_id=?', [$tour->id]);
$participantCount[$tour->id] = $result[0]->cnt;
$tours[$key]->start=Tour::toGermanDate($tour->start);
$tours[$key]->deadline=Tour::toGermanDate($tour->deadline);
$tours[$key]->start = Tour::toGermanDate($tour->start);
$tours[$key]->deadline = Tour::toGermanDate($tour->deadline);
}
return view('tour.index')->with('tours',$tours)->with('participantCount',$participantCount);
return view('tour.index')->with('tours', $tours)->with('participantCount', $participantCount);
}
public function index_old()
{
error_log("Tour:index_old");
$tours=Tour::where('start','<',Carbon::now())->orderBy('start')->get();
$participantCount=array();
foreach($tours as $key => $tour) {
$tours = Tour::where('start', '<', Carbon::now())->orderBy('start')->get();
$participantCount = array();
foreach ($tours as $key => $tour) {
$result = DB::select('select count(*) as cnt from bookings where tour_id=?', [$tour->id]);
$participantCount[$tour->id] = $result[0]->cnt;
$tours[$key]->start=Tour::toGermanDate($tour->start);
$tours[$key]->deadline=Tour::toGermanDate($tour->deadline);
$tours[$key]->start = Tour::toGermanDate($tour->start);
$tours[$key]->deadline = Tour::toGermanDate($tour->deadline);
}
return view('tour.index_old')->with('tours',$tours)->with('participantCount',$participantCount);
return view('tour.index_old')->with('tours', $tours)->with('participantCount', $participantCount);
}
/*
/*
/**
@ -62,10 +62,10 @@ class TourController extends Controller
{
error_log("Tour:create");
$tour = new Tour;
$tour->name="neue Tour";
$tour->beschreibung="Tour Beschreibung";
$tour->user_id=Auth::user()->id;
return view('tour.create')->with('tour',$tour);
$tour->name = "neue Tour";
$tour->beschreibung = "Tour Beschreibung";
$tour->user_id = Auth::user()->id;
return view('tour.create')->with('tour', $tour);
}
/**
@ -80,26 +80,26 @@ class TourController extends Controller
$request->validate(
[
'name'=>'required|min:3',
'beschreibung'=>'required',
'start'=>'required',
'deadline'=>'required',
'user_id'=>'required',
'bild'=>'mimes:jpg,jpeg,bmp,png,gif'
'name' => 'required|min:3',
'beschreibung' => 'required',
'start' => 'required',
'deadline' => 'required',
'user_id' => 'required',
'bild' => 'mimes:jpg,jpeg,bmp,png,gif'
]
);
$tour=new Tour;
$tour->name=$request->input('name');
$tour->user_id=$request->input('user_id');
$tour->beschreibung=$request->input('beschreibung');
$tour->start=Tour::toDBDate($request->input('start'));
$tour->deadline=Tour::toDBDate($request->input('deadline'));
$tour->max_participants=$request->input('max_participants');
$tour->is_cancelled=$request->input('is_cancelled',false);
$tour = new Tour;
$tour->name = $request->input('name');
$tour->user_id = $request->input('user_id');
$tour->beschreibung = $request->input('beschreibung');
$tour->start = Tour::toDBDate($request->input('start'));
$tour->deadline = Tour::toDBDate($request->input('deadline'));
$tour->max_participants = $request->input('max_participants');
$tour->is_cancelled = $request->input('is_cancelled', false);
$tour->save();
error_log("Stored deadline:".$tour->deadline);
error_log("Stored deadline:" . $tour->deadline);
return redirect('/tour');
}
@ -113,15 +113,15 @@ class TourController extends Controller
public function show(Tour $tour)
{
$creator = User::find($tour->user_id);
$bookings = Booking::where('tour_id',$tour->id)->get();
$bookings = Booking::where('tour_id', $tour->id)->get();
$users = array();
foreach($bookings as $booking) {
$user=User::find($booking->user_id);
foreach ($bookings as $booking) {
$user = User::find($booking->user_id);
array_push($users, $user);
}
// Vergangene Tour anzeigen
if($tour->start < Carbon::now()) {
if ($tour->start < Carbon::now()) {
$tour->start = Tour::toGermanDate($tour->start);
$tour->deadline = Tour::toGermanDate($tour->deadline);
return view('tour.show_old')
@ -131,7 +131,7 @@ class TourController extends Controller
}
// Zukünftige Tour anzeigen
$rooms=$this->fetch_rooms($tour->id);
$rooms = $this->fetch_rooms($tour->id);
$tour->start = Tour::toGermanDate($tour->start);
$tour->deadline = Tour::toGermanDate($tour->deadline);
@ -149,10 +149,11 @@ class TourController extends Controller
* @return \Illuminate\Http\Response
*/
private function fetch_rooms($tour_id) {
private function fetch_rooms($tour_id)
{
// - all existing rooms with booked users (if any)
// - all users without room
$sql="
$sql = "
SELECT
qry.tour_id,
qry.room_id,
@ -176,7 +177,7 @@ class TourController extends Controller
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."
tr.tour_id= " . $tour_id . "
) qry
LEFT JOIN users as u
@ -201,7 +202,7 @@ class TourController extends Controller
LEFT JOIN tour_rooms as tr
ON b.room_id = tr.id
WHERE
b.tour_id= ".$tour_id."
b.tour_id= " . $tour_id . "
AND
b.user_id = u.id
AND
@ -210,19 +211,21 @@ class TourController extends Controller
;
";
$rooms=DB::select($sql);
$rooms = DB::select($sql);
Log::info("TourController.fetch_rooms, returning rooms result:");
Log::info($rooms);
//Log::info("TourController.fetch_rooms, returning rooms result:");
//Log::info($rooms);
return($rooms);
return ($rooms);
}
public function edit(Tour $tour)
{
if (Auth::user()->role != 'ADMIN') {return redirect('/tour');}
if (Auth::user()->role != 'ADMIN') {
return redirect('/tour');
}
error_log("Tour:edit");
if ($tour->start<Carbon::now()) {
if ($tour->start < Carbon::now()) {
return view('tour.edit_old')->with('tour', $tour);
}
@ -232,7 +235,6 @@ class TourController extends Controller
$rooms = $this->fetch_rooms($tour->id);
return view('tour.edit')
->with('tour', $tour)
->with('rooms', $rooms);
@ -249,61 +251,62 @@ class TourController extends Controller
{
error_log("Tour:update");
$tour=Tour::find($request->input('tour_id'));
$tour = Tour::find($request->input('tour_id'));
$request->validate(
[
'tour_id' => 'required',
'name'=>'required|min:3',
'user_id'=>'required',
'bild'=>'mimes:jpg,jpeg,bmp,png,gif'
'name' => 'required|min:3',
'user_id' => 'required',
'bild' => 'mimes:jpg,jpeg,bmp,png,gif'
]
);
if ($request->bild){
if ($request->bild) {
$bild = Image::make($request->bild);
$breite = $bild->width();
$hoehe = $bild->height();
if ($breite>$hoehe) {
if ($breite > $hoehe) {
Image::make($request->bild)
->widen(1200)
->save(public_path().'/img/tour/'.$tour->id.'_gross.jpg');
->save(public_path() . '/img/tour/' . $tour->id . '_gross.jpg');
Image::make($request->bild)
->widen(64)
->save(public_path().'/img/tour/'.$tour->id.'.jpg');
}else {
->save(public_path() . '/img/tour/' . $tour->id . '.jpg');
} else {
Image::make($request->bild)
->heighten(900)
->save(public_path().'/img/tour/'.$tour->id.'_gross.jpg');
->save(public_path() . '/img/tour/' . $tour->id . '_gross.jpg');
Image::make($request->bild)
->widen(96)
->save(public_path().'/img/tour/'.$tour->id.'.jpg');
->save(public_path() . '/img/tour/' . $tour->id . '.jpg');
}
}
$tour->name=$request->input('name');
if ($request->beschreibung) $tour->beschreibung=$request->input('beschreibung');
if ($request->start) $tour->start=Tour::toDBDate($request->input('start'));
if ($request->deadline) $tour->deadline=Tour::toDBDate($request->input('deadline'));
if ($request->max_participants) $tour->max_participants=$request->input('max_participants');
$tour->is_cancelled= ($request->has('is_cancelled'));
if ($request->bericht) $tour->bericht=$request->bericht;
$tour->name = $request->input('name');
if ($request->beschreibung) $tour->beschreibung = $request->input('beschreibung');
if ($request->start) $tour->start = Tour::toDBDate($request->input('start'));
if ($request->deadline) $tour->deadline = Tour::toDBDate($request->input('deadline'));
if ($request->max_participants) $tour->max_participants = $request->input('max_participants');
$tour->is_cancelled = ($request->has('is_cancelled'));
if ($request->bericht) $tour->bericht = $request->bericht;
$tour->save();
error_log("Is cancelled:". $tour->is_cancelled);
error_log("Is cancelled:" . $tour->is_cancelled);
return redirect('/tour');
}
/*
/*
public function create_room($tour_id, $capacity) {
DB::delete("INSERT INTO booking_rooms")
}
*/
*/
public function upload_gallery(Request $request, Tour $tour){
public function upload_gallery(Request $request, Tour $tour)
{
dd($request);
}
@ -319,15 +322,18 @@ 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");
$user_id = Auth::user()->id;
Tour::join_room($tour_id,$user_id, $room_id);
return redirect('/tour/'.$tour_id);
Tour::join_room($tour_id, $user_id, $room_id);
return redirect('/tour/' . $tour_id);
}
public function join_room4user($tour_id,$room_id,$user_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::join_room($tour_id, $user_id, $room_id);
$tour = Tour::find($tour_id);
$tour->start = Tour::toGermanDate($tour->start);
@ -339,34 +345,40 @@ class TourController extends Controller
->with('tour', $tour)
->with('rooms', $rooms);
return redirect('/tour/'.$tour_id);
return redirect('/tour/' . $tour_id);
}
public function cancelBooking($tour_id) {
$user=Auth::user();
public function cancelBooking($tour_id)
{
$user = Auth::user();
Booking::where('tour_id', $tour_id)->where('user_id', $user->id)->delete();
return redirect('/tour');
}
public function cancelBookingAdmin($tour_id, $user_id) {
$user=Auth::user();
public function cancelBookingAdmin($tour_id, $user_id)
{
$user = Auth::user();
if (Auth::user()->role == "ADMIN") {
Booking::where('tour_id', $tour_id)->where('user_id', $user_id)->delete();
}
return redirect('/tour/'.$tour_id);
return redirect('/tour/' . $tour_id);
}
public function create_room($tour_id,$capacity) {
public function create_room($tour_id, $capacity)
{
Log::info("create_room Controller started");
$user=Auth::user();
Tour::create_room($tour_id,$capacity);
return redirect('tour/'.$tour_id.'/edit');
$user = Auth::user();
Tour::create_room($tour_id, $capacity);
return redirect('tour/' . $tour_id . '/edit');
}
public function delete_room($tour_id,$room_id) {
Log::info("create_room Controller started");
$user=Auth::user();
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');
public function delete_room($tour_id, $room_id)
{
Log::info("create_room Controller started");
$user = Auth::user();
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');
}
}
}

View file

@ -1,60 +1,79 @@
<?php
namespace App;
namespace App;
use Illuminate\Database\Eloquent\Model;
use Carbon\Carbon;
use Illuminate\Support\Facades\DB;
use Log;
use Illuminate\Database\Eloquent\Model;
use Carbon\Carbon;
use Illuminate\Support\Facades\DB;
use Log;
class Tour extends Model
{
class Tour extends Model
{
protected $fillable = [
'id', 'name', 'beschreibung','user_id','start','deadline','is_cancelled', 'status'
'id', 'name', 'beschreibung', 'user_id', 'start', 'deadline', 'is_cancelled', 'status', 'bericht', 'max_participants'
];
public static function getBookings($tour_id) {
error_log("getBookings for tour_id: ".$tour_id);
$bookings=Booking::where('tour_id',$tour_id)->get();
public static function getBookings($tour_id)
{
error_log("getBookings for tour_id: " . $tour_id);
$bookings = Booking::where('tour_id', $tour_id)->get();
return $bookings;
}
public static function has_participant($tour_id, $user_id) {
$booking=Booking::where('tour_id', $tour_id)->where('user_id',$user_id)->first();
if($booking) return true;
public static function has_participant($tour_id, $user_id)
{
$booking = Booking::where('tour_id', $tour_id)->where('user_id', $user_id)->first();
if ($booking) return true;
return false;
}
public static function has_space($tour_id)
{
//$tour = Tour::where("id", $tour_id)->get();
//Log::info($tour[0]);
$tour = Tour::find($tour_id);
//Log::info($tour);
$bookings = Booking::where('tour_id', $tour_id)->get();
if (count($bookings) >= $tour->max_participants) return false;
return true;
}
// new join with room parameter
public static function join_room($tour_id, $user_id, $room_id) {
Log::info("Tour::join_room, tour_id=".$tour_id.", user_id=".$user_id.", room_id=".$room_id);
public static function join_room($tour_id, $user_id, $room_id)
{
Log::info("Tour::join_room, tour_id=" . $tour_id . ", user_id=" . $user_id . ", room_id=" . $room_id);
$booking = Booking::firstOrCreate(
['tour_id' => $tour_id, 'user_id' => $user_id], // Retrieve if existing
['tour_id' => $tour_id, 'user_id' => $user_id, 'room_id' => $room_id,
'created_at' => Carbon::now(), 'updated_at' => Carbon::now() ] // or create new
'created_at' => Carbon::now(), 'updated_at' => Carbon::now()] // or create new
);
$booking->room_id=$room_id;
$booking->room_id = $room_id;
$booking->save();
//Log::info($booking);
}
public static function cancel($tour_id, $user_id) {
Booking::where('tour_id',$tour_id)->where('user_id',$user_id)->delete();
public static function cancel($tour_id, $user_id)
{
Booking::where('tour_id', $tour_id)->where('user_id', $user_id)->delete();
}
public static function is_over($tour_id) {
public static function is_over($tour_id)
{
$tour = Tour::find($tour_id);
if ($tour->start < Carbon::now()) return true;
return false;
}
public static function create_room($tour_id,$capacity) {
public static function create_room($tour_id, $capacity)
{
$tour = Tour::find($tour_id);
$name="Einzelzimmer";
if ($capacity!=1) { $name="Doppelzimmer";}
$sql="INSERT INTO tour_rooms (name,tour_id,capacity,created_at,updated_at) VALUES ('".$name."',".$tour_id.",".$capacity.",now(),now());";
$name = "Einzelzimmer";
if ($capacity != 1) {
$name = "Doppelzimmer";
}
$sql = "INSERT INTO tour_rooms (name,tour_id,capacity,created_at,updated_at) VALUES ('" . $name . "'," . $tour_id . "," . $capacity . ",now(),now());";
DB::insert($sql);
}
@ -67,7 +86,7 @@ class Tour extends Model
$month = $values[1];
$day = $values[2];
return $day.".".$month.".".$year;
return $day . "." . $month . "." . $year;
}
public static function toDBDate($deDate)
@ -76,13 +95,13 @@ class Tour extends Model
$values = explode(" ", $deDate);
$year = explode(".",$values[0])[2];
$month = explode(".",$values[0])[1];
$year = explode(".", $values[0])[2];
$month = explode(".", $values[0])[1];
$day = explode(".", $values[0])[0];
$dbDate=$year . "-" . $month . "-" . $day;
$dbDate = $year . "-" . $month . "-" . $day;
//Log::info("deDate=".$deDate." converted to:".$dbDate);
return $dbDate;
}
}
}

View file

@ -1,13 +1,13 @@
<?php
namespace App;
namespace App;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
class User extends Authenticatable
{
class User extends Authenticatable
{
use Notifiable;
/**
@ -37,11 +37,12 @@ class User extends Authenticatable
'email_verified_at' => 'datetime',
];
public static function has_tour($tour_id, $user_id) {
$tour=Tour::find($tour_id);
$user=User::first($user_id);
$booking=Booking::where('tour_id', $tour_id)->where('user_id', $user_id);
public static function has_tour($tour_id, $user_id)
{
// $tour=Tour::find($tour_id);
// $user=User::first($user_id);
$booking = Booking::where('tour_id', $tour_id)->where('user_id', $user_id);
if ($booking) return true;
return false;
}
}
}

View file

@ -12,33 +12,41 @@
<div class="card-body">
<form style="background-color: #fff;" class="text-dark" method="post" action="" enctype="multipart/form-data">
<form style="background-color: #fff;" class="text-dark" method="post" action=""
enctype="multipart/form-data">
@csrf
<div class="" style="display:flex;">
<!-- label class="ml-2 mt-4 col-form-label col-form-label-sm" style="width:150px; text-align:left;" for="name"><h4>Name:</h4></label> -->
<label class="ml-2" style="width:180px; text-align:left;font-size:18px;" for="name">Name:</label>
<input class="mr-1 form-control" type="text" id="name" name="name" value="{{ old('name') ?? $tour->name }}" readonly >
<input class="mr-1 form-control" type="text" id="name" name="name"
value="{{ old('name') ?? $tour->name }}" readonly>
</div>
<div class="mt-1" style="display:flex;">
<label class="ml-2" style="width:180px; text-align:left;font-size:18px;" for="name">Start:</label>
<input class="mr-1 form-control" type="text" id="start" name="start" value="{{ old('start') ?? $tour->start }}" readonly >
<input class="mr-1 form-control" type="text" id="start" name="start"
value="{{ old('start') ?? $tour->start }}" readonly>
</div>
<div class="mt-1" style="display:flex;">
<label class="ml-2" style="width:180px; text-align:left;font-size:18px;" for="creator">Ansprechpartner:</label>
<input class="mr-1 form-control" type="text" id="creator" name="creator" value="{{ old('creator') ?? $creator->name }}" readonly >
<input class="mr-1 form-control" type="text" id="creator" name="creator"
value="{{ old('creator') ?? $creator->name }}" readonly>
</div>
<div class="mt-1" style="display:flex;">
<label class="ml-2" style="width:180px; text-align:left;font-size:18px;" for="name">Anmeldeschluss:</label>
<input class="mr-1 form-control" type="text" id="anmeldeschluss" style="font-size:16px;" name="deadline" value="{{ old('anmeldeschluss') ?? $tour->deadline }}" readonly >
<input class="mr-1 form-control" type="text" id="anmeldeschluss" style="font-size:16px;"
name="deadline" value="{{ old('anmeldeschluss') ?? $tour->deadline }}" readonly>
</div>
<div class="mt-1" style="display:flex;">
<label class="ml-2" style="width:180px; text-align:left;font-size:18px;" for="name">Max Teilnehmer:</label>
<input class="mr-1 form-control" type="text" id="max_participants" style="font-size:16px;" name="max_participants" value="{{ old('max_participants') ?? $tour->max_participants }}" required >
<label class="ml-2" style="width:180px; text-align:left;font-size:18px;" for="name">Max
Teilnehmer:</label>
<input class="mr-1 form-control" type="text" id="max_participants"
style="font-size:16px;" name="max_participants"
value="{{ old('max_participants') ?? $tour->max_participants }}" required>
</div>
@if(App\Tour::has_participant($tour->id, Auth::user()->id))
@ -50,16 +58,19 @@
@if(file_exists (public_path ('img/tour/'.$tour->id.'.jpg')))
<!--File exists -->
<a href="/img/tour/{{$tour->id}}_gross.jpg" data-lightbox="{{$tour->id}}_gross.jpg" data-title="{{ $tour->name }}">
<img src="/img/tour/{{$tour->id}}.jpg" class="mt-3 ml-3" >
<a href="/img/tour/{{$tour->id}}_gross.jpg" data-lightbox="{{$tour->id}}_gross.jpg"
data-title="{{ $tour->name }}">
<img src="/img/tour/{{$tour->id}}.jpg" class="mt-3 ml-3">
</a>
@else
<img src="/img/placeholder/tour128x100.jpg" class="mt-3 ml-3" >
<img src="/img/placeholder/tour128x100.jpg" class="mt-3 ml-3">
@endif
<div class="mt-1" style="display:flex;">
<label class="ml-2" style="width:140px; text-align:left;font-size:18px;" for="is_cancelled">Storniert:</label>
<input class="mr-1 form-control" type="checkbox" id="is_cancelled" style="font-size:10px;width:20px;" name="is_cancelled"
<label class="ml-2" style="width:140px; text-align:left;font-size:18px;"
for="is_cancelled">Storniert:</label>
<input class="mr-1 form-control" type="checkbox" id="is_cancelled"
style="font-size:10px;width:20px;" name="is_cancelled"
@if($tour->is_cancelled)
checked
@endif
@ -74,15 +85,20 @@
<!-- TODO: Only if owner or admin -->
@if(Auth::user()->role=="ADMIN")
<a href="/tour/{{$tour->id}}/edit"><div type="submit" class="btn btn-danger col-3 mb-2 float-left mr-2">Bearbeiten</div></a>
<a href="/tour/{{$tour->id}}/edit">
<div type="submit" class="btn btn-danger col-3 mb-2 float-left mr-2">Bearbeiten
</div>
</a>
@endif
<a href="/tour" type="submit" class="btn btn-success col-3 mb-2 float-right mr-2">Ok</a>
@if(!App\Tour::has_participant($tour->id, Auth::user()->id))
@if(!App\Tour::has_participant($tour->id, Auth::user()->id) && App\Tour::has_space($tour->id))
<!-- Connected to Modal -->
<button id="myBtn" class="btn btn-danger float-left">Teilnehmen</button>
@else
<a href="/tour/{{$tour->id}}/cancelBooking" type="submit" class="btn btn-danger col-3 mb-2 float-right mr-2">Absagen</a>
@endif
@if(App\Tour::has_participant($tour->id, Auth::user()->id))
<a href="/tour/{{$tour->id}}/cancelBooking" type="submit"
class="btn btn-danger col-3 mb-2 float-right mr-2">Absagen</a>
@endif
</form>
@ -102,14 +118,16 @@
<!-- 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->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 href="/tour/{{$tour->id}}/join/{{$room->room_id}}"> ==> Buchen</a></b>
</span><b><a href="/tour/{{$tour->id}}/join/{{$room->room_id}}">
==> Buchen</a></b>
</p>
<!-- Intentional Assignment ! -->
@ -149,9 +167,11 @@
@if ($room_id != $room->room_id)
@if($room_id!="")
@if($room->room_name=="Ungebucht")
</div> <div style="height:30px;"></div>
</div>
<div style="height:30px;"></div>
@else
</div> <div style="height:2px;"></div>
</div>
<div style="height:2px;"></div>
@endif
@endif
@ -172,7 +192,8 @@
@endif
@endforeach
</div> <div style="height:2px;"></div>
</div>
<div style="height:2px;"></div>
</div>
@ -203,19 +224,19 @@
var span = document.getElementsByClassName("close")[0];
// When the user clicks on the button, open the modal
btn.onclick = function(e) {
btn.onclick = function (e) {
e.preventDefault();
modal.style.display = "block";
}
// When the user clicks on <span> (x), close the modal
span.onclick = function(e) {
span.onclick = function (e) {
e.preventDefault();
modal.style.display = "none";
}
// When the user clicks anywhere outside of the modal, close it
window.onclick = function(event) {
window.onclick = function (event) {
if (event.target == modal) {
modal.style.display = "none";
}

0
motorradig/setenv.sh Normal file → Executable file
View file