<!doctype html>
<html lang="{{ app()->getLocale() }}" dir="{{ in_array(app()->getLocale(), ['ar']) ? 'rtl' : 'ltr' }}">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>{{ __('vrc::lang.estimate') }} {{ $estimate->number }}</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/css/bootstrap.min.css">
</head>
<body class="bg-light">
<div class="container" style="max-width:760px; margin-top:30px;">
    <div class="card shadow-sm">
        <div class="card-header bg-primary text-white">
            <h4 class="mb-0">{{ __('vrc::lang.estimate') }} — {{ $estimate->number }}</h4>
        </div>
        <div class="card-body">
            @if(session('vrc_msg'))<div class="alert alert-info">{{ session('vrc_msg') }}</div>@endif

            <p>{{ __('vrc::lang.customer') }}: <strong>{{ optional($customer)->name }}</strong><br>
               {{ __('vrc::lang.status') }}: <strong>{{ __('vrc::lang.est_status_'.$estimate->status) }}</strong></p>

            <table class="table table-sm">
                <thead><tr><th>{{ __('vrc::lang.description') }}</th><th>{{ __('vrc::lang.qty') }}</th><th class="text-right">{{ __('vrc::lang.line_total') }}</th></tr></thead>
                <tbody>
                @foreach ($estimate->items as $it)
                    <tr><td>{{ $it->description }}</td><td>{{ $it->qty }}</td><td class="text-right">{{ $it->line_total }}</td></tr>
                @endforeach
                </tbody>
                <tfoot>
                    <tr><th colspan="2" class="text-right">{{ __('vrc::lang.grand_total') }}</th><th class="text-right">{{ $estimate->grand_total }}</th></tr>
                </tfoot>
            </table>

            @if(in_array($estimate->status, ['sent','draft']))
                <form method="POST" action="{{ route('vrc.portal.estimate.approve', $estimate->approval_token) }}" class="d-inline">
                    @csrf
                    <button class="btn btn-success btn-lg">{{ __('vrc::lang.approve') }}</button>
                </form>
                <form method="POST" action="{{ route('vrc.portal.estimate.decline', $estimate->approval_token) }}" class="d-inline" onsubmit="this.reason.value = prompt('{{ __('vrc::lang.reason') }}:')||'';">
                    @csrf
                    <input type="hidden" name="reason">
                    <button class="btn btn-outline-danger btn-lg">{{ __('vrc::lang.decline') }}</button>
                </form>
            @else
                <div class="alert alert-secondary">{{ __('vrc::lang.est_status_'.$estimate->status) }}</div>
            @endif
        </div>
    </div>
    <p class="text-center text-muted mt-3" style="font-size:12px;">{{ config('app.name') }}</p>
</div>
</body>
</html>
