
<?php $__env->startSection('content'); ?>

<div class="card mb-3">
    <div class="card-body">
        <h5 class="mb-3">Payment Statistics</h5>

        <!-- ✅ User & Date Filters -->
        <form method="GET" action="<?php echo e(route('admin.payment.stats')); ?>" class="row g-3">
            <div class="col-md-4">
                <label for="user_id" class="form-label">Select User</label>
                <select name="user_id" id="user_id" class="form-select" onchange="this.form.submit()">
                    <option value="">All Users</option>
                    <?php $__currentLoopData = $users; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $user): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <option value="<?php echo e($user->id); ?>" <?php echo e($selectedUser == $user->id ? 'selected' : ''); ?>>
                        <?php echo e($user->name); ?>

                    </option>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </select>
            </div>

            <div class="col-md-3">
                <label for="date1" class="form-label">Start Date</label>
                <input type="date" name="date1" id="date1" class="form-control" value="<?php echo e($startDate); ?>">
            </div>

            <div class="col-md-3">
                <label for="date2" class="form-label">End Date</label>
                <input type="date" name="date2" id="date2" class="form-control" value="<?php echo e($endDate); ?>">
            </div>

            <div class="col-md-2 d-flex align-items-end">
                <button type="submit" class="btn btn-primary"><i class="fas fa-search"></i> Search</button>
            </div>
        </form>

        <!-- ✅ Payment Summary Stats -->
        <div class="row mt-4">
            <div class="col-md-3">
                <div class="card text-center p-3">
                    <h6>Total Payments</h6>
                    <p><?php echo e($totalPayments); ?></p>
                </div>
            </div>
            <div class="col-md-3">
                <div class="card text-center p-3">
                    <h6>Total Amount</h6>
                    <p>E <?php echo e(number_format($totalAmount, 2)); ?></p>
                </div>
            </div>
            <div class="col-md-3">
                <div class="card text-center p-3">
                    <h6>Cash Collected</h6>
                    <p>E <?php echo e(number_format($cashCollected, 2)); ?></p>
                </div>
            </div>
            <div class="col-md-3">
                <div class="card text-center p-3">
                    <h6>Cash Not Collected</h6>
                    <p>E <?php echo e(number_format($cashNotCollected, 2)); ?></p>
                </div>
            </div>
            <div class="col-md-3 mt-3">
                <div class="card text-center p-3">
                    <h6>MoMo Collected</h6>
                    <p>E <?php echo e(number_format($momoCollected, 2)); ?></p>
                </div>
            </div>
            <div class="col-md-3 mt-3">
                <div class="card text-center p-3">
                    <h6>EFT Collected</h6>
                    <p>E <?php echo e(number_format($eftCollected, 2)); ?></p>
                </div>
            </div>
            <div class="col-md-3 mt-3">
                <div class="card text-center p-3">
                    <h6>Pending Payments</h6>
                    <p>E <?php echo e(number_format($pendingPayments, 2)); ?></p>
                </div>
            </div>
        </div>

        <!-- ✅ Payment List Table -->
        <div class="table-responsive mt-4">
            <h5>Payments List</h5>
            <small>
                <table id="order-table" class="table table-sm text-sm table-striped table-bordered nowrap">
                    <thead class="bg-light">
                        <tr>
                            <th>#</th>
                            <th>National ID</th>
                            <th>Name</th>
                            <th>Amount Paid</th>
                            <th>Months Covered</th>
                            <th>Cover Name</th>
                            <th>Payment Method</th>
                            <th>Payment Date</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php $__currentLoopData = $paymentList; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $index => $payment): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <tr>
                            <td><?php echo e($index + 1); ?></td>
                            <td><?php echo e($payment->national_id); ?></td>
                            <td><?php echo e($payment->surname); ?> <?php echo e($payment->name); ?></td>
                            <td>E <?php echo e(number_format($payment->pay_amount, 2)); ?></td>
                            <td><?php echo e(date('F-Y', strtotime($payment->months))); ?></td>
                            <td><?php echo e($payment->cover_name); ?></td>
                            <td><?php echo e($payment->mop); ?></td>
                            <td><?php echo e(date('d-M-Y H:i', strtotime($payment->created_at))); ?></td>
                        </tr>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </tbody>
                </table>
            </small>
        </div>

    </div>
</div>

<?php $__env->stopSection(); ?>
<?php echo $__env->make('layouts.admin', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH C:\WORK-STATION\MBBS\Insurance-Version Controls\03-01-2026\resources\views/admin/payment-stats.blade.php ENDPATH**/ ?>