@extends('layouts.base_pdf')

@section('inner_content')

    <br>
    <htmlpageheader name="page-header">
        <br><br>
        <div class="separator"><strong><i>{{ $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
            </td>
            <td class="header-details">
                <div class="title"><strong>Receipt Voucher</strong></div>
                <div class="number">EI#: {{ $transaction->bill_no }}</div>
                <div class="ref">Ref# {{ $booking->marking ?? "-" }}</div>
                <div class="date">Date: {{ $transaction->created_at }}</div>
                <div>&nbsp;</div>
            </td>
        </tr>
        <tr>
            <td colspan="3" class="bill-to">
                <span class="sub-title">Received From: </span>
            </td>
        </tr>
        <tr>
            <td colspan="3" class="address">
                <div class="label">{{ $supplier->name }}
                    @if ($supplier->e_invoice === 1)
                        (TIN: {{ $supplier->tin }})
                    @endif
                </div>
                @php
                    $billingAddress = $supplier->addresses()->where('billing', '=', true)->first();
                @endphp
                <div class="address">
                    {{ $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>

    @php
        $total = round($transaction->amount, 2);
    @endphp

    <table>
        <tr>
            <td>
                <p><strong>RECEIVE THE SUM OF: <span style="text-decoration: underline;">{{ \App\Classes\General\Helper::convert(round($transaction->amount, 2)) }}</span></strong></p>
            </td>
        </tr>
    </table>

    <table width="100%" border="1" cellpadding="5" cellspacing="0" style="border-collapse: collapse; margin-top: 20px; font-size: 12px;">
        <thead>
            <tr style="background-color: #f0f0f0;">
                <th>Payment Method</th>
                <th>Transaction ID</th>
                <th style="text-align:right;">Payment Amount</th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td style="text-transform: uppercase;">{{ ucwords(str_replace('_', ' ', \App\Classes\ValueObjects\Constants\PaymentMethodType::PAYMENT_METHODS_ID[$transaction->payment_method])) }}</td>
                <td>{{ $transaction->owner->bill_no ?? '-' }}</td>
                <td style="text-align:right;">{{ number_format($total, 2) }}</td>
            </tr>
        </tbody>
    </table>

    <p><strong>Paid For</strong></p>

    <table width="100%" border="1" cellpadding="5" cellspacing="0" style="border-collapse: collapse; font-size: 12px;">
        <thead>
            <tr style="background-color: #f0f0f0;">
                <th>Description</th>
                <th style="text-align:right;">Amount</th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td>PAYMENT FOR REF. {{ $booking->marking ?? 'N/A' }}</td>
                <td style="text-align:right;">{{ number_format($total, 2) }}</td>
            </tr>
        </tbody>
    </table>

    <br><br><br><br><br> <br><br>

    <p style="text-align: right; font-weight: bold; margin-top: 10px; border-top: 1px solid #000; padding-top: 5px;">
        TOTAL: {{ number_format($total, 2) }}
    </p>
    <p style="text-align:center; font-size: 10px; margin-top: 30px;">AUTO GENERATED BY EXCHANGE PORTAL, NO SIGNATURE REQUIRED</p>

@endsection
