Heray-Was-Here
Server : LiteSpeed
System : Linux uk-fast-web1372.main-hosting.eu 4.18.0-553.121.1.lve.el8.x86_64 #1 SMP Thu Apr 30 16:40:41 UTC 2026 x86_64
User : u390967363 ( 390967363)
PHP Version : 8.2.30
Disable Function : system, exec, shell_exec, passthru, mysql_list_dbs, ini_alter, dl, symlink, link, chgrp, leak, popen, apache_child_terminate, virtual, mb_send_mail
Directory :  /home/u390967363/domains/aibenproperties.com/public_html/app/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/u390967363/domains/aibenproperties.com/public_html/app/staff-activity.php
<?php
require_once __DIR__ . '/includes/header.php';

$roleRaw = (string)($_SESSION['user_role'] ?? 'guest');
$role = strtolower(preg_replace('/[^a-z0-9]+/','_', $roleRaw));
$allowed = [
    'staff','user',
    'marketing','marketer',
    'contact_rep','contact_centre','contact_center','customer_rep',
    'finance','finance_officer','finance_manager',
    'operations','operations_officer','operations_manager'
];
if (!in_array($role, $allowed, true)) {
    routeToRoleHome($role);
}

$companyId = function_exists('getCurrentCompanyId') ? (int)(getCurrentCompanyId() ?: 0) : (int)($_SESSION['company_id'] ?? 0);
$userId = (int)($_SESSION['user_id'] ?? 0);
$search = isset($_GET['search']) ? trim((string)$_GET['search']) : '';

$rows = [];
try {
    ensureAuditTableExists();
    $sql = "SELECT created_at, action, details, ip_address FROM audit_logs WHERE user_id = ?";
    $params = [$userId];
    if ($search !== '') {
        $sql .= " AND (action LIKE ? OR details LIKE ?)";
        $like = '%' . $search . '%';
        $params[] = $like;
        $params[] = $like;
    }
    if ($companyId && function_exists('tableHasColumn') && tableHasColumn('audit_logs','company_id')) { $sql .= " AND (company_id = ? OR company_id IS NULL)"; $params[] = $companyId; }
    $sql .= " ORDER BY id DESC LIMIT 50";
    $st = $pdo->prepare($sql);
    $st->execute($params);
    $rows = $st->fetchAll(PDO::FETCH_ASSOC) ?: [];
} catch (Throwable $e) { $rows = []; }

?>
<div class="d-flex flex-wrap justify-content-between align-items-center gap-2 mb-3">
    <div>
        <div class="text-muted small">Activity</div>
        <h2 class="h4 mb-0">My Activity</h2>
    </div>
</div>

<div class="card shadow-sm border-0">
    <div class="card-body">
        <?php if (!$rows): ?>
            <div class="text-muted">No activity yet.</div>
        <?php else: ?>
            <div class="table-responsive">
                <table class="table align-middle mb-0">
                    <thead class="table-light">
                        <tr>
                            <th>Date</th>
                            <th>Action</th>
                            <th>Details</th>
                            <th>IP</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php foreach ($rows as $r): ?>
                            <tr>
                                <td class="small text-muted">
                                    <?php
                                        $t = (string)($r['created_at'] ?? '');
                                        echo htmlspecialchars($t !== '' ? date('M j, Y g:ia', strtotime($t)) : '-');
                                    ?>
                                </td>
                                <td class="fw-semibold"><?= htmlspecialchars((string)($r['action'] ?? '')) ?></td>
                                <td class="small text-muted"><?= htmlspecialchars((string)($r['details'] ?? '')) ?></td>
                                <td class="small text-muted"><?= htmlspecialchars((string)($r['ip_address'] ?? '')) ?></td>
                            </tr>
                        <?php endforeach; ?>
                    </tbody>
                </table>
            </div>
        <?php endif; ?>
    </div>
</div>

<?php require_once __DIR__ . '/includes/footer.php'; ?>

Hry