@extends('layouts.app')
@section('title', 'Voucher Form')
@section('breadcrumb')
    @include('components.breadcrumb', ['items' => ['Accounts' => route('cash.index'), 'Vouchers' => route('vouchers.index'), ucfirst($type) => null]])
@endsection
@section('content')
<div class="max-w-2xl mx-auto">
    <x-card :title="'New ' . ucfirst($type)" :icon="$type === 'receipt' ? 'plus-circle' : 'minus-circle'">
        <form action="{{ route('vouchers.store') }}" method="POST" class="space-y-4">
            @csrf
            <input type="hidden" name="type" value="{{ $type }}">
            <div class="grid grid-cols-2 gap-4">
                <x-form-input name="voucher_date" label="Date" type="date" icon="calendar" :value="old('voucher_date', now()->format('Y-m-d'))" required />
                <x-form-input name="mode" label="Payment Mode" type="select" icon="credit-card" :options="['cash' => 'Cash', 'bank_transfer' => 'Bank Transfer', 'cheque' => 'Cheque', 'mobile_banking' => 'Mobile Banking']" />
            </div>
            <x-form-input name="party_id" label="{{ $type === 'receipt' ? 'Received From' : 'Paid To' }}" type="select" icon="user" :options="$parties->pluck('name','id')" required />
            <x-form-input name="account_id" label="{{ $type === 'receipt' ? 'Deposit To' : 'Paid From' }}" type="select" icon="landmark" :options="$accounts->pluck('name','id')" required />
            <x-form-input name="amount" label="Amount" type="number" icon="circle-dollar-sign" step="0.01" min="0.01" required />
            <div class="grid grid-cols-2 gap-4">
                <x-form-input name="cheque_no" label="Cheque No" icon="hash" />
                <x-form-input name="cheque_date" label="Cheque Date" type="date" icon="calendar" />
            </div>
            <x-form-input name="description" label="Description" type="textarea" icon="message-square" />
            <div class="flex justify-end gap-2">
                <x-button variant="secondary" :href="route('vouchers.index')">Cancel</x-button>
                <x-button :variant="$type === 'receipt' ? 'success' : 'danger'" icon="save" type="submit">Save {{ ucfirst($type) }}</x-button>
            </div>
        </form>
    </x-card>
</div>
@endsection
