CoolFace
Apppublic

gcoder824/subdocflow-smooth-document-request-system

sourceHugging Faceupdated 11mo agoView on Hugging Face
0likes
admin_dashboard.html423 linesDownload Raw Back to root
1 2<?php3session_start();4require_once 'config.php';5 6if (!isset($_SESSION['user_id']) || $_SESSION['role'] != 'admin') {7    header("Location: login.php");8    exit;9}10 11// Get admin stats12$totalRequests = $pdo->query("SELECT COUNT(*) FROM document_requests")->fetchColumn();13$completedRequests = $pdo->query("SELECT COUNT(*) FROM document_requests WHERE status = 'completed'")->fetchColumn();14$inProgressRequests = $pdo->query("SELECT COUNT(*) FROM document_requests WHERE status = 'processing'")->fetchColumn();15$pendingRequests = $pdo->query("SELECT COUNT(*) FROM document_requests WHERE status = 'pending'")->fetchColumn();16 17// Get recent requests18$stmt = $pdo->query("19    SELECT dr.*, u.first_name, u.last_name, u.block_lot, dt.name as document_name 20    FROM document_requests dr21    JOIN users u ON dr.user_id = u.id22    JOIN document_types dt ON dr.document_type_id = dt.id23    ORDER BY dr.request_date DESC24    LIMIT 525");26$recentRequests = $stmt->fetchAll(PDO::FETCH_ASSOC);27 28// Get document type counts29$documentStats = $pdo->query("30    SELECT dt.name, COUNT(dr.id) as count 31    FROM document_types dt32    LEFT JOIN document_requests dr ON dt.id = dr.document_type_id33    GROUP BY dt.name34")->fetchAll(PDO::FETCH_ASSOC);35 36// Get recent activity37$recentActivity = $pdo->query("38    SELECT * FROM notifications 39    ORDER BY created_at DESC 40    LIMIT 341")->fetchAll(PDO::FETCH_ASSOC);42?>43<!DOCTYPE html>44<html lang="en">45<head>46    <meta charset="UTF-8">47    <meta name="viewport" content="width=device-width, initial-scale=1.0">48    <title>Admin Dashboard - SubDocFlow</title>49    <link rel="icon" type="image/x-icon" href="/static/favicon.ico">50    <script src="https://cdn.tailwindcss.com"></script>51    <script src="https://unpkg.com/feather-icons"></script>52    <script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>53    <style>54        @import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');55        body {56            font-family: 'Poppins', sans-serif;57        }58        .sidebar {59            transition: all 0.3s ease;60        }61        .sidebar.collapsed {62            width: 80px;63        }64        .sidebar.collapsed .sidebar-text {65            display: none;66        }67        .sidebar.collapsed .sidebar-icon {68            margin-right: 0;69        }70        .main-content {71            transition: margin-left 0.3s ease;72        }73        .notification-dot {74            position: absolute;75            top: -2px;76            right: -2px;77            width: 12px;78            height: 12px;79            background-color: #ef4444;80            border-radius: 50%;81            border: 2px solid #fff;82        }83    </style>84</head>85<body class="bg-gray-50">86    <div class="flex h-screen">87        <!-- Sidebar -->88        <div class="sidebar bg-white shadow-md w-64 flex-shrink-0">89            <div class="p-4 border-b border-gray-200">90                <div class="flex items-center">91                    <i data-feather="file-text" class="text-indigo-600 h-8 w-8"></i>92                    <span class="sidebar-text ml-2 text-xl font-bold text-gray-900">SubDocFlow</span>93                </div>94            </div>95            <nav class="p-4">96                <ul class="space-y-2">97                    <li>98                        <a href="admin_dashboard.html" class="flex items-center p-2 rounded-lg bg-indigo-50 text-indigo-700">99                            <i data-feather="home" class="sidebar-icon h-5 w-5"></i>100                            <span class="sidebar-text ml-3">Dashboard</span>101                        </a>102                    </li>103                    <li>104                        <a href="admin_requests.html" class="flex items-center p-2 rounded-lg text-gray-700 hover:bg-gray-100">105                            <i data-feather="inbox" class="sidebar-icon h-5 w-5"></i>106                            <span class="sidebar-text ml-3">Requests</span>107                        </a>108                    </li>109                    <li>110                        <a href="admin_residents.html" class="flex items-center p-2 rounded-lg text-gray-700 hover:bg-gray-100">111                            <i data-feather="users" class="sidebar-icon h-5 w-5"></i>112                            <span class="sidebar-text ml-3">Residents</span>113                        </a>114                    </li>115                    <li>116                        <a href="admin_documents.html" class="flex items-center p-2 rounded-lg text-gray-700 hover:bg-gray-100">117                            <i data-feather="file" class="sidebar-icon h-5 w-5"></i>118                            <span class="sidebar-text ml-3">Documents</span>119                        </a>120                    </li>121                    <li>122                        <a href="admin_reports.html" class="flex items-center p-2 rounded-lg text-gray-700 hover:bg-gray-100">123                            <i data-feather="bar-chart-2" class="sidebar-icon h-5 w-5"></i>124                            <span class="sidebar-text ml-3">Reports</span>125                        </a>126                    </li>127                    <li>128                        <a href="admin_settings.html" class="flex items-center p-2 rounded-lg text-gray-700 hover:bg-gray-100">129                            <i data-feather="settings" class="sidebar-icon h-5 w-5"></i>130                            <span class="sidebar-text ml-3">Settings</span>131                        </a>132                    </li>133                </ul>134                <div class="mt-8 pt-4 border-t border-gray-200">135                    <a href="login.html" class="flex items-center p-2 rounded-lg text-gray-700 hover:bg-gray-100">136                        <i data-feather="log-out" class="sidebar-icon h-5 w-5"></i>137                        <span class="sidebar-text ml-3">Logout</span>138                    </a>139                </div>140            </nav>141        </div>142 143        <!-- Main Content -->144        <div class="main-content flex-1 flex flex-col overflow-hidden">145            <!-- Header -->146            <header class="bg-white shadow-sm">147                <div class="flex items-center justify-between px-6 py-4">148                    <div class="flex items-center">149                        <button id="sidebar-toggle" class="p-2 rounded-md text-gray-500 hover:text-gray-600 hover:bg-gray-100 focus:outline-none">150                            <i data-feather="menu"></i>151                        </button>152                        <h1 class="ml-4 text-xl font-semibold text-gray-900">Admin Dashboard</h1>153                    </div>154                    <div class="flex items-center space-x-4">155                        <button class="p-2 rounded-full text-gray-500 hover:text-gray-600 hover:bg-gray-100 focus:outline-none relative">156                            <i data-feather="bell"></i>157                            <span class="notification-dot"></span>158                        </button>159                    <div class="flex items-center">160                        <img src="http://static.photos/people/200x200/2" alt="Admin" class="h-8 w-8 rounded-full">161                        <span class="ml-2 text-sm font-medium text-gray-700"><?php echo htmlspecialchars($_SESSION['name']); ?></span>162                        <a href="logout.php" class="ml-4 text-sm text-gray-500 hover:text-gray-700">Logout</a>163                    </div>164</div>165                </div>166            </header>167 168            <!-- Content -->169            <main class="flex-1 overflow-y-auto p-6 bg-gray-50">170                <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6 mb-6">171                    <!-- Stats Cards -->172                    <div class="bg-white shadow rounded-lg p-6">173                        <div class="flex items-center">174                            <div class="p-3 rounded-full bg-indigo-100 text-indigo-600">175                                <i data-feather="file-text"></i>176                            </div>177                            <div class="ml-4">178                                <h2 class="text-lg font-medium text-gray-900">Total Requests</h2>179                                <p class="text-2xl font-bold text-gray-900"><?php echo $totalRequests; ?></p>180</div>181                        </div>182                    </div>183                    <div class="bg-white shadow rounded-lg p-6">184                        <div class="flex items-center">185                            <div class="p-3 rounded-full bg-green-100 text-green-600">186                                <i data-feather="check-circle"></i>187                            </div>188                            <div class="ml-4">189                                <h2 class="text-lg font-medium text-gray-900">Completed</h2>190                                <p class="text-2xl font-bold text-gray-900"><?php echo $completedRequests; ?></p>191</div>192                        </div>193                    </div>194                    <div class="bg-white shadow rounded-lg p-6">195                        <div class="flex items-center">196                            <div class="p-3 rounded-full bg-yellow-100 text-yellow-600">197                                <i data-feather="clock"></i>198                            </div>199                            <div class="ml-4">200                                <h2 class="text-lg font-medium text-gray-900">In Progress</h2>201                                <p class="text-2xl font-bold text-gray-900"><?php echo $inProgressRequests; ?></p>202</div>203                        </div>204                    </div>205                    <div class="bg-white shadow rounded-lg p-6">206                        <div class="flex items-center">207                            <div class="p-3 rounded-full bg-red-100 text-red-600">208                                <i data-feather="alert-circle"></i>209                            </div>210                            <div class="ml-4">211                                <h2 class="text-lg font-medium text-gray-900">Pending</h2>212                                <p class="text-2xl font-bold text-gray-900"><?php echo $pendingRequests; ?></p>213</div>214                        </div>215                    </div>216                </div>217 218                <!-- Recent Requests -->219                <div class="bg-white shadow rounded-lg p-6">220                    <div class="flex items-center justify-between mb-6">221                        <h2 class="text-lg font-medium text-gray-900">Recent Requests</h2>222                        <a href="admin_requests.html" class="text-sm font-medium text-indigo-600 hover:text-indigo-500">View all</a>223                    </div>224                    <div class="overflow-x-auto">225                        <table class="min-w-full divide-y divide-gray-200">226                            <thead class="bg-gray-50">227                                <tr>228                                    <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Resident</th>229                                    <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Document</th>230                                    <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Date Requested</th>231                                    <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Status</th>232                                    <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Actions</th>233                                </tr>234                            </thead>235                            <tbody class="bg-white divide-y divide-gray-200">236                                <?php foreach ($recentRequests as $request): ?>237                                <tr>238                                    <td class="px-6 py-4 whitespace-nowrap">239                                        <div class="flex items-center">240                                            <div class="flex-shrink-0 h-10 w-10">241                                                <img class="h-10 w-10 rounded-full" src="http://static.photos/people/200x200/<?php echo rand(1,10); ?>" alt="">242                                            </div>243                                            <div class="ml-4">244                                                <div class="text-sm font-medium text-gray-900"><?php echo htmlspecialchars($request['first_name'] . ' ' . $request['last_name']); ?></div>245                                                <div class="text-sm text-gray-500"><?php echo htmlspecialchars($request['block_lot']); ?></div>246                                            </div>247                                        </div>248                                    </td>249                                    <td class="px-6 py-4 whitespace-nowrap">250                                        <div class="text-sm text-gray-900"><?php echo htmlspecialchars($request['document_name']); ?></div>251                                    </td>252                                    <td class="px-6 py-4 whitespace-nowrap">253                                        <div class="text-sm text-gray-500"><?php echo date('M j, Y g:i A', strtotime($request['request_date'])); ?></div>254                                    </td>255                                    <td class="px-6 py-4 whitespace-nowrap">256                                        <?php 257                                        $statusClass = [258                                            'pending' => 'bg-yellow-100 text-yellow-800',259                                            'processing' => 'bg-blue-100 text-blue-800',260                                            'approved' => 'bg-green-100 text-green-800',261                                            'rejected' => 'bg-red-100 text-red-800',262                                            'completed' => 'bg-purple-100 text-purple-800'263                                        ];264                                        ?>265                                        <span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full <?php echo $statusClass[strtolower($request['status'])]; ?>">266                                            <?php echo ucfirst($request['status']); ?>267                                        </span>268                                    </td>269                                    <td class="px-6 py-4 whitespace-nowrap text-sm font-medium">270                                        <a href="admin_request_detail.php?id=<?php echo $request['id']; ?>" class="text-indigo-600 hover:text-indigo-900 mr-3">View</a>271                                        <?php if ($request['status'] == 'pending' || $request['status'] == 'processing'): ?>272                                        <a href="admin_process_request.php?action=approve&id=<?php echo $request['id']; ?>" class="text-green-600 hover:text-green-900">Approve</a>273                                        <?php endif; ?>274                                    </td>275                                </tr>276                                <?php endforeach; ?>277<tr>278                                    <td class="px-6 py-4 whitespace-nowrap">279                                        <div class="flex items-center">280                                            <div class="flex-shrink-0 h-10 w-10">281                                                <img class="h-10 w-10 rounded-full" src="http://static.photos/people/200x200/4" alt="">282                                            </div>283                                            <div class="ml-4">284                                                <div class="text-sm font-medium text-gray-900">Sarah Johnson</div>285                                                <div class="text-sm text-gray-500">Block 3, Lot 8</div>286                                            </div>287                                        </div>288                                    </td>289                                    <td class="px-6 py-4 whitespace-nowrap">290                                        <div class="text-sm text-gray-900">Amenities Permit</div>291                                    </td>292                                    <td class="px-6 py-4 whitespace-nowrap">293                                        <div class="text-sm text-gray-500">Today, 08:45 AM</div>294                                    </td>295                                    <td class="px-6 py-4 whitespace-nowrap">296                                        <span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-red-100 text-red-800">Pending</span>297                                    </td>298                                    <td class="px-6 py-4 whitespace-nowrap text-sm font-medium">299                                        <a href="#" class="text-indigo-600 hover:text-indigo-900 mr-3">View</a>300                                        <a href="#" class="text-green-600 hover:text-green-900">Approve</a>301                                    </td>302                                </tr>303                                <tr>304                                    <td class="px-6 py-4 whitespace-nowrap">305                                        <div class="flex items-center">306                                            <div class="flex-shrink-0 h-10 w-10">307                                                <img class="h-10 w-10 rounded-full" src="http://static.photos/people/200x200/5" alt="">308                                            </div>309                                            <div class="ml-4">310                                                <div class="text-sm font-medium text-gray-900">Michael Brown</div>311                                                <div class="text-sm text-gray-500">Block 7, Lot 15</div>312                                            </div>313                                        </div>314                                    </td>315                                    <td class="px-6 py-4 whitespace-nowrap">316                                        <div class="text-sm text-gray-900">Lot Title</div>317                                    </td>318                                    <td class="px-6 py-4 whitespace-nowrap">319                                        <div class="text-sm text-gray-500">Yesterday, 02:15 PM</div>320                                    </td>321                                    <td class="px-6 py-4 whitespace-nowrap">322                                        <span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-green-100 text-green-800">Completed</span>323                                    </td>324                                    <td class="px-6 py-4 whitespace-nowrap text-sm font-medium">325                                        <a href="#" class="text-indigo-600 hover:text-indigo-900 mr-3">View</a>326                                        <a href="#" class="text-gray-600 hover:text-gray-900">Download</a>327                                    </td>328                                </tr>329                                <tr>330                                    <td class="px-6 py-4 whitespace-nowrap">331                                        <div class="flex items-center">332                                            <div class="flex-shrink-0 h-10 w-10">333                                                <img class="h-10 w-10 rounded-full" src="http://static.photos/people/200x200/6" alt="">334                                            </div>335                                            <div class="ml-4">336                                                <div class="text-sm font-medium text-gray-900">Emily Davis</div>337                                                <div class="text-sm text-gray-500">Block 2, Lot 4</div>338                                            </div>339                                        </div>340                                    </td>341                                    <td class="px-6 py-4 whitespace-nowrap">342                                        <div class="text-sm text-gray-900">Vehicle Ticket</div>343                                    </td>344                                    <td class="px-6 py-4 whitespace-nowrap">345                                        <div class="text-sm text-gray-500">Yesterday, 10:30 AM</div>346                                    </td>347                                    <td class="px-6 py-4 whitespace-nowrap">348                                        <span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-yellow-100 text-yellow-800">In Progress</span>349                                    </td>350                                    <td class="px-6 py-4 whitespace-nowrap text-sm font-medium">351                                        <a href="#" class="text-indigo-600 hover:text-indigo-900 mr-3">View</a>352                                        <a href="#" class="text-green-600 hover:text-green-900">Approve</a>353                                    </td>354                                </tr>355                            </tbody>356                        </table>357                    </div>358                </div>359 360                <!-- Quick Stats -->361                <div class="mt-6 grid grid-cols-1 md:grid-cols-2 gap-6">362                    <div class="bg-white shadow rounded-lg p-6">363                        <h2 class="text-lg font-medium text-gray-900 mb-4">Documents Overview</h2>364                        <div class="grid grid-cols-3 gap-4">365                            <?php foreach ($documentStats as $stat): ?>366                            <div class="text-center">367                                <div class="text-2xl font-bold text-indigo-600"><?php echo $stat['count']; ?></div>368                                <div class="text-sm text-gray-500"><?php echo htmlspecialchars($stat['name']); ?></div>369                            </div>370                            <?php endforeach; ?>371</div>372                    </div>373                    <div class="bg-white shadow rounded-lg p-6">374                        <h2 class="text-lg font-medium text-gray-900 mb-4">Recent Activity</h2>375                        <div class="space-y-4">376                            <?php foreach ($recentActivity as $activity): ?>377                            <div class="flex items-start">378                                <div class="flex-shrink-0">379                                    <div class="h-10 w-10 rounded-full bg-blue-100 flex items-center justify-center text-blue-600">380                                        <i data-feather="bell" class="h-5 w-5"></i>381                                    </div>382                                </div>383                                <div class="ml-3">384                                    <p class="text-sm font-medium text-gray-900"><?php echo htmlspecialchars($activity['title']); ?></p>385                                    <p class="text-sm text-gray-500"><?php echo htmlspecialchars($activity['message']); ?></p>386                                    <p class="text-xs text-gray-400 mt-1"><?php echo date('M j, Y g:i A', strtotime($activity['created_at'])); ?></p>387                                </div>388                            </div>389                            <?php endforeach; ?>390</div>391                        <div class="mt-4 text-center">392                        <a href="admin_activity_log.php" class="text-sm font-medium text-indigo-600 hover:text-indigo-500">View all activity</a>393</div>394                    </div>395                </div>396            </main>397        </div>398    </div>399        <script>400            // Toggle sidebar401            document.getElementById('sidebar-toggle').addEventListener('click', function() {402                const sidebar = document.querySelector('.sidebar');403                sidebar.classList.toggle('collapsed');404            });405 406            // Initialize feather icons407            feather.replace();408 409            // Auto-refresh notifications every 30 seconds410            setInterval(function() {411                fetch('check_notifications.php')412                    .then(response => response.json())413                    .then(data => {414                        if (data.count > 0) {415                            document.querySelector('.notification-dot').style.display = 'block';416                        }417                    });418            }, 30000);419        </script>420<?php include 'footer.php'; ?>421</body>422</html>423