<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>document</title>
    <style>

        body {
            font-family: sun-extA;
            overflow: wrap;
        }
        table {
            width: 100%;
        }
        td.title {
            text-align: left;
        }
        td.document-detail {
            text-align: left;
            border: 1px solid black;
            padding: 1em 1em 1em 1em;
            width: 16em;
        }
        .buyer-seller-title {
            font-size: 1.2em;
            font-weight: bolder;
        }
        td.description, th.description {
            text-align: justify;
            max-width: 40em;
        }
        td.stock-code, th.stock-code {
            text-align: center;
        }
        th {
            border-bottom: 1px solid black;
        }
        td.description, th.description {
            text-align: justify;
        }
        .total {
            border-top: 1px solid black;
            border-bottom: 3px double black;
            font-weight: bolder;
        }
        .center {
            text-align: center;
        }
        .right {
            text-align: right;
        }
        .middle {
            vertical-align: middle;
        }
        .top {
            vertical-align: top;
        }
        td {
            padding-bottom: 1em;
        }
        .subtotal td {
            border-top: 1px solid black;
        }

    </style>
</head>
<body>
    <table class="header">
        <tr>
            <td class="title">
                <h1>
                    {{ $title }}
                </h1>
            </td>
            <td class="document-detail">
                PO#: {{$detail['po']}} <br>
                Ref#: {{ $detail['ref'] }} <br>
                Date: {{ $detail['date'] }}
            </td>
        </tr>
    </table>

    <br>
    
    <table class="buyer-seller">
        <tr>
            <td width="50%" class="top">
                <span class="buyer-seller-title">
                    Buyer
                </span>
                <br>
                @if($buyer['marking_no'])
                <div class="buyer-company">
                    Marking#: {{$buyer['marking_no']}}
                </div>
                @endif
                <span class="buyer-company">
                    {{ $buyer['buyer_company'] }}
                </span>
                <span class="reg">
                    ({{ $buyer['reg_no'] }})
                </span>
                <br>
                <span class="address">
                    {{ $buyer['address'] }}
                </span>
                <br>
                <span class="contact-no">
                    Phone: {{ $buyer['phone'] }}
                </span>
            </td>
            <td width="50%" class="top">
                <span class="buyer-seller-title">
                    Seller
                </span>
                <br>
                <span class="buyer-company">
                    {{ $seller['seller_company'] }}
                </span>
                <div class="address">
                    {{ $seller['address'] }}
                </div>
                @if($seller['phone'])
                <div class="contact-no">
                    Phone: {{ $seller['phone'] }}
                </div>
                @endif
            </td>
        </tr>
    </table>

        <br>

    <table class="line-table" style="overflow: wrap" autosize="1">
        <thead>
            <tr>
                <th width="5%" >No</th>
                <th class="stock-code" width="10%">Stock Code</th>
                <th class="description">Description</th>
                <th width="10%">Quantity</th>
                <th width="12%">Unit Price (RM)</th>
                <th width="10%">Total Amount<br>(RM)</th>
            </tr>
        </thead>
        <tbody>
            @foreach ($lines as $line)
            <tr>
                <td width="5%" class="center top">{{$line->order}}</td>
                <td class="stock-code top" width="10%">{{$line->stock_code}}</td>
                <td class="description" >{{$line->description}}</td>
                <td width="10%" class="center top">{{$line->quantity}}</td>
                <td width="12%" class="center top">{{number_format($line->unit_price_rm, 2)}}</td>
                <td width="20%" class="right top">{{number_format($line->total, 2)}}</td>
            </tr>
            @endforeach
        </tbody>
        <tfoot>
            <tr class="subtotal">
                <td colspan="4"></td>
                <td class="right middle">Subtotal</td>
                <td class="right middle">{{ number_format($subtotal, 2) }}</td>
            </tr>
            @if($adjustment)
            <tr class="adjustment">
                <td colspan="4"></td>
                <td class="right middle">Adjustment</td>
                <td class="right middle">{{ number_format($adjustment, 2) }}</td>
            </tr>
            @endif
            @if($billingcharges)
            <tr class="billingcharges">
                <td colspan="4"></td>
                <td class="right middle">Billing Charges</td>
                <td class="right middle">{{ number_format($billingcharges, 2) }}</td>
            </tr>
            @endif
            <tr>
                <td colspan="4"></td>
                <td class="right middle">Total</td>
                <td class="total right middle">{{ number_format($total, 2) }}</td>
            </tr>
        </tfoot>
    </table>
    
    
</body>
</html>