@extends('layouts.base_pdf')
@section('inner_content')
<style>
    @page { margin-top: 13mm; }
</style>

    <br>
    <htmlpageheader name="page-header">
        <br><br>
        <div class="separator"><strong><i>{{ str_replace(['BI-'], 'BDO-', $transaction->bill_no) }}</i></strong></div>
    </htmlpageheader>

    <table>
        <tr>
            <td class="header-logo">
                <img src="{{ asset('images/ri_1.png') }}" alt="logo" id="logo" class="logo">
            </td>
            <td class="header-cief-address">
                <span class="company-name"><strong>CIEF WORLDWIDE SDN BHD</strong></span>
                <span class="company-reg">(1134596-M)</span><br>
                No. 72-3, Jalan Jalil 1,<br>
                The Earth Bukit Jalil,<br>
                57000 Kuala Lumpur<br>
                Tel: 03-8082 1252<br>
                TIN: C23880226040, MSIC: 46909<br>
                SST: W10-2403-32000643
            </td>
            <td class="header-details">
                <div class="title">
                    <strong>
                        Delivery Order
                    </strong>
                </div>

                <div class="number">EBDO#: {{ str_replace(['BI-'], 'BDO-', $transaction->bill_no) }}</div>
                <div class="ref">Ref#: {{ $transaction->booking->marking }}</div>
                <div class="date">Date: {{
                    $supplier->segments->whereIn('id', [23])->first() ? \Carbon\Carbon::now() : $po_order_transaction->created_at }}</div>
                <div>&nbsp;</div>
            </td>
        <tr>
            <td colspan="3" class="bill-to">
            <span class="sub-title">
                Bill To
            </span>
            </td>
        </tr>
        <tr>
            <td colspan="3" class="address">
                <div class="label">
                    {{ $supplier->name }}
                    @if ($brn)
                        (ROC: {{ $brn->reference }})
                    @endif
                </div>
                <div class="address">
                    @php
                        $billingAddress = $supplier->addresses()->where('billing', '=', true)->first();
                    @endphp
                    {{ $billingAddress->street_one }}
                    {{ $billingAddress->street_two }} ,
                    {{ $billingAddress->district()->first()->name }},
                    {{ $billingAddress->postcode }}
                    {{ $billingAddress->state()->first()->name }},
                    {{ $billingAddress->country()->first()->name }}
                </div>
                <div>
                    Phone: {{ $supplier->contacts()->first()->phone }}
                </div>
            </td>
        </tr>
    </table>

    <br>
    <br>

    <?php
        $voucher_redemption = $voucher_redemption ?? null;
    ?>

    @include('pages.pdfs.purchase_order_table_v3')

    <br>
    <br>

    <htmlpagefooter name="page-footer">
        <table width="100%">
            <tr>
                <td style="text-align: right; ">This is generated by computer. No signature required.</td>
                <td style="text-align: right; ">Page {PAGENO} of {nbpg}</td>
            </tr>
        </table>
    </htmlpagefooter>

    {{-- Notes: ONLY on last page --}}
    <ifpage pages="L">
        <div style="height: 5mm;"></div>
        <div class="note" style="
            position: fixed;
            bottom: 5mm;
        ">
            <table style="width: 100%; border-spacing: 0;">
                <tbody>
                    <tr>
                        <td width="60%">
                            CIEF WORLDWIDE SDN BHD<br>
                        </td>
                        <td width="40%" valign="top">
                            E & O.E<br>
                            Receive In Good Order & Condition<br>
                        </td>
                    </tr>
                </tbody>
            </table>
        </div>
    </ifpage>
@endsection
