@extends('layouts.admin')
@section('styles')
    <link rel="stylesheet" href="{{ asset('assets/admin/css/vendors/select2.css') }}">
@endsection
@section('app')
    <div class="container-fluid">
        <div class="list-product-header">
            <div>
                <a class="btn btn-dark" href="{{ route('manage.transactions') }}">Kembali</a>
            </div>
        </div>
        <div class="card">
            <div class="card-body">
                <form class="row g-3 custom-input" action="{{ route('manage.transaction.store') }}" method="post"
                    enctype="multipart/form-data">
                    @csrf
                    <div class="col-lg-4 position-relative">
                        <label class="form-label" for="barber">Barber
                        </label>
                        <select name="barber" class="form-control @error('barber') is-invalid @enderror select2"
                            id="barber">
                            <option value=""></option>
                            @foreach ($barber as $item)
                                <option value="{{ $item->id }}" @selected(old('barber') == $item->id)>
                                    {{ $item->biography->full_name }}
                                </option>
                            @endforeach
                        </select>
                        @error('barber')
                            <div class="invalid-feedback">
                                {{ $message }}
                            </div>
                        @enderror
                    </div>
                    <div class="col-lg-4 position-relative">
                        <label class="form-label" for="customer">Pelanggan
                        </label>
                        <select name="customer" class="form-control @error('customer') is-invalid @enderror select2"
                            id="customer">
                            <option value=""></option>
                            @foreach ($customers as $customer)
                                <option value="{{ $customer->id }}" @selected(old('customer') == $customer->id)>
                                    {{ $customer->name }}
                                </option>
                            @endforeach
                        </select>
                        @error('customer')
                            <div class="invalid-feedback">
                                {{ $message }}
                            </div>
                        @enderror
                    </div>
                    <div class="col-lg-4 position-relative">
                        <label class="form-label" for="service">Layanan
                        </label>
                        <select name="service" class="form-control @error('service') is-invalid @enderror select2"
                            id="service">
                            <option value=""></option>
                            @foreach ($services as $service)
                                <option value="{{ $service->id }}" @selected(old('service') == $service->id)>
                                    {{ $service->name }}
                                </option>
                            @endforeach
                        </select>
                        @error('service')
                            <div class="invalid-feedback">
                                {{ $message }}
                            </div>
                        @enderror
                    </div>
                    <div class="col-lg-6 position-relative">
                        <label class="form-label" for="price">Harga</label>
                        <input name="price" class="form-control rupiah-format @error('price') is-invalid @enderror"
                            id="price" type="text" placeholder="Masukan Harga" value="{{ old('price') }}"
                            inputmode="numeric" readonly>
                        @error('price')
                            <div class="invalid-feedback">
                                {{ $message }}
                            </div>
                        @enderror
                    </div>
                    <div class="col-lg-6 position-relative">
                        <label class="form-label" for="discount">Diskon</label>
                        <input name="discount" class="form-control rupiah-format @error('discount') is-invalid @enderror"
                            id="discount" type="text" placeholder="Masukan Diskon" value="{{ old('discount') }}"
                            inputmode="numeric">
                        @error('discount')
                            <div class="invalid-feedback">
                                {{ $message }}
                            </div>
                        @enderror
                    </div>
                    <div class="col-lg-6 position-relative">
                        <label class="form-label" for="total">Total</label>
                        <input name="total" class="form-control rupiah-format @error('total') is-invalid @enderror"
                            id="total" type="text" placeholder="Masukan Total" value="{{ old('total') }}"
                            inputmode="numeric">
                        @error('total')
                            <div class="invalid-feedback">
                                {{ $message }}
                            </div>
                        @enderror
                    </div>
                    <div class="col-lg-6 position-relative">
                        <label class="form-label" for="image">Gambar
                            <span class="form-span"><i>(Opsional,.jpeg,.png,.jpg,.gif,.svg)</i></span>
                        </label>
                        <input name="image" class="form-control @error('image') is-invalid @enderror" id="image"
                            type="file" value="{{ old('image') }}"
                            accept="image/jpeg,image/png,image/jpg,image/gif,image/svg">
                        @error('image')
                            <div class="invalid-feedback">
                                {{ $message }}
                            </div>
                        @enderror
                    </div>
                    <div class="col-lg-12 position-relative">
                        <label class="form-label" for="payment_method">Metode Pembayaran</label>
                        <div class="form-check radio ps-0">
                            <ul class="radio-wrapper">
                                <li>
                                    <input class="form-check-input" id="radio-cash" type="radio" name="payment_method"
                                        value="1" @checked(old('payment_method') == '1')>
                                    <label class="form-check-label" for="radio-cash">
                                        Tunai
                                    </label>
                                </li>
                                <li>
                                    <input class="form-check-input" id="radio-qris" type="radio" name="payment_method"
                                        value="2" @checked(old('payment_method') == '2')>
                                    <label class="form-check-label" for="radio-qris">
                                        Qris
                                    </label>
                                </li>
                                <li>
                                    <input class="form-check-input" id="radio-other" type="radio"
                                        name="payment_method" value="3" @checked(old('payment_method') == '3')>
                                    <label class="form-check-label" for="radio-other">
                                        Lainnya
                                    </label>
                                </li>
                            </ul>
                        </div>
                        @error('payment_method')
                            <div class="invalid-feedback">
                                {{ $message }}
                            </div>
                        @enderror
                    </div>
                    <div class="col-12">
                        <button class="btn btn-primary button-disable" type="submit">Simpan</button>
                    </div>
                </form>
            </div>
        </div>
    </div>
@endsection
@section('afterScripts')
    <script src="{{ asset('assets/js/forms/button-disable.js?ver=1.0.0') }}"></script>
    <script src="{{ asset('assets/js/forms/rupiah-format.js?ver=1.0.0') }}"></script>
    <script src="{{ asset('assets/admin/js/select2/select2.js') }}"></script>
    <script src="{{ asset('assets/admin/js/select2/select2-config.js?ver=1.0.0') }}"></script>
    <script src="{{ asset('assets/admin/js/custom/transaction.js?ver=1.0.0') }}"></script>
@endsection
