@extends('layouts.app')

@section('title')
  Dashboard
@endsection

@section('admin-content')
    <script src="https://cdn.jsdelivr.net/npm/autonumeric@4.6.0/dist/autoNumeric.min.js"></script>

    <section class="content-header">
        <div class="container-fluid">
            <div class="row mb-2">
                <div class="col-sm-6">
                    <h1>Edit Expense Other</h1>
                </div>
                <div class="col-sm-6">
                    <ol class="breadcrumb float-sm-right">
                        <li class="breadcrumb-item"><a href="{{ route('dashboard.index') }}">Dashboard</a></li>
                        </li>
                    </ol>
                </div>
            </div>
        </div>
    </section>
    <section class="content">
        <div class="container-fluid">
            <div class="card card-primary card-outline">
                <div class="card-body">
					<form method="POST" action="{{ route('forms.other.update', $form->id) }}" enctype="multipart/form-data">
                        @csrf
                        @method('PUT')
                        @include('backend.layouts.partials.messages')
                        <div class="row">
                            <div class="col-lg-6">
                                <div class="mb-3">
                                    <label class="form-label">Kategori <span class="font-italic font-weight-normal">(required)</span></label>
                                    <select class="form-control" name="kategori_id" id="kategori_id" required>
                                        <option value="">Pilih Kategori</option>
                                        @foreach ($kategori as $item)
                                            <option value="{{ $item->id }}" {{ $form->kategori_id == $item->id ? 'selected' : '' }}>
                                                {{ $item->name }}
                                            </option>
                                        @endforeach
                                    </select>
                                </div>
                                <div class="mb-3">
                                    <label class="form-label">Tanggal <span class="font-italic font-weight-normal">(required)</span></label>
                                    <input type="date" class="form-control" name="tanggal" id="tanggal" required value="{{ $form->tanggal }}">
                                </div>
                                <div class="mb-3">
                                    <label class="form-label">Total <span class="font-italic font-weight-normal">(required)</span></label>
                                    <input type="string" class="form-control" name="total" id="total" required value="{{ $form->total }}">
                                </div>
                            </div>

                            <div class="col-lg-6">
                                <div class="mb-3">
                                    <label class="form-label">Bukti Total <span class="font-italic font-weight-normal">(required)</span></label>
                                    <input type="file" class="form-control" name="bukti_total" value="{{ $form->bukti_total }}">
                                </div>
                                <div class="mb-3">
                                    <label class="form-label">Keterangan <span class="font-italic font-weight-normal">(required)</span></label>
                                    <textarea class="form-control" name="keterangan" id="keterangan" required>{{ $form->keterangan }}</textarea>
                                </div>
                            </div>

                            <button type="submit" class="btn btn-primary ml-2">Update</button>
                        </div>
					</form>
                </div>
            </div>
        </div>
    </section>

    <script>
        new AutoNumeric('#total', {
            digitGroupSeparator: '.', // Pemisah ribuan
            decimalCharacter: ',',    // Karakter desimal (tidak digunakan karena tanpa desimal)
            currencySymbol: 'Rp.',    // Simbol mata uang
            decimalPlaces: 0,         // Tidak ada angka desimal
            unformatOnSubmit: true    // Nilai asli tanpa format saat dikirimkan
        });
    </script>
@endsection
