@extends('layouts.app')
@section('title', 'Journal Entries')
@section('page_title', 'Journal Entries')
@section('breadcrumbs')
    <li class="breadcrumb-item"><a href="{{ route('dashboard') }}">Home</a></li><li class="breadcrumb-item active">Journals</li>
@endsection
@section('page_actions')
    @can('accounting.create')
        <a href="{{ route('journals.income') }}" class="btn btn-outline-success"><i class="bi bi-arrow-down-circle me-1"></i>Income</a>
        <a href="{{ route('journals.expense') }}" class="btn btn-outline-danger"><i class="bi bi-arrow-up-circle me-1"></i>Expense</a>
        <a href="{{ route('journals.create') }}" class="btn btn-primary"><i class="bi bi-journal-plus me-1"></i>Journal</a>
    @endcan
@endsection

@section('content')
    <div class="card"><div class="card-body">
        <table class="table table-hover align-middle">
            <thead><tr><th>Entry #</th><th>Date</th><th>Type</th><th>Description</th><th class="text-end">Amount</th><th class="text-end"></th></tr></thead>
            <tbody>
                @forelse($entries as $e)
                    <tr>
                        <td><a href="{{ route('journals.show', $e) }}" class="fw-semibold text-decoration-none">{{ $e->entry_number }}</a></td>
                        <td class="small">{{ $e->date->format('d M Y') }}</td>
                        <td><span class="badge bg-soft-info text-capitalize">{{ $e->type }}</span></td>
                        <td class="small">{{ $e->description }}</td>
                        <td class="text-end">{{ number_format($e->total_debit) }}</td>
                        <td class="text-end"><a href="{{ route('journals.show', $e) }}" class="btn btn-sm btn-light border"><i class="bi bi-eye"></i></a></td>
                    </tr>
                @empty
                    <tr><td colspan="6" class="text-center text-muted py-4">No journal entries yet.</td></tr>
                @endforelse
            </tbody>
        </table>
        {{ $entries->links() }}
    </div></div>
@endsection
