@extends('layouts.app')
@section('title', __('medbilling::lang.reports'))
@section('content')
<section class="content-header"><h1>@lang('medbilling::lang.reports')</h1>
    <p>@lang('medbilling::lang.reports_help')</p>
</section>
<section class="content">
    <div class="row">
        <div class="col-md-6">
            @component('components.widget', ['class' => 'box-primary', 'title' => __('medbilling::lang.billed_vs_collected')])
                <table class="table table-bordered">
                    <tr><th>@lang('medbilling::lang.invoices')</th><td class="text-right">{{ $billedVsCollected['invoices'] }}</td></tr>
                    <tr><th>@lang('medbilling::lang.billed')</th><td class="text-right">{{ number_format($billedVsCollected['billed'], 2) }}</td></tr>
                    <tr><th>@lang('medbilling::lang.collected')</th><td class="text-right">{{ number_format($billedVsCollected['collected'], 2) }}</td></tr>
                    <tr><th>@lang('medbilling::lang.outstanding')</th><td class="text-right"><strong>{{ number_format($billedVsCollected['outstanding'], 2) }}</strong></td></tr>
                </table>
            @endcomponent
        </div>
        <div class="col-md-6">
            @component('components.widget', ['class' => 'box-primary', 'title' => __('medbilling::lang.claims_by_status')])
                <table class="table table-bordered table-striped">
                    <thead><tr>
                        <th>@lang('medbilling::lang.status')</th>
                        <th class="text-right">@lang('medbilling::lang.count')</th>
                        <th class="text-right">@lang('medbilling::lang.total_claimed')</th>
                        <th class="text-right">@lang('medbilling::lang.total_approved')</th>
                        <th class="text-right">@lang('medbilling::lang.payer_share')</th>
                    </tr></thead>
                    <tbody>
                    @forelse($claimsByStatus as $row)
                        <tr>
                            <td>@lang('medbilling::lang.claim_status_' . $row->status)</td>
                            <td class="text-right">{{ $row->cnt }}</td>
                            <td class="text-right">{{ number_format($row->claimed, 2) }}</td>
                            <td class="text-right">{{ number_format($row->approved, 2) }}</td>
                            <td class="text-right">{{ number_format($row->payer_share, 2) }}</td>
                        </tr>
                    @empty
                        <tr><td colspan="5" class="text-center text-muted">@lang('medbilling::lang.no_data')</td></tr>
                    @endforelse
                    </tbody>
                </table>
            @endcomponent
        </div>
    </div>
    <div class="row">
        <div class="col-md-12">
            @component('components.widget', ['class' => 'box-primary', 'title' => __('medbilling::lang.payer_aging')])
                <table class="table table-bordered table-striped">
                    <thead><tr>
                        <th>@lang('medbilling::lang.payer')</th>
                        <th class="text-right">@lang('medbilling::lang.aging_0_30')</th>
                        <th class="text-right">@lang('medbilling::lang.aging_31_60')</th>
                        <th class="text-right">@lang('medbilling::lang.aging_61_90')</th>
                        <th class="text-right">@lang('medbilling::lang.aging_90p')</th>
                        <th class="text-right">@lang('medbilling::lang.total')</th>
                    </tr></thead>
                    <tbody>
                    @forelse($payerAging as $payer => $b)
                        <tr>
                            <td>{{ $payer }}</td>
                            <td class="text-right">{{ number_format($b['b0_30'], 2) }}</td>
                            <td class="text-right">{{ number_format($b['b31_60'], 2) }}</td>
                            <td class="text-right">{{ number_format($b['b61_90'], 2) }}</td>
                            <td class="text-right">{{ number_format($b['b90p'], 2) }}</td>
                            <td class="text-right"><strong>{{ number_format($b['total'], 2) }}</strong></td>
                        </tr>
                    @empty
                        <tr><td colspan="6" class="text-center text-muted">@lang('medbilling::lang.no_data')</td></tr>
                    @endforelse
                    </tbody>
                </table>
            @endcomponent
        </div>
    </div>
</section>
@endsection
