@extends('layouts.app')
@section('title', __('Invoices'))
@section('content')
<div class="card">
    <div class="card-body">
        <div class="d-flex flex-wrap gap-2 justify-content-between mb-3">
            <form class="d-flex gap-2"><input name="search" class="form-control" placeholder="{{ __('Invoice number or customer') }}" value="{{ request('search') }}"><button class="btn btn-light"><i class="fa-solid fa-magnifying-glass"></i></button></form>
            <a href="{{ route('invoices.create') }}" class="btn btn-success"><i class="fa-solid fa-plus me-1"></i>{{ __('New Sale') }}</a>
        </div>
        <div class="table-responsive">
            <table class="table align-middle">
                <thead><tr><th>{{ __('Invoice') }}</th><th>{{ __('Customer') }}</th><th>{{ __('Type') }}</th><th>{{ __('Total') }}</th><th>{{ __('Paid / Due') }}</th><th>{{ __('Status') }}</th></tr></thead>
                <tbody>@forelse($invoices as $invoice)<tr><td><a class="fw-bold" href="{{ route('invoices.show', $invoice) }}">{{ $invoice->invoice_number }}</a><small class="d-block text-muted">{{ \App\Support\DualDate::format($invoice->invoice_date, 'd M Y') }}</small></td><td>{{ $invoice->customer?->name ?? __('Walk-in Customer') }}</td><td>{{ __($invoice->sale_type === 'retail' ? 'Retail' : 'Wholesale') }}</td><td class="money">{{ number_format($invoice->total, 2) }} {{ $invoice->currency_code }}</td><td><span class="text-success money">{{ number_format($invoice->paid_amount, 2) }}</span> / <span class="text-danger money">{{ number_format($invoice->due_amount, 2) }}</span></td><td><span class="badge badge-soft rounded-pill">{{ __(ucfirst($invoice->status)) }}</span></td></tr>@empty<tr><td colspan="6" class="text-center text-muted py-5">{{ __('No invoices yet.') }}</td></tr>@endforelse</tbody>
            </table>
        </div>
        {{ $invoices->links('pagination::bootstrap-5') }}
    </div>
</div>
@endsection
