491 lines
13 KiB
PHP
491 lines
13 KiB
PHP
<!DOCTYPE html>
|
|
<html lang="id">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<meta name="csrf-token" content="{{ csrf_token() }}">
|
|
<title>Kelola Pengguna - Admin</title>
|
|
<style>
|
|
* {
|
|
margin: 0;
|
|
padding: 0;
|
|
box-sizing: border-box;
|
|
}
|
|
|
|
body {
|
|
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
min-height: 100vh;
|
|
padding: 20px;
|
|
}
|
|
|
|
.container {
|
|
max-width: 1400px;
|
|
margin: 0 auto;
|
|
}
|
|
|
|
.header {
|
|
background: white;
|
|
padding: 25px 30px;
|
|
border-radius: 10px;
|
|
margin-bottom: 25px;
|
|
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
}
|
|
|
|
.header h1 {
|
|
color: #333;
|
|
font-size: 28px;
|
|
}
|
|
|
|
.header-actions {
|
|
display: flex;
|
|
gap: 10px;
|
|
}
|
|
|
|
.btn {
|
|
padding: 10px 20px;
|
|
border: none;
|
|
border-radius: 5px;
|
|
cursor: pointer;
|
|
font-size: 14px;
|
|
text-decoration: none;
|
|
transition: all 0.3s;
|
|
display: inline-block;
|
|
}
|
|
|
|
.btn-primary {
|
|
background: #667eea;
|
|
color: white;
|
|
}
|
|
|
|
.btn-primary:hover {
|
|
background: #5568d3;
|
|
}
|
|
|
|
.btn-danger {
|
|
background: #e74c3c;
|
|
color: white;
|
|
}
|
|
|
|
.btn-danger:hover {
|
|
background: #c0392b;
|
|
}
|
|
|
|
.alert {
|
|
padding: 15px 20px;
|
|
border-radius: 5px;
|
|
margin-bottom: 20px;
|
|
font-size: 14px;
|
|
}
|
|
|
|
.alert-success {
|
|
background: #d4edda;
|
|
color: #155724;
|
|
border: 1px solid #c3e6cb;
|
|
}
|
|
|
|
.alert-error {
|
|
background: #f8d7da;
|
|
color: #721c24;
|
|
border: 1px solid #f5c6cb;
|
|
}
|
|
|
|
.stats {
|
|
display: grid;
|
|
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
|
gap: 20px;
|
|
margin-bottom: 25px;
|
|
}
|
|
|
|
.stat-card {
|
|
background: white;
|
|
padding: 20px;
|
|
border-radius: 10px;
|
|
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
|
text-align: center;
|
|
}
|
|
|
|
.stat-card h3 {
|
|
color: #666;
|
|
font-size: 14px;
|
|
margin-bottom: 10px;
|
|
text-transform: uppercase;
|
|
}
|
|
|
|
.stat-card .number {
|
|
color: #667eea;
|
|
font-size: 32px;
|
|
font-weight: bold;
|
|
}
|
|
|
|
.content {
|
|
background: white;
|
|
padding: 30px;
|
|
border-radius: 10px;
|
|
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
|
}
|
|
|
|
.search-bar {
|
|
margin-bottom: 20px;
|
|
display: flex;
|
|
gap: 10px;
|
|
align-items: center;
|
|
}
|
|
|
|
.search-bar input {
|
|
flex: 1;
|
|
padding: 12px 15px;
|
|
border: 2px solid #e0e0e0;
|
|
border-radius: 5px;
|
|
font-size: 14px;
|
|
transition: border-color 0.3s;
|
|
}
|
|
|
|
.search-bar input:focus {
|
|
outline: none;
|
|
border-color: #667eea;
|
|
}
|
|
|
|
.search-bar button {
|
|
background: #667eea;
|
|
color: white;
|
|
padding: 12px 25px;
|
|
border: none;
|
|
border-radius: 5px;
|
|
cursor: pointer;
|
|
font-size: 14px;
|
|
transition: background 0.3s;
|
|
}
|
|
|
|
.search-bar button:hover {
|
|
background: #5568d3;
|
|
}
|
|
|
|
.table-responsive {
|
|
overflow-x: auto;
|
|
}
|
|
|
|
table {
|
|
width: 100%;
|
|
border-collapse: collapse;
|
|
margin-top: 20px;
|
|
}
|
|
|
|
thead {
|
|
background: #f8f9fa;
|
|
}
|
|
|
|
th {
|
|
padding: 15px;
|
|
text-align: left;
|
|
font-weight: 600;
|
|
color: #333;
|
|
border-bottom: 2px solid #e0e0e0;
|
|
}
|
|
|
|
td {
|
|
padding: 15px;
|
|
border-bottom: 1px solid #f0f0f0;
|
|
color: #666;
|
|
}
|
|
|
|
tr:hover {
|
|
background: #f8f9fa;
|
|
}
|
|
|
|
.badge {
|
|
display: inline-block;
|
|
padding: 5px 12px;
|
|
border-radius: 20px;
|
|
font-size: 12px;
|
|
font-weight: 600;
|
|
}
|
|
|
|
.badge-admin {
|
|
background: #667eea;
|
|
color: white;
|
|
}
|
|
|
|
.badge-user {
|
|
background: #27ae60;
|
|
color: white;
|
|
}
|
|
|
|
.badge-verified {
|
|
background: #2ecc71;
|
|
color: white;
|
|
}
|
|
|
|
.badge-unverified {
|
|
background: #95a5a6;
|
|
color: white;
|
|
}
|
|
|
|
.action-btn {
|
|
padding: 6px 12px;
|
|
margin: 0 3px;
|
|
border: none;
|
|
border-radius: 4px;
|
|
cursor: pointer;
|
|
font-size: 12px;
|
|
transition: all 0.3s;
|
|
text-decoration: none;
|
|
display: inline-block;
|
|
}
|
|
|
|
.btn-edit {
|
|
background: #3498db;
|
|
color: white;
|
|
}
|
|
|
|
.btn-edit:hover {
|
|
background: #2980b9;
|
|
}
|
|
|
|
.btn-delete {
|
|
background: #e74c3c;
|
|
color: white;
|
|
}
|
|
|
|
.btn-delete:hover {
|
|
background: #c0392b;
|
|
}
|
|
|
|
.btn-view {
|
|
background: #95a5a6;
|
|
color: white;
|
|
}
|
|
|
|
.btn-view:hover {
|
|
background: #7f8c8d;
|
|
}
|
|
|
|
.pagination {
|
|
margin-top: 20px;
|
|
display: flex;
|
|
justify-content: center;
|
|
gap: 5px;
|
|
}
|
|
|
|
.pagination a, .pagination span {
|
|
padding: 8px 12px;
|
|
border: 1px solid #e0e0e0;
|
|
border-radius: 4px;
|
|
color: #667eea;
|
|
text-decoration: none;
|
|
transition: all 0.3s;
|
|
}
|
|
|
|
.pagination a:hover {
|
|
background: #667eea;
|
|
color: white;
|
|
}
|
|
|
|
.pagination .active {
|
|
background: #667eea;
|
|
color: white;
|
|
border-color: #667eea;
|
|
}
|
|
|
|
.empty-state {
|
|
text-align: center;
|
|
padding: 40px;
|
|
color: #999;
|
|
}
|
|
|
|
.empty-state i {
|
|
font-size: 48px;
|
|
margin-bottom: 10px;
|
|
}
|
|
|
|
@media (max-width: 768px) {
|
|
.header {
|
|
flex-direction: column;
|
|
gap: 15px;
|
|
text-align: center;
|
|
}
|
|
|
|
.header-actions {
|
|
flex-direction: column;
|
|
width: 100%;
|
|
}
|
|
|
|
.btn {
|
|
width: 100%;
|
|
}
|
|
|
|
table {
|
|
font-size: 12px;
|
|
}
|
|
|
|
th, td {
|
|
padding: 10px 5px;
|
|
}
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="container">
|
|
<!-- Header -->
|
|
<div class="header">
|
|
<div>
|
|
<h1>👥 Kelola Pengguna</h1>
|
|
<p style="color: #666; margin-top: 5px;">Dashboard Admin - TA Bibit Cabai</p>
|
|
</div>
|
|
<div class="header-actions">
|
|
<a href="{{ route('admin.users.create') }}" class="btn btn-primary">+ Tambah Pengguna</a>
|
|
<a href="{{ route('admin.dashboard') }}" class="btn btn-primary">← Dashboard</a>
|
|
<form method="POST" action="{{ route('logout') }}" style="display: inline;">
|
|
@csrf
|
|
<button type="submit" class="btn btn-danger">Logout</button>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Alert Messages -->
|
|
@if(session('success'))
|
|
<div class="alert alert-success">
|
|
✓ {{ session('success') }}
|
|
</div>
|
|
@endif
|
|
|
|
@if(session('error'))
|
|
<div class="alert alert-error">
|
|
✗ {{ session('error') }}
|
|
</div>
|
|
@endif
|
|
|
|
<!-- Stats Cards -->
|
|
<div class="stats">
|
|
<div class="stat-card">
|
|
<h3>Total Pengguna</h3>
|
|
<div class="number">{{ $totalUsers ?? 0 }}</div>
|
|
</div>
|
|
<div class="stat-card">
|
|
<h3>Admin</h3>
|
|
<div class="number">{{ $totalAdmins ?? 0 }}</div>
|
|
</div>
|
|
<div class="stat-card">
|
|
<h3>Email Terverifikasi</h3>
|
|
<div class="number">{{ $verifiedUsers ?? 0 }}</div>
|
|
</div>
|
|
<div class="stat-card">
|
|
<h3>Pengguna Aktif (30 Hari)</h3>
|
|
<div class="number">{{ $activeUsers ?? 0 }}</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Main Content -->
|
|
<div class="content">
|
|
<!-- Search Bar -->
|
|
<div class="search-bar">
|
|
<input type="text" id="searchInput" placeholder="🔍 Cari pengguna berdasarkan nama, email, atau nomor telepon...">
|
|
<button onclick="searchUsers()">Cari</button>
|
|
</div>
|
|
|
|
<!-- Users Table -->
|
|
@if(isset($users) && $users->count() > 0)
|
|
<div class="table-responsive">
|
|
<table id="usersTable">
|
|
<thead>
|
|
<tr>
|
|
<th>ID</th>
|
|
<th>Nama</th>
|
|
<th>Email</th>
|
|
<th>Telepon</th>
|
|
<th>Alamat</th>
|
|
<th>Status</th>
|
|
<th>Verifikasi</th>
|
|
<th>Aksi</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
@foreach($users as $user)
|
|
<tr>
|
|
<td>{{ $user->id }}</td>
|
|
<td><strong>{{ $user->name }}</strong></td>
|
|
<td>{{ $user->email }}</td>
|
|
<td>{{ $user->phone ?? '-' }}</td>
|
|
<td>{{ Str::limit($user->address ?? '-', 30) }}</td>
|
|
<td>
|
|
@if($user->is_admin == 1)
|
|
<span class="badge badge-admin">Admin</span>
|
|
@else
|
|
<span class="badge badge-user">User</span>
|
|
@endif
|
|
</td>
|
|
<td>
|
|
@if($user->email_verified_at)
|
|
<span class="badge badge-verified">✓ Terverifikasi</span>
|
|
@else
|
|
<span class="badge badge-unverified">Belum Verifikasi</span>
|
|
@endif
|
|
</td>
|
|
<td>
|
|
<a href="{{ route('admin.users.show', $user) }}" class="action-btn btn-view">Detail</a>
|
|
<a href="{{ route('admin.users.edit', $user) }}" class="action-btn btn-edit">Edit</a>
|
|
<form method="POST" action="{{ route('admin.users.destroy', $user) }}" style="display: inline;" onsubmit="return confirm('Apakah Anda yakin ingin menghapus pengguna ini?');">
|
|
@csrf
|
|
@method('DELETE')
|
|
<button type="submit" class="action-btn btn-delete">Hapus</button>
|
|
</form>
|
|
</td>
|
|
</tr>
|
|
@endforeach
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
|
|
<!-- Pagination -->
|
|
@if(isset($users))
|
|
<div class="pagination">
|
|
{{ $users->links() }}
|
|
</div>
|
|
@endif
|
|
@else
|
|
<div class="empty-state">
|
|
<div>📭</div>
|
|
<h3>Tidak ada data pengguna</h3>
|
|
<p>Belum ada pengguna terdaftar dalam sistem</p>
|
|
</div>
|
|
@endif
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
// Search function
|
|
function searchUsers() {
|
|
const input = document.getElementById('searchInput');
|
|
const filter = input.value.toLowerCase();
|
|
const table = document.getElementById('usersTable');
|
|
|
|
if (!table) return;
|
|
|
|
const tr = table.getElementsByTagName('tr');
|
|
|
|
for (let i = 1; i < tr.length; i++) {
|
|
let td = tr[i].getElementsByTagName('td');
|
|
let found = false;
|
|
|
|
for (let j = 0; j < td.length; j++) {
|
|
if (td[j]) {
|
|
let txtValue = td[j].textContent || td[j].innerText;
|
|
if (txtValue.toLowerCase().indexOf(filter) > -1) {
|
|
found = true;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
tr[i].style.display = found ? '' : 'none';
|
|
}
|
|
}
|
|
|
|
// Search on input
|
|
document.getElementById('searchInput')?.addEventListener('keyup', searchUsers);
|
|
</script>
|
|
</body>
|
|
</html> |