@extends("layouts.app")
@section("title", __("vrc::lang.report_rework"))
@section("content")
<section class="content-header"><h1>@lang("vrc::lang.report_rework")</h1></section>
<section class="content">
    @component("components.widget", ["class" => "box-primary"])
        @include("vrc::reports._filter")

        <div class="row" style="margin-bottom:10px;">
            <div class="col-md-4">
                <div class="info-box bg-aqua"><span class="info-box-icon"><i class="fa fa-refresh"></i></span>
                    <div class="info-box-content"><span class="info-box-text">@lang("vrc::lang.rework_rate")</span>
                        <span class="info-box-number">{{ $rate }}%</span></div></div>
            </div>
            <div class="col-md-4">
                <div class="info-box"><span class="info-box-icon"><i class="fa fa-car"></i></span>
                    <div class="info-box-content"><span class="info-box-text">@lang("vrc::lang.rework")</span>
                        <span class="info-box-number">{{ $reworkCount }}</span></div></div>
            </div>
            <div class="col-md-4">
                <div class="info-box"><span class="info-box-icon"><i class="fa fa-list"></i></span>
                    <div class="info-box-content"><span class="info-box-text">@lang("vrc::lang.repair_orders")</span>
                        <span class="info-box-number">{{ $total }}</span></div></div>
            </div>
        </div>

        <table class="table table-bordered table-condensed">
            <thead><tr>
                <th>@lang("vrc::lang.repair_order")</th>
                <th>@lang("vrc::lang.vehicle")</th>
                <th>@lang("vrc::lang.original")</th>
                <th>@lang("vrc::lang.reason")</th>
                <th>@lang("vrc::lang.status")</th>
                <th></th>
            </tr></thead>
            <tbody>
            @forelse($rows as $r)
                <tr>
                    <td><a href="{{ route('vrc.repair-orders.show', $r->id) }}">{{ $r->number ?: '#'.$r->id }}</a></td>
                    <td>{{ optional($r->vehicle)->label ?? optional($r->vehicle)->plate_number }}</td>
                    <td>@if($r->reworkOf)<a href="{{ route('vrc.repair-orders.show', $r->reworkOf->id) }}">{{ $r->reworkOf->number ?: '#'.$r->reworkOf->id }}</a>@else — @endif</td>
                    <td>{{ $r->rework_reason }}</td>
                    <td><span class="label label-default">@lang("vrc::lang.ro_status_".$r->status)</span></td>
                    <td>@if($r->rework_ncr_id)<span class="label label-warning">NCR</span>@endif</td>
                </tr>
            @empty
                <tr><td colspan="6" class="text-center text-muted">—</td></tr>
            @endforelse
            </tbody>
        </table>
    @endcomponent
</section>
@endsection
