36398-vm/profile.php
2025-11-28 03:31:58 +00:00

71 lines
2.5 KiB
PHP

<?php
session_start();
if (!isset($_SESSION["role"])) {
header("location: login.php");
}
require 'db/config.php';
$username = $_SESSION["username"];
// Fetch user details
$stmt = db()->prepare("SELECT * FROM users WHERE username = ?");
$stmt->execute([$username]);
$user = $stmt->fetch();
// Fetch user attendance
$stmt = db()->prepare("SELECT attendance_date, status FROM attendance WHERE user_id = ? ORDER BY attendance_date DESC");
$stmt->execute([$user['id']]);
$attendance_records = $stmt->fetchAll();
?>
<!DOCTYPE html>
<html>
<head>
<title>Employee Profile</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
<link href="assets/css/custom.css" rel="stylesheet">
</head>
<body>
<div class="d-flex">
<?php include 'sidebar.php'; ?>
<div class="content p-4">
<h1 class="mb-4">Employee Profile</h1>
<div class="card mb-4">
<div class="card-body">
<h5 class="card-title">Profile Details</h5>
<p><strong>Name:</strong> <?php echo htmlspecialchars($user['full_name']); ?></p>
<p><strong>Username:</strong> <?php echo htmlspecialchars($user['username']); ?></p>
<p><strong>Role:</strong> <?php echo htmlspecialchars($user['role']); ?></p>
</div>
</div>
<div class="card">
<div class="card-body">
<h5 class="card-title">Attendance History</h5>
<table class="table table-striped">
<thead>
<tr>
<th>Date</th>
<th>Status</th>
</tr>
</thead>
<tbody>
<?php foreach ($attendance_records as $record): ?>
<tr>
<td><?php echo htmlspecialchars($record['attendance_date']); ?></td>
<td><?php echo htmlspecialchars($record['status']); ?></td>
</tr>
<?php endforeach; ?>
<?php if (empty($attendance_records)): ?>
<tr>
<td colspan="2" class="text-center">No attendance records found.</td>
</tr>
<?php endif; ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</body>
</html>