@extends('layouts.app')

@section('content')
    <div class="container-fluid p-4">
        <div class="card shadow-sm p-3">
            <h4 class="fw-bold" style="color: #063986;">Edit Booking</h4>
            <form action="{{ route('admin.updatebooking', ['id_booking' => $booking->id_booking]) }}" method="POST" enctype="multipart/form-data">
                @csrf
                @method('PUT')
                
                <div class="mb-3">
                    <label for="id_user" class="form-label">Nama Customer</label>
                    <select name="id_user" id="id_user" class="form-control" required>
                        <option value="">Pilih Customer</option>
                        @foreach($users as $user)
                            <option value="{{ $user->id_user }}" {{ $booking->id_user == $user->id_user ? 'selected' : '' }}>
                                {{ $user->name }}
                            </option>
                        @endforeach
                    </select>
                </div>

                <div class="mb-3">
                    <label for="id_kamar" class="form-label">Nomor Kamar</label>
                    <select name="id_kamar" id="id_kamar" class="form-control" required>
                        <option value="">Pilih Kamar</option>
                        @foreach($rooms as $room)
                            <option value="{{ $room->id_kamar }}" {{ $booking->id_kamar == $room->id_kamar ? 'selected' : '' }}>
                                {{ $room->room_number }}
                            </option>
                        @endforeach
                    </select>
                </div>

                <div class="mb-3">
                    <label for="tanggal_booking" class="form-label">Tanggal Booking</label>
                    <input type="date" name="tanggal_booking" id="tanggal_booking" class="form-control" 
                           value="{{ old('tanggal_booking', $booking->tanggal_booking) }}" required>
                </div>

                <div class="mb-3">
                    <label for="tanggal_checkin" class="form-label">Tanggal Check-in</label>
                    <input type="date" name="tanggal_checkin" id="tanggal_checkin" class="form-control" 
                           value="{{ old('tanggal_checkin', $booking->tanggal_checkin) }}" required>
                </div>

                <div class="mb-3">
                    <label for="tanggal_checkout" class="form-label">Tanggal Check-out</label>
                    <input type="date" name="tanggal_checkout" id="tanggal_checkout" class="form-control" 
                           value="{{ old('tanggal_checkout', $booking->tanggal_checkout) }}" required>
                </div>

                <div class="mb-3">
                    <label for="status_booking" class="form-label">Status Booking</label>
                    <select name="status_booking" id="status_booking" class="form-control" required>
                        <option value="Pending" {{ $booking->status_booking == 'Pending' ? 'selected' : '' }}>Pending</option>
                        <option value="Dikonfirmasi" {{ $booking->status_booking == 'Dikonfirmasi' ? 'selected' : '' }}>Dikonfirmasi</option>
                        <option value="Dibatalkan" {{ $booking->status_booking == 'Dibatalkan' ? 'selected' : '' }}>Dibatalkan</option>
                    </select>
                </div>

                <div class="d-flex justify-content-between">
                    <a href="{{ route('admin.booking') }}" class="btn btn-secondary">Batal</a>
                    <button type="submit" class="btn text-white" style="background: linear-gradient(135deg, #8AC0DF, #48499B);">Simpan</button>
                </div>
            </form>
        </div>
    </div>
@endsection
