@extends('layouts.app')

@section('title', __('bms::lang.asset_reports'))

@section('content')

<section class="content-header">
    <h1>@lang('bms::lang.asset_reports')
        <small>@lang('bms::lang.asset_reports_help')</small>
    </h1>
</section>

<section class="content">
    <div class="row">
        <div class="col-md-4">
            <div class="info-box bg-light-blue"><span class="info-box-icon"><i class="fa fas fa-boxes"></i></span>
                <div class="info-box-content">
                    <span class="info-box-text">@lang('bms::lang.total_assets')</span>
                    <span class="info-box-number">{{ number_format($totalAssets) }}</span>
                </div>
            </div>
        </div>
        <div class="col-md-4">
            <div class="info-box bg-aqua"><span class="info-box-icon"><i class="fa fas fa-layer-group"></i></span>
                <div class="info-box-content">
                    <span class="info-box-text">@lang('bms::lang.total_units')</span>
                    <span class="info-box-number">{{ number_format($totalUnits) }}</span>
                </div>
            </div>
        </div>
        <div class="col-md-4">
            <div class="info-box bg-green"><span class="info-box-icon"><i class="fa fas fa-coins"></i></span>
                <div class="info-box-content">
                    <span class="info-box-text">@lang('bms::lang.total_value')</span>
                    <span class="info-box-number">{{ number_format($totalValue, 2) }}</span>
                </div>
            </div>
        </div>
    </div>

    <div class="row">
        <div class="col-md-6">
            @component('components.widget', ['class' => 'box-primary', 'title' => __('bms::lang.by_category')])
                <table class="table table-bordered table-striped">
                    <thead><tr><th>@lang('bms::lang.category')</th><th>@lang('bms::lang.assets')</th><th>@lang('bms::lang.total_units')</th><th>@lang('bms::lang.total_value')</th></tr></thead>
                    <tbody>
                        @forelse ($byCategory as $r)
                            <tr><td>{{ $categories[$r->category] ?? $r->category }}</td><td>{{ $r->c }}</td><td>{{ (int) $r->q }}</td><td>{{ number_format((float) $r->v, 2) }}</td></tr>
                        @empty
                            <tr><td colspan="4" class="text-center text-muted">@lang('bms::lang.no_assets')</td></tr>
                        @endforelse
                    </tbody>
                </table>
            @endcomponent
        </div>
        <div class="col-md-6">
            @component('components.widget', ['class' => 'box-primary', 'title' => __('bms::lang.by_placement')])
                <table class="table table-bordered table-striped">
                    <thead><tr><th>@lang('bms::lang.current_placement')</th><th>@lang('bms::lang.assets')</th><th>@lang('bms::lang.total_units')</th></tr></thead>
                    <tbody>
                        @forelse ($byPlacement as $r)
                            <tr><td>{{ $r->label }}</td><td>{{ $r->c }}</td><td>{{ (int) $r->q }}</td></tr>
                        @empty
                            <tr><td colspan="3" class="text-center text-muted">@lang('bms::lang.no_assets')</td></tr>
                        @endforelse
                    </tbody>
                </table>
            @endcomponent
        </div>
    </div>

    <div class="row">
        <div class="col-md-6">
            @component('components.widget', ['class' => 'box-warning', 'title' => __('bms::lang.by_condition')])
                <table class="table table-bordered table-striped">
                    <thead><tr><th>@lang('bms::lang.condition')</th><th>@lang('bms::lang.assets')</th><th>@lang('bms::lang.total_units')</th></tr></thead>
                    <tbody>
                        @forelse ($byCondition as $r)
                            <tr><td>{{ $conditions[$r->condition] ?? $r->condition }}</td><td>{{ $r->c }}</td><td>{{ (int) $r->q }}</td></tr>
                        @empty
                            <tr><td colspan="3" class="text-center text-muted">@lang('bms::lang.no_assets')</td></tr>
                        @endforelse
                    </tbody>
                </table>
            @endcomponent
        </div>
        <div class="col-md-6">
            @component('components.widget', ['class' => 'box-info', 'title' => __('bms::lang.by_status')])
                <table class="table table-bordered table-striped">
                    <thead><tr><th>@lang('bms::lang.asset_status')</th><th>@lang('bms::lang.assets')</th><th>@lang('bms::lang.total_units')</th></tr></thead>
                    <tbody>
                        @forelse ($byStatus as $r)
                            <tr><td>{{ $statuses[$r->status] ?? $r->status }}</td><td>{{ $r->c }}</td><td>{{ (int) $r->q }}</td></tr>
                        @empty
                            <tr><td colspan="3" class="text-center text-muted">@lang('bms::lang.no_assets')</td></tr>
                        @endforelse
                    </tbody>
                </table>
            @endcomponent
        </div>
    </div>

    <a href="{{ route('bms.assets.index') }}" class="tw-dw-btn tw-dw-btn-outline tw-dw-btn-neutral"><i class="fa fa-arrow-left"></i> @lang('bms::lang.back_to_assets')</a>
</section>

@endsection
