@extends('layouts.app')

@section('page-title', 'Quotation #'.$quotation->quotation_number)

@section('content')
<div class="container-fluid" id="quotation-print">
    <div class="row">
        <div class="col-md-12">
            <div class="card">
                <div class="card-body">
                    <div class="d-flex justify-content-between">
                        <h4>Quotation #{{ $quotation->quotation_number }}</h4>
                        <button class="btn btn-sm btn-primary" onclick="window.print()">Print</button>
                    </div>
                    <hr>
                    <div class="row">
                        <div class="col-md-6">
                            <strong>Bill To:</strong> {{ $quotation->bill_to }}<br>
                            <strong>Company:</strong> {{ $quotation->company_name }}<br>
                            <strong>Mobile:</strong> {{ $quotation->mobile }}<br>
                            <strong>Email:</strong> {{ $quotation->email }}<br>
                        </div>
                        <div class="col-md-6 text-end">
                            <strong>Date:</strong> {{ $quotation->date ? \Illuminate\Support\Carbon::parse($quotation->date)->format('Y-m-d') : '' }}<br>
                            <strong>Status:</strong> {{ ucfirst($quotation->status) }}
                        </div>
                    </div>

                    <table class="table table-bordered mt-3">
                        <thead>
                            <tr>
                                <th>Description</th>
                                <th>Qty</th>
                                <th>Rate</th>
                                <th>Amount</th>
                            </tr>
                        </thead>
                        <tbody>
                            @foreach($quotation->items as $item)
                                <tr>
                                    <td>{{ $item->description }}</td>
                                    <td>{{ $item->qty }}</td>
                                    <td>{{ number_format($item->rate,2) }}</td>
                                    <td>{{ number_format($item->amount,2) }}</td>
                                </tr>
                            @endforeach
                        </tbody>
                        <tfoot>
                            <tr>
                                <td colspan="3" class="text-end"><strong>Sub-Total</strong></td>
                                <td>{{ number_format($quotation->subtotal,2) }}</td>
                            </tr>
                            <tr>
                                <td colspan="3" class="text-end"><strong>Total</strong></td>
                                <td>{{ number_format($quotation->total,2) }}</td>
                            </tr>
                        </tfoot>
                    </table>

                    @if($quotation->in_word)
                        <p><strong>In Words:</strong> {{ $quotation->in_word }}</p>
                    @endif

                    @if($quotation->note)
                        <p><strong>Note:</strong> {{ $quotation->note }}</p>
                    @endif
                </div>
            </div>
        </div>
    </div>
</div>
@endsection

@section('styles')
<style>
@media print {
    #quotation-print .btn { display: none; }
}
</style>
@endsection
