{include file="sections/header.tpl"}
<div class="card border-0 shadow-sm mb-4">
    <div class="card-header bg-primary bg-gradient text-white">
        <i class="isax isax-chart-1 me-2"></i>{ucwords($pg)}
    </div>
    <div class="card-body">
        <form id="site-search" method="post" action="{Text::url('paymentgateway/audit/')}{$pg}" class="mb-3">
            <div class="input-group">
                <input type="text" name="q" class="form-control" placeholder="{Lang::T('Search')}..." value="{$q}">
                <button type="submit" class="btn btn-success">
                    <i class="isax isax-search-normal-1"></i>
                </button>
            </div>
        </form>
        <div class="table-responsive">
            <table class="table table-bordered table-striped table-hover mb-0">
                <thead class="table-light">
                    <tr>
                        <th>{Lang::T('TRX ID')}</th>
                        <th>{Lang::T('PG ID')}</th>
                        <th>{Lang::T('Username')}</th>
                        <th>{Lang::T('Plan Name')}</th>
                        <th>{Lang::T('Routers')}</th>
                        <th>{Lang::T('Price')}</th>
                        <th>{Lang::T('Payment Link')}</th>
                        <th>{Lang::T('Channel')}</th>
                        <th>{Lang::T('Created')}</th>
                        <th>{Lang::T('Expired')}</th>
                        <th>{Lang::T('Paid')}</th>
                        <th>{Lang::T('Invoice')}</th>
                        <th>{Lang::T('Status')}</th>
                    </tr>
                </thead>
                <tbody>
                    {foreach $pgs as $pg}
                        <tr class="{if $pg['status'] == 1}table-warning{elseif $pg['status'] == 2}table-success{else}table-danger{/if}">
                            <td>{$pg['id']}</td>
                            <td><a href="{Text::url('paymentgateway/audit-view/')}{$pg['id']}"
                                    class="text-dark text-decoration-none">{$pg['gateway_trx_id']}</a></td>
                            <td><a href="{Text::url('customers/viewu/')}{$pg['username']}"
                                    class="text-dark text-decoration-none">{$pg['username']}</a>
                            </td>
                            <td>{$pg['plan_name']}</td>
                            <td>{$pg['routers']}</td>
                            <td>{Lang::moneyFormat($pg['price'])}</td>
                            <td>
                                {if $pg['pg_url_payment']}
                                    <a href="{$pg['pg_url_payment']}" target="_blank" class="btn btn-sm btn-light w-100"
                                        rel="noopener noreferrer">
                                        <i class="isax isax-link-1 me-1"></i>{Lang::T('open')}
                                    </a>
                                {/if}
                            </td>
                            <td>{$pg['payment_method']} - {$pg['payment_channel']}</td>
                            <td>{if $pg['created_date'] != null}{Lang::dateTimeFormat($pg['created_date'])}{/if}</td>
                            <td>{if $pg['expired_date'] != null}{Lang::dateTimeFormat($pg['expired_date'])}{/if}</td>
                            <td>{if $pg['paid_date'] != null}{Lang::dateTimeFormat($pg['paid_date'])}{/if}</td>
                            <td>{if $pg['trx_invoice']}<a href="{Text::url('reports/activation&q=')}{$pg['trx_invoice']}"
                                    class="text-dark text-decoration-none">{$pg['trx_invoice']}</a>{/if}</td>
                            <td>
                                {if $pg['status'] == 1}
                                    <span class="badge bg-warning">UNPAID</span>
                                {elseif $pg['status'] == 2}
                                    <span class="badge bg-success">PAID</span>
                                {elseif $pg['status'] == 3}
                                    <span class="badge bg-danger">FAILED</span>
                                {else}
                                    <span class="badge bg-secondary">CANCELED</span>
                                {/if}
                            </td>
                        </tr>
                    {/foreach}
                </tbody>
            </table>
        </div>
    </div>
    <div class="card-footer">
        {include file="pagination.tpl"}
        <a href="{Text::url('paymentgateway')}" class="btn btn-light btn-sm">
            <i class="isax isax-arrow-left-2 me-1"></i>{Lang::T('back')}
        </a>
    </div>
</div>

{include file="sections/footer.tpl"}