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


    <div class="card shadow-lg border-0 mb-4">
        <div class="card-title text-center ">{Lang::T('Payment Gateway Audit')}
        </div>

        <div class="card-body">
            <!-- Search Form -->
            <form id="site-search" method="post" action="{$_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}">
                    <div class="input-group-append">
                        <button type="submit" class="btn btn-success">
                            <i class="glyphicon glyphicon-search"></i> {Lang::T('Search')}
                        </button>
                    </div>
                </div>
            </form>

            <!-- Responsive Table -->
            <div class="table-responsive">
                <table class="table table-bordered table-hover table-sm">
                    <thead class="thead-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('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="{$_url}paymentgateway/audit-view/{$pg['id']}" class="text-dark">{$pg['gateway_trx_id']}</a></td>
                                <td><a href="{$_url}customers/viewu/{$pg['username']}" class="text-dark">{$pg['username']}</a></td>
                                <td>{$pg['plan_name']}</td>
                                <td>{$pg['routers']}</td>
                                <td>{Lang::moneyFormat($pg['price'])}</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="{$_url}reports/activation&q={$pg['trx_invoice']}" class="text-dark">{$pg['trx_invoice']}</a>
                                    {/if}
                                </td>
                                <td>
                                    {if $pg['status'] == 1}UNPAID
                                    {elseif $pg['status'] == 2}PAID
                                    {elseif $pg['status'] == 3}FAILED
                                    {else}CANCELED{/if}
                                </td>
                            </tr>
                        {/foreach}
                    </tbody>
                </table>
            </div>

            <!-- Status Legend -->
            <div class="mt-4">
                <h5>{Lang::T('Status Key')}</h5>
                <ul class="list-inline">
                    <li class="list-inline-item">
                        <span class="badge badge-warning">Unpaid</span> - {Lang::T('Pending Payment')}
                    </li>
                    <li class="list-inline-item">
                        <span class="badge badge-success">Paid</span> - {Lang::T('Transaction Completed')}
                    </li>
                    <li class="list-inline-item">
                        <span class="badge badge-danger">Cancelled</span> - {Lang::T('Transaction Cancelled or Failed')}
                    </li>
                </ul>
            </div>

            <!-- Pagination -->
            {include file="pagination.tpl"}

            <!-- Back Button -->
            <a href="{$_url}paymentgateway/" class="btn btn-secondary btn-sm mt-3">
                <i class="fa fa-arrow-left"></i> {Lang::T('Back')}
            </a>
        </div>
    </div>
</div>
{include file="sections/footer.tpl"}
