<?php
    $orderDetailJson = $order->detailJson();
    $orderSelectedOptions = json_decode(@$orderDetailJson->selected_options ?? '{}');
    $orderSummary = $order->getOrderAllTestsRequested();
?>

<tr>
    <td>
        <table border="0" cellpadding="0" cellspacing="0"
            style="border-collapse:collapse;border-spacing:0;width:100%;color:rgb(51,51,51);font-family:'Helvetica Neue',Helvetica,Arial,sans-serif">
            <tbody>
                <tr height="24" style="background-color:rgb(250,250,250)">
                    <td colspan="5" valign="top"
                        style="text-align:center;text-transform:uppercase;padding:10px;border-top-left-radius:3px;border-bottom-left-radius:3px">
                        <span
                            style="font-size:15px;font-weight:600;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif">Order
                            Information</span>
                    </td>
                </tr>
                <tr height="15">
                    <td colspan="5"></td>
                </tr>
                <tr>
                    <td colspan="3" style="width:200px;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif">Date:
                        <?= date('m/d/Y', strtotime($order->created_at)) ?>
                    </td>
                    <td colspan="2" align="right" valign="top"
                        style="width:430px;padding:0 6px;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif">Order #: {{ $order->orderNumber() }}</td>
                </tr>
                <tr height="15">
                    <td colspan="5"></td>
                </tr>
                <tr height="24" style="background-color:rgb(250,250,250)">
                    <td colspan="5" valign="top"
                        style="text-align:center;text-transform:uppercase;padding:6px;border-top-left-radius:3px;border-bottom-left-radius:3px">
                        <span style="font-size:15px;font-weight:600">Tests Ordered</span></td>
                </tr>
                <tr height="15">
                    <td colspan="5"></td>
                </tr>
                @foreach ($orderSummary['all_tests'] as $test => $price)
                    <tr>
                        <td colspan="3" style="padding:0 0 0 0;vertical-align:top;">
                            <span
                                style="font-weight:400;">{{ getTestDisplayName($test) }}</span>
                        </td>
                        <td align="right" valign="top" style="padding:0 0px;">
                            @if($price > 1)
                                <span style="font-weight:400;white-space:nowrap;display:block;">${{ number_format($price, 2) }}</span>
                            @endif
                        </td>
                    </tr>
                @endforeach

                @if (@$orderSelectedOptions->partner == 1)

                @foreach ($orderSummary['all_tests'] as $pTestKey => $pTestPrice)
                    <tr>
                        <td colspan="3" style="padding:0 0 0 0;vertical-align:top;">
                            <span
                                style="font-weight:400;">{{ getTestLabelByKey($pTestKey) }} (Partner Test)</span>
                        </td>
                        <td align="right" valign="top" style="padding:0 0px;">
                            <span
                                style="font-weight:400;white-space:nowrap;display:block;">${{ number_format($pTestPrice, 2) }}</span>
                        </td>
                    </tr>
                @endforeach
                @endif
            </tbody>
        </table>
    </td>
</tr>
<tr>
    <td>
        <table border="0" cellpadding="0" cellspacing="0"
            style="border-collapse:collapse;border-spacing:0;width:100%;color:rgb(51,51,51);font-family:'Helvetica Neue',Helvetica,Arial,sans-serif">
            <tbody>
                <tr height="10">
                    <td colspan="3"></td>
                </tr>
                <tr height="10">
                    <td height="1" colspan="3">
                        <div style="line-height:1px;height:1px;background-color:rgb(238,238,238)"></div>
                    </td>
                </tr>
                @if (@$orderSelectedOptions->partner == 1)
                    <tr height="28">
                        <td align="right"
                            style="color:#000;font-size:14px;font-weight:400;padding:0 30px 0 0;border:none;border-width:1px;border-color:rgb(238,238,238)">
                            Subtotal</td>
                        <td width="1" style="background-color:rgb(238,238,238);width:1px"></td>
                        <td width="90" align="right"
                            style="width:120px;font-size:16px;font-weight:400;white-space:nowrap">
                            ${{ number_format(@$orderSummary['sub_total'], 2) }}
                        </td>
                    </tr>
                    <tr height="28">
                        <td align="right"
                            style="color:#048a16;font-size:14px;font-weight:400;padding:0 30px 0 0;border:none;border-width:1px;border-color:rgb(238,238,238)">
                            Partner Discount</td>
                        <td width="1" style="background-color:rgb(238,238,238);width:1px"></td>
                        <td width="90" align="right"
                            style="width:120px;font-size:16px;font-weight:400; color:#048a16;white-space:nowrap">
                            -${{ number_format(@$orderSummary['partner_total_discount'], 2) }}
                        </td>
                    </tr>
                @endif
                <tr height="28">
                    <td align="right"
                        style="color:#000;font-size:14px;font-weight:600;padding:0 30px 0 0;border:none;border-width:1px;border-color:rgb(238,238,238)">
                        TOTAL</td>
                    <td width="1" style="background-color:rgb(238,238,238);width:1px"></td>
                    <td width="90" align="right"
                        style="width:120px;font-size:16px;font-weight:600;white-space:nowrap">
                        ${{ number_format(@$orderSummary['final_total'], 2) }}
                    </td>
                </tr>
                <tr height="10">
                    <td height="1" colspan="3">
                        <div style="line-height:1px;height:1px;background-color:rgb(238,238,238)"></div>
                    </td>
                </tr>
            </tbody>
        </table>
    </td>
</tr>
