

<?php $__env->startSection('content'); ?>
<div class="container">
    <div class="container-header">
        <h1><?php echo e($title); ?></h1>
    </div>

    <div class="card mb-25">
        <div class="card-body">
            <form method="get" class="filter-form">
                <div class="row">
                    <div class="form-group width-33">
                        <label class="form-label">Method</label>
                        <select name="method" class="form-control">
                            <option value="">All</option>
                            <option value="paystack" <?php echo e(request('method') === 'paystack' ? 'selected' : ''); ?>>Paystack</option>
                            <option value="flutterwave" <?php echo e(request('method') === 'flutterwave' ? 'selected' : ''); ?>>Flutterwave</option>
                            <option value="bank" <?php echo e(request('method') === 'bank' ? 'selected' : ''); ?>>Bank transfer</option>
                        </select>
                    </div>
                    <div class="form-group width-33">
                        <label class="form-label">Status</label>
                        <select name="status" class="form-control">
                            <option value="">All</option>
                            <option value="pending" <?php echo e(request('status') === 'pending' ? 'selected' : ''); ?>>Pending</option>
                            <option value="success" <?php echo e(request('status') === 'success' ? 'selected' : ''); ?>>Success</option>
                            <option value="failed" <?php echo e(request('status') === 'failed' ? 'selected' : ''); ?>>Failed</option>
                            <option value="cancelled" <?php echo e(request('status') === 'cancelled' ? 'selected' : ''); ?>>Cancelled</option>
                        </select>
                    </div>
                    <div class="form-group width-33" style="margin-top: 26px;">
                        <button class="btn btn-primary" type="submit">Filter</button>
                    </div>
                </div>
            </form>
        </div>
    </div>

    <div class="card table-card">
        <div class="table-header">
            <form method="get" action="<?php echo e(route('backend.payments.index')); ?>" class="table-search-form">
                <?php if(request('method')): ?><input type="hidden" name="method" value="<?php echo e(request('method')); ?>"><?php endif; ?>
                <?php if(request('status')): ?><input type="hidden" name="status" value="<?php echo e(request('status')); ?>"><?php endif; ?>
                <div class="table-search">
                    <input type="text" name="search" class="search-input" placeholder="Search by reference, amount, user..." value="<?php echo e($search ?? ''); ?>">
                    <i class="las la-search"></i>
                </div>
                <button type="submit" class="btn btn-secondary search-btn">Search</button>
                <?php if(!empty($search)): ?>
                    <a href="<?php echo e(route('backend.payments.index', request()->only('method', 'status'))); ?>" class="btn btn-outline">Clear</a>
                <?php endif; ?>
            </form>
        </div>
        <div class="table-responsive">
            <table class="table">
                <thead>
                    <tr>
                        <th>#</th>
                        <th>User</th>
                        <th>Method</th>
                        <th>Amount</th>
                        <th>Reference</th>
                        <th>Status</th>
                        <th>Date</th>
                        <th>Action</th>
                    </tr>
                </thead>
                <tbody>
                    <?php $__empty_1 = true; $__currentLoopData = $payments; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $payment): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                        <tr>
                            <td><?php echo e($payments->firstItem() + $loop->index); ?></td>
                            <td><?php echo e($payment->user?->email ?? 'N/A'); ?></td>
                            <td><?php echo e(ucfirst($payment->method)); ?></td>
                            <td><?php echo e($payment->currency); ?> <?php echo e(number_format($payment->amount, 2)); ?></td>
                            <td><?php echo e($payment->reference); ?></td>
                            <td>
                                <?php
                                    $class = match ($payment->status) {
                                        'success'  => 'status success',
                                        'pending'  => 'status pending',
                                        'failed'   => 'status failed',
                                        'cancelled'=> 'status failed',
                                        default    => 'status',
                                    };
                                ?>
                                <span class="<?php echo e($class); ?>"><?php echo e(ucfirst($payment->status)); ?></span>
                            </td>
                            <td><?php echo e($payment->created_at?->format('Y-m-d H:i')); ?></td>
                            <td>
                                <div class="table-actions">
                                    <a href="<?php echo e(route('backend.payments.show', $payment)); ?>" class="table-btn">
                                        <i class="las la-eye"></i>
                                    </a>
                                    <?php if($payment->method === 'bank' && $payment->status === 'pending'): ?>
                                        <form action="<?php echo e(route('backend.payments.approve-bank', $payment)); ?>" method="post" class="d-inline" onsubmit="return confirm('Approve this bank payment?');">
                                            <?php echo csrf_field(); ?>
                                            <button type="submit" class="table-btn"><i class="las la-check"></i></button>
                                        </form>
                                        <form action="<?php echo e(route('backend.payments.reject-bank', $payment)); ?>" method="post" class="d-inline" onsubmit="return confirm('Reject this bank payment?');">
                                            <?php echo csrf_field(); ?>
                                            <button type="submit" class="table-btn"><i class="las la-times"></i></button>
                                        </form>
                                    <?php endif; ?>
                                </div>
                            </td>
                        </tr>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                        <tr><td colspan="8" class="text-center">No payments found.</td></tr>
                    <?php endif; ?>
                </tbody>
            </table>
        </div>

        <?php if($payments instanceof \Illuminate\Pagination\LengthAwarePaginator): ?>
            <div class="pagination-wrapper">
                <?php echo e($payments->links('vendor.pagination.default')); ?>

            </div>
        <?php endif; ?>
    </div>
</div>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('backend.layout.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\Users\HP\Desktop\product\smsflow\core\resources\views/backend/payments/index.blade.php ENDPATH**/ ?>