Files
UAS_WebGIS_MuthiaNurainiAst…/povertymap/includes/user-profile.php
T
2026-06-15 21:53:17 +07:00

47 lines
2.0 KiB
PHP

<?php
$nama = htmlspecialchars($_SESSION['nama'] ?? 'Pengguna');
$role = $_SESSION['role'] ?? '';
$roleLabel = $role === 'superadmin' ? 'Super Admin' : (in_array($role, ['admin','user'], true) ? 'Admin' : ($role ? ucfirst($role) : 'User'));
$parts = preg_split('/\s+/', trim($_SESSION['nama'] ?? 'U'));
$initials = '';
foreach (array_slice($parts, 0, 2) as $p) { $initials .= mb_strtoupper(mb_substr($p, 0, 1)); }
if ($initials === '') $initials = 'U';
$avatarClass = $role === 'superadmin' ? 'avatar-admin' : 'avatar-user';
?>
<style>
.sb-account {
display: flex; align-items: center; gap: 10px;
padding: 10px; margin-bottom: 8px;
background: var(--bg, #f0f4f8); border-radius: 10px;
border: 1px solid var(--border, #e2e8f0);
}
.sb-avatar {
width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0;
display: flex; align-items: center; justify-content: center;
font-size: 13px; font-weight: 700; color: #fff;
letter-spacing: .3px;
}
.sb-avatar.avatar-admin { background: linear-gradient(135deg, #7c3aed, #2563eb); }
.sb-avatar.avatar-user { background: linear-gradient(135deg, #0891b2, #2563eb); }
.sb-account-info { flex: 1; min-width: 0; text-align: left; }
.sb-account-name {
font-size: 13px; font-weight: 700; color: var(--text, #1e293b);
white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
line-height: 1.3;
}
.sb-account-role {
display: inline-block; margin-top: 3px;
font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: 20px;
text-transform: capitalize;
}
.sb-account-role.role-admin { background: #ede9fe; color: #7c3aed; }
.sb-account-role.role-user { background: #dbeafe; color: #2563eb; }
</style>
<div class="sb-account">
<div class="sb-avatar <?= $avatarClass ?>"><?= $initials ?></div>
<div class="sb-account-info">
<div class="sb-account-name"><?= $nama ?></div>
<span class="sb-account-role <?= $role === 'superadmin' ? 'role-admin' : 'role-user' ?>"><?= htmlspecialchars($roleLabel) ?></span>
</div>
</div>