@extends('layouts.app')
@section('title','Journal Entries')
@section('page_title','Journal Entries')
@section('content')
<div class="page-head"><div><h1>Journal Entries</h1><p>Every posted financial document creates a balanced and immutable journal.</p></div><a class="btn btn-primary" href="{{ route('journals.create') }}">+ Manual Journal</a></div>
@if($drafts->isNotEmpty())<div class="card" style="margin-bottom:18px"><div class="card-head"><strong>Manual Journals Awaiting Action</strong></div><div class="table-wrap"><table class="table"><thead><tr><th>Voucher</th><th>Date</th><th>Description</th><th>Debit</th><th>Status</th><th></th></tr></thead><tbody>@foreach($drafts as $v)@php($s=$v->status instanceof \App\Enums\DocumentStatus?$v->status->value:$v->status)<tr><td>{{ $v->voucher_number }}</td><td>{{ $v->posting_date->format('d M Y') }}</td><td>{{ $v->description }}</td><td>{{ number_format((float)$v->debit_total,2) }}</td><td><span class="badge status-{{ $s }}">{{ ucwords(str_replace('_',' ',$s)) }}</span></td><td><a class="btn btn-secondary btn-sm" href="{{ route('journals.vouchers.show',$v) }}">Open</a></td></tr>@endforeach</tbody></table></div></div>@endif
<div class="card"><div class="toolbar"><form class="search"><input class="control" name="search" value="{{ request('search') }}" placeholder="Journal, reference, description"><input class="control" type="date" name="from" value="{{ request('from') }}"><input class="control" type="date" name="to" value="{{ request('to') }}"><button class="btn btn-secondary">Filter</button></form></div><div class="table-wrap"><table class="table"><thead><tr><th>Journal</th><th>Posting Date</th><th>Source</th><th>Reference</th><th>Description</th><th>Debit</th><th>Credit</th><th></th></tr></thead><tbody>@forelse($journals as $j)<tr><td><strong>{{ $j->journal_number }}</strong></td><td>{{ $j->posting_date->format('d M Y') }}</td><td>{{ ucwords(str_replace('_',' ',$j->source_module)) }}</td><td>{{ $j->reference_number }}</td><td>{{ $j->description }}</td><td>{{ number_format((float)$j->debit_total,2) }}</td><td>{{ number_format((float)$j->credit_total,2) }}</td><td><a class="btn btn-secondary btn-sm" href="{{ route('journals.show',$j) }}">Open</a></td></tr>@empty<tr><td colspan="8" class="empty">No journals found.</td></tr>@endforelse</tbody></table></div>{{ $journals->links() }}</div>
@endsection
