@extends('layouts.app')
@section('title', $title)
@section('content')
<div class="card">
    <div class="card-body p-4">
        @include('reports.partials.header', ['title' => $title, 'period' => __('As of').' '.\App\Support\DualDate::format(now(), 'Y-m-d')])
        <div class="text-end mb-3 no-print"><button onclick="window.print()" class="btn btn-light btn-sm"><i class="fa-solid fa-print me-1"></i>{{ __('Print') }}</button></div>
        <div class="table-responsive">
            <table class="table">
                <thead><tr><th>{{ $type === 'customer' ? __('Customer') : __('Supplier') }}</th><th>{{ __('Phone') }}</th><th class="text-end">{{ __('Current Balance') }}</th><th class="no-print"></th></tr></thead>
                <tbody>
                    @php($total = 0)
                    @foreach($parties as $party)
                        @php($total += $party->balance)
                        <tr><td>{{ $party->name }}</td><td>{{ $party->phone ?: '-' }}</td><td class="text-end text-danger fw-bold money">{{ number_format($party->balance, 2) }} {{ $moneyCode }}</td><td class="text-end no-print"><a class="btn btn-light btn-sm" href="{{ $type === 'customer' ? route('reports.customer-ledger', $party) : route('reports.supplier-ledger', $party) }}"><i class="fa-solid fa-book"></i></a></td></tr>
                    @endforeach
                </tbody>
                <tfoot><tr><th colspan="2">{{ __('Total Balance') }}</th><th class="text-end money">{{ number_format($total, 2) }} {{ $moneyCode }}</th><th class="no-print"></th></tr></tfoot>
            </table>
        </div>
    </div>
</div>
@if(!empty($appSettings['report_footer']))<p class="text-center text-muted small mt-3">{{ $appSettings['report_footer'] }}</p>@endif
@endsection
