LMIV-SNACKAUTOMAT/resources/views/admin/vending-machines/edit.blade.php

148 lines
8.1 KiB
PHP

@extends('layouts.vending')
@section('title', $vendingMachine->name . ' bearbeiten')
@section('content')
<div class="max-w-4xl mx-auto px-4">
<div class="mb-8">
<div class="flex items-center space-x-4 mb-4">
<a href="{{ route('vending-machines.index') }}" class="text-blue-600 hover:text-blue-800">
Zurück zur Übersicht
</a>
</div>
<h1 class="text-3xl font-bold text-gray-900">{{ $vendingMachine->name }} bearbeiten</h1>
<p class="text-gray-600 mt-2">Automatendaten bearbeiten</p>
</div>
<form action="{{ route('vending-machines.update', $vendingMachine) }}" method="POST" class="space-y-8">
@csrf
@method('PUT')
<!-- Grundinformationen -->
<div class="bg-white shadow rounded-lg p-6">
<h2 class="text-xl font-semibold text-gray-900 mb-6 border-b border-gray-200 pb-2">
Grundinformationen
</h2>
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
<div>
<label for="name" class="block text-sm font-medium text-gray-700 mb-2">
Automatname *
</label>
<input type="text" id="name" name="name" value="{{ old('name', $vendingMachine->name) }}" required
class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-green-500 @error('name') border-red-500 @enderror">
@error('name')
<p class="mt-1 text-sm text-red-600">{{ $message }}</p>
@enderror
</div>
<div>
<label for="slug" class="block text-sm font-medium text-gray-700 mb-2">
URL-Slug
</label>
<input type="text" id="slug" name="slug" value="{{ old('slug', $vendingMachine->slug) }}"
class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-green-500 @error('slug') border-red-500 @enderror">
<p class="mt-1 text-sm text-gray-500">Aktuell: {{ $vendingMachine->slug }} (Leer lassen für automatische Generierung)</p>
@error('slug')
<p class="mt-1 text-sm text-red-600">{{ $message }}</p>
@enderror
</div>
<div>
<label for="machine_number" class="block text-sm font-medium text-gray-700 mb-2">
Maschinennummer *
</label>
<input type="text" id="machine_number" name="machine_number" value="{{ old('machine_number', $vendingMachine->machine_number) }}" required
placeholder="z.B. automat-1, snackost"
class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-green-500 @error('machine_number') border-red-500 @enderror">
<p class="mt-1 text-sm text-gray-500">Aktuell: {{ $vendingMachine->machine_number }} (für URLs verwendet)</p>
@error('machine_number')
<p class="mt-1 text-sm text-red-600">{{ $message }}</p>
@enderror
</div>
<div class="md:col-span-2">
<label for="location" class="block text-sm font-medium text-gray-700 mb-2">
Standort *
</label>
<input type="text" id="location" name="location" value="{{ old('location', $vendingMachine->location) }}" required
placeholder="z.B. Bürogebäude A, 1. Stock, Pausenbereich"
class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-green-500 @error('location') border-red-500 @enderror">
@error('location')
<p class="mt-1 text-sm text-red-600">{{ $message }}</p>
@enderror
</div>
<div class="md:col-span-2">
<label for="description" class="block text-sm font-medium text-gray-700 mb-2">
Beschreibung
</label>
<textarea id="description" name="description" rows="3"
placeholder="Zusätzliche Informationen zum Automaten..."
class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-green-500 @error('description') border-red-500 @enderror">{{ old('description', $vendingMachine->description) }}</textarea>
@error('description')
<p class="mt-1 text-sm text-red-600">{{ $message }}</p>
@enderror
</div>
<div>
<label class="flex items-center">
<input type="checkbox" name="is_active" id="is_active" value="1"
class="h-4 w-4 text-green-600 focus:ring-green-500 border-gray-300 rounded"
{{ old('is_active', $vendingMachine->is_active) ? 'checked' : '' }}>
<span class="ml-2 text-sm text-gray-700">Automat ist aktiv</span>
</label>
<p class="text-xs text-gray-500 mt-1">Nur aktive Automaten werden öffentlich angezeigt</p>
</div>
</div>
</div>
<!-- Slot-Übersicht -->
<div class="bg-white shadow rounded-lg p-6">
<h2 class="text-xl font-semibold text-gray-900 mb-6 border-b border-gray-200 pb-2">
Slot-Übersicht
</h2>
<div class="grid grid-cols-1 md:grid-cols-2 gap-6 mb-6">
<div class="bg-blue-50 border border-blue-200 rounded-lg p-4">
<h3 class="font-semibold text-blue-900 mb-2">Gesamte Slots</h3>
<p class="text-2xl font-bold text-blue-800">{{ $vendingMachine->slots->count() }}</p>
</div>
<div class="bg-green-50 border border-green-200 rounded-lg p-4">
<h3 class="font-semibold text-green-900 mb-2">Belegte Slots</h3>
<p class="text-2xl font-bold text-green-800">{{ $vendingMachine->slots->whereNotNull('pivot.product_id')->count() }}</p>
</div>
</div>
<div class="flex justify-between items-center">
<p class="text-gray-600">
Verwenden Sie die Slot-Verwaltung, um einzelne Fächer zu konfigurieren und mit Produkten zu befüllen.
</p>
<a href="{{ route('slots.index') }}?machine={{ $vendingMachine->id }}"
class="inline-flex items-center px-4 py-2 border border-purple-300 text-sm font-medium rounded-md text-purple-700 bg-white hover:bg-purple-50">
Slots verwalten
</a>
</div>
</div>
<!-- Aktionsbuttons -->
<div class="flex justify-between items-center bg-gray-50 px-6 py-4 rounded-lg">
<a href="{{ route('vending-machines.index') }}"
class="inline-flex items-center px-4 py-2 border border-gray-300 text-sm font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50">
Abbrechen
</a>
<div class="flex space-x-3">
<a href="{{ route('vending-machines.show', $vendingMachine) }}"
class="inline-flex items-center px-4 py-2 border border-gray-300 text-sm font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50">
Vorschau
</a>
<button type="submit"
class="inline-flex items-center px-4 py-2 border border-transparent text-sm font-medium rounded-md text-white bg-green-600 hover:bg-green-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-green-500">
Änderungen speichern
</button>
</div>
</div>
</form>
</div>
@endsection