<!doctype html>
<html lang="en">

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link rel="shortcut icon" href="{{ asset('favicon.ico') }}" type="image/x-icon">
    <title>{{ config('app.name') . ' ' . 'Weekly Statement' }}</title>
    <style>
        @page {
            margin: 45px;
        }

        body {
            font-family: Arial, Helvetica, sans-serif;
        }

        table {
            /*border: 1px solid #FFFFFF;*/
            width: 100%;
            border-collapse: collapse;
            font-size: 10pt;
        }

        td,
        th {
            /*border: 1px solid #000000;*/
            width: auto;
        }

        td {
            padding: 4px 0;
        }

        .page-break {
            page-break-after: always;
        }

        .next-line {
            margin-bottom: 10px;
        }

        .logo {
            height: 50px;
            width: auto;
        }

        #header .h-r {
            width: 60%;
            padding: 5px 10px;
        }

        #header .h-l {
            width: 40%;
            padding: 3px 10px;
        }

        .title {
            font-size: 12pt;
            font-weight: bold;
        }

        .sub-title {
            font-size: 11pt;
            font-weight: bold;
        }

        .content {
            font-size: 10pt;
            width: 50%;
        }

        .sub-content {
            font-size: 10pt;
            line-height: 1.5;
        }

        #footer {
            position: fixed;
            bottom: -20px;
            left: 0px;
            right: 0px;
            height: 50px;
            align-self: center;
        }

        .no-border {
            border: none !important;
        }

        .v-align-baseline {
            vertical-align: baseline;
        }

        .p-0 {
            padding: 0;
        }
    </style>
</head>

<body>
    <table class="no-border">
        <tr>
            <td class="title no-border" rowspan="3" style="width: 60%; padding: 0">
                <img class="logo" style="height: 90px;"
                    src="data:image/png;base64,{{ base64_encode(file_get_contents(config('amplivo.admin_url') . 'upload/' . $pdfContent->pdf_logo)) }}"
                    alt="logo">
            </td>
        </tr>
        <tr>
            <td class="no-border" style="width: 40%; padding: 0" align="right">
                <b>{{ $pdfContent->su_business_name }}</b> <br>
                {{ $pdfContent->su_address_1 }} <br>
                {{ $pdfContent->su_address_2 }} <br>
                {{ $pdfContent->su_address_3 }} <br>
                {{ $pdfContent->su_address_4 }} <br>
                {{ $pdfContent->su_address_5 }} <br>
            </td>
        </tr>
    </table>

    <table class="next-line">
        <tr class="no-border">
            <th align="center">
                <h1>{{ $pdfContent->commission_statement }}</h1>
            </th>
        </tr>
    </table>

    <table>
        <tr>
            <td class="content" style="width: 90%">
                {{-- <div><b>{{ $pdfContent->supporter }} :</b></div> --}}
                <div class="sub-content">
                    <span class="bold-content">{{ $pdfContent->username }} : </span> <b>{{ $userDetail->username ?? '' }}</b> <br>
                    <span class="bold-content">{{ $pdfContent->name }} :
                    </span><b>{{ ($userDetail->first_name ?? '') . ' ' . ($userDetail->last_name ?? '') }} </b><br>
                    <span class="bold-content">{{ $pdfContent->address }} :</span><b>
                        @if (isset($address->address_1) && !empty($address->address_1))
                            {{ $address->address_1 }},
                        @endif
                        @if (isset($address->address_2) && !empty($address->address_2))
                            {{ $address->address_2 }},
                        @endif
                        @if((isset($address->city) && !empty($address->city)))
                             {{ $address->city ?? '' }},
                        @endif
                        @if ((isset($address->state) && !empty($address->state)))
                         {{ isset($address->state) ? $address->state->name . ',' : '' }}
                        @endif
                        {{ $address->country->country_name ?? '' }}
                        {{ isset($address->postal_code) ? $address->postal_code : '' }}
                    </b><br>
                    <span class="bold-content">{{ $pdfContent->year_week }} :</span><b>{{ date('Y/W', strtotime($created_at)) }}</b>
                </div>
            </td>

        </tr>
    </table>

    <table class="next-line"></table>
    <table class="next-line"></table>

    <table class="no-border">
        <tr style="border-bottom: 2px solid black;">
            <td class="sub-title" style="width:50%;padding-bottom: 3pt;" align="left">
                <b>{{ $pdfContent->commission_type }}</b>
            </td>
            <td class="sub-title" style="width:50%" align="right">
                <b>{{ $pdfContent->commission_value }}</b>
            </td>
        </tr>
        <tr>
            <td colspan="2" style="height: 10px;"></td>
        </tr>

        @foreach ($logs as $val)
            <tr>
                <td>{{ getActionMessageOfWalletLog($val) }}</td>
                <td style="width:50%" align="right">{{ number_format($val->daily_sum, 2) }} {{ $pdfContent->euro }}</td>
            </tr>
        @endforeach
        <tr>
            <td colspan="2" style="height: 10px;"></td>
        </tr> <!-- Spacer row BEFORE -->
        <tr style="border-bottom: 2px solid black">
            <td></td>
            <td></td>
        </tr>
        <tr>
            <td class="sub-title" style="width:50%" align="left">{{ $pdfContent->grand_total }}</td>
            <td style="width:50%" align="right">{{ number_format($total, 2) }} {{ $pdfContent->euro }}</td>
        </tr>

    </table>

    <table class="next-line"></table>

    <table class="next-line"></table>

    <table id="footer" class="no-border">
        <tr>
            <td class="no-border" align="center">
                {{ $pdfContent->footer_text_line_1 }} <br>
                {{ $pdfContent->footer_text_line_2 }}.
            </td>
        </tr>
    </table>
</body>

</html>
