@extends('layouts.app')

@section('title', __('vrc::lang.vrc_module'))

@section('content')
<section class="content-header">
    <h1>@lang('vrc::lang.vrc_module')</h1>
    <p>@lang('vrc::lang.module_tagline')</p>
</section>

<section class="content">
    <div class="row">
        <div class="col-md-3 col-sm-6">
            <div class="info-box bg-aqua"><span class="info-box-icon"><i class="fa fa-wrench"></i></span>
                <div class="info-box-content"><span class="info-box-text">@lang('vrc::lang.open_orders')</span><span class="info-box-number">{{ $tiles['open_orders'] ?? 0 }}</span></div></div>
        </div>
        <div class="col-md-3 col-sm-6">
            <div class="info-box bg-yellow"><span class="info-box-icon"><i class="fa fa-cogs"></i></span>
                <div class="info-box-content"><span class="info-box-text">@lang('vrc::lang.ro_status_in_progress')</span><span class="info-box-number">{{ $tiles['in_progress'] ?? 0 }}</span></div></div>
        </div>
        <div class="col-md-3 col-sm-6">
            <div class="info-box bg-green"><span class="info-box-icon"><i class="fa fa-check"></i></span>
                <div class="info-box-content"><span class="info-box-text">@lang('vrc::lang.ro_status_ready_for_pickup')</span><span class="info-box-number">{{ $tiles['ready_for_pickup'] ?? 0 }}</span></div></div>
        </div>
        <div class="col-md-3 col-sm-6">
            <div class="info-box bg-purple"><span class="info-box-icon"><i class="fa fa-money"></i></span>
                <div class="info-box-content"><span class="info-box-text">@lang('vrc::lang.revenue_mtd')</span><span class="info-box-number">{{ number_format($tiles['revenue_mtd'] ?? 0, 2) }}</span></div></div>
        </div>
    </div>

    <div class="row">
        <div class="col-md-6">
            @component('components.widget', ['class' => 'box-primary', 'title' => __('vrc::lang.open_by_status')])
                <table class="table table-condensed">
                    @forelse ($byStatus as $status => $count)
                        <tr><td><a href="{{ route('vrc.repair-orders.index') }}">{{ __('vrc::lang.ro_status_' . $status) }}</a></td><td class="text-right"><span class="badge">{{ $count }}</span></td></tr>
                    @empty
                        <tr><td class="text-muted">@lang('vrc::lang.no_open_orders')</td></tr>
                    @endforelse
                </table>
            @endcomponent
        </div>
        <div class="col-md-6">
            @component('components.widget', ['class' => 'box-warning', 'title' => __('vrc::lang.low_stock')])
                <table class="table table-condensed">
                    <thead><tr><th>@lang('vrc::lang.part')</th><th class="text-right">@lang('vrc::lang.qty')</th></tr></thead>
                    @forelse ($lowStock as $row)
                        <tr><td>{{ $row['name'] }}</td><td class="text-right">{{ $row['qty_available'] }}</td></tr>
                    @empty
                        <tr><td colspan="2" class="text-muted">@lang('vrc::lang.no_low_stock')</td></tr>
                    @endforelse
                </table>
            @endcomponent
        </div>
    </div>
</section>
@endsection
