@extends('layouts.app')

@section('title', 'Edit Cashbook Entry')
@section('page-title', 'Edit Cashbook Entry')

@section('content')
<div class="row">
    <div class="col-8">
        <div class="card">
            <div class="card-header">
                <h5 class="mb-0">Edit Entry #{{ $cashbook->id }}</h5>
            </div>
            <div class="card-body">
                <form method="POST" action="{{ route('cashbooks.update', $cashbook->id) }}">
                    @csrf
                    @method('PUT')
                    <div class="row g-2">
                        <div class="col-md-6">
                            <label class="form-label">Reference</label>
                            <input type="text" name="reference" class="form-control" value="{{ old('reference', $cashbook->reference) }}">
                        </div>
                        <div class="col-md-3">
                            <label class="form-label">Invoice ID</label>
                            <input type="number" name="invoice_id" class="form-control" value="{{ old('invoice_id', $cashbook->invoice_id) }}">
                        </div>
                        <div class="col-md-3">
                            <label class="form-label">Invoice Installment ID</label>
                            <input type="number" name="invoice_installment_id" class="form-control" value="{{ old('invoice_installment_id', $cashbook->invoice_installment_id) }}">
                        </div>
                        <div class="col-md-3 mt-2">
                            <label class="form-label">Payment Type</label>
                            <select name="payment_type" class="form-control">
                                <option value="">-- Select --</option>
                                <option value="cash" {{ old('payment_type', $cashbook->payment_type)=='cash' ? 'selected' : '' }}>Cash</option>
                                <option value="bank" {{ old('payment_type', $cashbook->payment_type)=='bank' ? 'selected' : '' }}>Bank</option>
                                <option value="other" {{ old('payment_type', $cashbook->payment_type)=='other' ? 'selected' : '' }}>Other</option>
                            </select>
                        </div>
                        <div class="col-md-3 mt-2">
                            <label class="form-label">Out</label>
                            <input type="text" name="out_values" class="form-control" value="{{ old('out_values', $cashbook->out_values) }}">
                        </div>
                        <div class="col-md-3 mt-2">
                            <label class="form-label">Income</label>
                            <input type="text" name="income_values" class="form-control" value="{{ old('income_values', $cashbook->income_values) }}">
                        </div>
                        <div class="col-md-3 d-flex align-items-end">
                            <button class="btn btn-primary w-100">Update</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
@endsection
