@extends('layouts.app')

@section('title','Edit Transaksi')

@section('content')

<div class="container" style="max-width:920px">
    <div class="card-modern p-4">
        <h3 class="mb-2">Edit Transaksi</h3>

        @if($errors->any())
            <div class="alert alert-danger"><ul class="mb-0">@foreach($errors->all() as $error)<li>{{ $error }}</li>@endforeach</ul></div>
        @endif

        <form action="{{ route('transaksi.update',$transaksi->id) }}" method="POST">
            @csrf @method('PUT')
            <div class="row g-3">
                <div class="col-md-6">
                    <label class="form-label small">Tiket</label>
                    <select name="tiket_id" class="form-control input-rounded">
                        @foreach($tikets as $tiket)
                            <option value="{{ $tiket->id }}" {{ $transaksi->tiket_id==$tiket->id ? 'selected':'' }}>{{ $tiket->event->nama_event }} - {{ $tiket->jenis }}</option>
                        @endforeach
                    </select>
                </div>
                <div class="col-md-6">
                    <div class="floating-label">
                        <input type="text" name="nama_pembeli" class="input-rounded form-control" placeholder=" " value="{{ old('nama_pembeli',$transaksi->nama_pembeli) }}" required>
                        <label>Nama Pembeli</label>
                    </div>
                </div>

                <div class="col-md-4">
                    <div class="floating-label">
                        <input type="number" name="jumlah" class="input-rounded form-control" placeholder=" " value="{{ old('jumlah',$transaksi->jumlah) }}" required>
                        <label>Jumlah</label>
                    </div>
                </div>

                <div class="col-md-4">
                    <div class="floating-label">
                        <input type="number" name="total_harga" class="input-rounded form-control" placeholder=" " value="{{ old('total_harga',$transaksi->total_harga) }}" required>
                        <label>Total Harga (Rp)</label>
                    </div>
                </div>

                <div class="col-md-4">
                    <label class="form-label small">Metode Pembayaran</label>
                    <select name="metode_pembayaran" class="form-control input-rounded">
                        <option value="Pending" {{ $transaksi->metode_pembayaran=="Pending" ? 'selected':'' }}>Pending</option>
                        <option value="Confirmed" {{ $transaksi->metode_pembayaran=="Confirmed" ? 'selected':'' }}>Confirmed</option>
                        <option value="Rejected" {{ $transaksi->metode_pembayaran=="Rejected" ? 'selected':'' }}>Rejected</option>
                    </select>
                </div>

                <div class="col-md-4">
                    <label class="form-label small">Status</label>
                    <select name="status" class="form-control input-rounded">
                        <option value="Pending" {{ $transaksi->status=="Pending" ? 'selected':'' }}>Pending</option>
                        <option value="Confirmed" {{ $transaksi->status=="Confirmed" ? 'selected':'' }}>Confirmed</option>
                        <option value="Rejected" {{ $transaksi->status=="Rejected" ? 'selected':'' }}>Rejected</option>
                    </select>
                </div>
            </div>

            <div class="mt-3 d-flex gap-2">
                <button class="btn btn-primary">Update</button>
                <a href="{{ route('transaksi.index') }}" class="btn btn-outline-secondary">Batal</a>
            </div>
        </form>
    </div>
</div>

@endsection