276 lines
14 KiB
PHP
276 lines
14 KiB
PHP
@extends('layouts.vending')
|
|
|
|
@section('title', isset($tenant) ? $tenant->name . ' - Snackautomat' : 'Snackautomat')
|
|
|
|
@section('content')
|
|
<div class="max-w-7xl mx-auto px-4">
|
|
@if(isset($tenant))
|
|
<!-- Tenant Header -->
|
|
<div class="mb-6 bg-white rounded-lg shadow p-6">
|
|
<div class="flex items-center justify-between">
|
|
<div class="flex items-center">
|
|
@if($tenant->logo)
|
|
<img src="{{ asset('storage/' . $tenant->logo) }}"
|
|
alt="{{ $tenant->name }} Logo"
|
|
class="h-16 w-16 object-contain mr-4">
|
|
@endif
|
|
<div>
|
|
<h1 class="text-2xl font-bold text-gray-900">{{ $tenant->name }}</h1>
|
|
@if($tenant->description)
|
|
<p class="text-gray-600">{{ $tenant->description }}</p>
|
|
@endif
|
|
</div>
|
|
</div>
|
|
|
|
@php
|
|
$isPublicSlugContext = request()->route('publicSlug') !== null;
|
|
$isTenantContext = request()->route('tenant') !== null;
|
|
$isPublicContext = (!auth()->check()) && ($isPublicSlugContext || $isTenantContext);
|
|
@endphp
|
|
|
|
@if(!$isPublicContext)
|
|
@auth
|
|
@if(Auth::user()->isSuperAdmin())
|
|
<a href="{{ route('vending.tenants') }}"
|
|
class="text-blue-600 hover:text-blue-800 text-sm">
|
|
← Alle Mandanten
|
|
</a>
|
|
@elseif(Auth::user()->isTenantAdmin())
|
|
<a href="javascript:history.back()"
|
|
class="text-blue-600 hover:text-blue-800 text-sm">
|
|
← Zurück
|
|
</a>
|
|
@endif
|
|
@else
|
|
<a href="{{ route('vending.tenants') }}"
|
|
class="text-blue-600 hover:text-blue-800 text-sm">
|
|
← Alle Mandanten
|
|
</a>
|
|
@endauth
|
|
@endif
|
|
</div>
|
|
</div>
|
|
@endif
|
|
|
|
<!-- Machine Selection - nur für eingeloggte Benutzer oder wenn mehr als 1 Automat und nicht im öffentlichen Kontext -->
|
|
@php
|
|
$isPublicSlugContext = request()->route('publicSlug') !== null;
|
|
$isTenantContext = request()->route('tenant') !== null;
|
|
$isPublicContext = (!auth()->check()) && ($isPublicSlugContext || $isTenantContext);
|
|
$showMachineSelection = $vendingMachines->count() > 1 && !$isPublicContext;
|
|
@endphp
|
|
|
|
@if($showMachineSelection)
|
|
<div class="mb-6">
|
|
<h2 class="text-2xl font-bold mb-4">
|
|
Automat auswählen
|
|
@if($isPublicSlugContext && auth()->check())
|
|
<span class="text-sm font-normal text-gray-600">(Admin-Modus)</span>
|
|
@endif
|
|
</h2>
|
|
<div class="grid grid-cols-1 md:grid-cols-3 gap-4">
|
|
@foreach($vendingMachines as $machine)
|
|
@php
|
|
// Prüfe ob wir im public_slug Kontext sind (über URL-Parameter)
|
|
$isPublicSlugContext = request()->route('publicSlug') !== null;
|
|
|
|
if (isset($tenant)) {
|
|
if ($isPublicSlugContext && $tenant->public_slug) {
|
|
$machineUrl = route('vending.public.machine', ['publicSlug' => $tenant->public_slug, 'machineNumber' => $machine->machine_number]);
|
|
} else {
|
|
$machineUrl = route('vending.public.machine', ['publicSlug' => $tenant->public_slug, 'machineNumber' => $machine->machine_number]);
|
|
}
|
|
} else {
|
|
// Fallback für Maschinen ohne Mandant - sollte nicht vorkommen
|
|
$machineUrl = '#';
|
|
}
|
|
@endphp
|
|
<a href="{{ $machineUrl }}"
|
|
class="block p-4 border rounded-lg {{ $selectedMachine && $selectedMachine->id === $machine->id ? 'border-blue-500 bg-blue-50' : 'border-gray-300 hover:border-gray-400' }}">
|
|
<h3 class="font-semibold">{{ $machine->name }}</h3>
|
|
<p class="text-gray-600">{{ $machine->location }}</p>
|
|
@if($machine->machine_number)
|
|
<p class="text-xs text-blue-600 mt-2">
|
|
Maschinennummer: {{ $machine->machine_number }}
|
|
</p>
|
|
@endif
|
|
<p class="text-xs text-blue-600 mt-1">
|
|
@if(isset($tenant))
|
|
Mandant: {{ $tenant->name }}
|
|
@else
|
|
Direkt-URL: {{ $machineUrl }}
|
|
@endif
|
|
</p>
|
|
</a>
|
|
@endforeach
|
|
</div>
|
|
</div>
|
|
@endif
|
|
|
|
@if($selectedMachine)
|
|
<!-- Machine Info -->
|
|
<div class="mb-6 bg-white rounded-lg shadow p-6">
|
|
<div class="flex justify-between items-start mb-4">
|
|
<div>
|
|
<h1 class="text-3xl font-bold mb-2">{{ $selectedMachine->name }}</h1>
|
|
<p class="text-gray-600 mb-4">{{ $selectedMachine->location }}</p>
|
|
@if($selectedMachine->description)
|
|
<p class="text-gray-700">{{ $selectedMachine->description }}</p>
|
|
@endif
|
|
</div>
|
|
|
|
<!-- Admin Controls für eingeloggte Benutzer -->
|
|
@auth
|
|
@if($isPublicSlugContext)
|
|
<div class="flex flex-col space-y-2">
|
|
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-blue-100 text-blue-800">
|
|
Admin-Modus
|
|
</span>
|
|
<a href="{{ route('vending-machines.show', $selectedMachine) }}"
|
|
class="inline-flex items-center px-3 py-2 border border-gray-300 text-sm font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50"
|
|
target="_blank">
|
|
Bearbeiten
|
|
</a>
|
|
</div>
|
|
@endif
|
|
@else
|
|
@if($isPublicSlugContext)
|
|
<div class="text-right">
|
|
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-green-100 text-green-800">
|
|
QR-Code Ansicht
|
|
</span>
|
|
</div>
|
|
@endif
|
|
@endauth
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Product Grid -->
|
|
<div class="bg-white rounded-lg shadow p-6">
|
|
<h2 class="text-2xl font-bold mb-6">Verfügbare Produkte</h2>
|
|
|
|
@if($selectedMachine->slots->where('is_active', true)->count() > 0)
|
|
<div class="grid grid-cols-2 md:grid-cols-4 lg:grid-cols-6 gap-4">
|
|
@foreach($selectedMachine->slots->where('is_active', true)->sortBy('slot_number') as $slot)
|
|
@php
|
|
$product = $slot->currentProduct();
|
|
$quantity = $slot->products->sum('pivot.quantity');
|
|
@endphp
|
|
|
|
<div class="border rounded-lg p-4 hover:shadow-lg transition-shadow
|
|
{{ $quantity > 0 ? 'cursor-pointer hover:border-blue-500' : 'opacity-50' }}"
|
|
@if($quantity > 0 && $product)
|
|
@php
|
|
$isPublicSlugContext = request()->route('publicSlug') !== null;
|
|
|
|
if (isset($tenant)) {
|
|
if ($isPublicSlugContext && $tenant->public_slug) {
|
|
$productUrl = route('vending.tenant.product', ['publicSlug' => $tenant->public_slug, 'product' => $product->id]);
|
|
} else {
|
|
$productUrl = route('vending.tenant.product', ['publicSlug' => $tenant->slug, 'product' => $product->id]);
|
|
}
|
|
} else {
|
|
$productUrl = route('vending.product', $product);
|
|
}
|
|
@endphp
|
|
onclick="window.location.href='{{ $productUrl }}'"
|
|
@endif>
|
|
|
|
<!-- Slot Number -->
|
|
<div class="text-center mb-2">
|
|
<span class="text-2xl font-bold text-blue-600">{{ $slot->slot_number }}</span>
|
|
</div>
|
|
|
|
@if($product && $quantity > 0)
|
|
<!-- Product Image -->
|
|
<div class="mb-2 text-center">
|
|
@if($product->image)
|
|
<img src="{{ asset('storage/' . $product->image) }}"
|
|
alt="{{ $product->name }}"
|
|
class="w-16 h-16 object-cover mx-auto rounded">
|
|
@else
|
|
<div class="w-16 h-16 bg-gray-200 rounded mx-auto flex items-center justify-center">
|
|
<span class="text-gray-400 text-xs">Kein Bild</span>
|
|
</div>
|
|
@endif
|
|
</div>
|
|
|
|
<!-- Product Info -->
|
|
<div class="text-center">
|
|
<h3 class="font-semibold text-sm mb-1 line-clamp-2">{{ $product->name }}</h3>
|
|
|
|
@if(isset($tenant) && $tenant->show_prices)
|
|
<p class="text-lg font-bold text-green-600">
|
|
{{ number_format($slot->products->first()->pivot->current_price ?? $product->price, 2) }}€
|
|
</p>
|
|
@elseif(!isset($tenant))
|
|
<!-- Wenn kein Mandant gesetzt ist, Preis anzeigen -->
|
|
<p class="text-lg font-bold text-green-600">
|
|
{{ number_format($slot->products->first()->pivot->current_price ?? $product->price, 2) }}€
|
|
</p>
|
|
@endif
|
|
|
|
@if(isset($tenant) && $tenant->show_stock)
|
|
<p class="text-xs text-gray-500">{{ $quantity }} verfügbar</p>
|
|
@elseif(!isset($tenant))
|
|
<!-- Wenn kein Mandant gesetzt ist, Verfügbarkeit anzeigen -->
|
|
<p class="text-xs text-gray-500">{{ $quantity }} verfügbar</p>
|
|
@endif
|
|
</div>
|
|
@else
|
|
<!-- Empty Slot -->
|
|
<div class="text-center py-8">
|
|
<div class="text-gray-400 text-sm">Leer</div>
|
|
</div>
|
|
@endif
|
|
</div>
|
|
@endforeach
|
|
</div>
|
|
@else
|
|
<div class="text-center py-12">
|
|
<p class="text-gray-500">Keine aktiven Fächer in diesem Automaten.</p>
|
|
</div>
|
|
@endif
|
|
</div>
|
|
|
|
<!-- Instructions -->
|
|
<div class="mt-6 bg-blue-50 border border-blue-200 rounded-lg p-4">
|
|
<h3 class="font-semibold text-blue-900 mb-2">Anleitung:</h3>
|
|
<p class="text-blue-800 text-sm">
|
|
Klicken Sie auf ein Produkt mit der entsprechenden Fachnummer, um detaillierte Informationen gemäß LMIV (Lebensmittelinformationsverordnung) anzuzeigen.
|
|
</p>
|
|
</div>
|
|
@else
|
|
<div class="text-center py-12">
|
|
<h2 class="text-2xl font-bold text-gray-600 mb-4">Kein Automat verfügbar</h2>
|
|
<p class="text-gray-500 mb-6">
|
|
@if(isset($tenant))
|
|
Derzeit sind keine aktiven Snackautomaten für {{ $tenant->name }} verfügbar.
|
|
@else
|
|
Derzeit sind keine aktiven Snackautomaten verfügbar.
|
|
@endif
|
|
</p>
|
|
@if(!isset($tenant))
|
|
<a href="{{ route('vending.tenants') }}"
|
|
class="inline-flex items-center px-4 py-2 bg-blue-600 text-white font-medium rounded-md hover:bg-blue-700 transition-colors">
|
|
Mandanten durchsuchen
|
|
<svg class="w-4 h-4 ml-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5l7 7-7 7"></path>
|
|
</svg>
|
|
</a>
|
|
@endif
|
|
</div>
|
|
@endif
|
|
</div>
|
|
@endsection
|
|
|
|
@section('head')
|
|
<style>
|
|
.line-clamp-2 {
|
|
display: -webkit-box;
|
|
-webkit-line-clamp: 2;
|
|
-webkit-box-orient: vertical;
|
|
overflow: hidden;
|
|
}
|
|
</style>
|
|
@endsection |