<?php
// Your User and Wallet classes and any necessary configurations go here

$search_term = isset($_GET['search']) ? $_GET['search'] : '';
$users = User::find_all();

foreach ($users as $usera) {
    if (stripos($usera->email, $search_term) !== false || stripos($usera->first_name . " " . $usera->last_name, $search_term) !== false) {
        $his_wallet = Wallet::find_by_user_id($usera->id);

        if ($his_wallet) {
            $his_wallet = array_shift($his_wallet);
            $balance = $his_wallet->balance;
        } else {
            $balance = 0;
        }
?>

        <tr class='hover:bg-sky-300 hover:text-sky-950'>
            <td class="font-normal leading-normal"><?= $usera->id ?></td>
            <td class="font-normal leading-normal"><?= $usera->email ?></td>
            <td class="font-normal leading-normal"><?= $usera->first_name . " " . $usera->last_name ?></td>
            <td class="font-normal leading-normal">₦<?= $balance ?></td>
            <td class="font-normal leading-normal">
                <?= $usera->status == 1 ? '<span class="badge badge-lg bg-gradient-to-tl from-green-600 to-lime-400">Verified</span>' : '<span class="badge badge-lg bg-gradient-to-tl from-red-600 to-rose-400">Not Verify</span>' ?>
            </td>
            <td>
                <a href="./?page=users&sub_service=-user_detail&userah=<?= base64_encode($usera->id) ?>" class="hover:shadow-soft-xs inline hover:scale-105 rounded-lg px-4 py-1 text-white bg-sky-950">View</a>
            </td>
        </tr>

<?php
    } // End if statement
} // End foreach loop
?>
