<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Invoice <%= inv_id %></title>
    <style>
        body {
            font-family: Arial, sans-serif;
            margin: 0;
            padding: 0;
            background-color:white;
            font-size: 10px;
        }
        .invoice-box {
            width: fit-content;
            height: 100%;
            margin: 10px auto;
            padding: 40px;
            background-color: white;
        }
        h2 {
            font-size: 15px !important;
            font-weight: 600 !important;
        }
        h3 {
            padding: 0px !important;
            margin-bottom: 2px !important;
        }
        p{
            margin: 2px !important;
        }
        .header {
            display: flex;
            justify-content: space-between;
            align-items: center;
        }
        .header img {
            max-width: 200px;
        }
        .paid-label {
            /* background-color: green; */
            color: green;
            text-align: right;
            padding: 10px 45px;
            border-radius: 3px;
            font-size: 20px;
            font-weight: 700;
            text-transform: uppercase;
            margin-bottom: 15px;
        }
        .company-info {
            text-align: right;
        }
        .company-info h2 {
            margin: 0;
        }
        .invoice-details {
            margin-top: 20px;
        }
        .invoice-details table {
            width: 100%;
            border-collapse: collapse;
            font-size: 10px;
            margin-top: 10px;
        }
        .invoice-details th {
            padding: 5px;
            border: 1px solid #ccc;
            text-align: center;
            font-size: 10px;
        }
        .invoice-details td {
            padding: 5px;
            font-size: 10px;
            border: 1px solid #ccc;
            text-align: left;
        }
        .transactions {
            margin-top: 10px;
        }
        .transactions table {
            width: 100%;
            margin-top: 10px !important;
            border-collapse: collapse;
        }
        .transactions th {
            padding: 5px;
            border: 1px solid #ccc;
            text-align: center;
            font-size: 10px;
        }
        .transactions td {
            padding: 5px;
            font-size: 10px;
            border: 1px solid #ccc;
            text-align: left;
        }
        thead {
            background-color: #f2f2f2;
        }
        tfoot {
            background-color: #f2f2f2;
        }
        
    </style>
</head>
<body>

    <div class="invoice-box">
        <table style="width: 100%;">
            <tr>
                <td style="width: 70%;">
                    <img width="200" src="https://api.wabill.antmedia.id/images/logo.png" alt="AntmediaHost Logo">
                </td>
                <td style="text-align: right;">
                    <% if(inv_status == 'Paid') { %>
                        <span class="paid-label">Paid</span>
                    <% } else { %>
                        <span class="paid-label" style="color: red !important;">UnPaid</span>
                    <% } %>
                </td>
            </tr>
        </table>
        <div class="company-info">
            <h2>PT. Semut Data Indonesia</h2>
            <p style="padding: 0 !important; margin: 5px 0px;">BCA : 0953611691</p>
            <p style="padding: 0 !important; margin: 5px 0px;">Mandiri : 1330013530878</p>
            <p style="padding: 0 !important; margin: 5px 0px;">BRI : 001201003011308</p>
        </div>

        <div class="invoice-details">
            <h3>Invoice: #<%= inv_id %></h3>
            <p style="padding: 0 !important; margin: 5px 0px;">Date: <%= inv_date %></p>
            <p style="padding: 0 !important; margin: 5px 0px;">Due Date: <%= inv_duedate %></p>
            <h3>Invoiced To:</h3>
            <p>
                <%= company %><br>
                <%= client_name %><br>
                <%- client_address %>
            </p>

            <table style="font-size: 11px;">
                <thead>
                    <tr>
                        <th>Description</th>
                        <th style="width: 150px;">Total</th>
                    </tr>
                </thead>
                <tbody>
                    <% items.forEach(function(item, index) { %>
                    <tr>
                        <td><%= item.description %></td>
                        <td style="text-align: end !important;"><%= item.amount %></td>
                    </tr>
                    <% }); %>
                </tbody>
                <tfoot >
                    <tr>
                        <td style="text-align: end !important;">Sub Total</td>
                        <td style="text-align: end !important;"><%= sub_total %></td>
                    </tr>
                    <tr>
                        <td style="text-align: end !important;">11.00% PPN</td>
                        <td style="text-align: end !important;"><%= ppn %></td>
                    </tr>
                    <tr>
                        <td style="text-align: end !important;">Credit</td>
                        <td style="text-align: end !important;"><%= credit %></td>
                    </tr>
                    <tr>
                        <td style="text-align: end !important;"><strong>Total</strong></td>
                        <td style="text-align: end !important;"><strong><%= total %></strong></td>
                    </tr>
                </tfoot>
            </table>
        </div>

        <div class="transactions">
            <h3>Transactions</h3>
            <table style="font-size: 11px;">
                <thead>
                    <tr>
                        <th>Date</th>
                        <th>Gateway</th>
                        <th>Transaction ID</th>
                        <th>Amount</th>
                    </tr>
                </thead>
                <tbody>
                    <% transaction.forEach(function(item, index) { %>
                    <tr>
                        <td><%= item.date %></td>
                        <td><%= item.gateway %></td>
                        <td>-</td>
                        <td style="text-align: end !important;"><%= item.amount %></td>
                    </tr>
                    <% }); %>
                </tbody>
                <tfoot>
                    <tr>
                        <td colspan="3" style="text-align: end !important;">Balance</td>
                        <td style="text-align: end !important; width: 150px;"><%= balance %></td>
                    </tr>
                </tfoot>
            </table>
        </div>
    </div>

</body>
</html>
