LMIV-SNACKAUTOMAT/resources/views/layouts/vending.blade.php

155 lines
7.7 KiB
PHP

<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="csrf-token" content="{{ csrf_token() }}">
<title>@yield('title', 'LMIV Snackautomat')</title>
<!-- Tailwind CSS via CDN -->
<script src="https://cdn.tailwindcss.com"></script>
<!-- Alpine.js für interaktive Elemente -->
<script defer src="https://unpkg.com/alpinejs@3.x.x/dist/cdn.min.js"></script>
@yield('head')
</head>
<body class="bg-gray-100 min-h-screen flex flex-col">
@php
// Prüfe, ob wir auf der Welcome-Seite sind
$isWelcomePage = request()->route()->getName() === 'vending.index';
// Prüfe, ob wir im öffentlichen Kontext sind:
// 1. QR-Code Kontext (public_slug in der URL) ODER
// 2. Normaler Mandanten-Kontext OHNE Anmeldung
$isPublicSlugContext = request()->route('publicSlug') !== null;
$isTenantContext = request()->route('tenant') !== null;
$isPublicContext = (!auth()->check()) && ($isPublicSlugContext || $isTenantContext);
@endphp
<!-- Navigation -->
@if($isWelcomePage)
<!-- Welcome Page Navigation - nur Admin Login -->
<nav class="bg-blue-600 text-white shadow-lg">
<div class="max-w-7xl mx-auto px-4">
<div class="flex justify-between h-16">
<div class="flex items-center">
<a href="{{ route('vending.index') }}" class="text-xl font-bold">
LMIV Snackautomat
</a>
</div>
<div class="flex items-center space-x-4">
@auth
<a href="{{ route('admin.dashboard') }}" class="hover:text-blue-200">
Admin Dashboard
</a>
<form method="POST" action="{{ route('logout') }}" class="inline">
@csrf
<button type="submit" class="hover:text-blue-200">
Abmelden ({{ Auth::user()->email }}@if(session('current_tenant')) - {{ session('current_tenant')->name }}@endif)
</button>
</form>
@else
<a href="{{ route('login') }}" class="hover:text-blue-200 font-medium">
Admin Login
</a>
@endauth
</div>
</div>
</div>
</nav>
@elseif(!$isPublicContext)
<!-- Standard Navigation für andere Seiten -->
<nav class="bg-blue-600 text-white shadow-lg">
<div class="max-w-7xl mx-auto px-4">
<div class="flex justify-between h-16">
<div class="flex items-center">
<a href="{{ route('vending.index') }}" class="text-xl font-bold">
LMIV Snackautomat
</a>
</div>
<div class="flex items-center space-x-4">
@if(!Auth::check() || Auth::user()->isSuperAdmin())
<a href="{{ route('vending.tenants') }}" class="hover:text-blue-200">
Mandanten
</a>
@endif
@auth
<a href="{{ route('admin.dashboard') }}" class="hover:text-blue-200">
Admin-Dashboard
</a>
@if(Auth::user()->isSuperAdmin())
<div class="relative" x-data="{ open: false }">
<button @click="open = !open" class="hover:text-blue-200 flex items-center">
Mandanten
<svg class="w-4 h-4 ml-1" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7"></path>
</svg>
</button>
<div x-show="open" @click.away="open = false" x-transition:enter="transition ease-out duration-200" x-transition:enter-start="opacity-0 scale-95" x-transition:enter-end="opacity-100 scale-100" x-transition:leave="transition ease-in duration-75" x-transition:leave-start="opacity-100 scale-100" x-transition:leave-end="opacity-0 scale-95" class="absolute right-0 mt-2 w-48 bg-white rounded-md shadow-lg py-1 z-50">
<a href="{{ route('tenants.select') }}" class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100">Mandant wählen</a>
<a href="{{ route('admin.tenants.index') }}" class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100">Mandanten verwalten</a>
@if(session('current_tenant'))
<div class="border-t border-gray-100"></div>
<a href="{{ route('tenants.leave') }}" class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100">
Mandant verlassen
</a>
<div class="px-4 py-2 text-xs text-gray-500">
Aktuell: {{ session('current_tenant')->name }}
</div>
@endif
</div>
</div>
@endif
<form method="POST" action="{{ route('logout') }}" class="inline">
@csrf
<button type="submit" class="hover:text-blue-200">
Abmelden ({{ Auth::user()->name }}@if(session('current_tenant')) - {{ session('current_tenant')->name }}@endif)
</button>
</form>
@else
@endauth
</div>
</div>
</div>
</nav>
@endif
<!-- Flash Messages -->
@if(session('success'))
<div class="bg-green-100 border border-green-400 text-green-700 px-4 py-3 rounded mx-4 mt-4" role="alert">
<span class="block sm:inline">{{ session('success') }}</span>
</div>
@endif
@if(session('error'))
<div class="bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded mx-4 mt-4" role="alert">
<span class="block sm:inline">{{ session('error') }}</span>
</div>
@endif
<!-- Main Content -->
<main class="flex-1 {{ $isPublicContext ? 'py-6' : 'py-6' }}">
@yield('content')
</main>
<!-- Footer - vereinfacht für öffentliche Benutzer -->
@if($isPublicContext)
<footer class="bg-gray-800 text-white py-4 mt-auto">
<div class="max-w-7xl mx-auto px-4 text-center">
<p>&copy; {{ date('Y') }} LMIV Snackautomat</p>
</div>
</footer>
@else
<footer class="bg-gray-800 text-white py-4 mt-auto">
<div class="max-w-7xl mx-auto px-4 text-center">
<p>&copy; {{ date('Y') }} LMIV Snackautomat System</p>
</div>
</footer>
@endif
@yield('scripts')
</body>
</html>