Sindbad~EG File Manager
<?php
require_once '../config/config.php';
// Check if user is logged in
if (!isLoggedIn()) {
redirect('login.php');
}
$db = new Database();
$conn = $db->getConnection();
// Get some basic stats
$query = "SELECT COUNT(*) as total FROM attendance_records";
$stmt = $conn->prepare($query);
$stmt->execute();
$total_records = $stmt->fetch()['total'];
$query = "SELECT COUNT(*) as total FROM programs WHERE is_active = 1";
$stmt = $conn->prepare($query);
$stmt->execute();
$total_programs = $stmt->fetch()['total'];
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Infinite Scroll Test - Admin Panel</title>
<script src="https://cdn.tailwindcss.com"></script>
<script>
tailwind.config = {
theme: {
extend: {
colors: {
primary: '#3B82F6',
secondary: '#F59E0B',
accent: '#6B7280'
}
}
}
}
</script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet">
<style>
.gradient-bg {
background: linear-gradient(135deg, #3B82F6 0%, #F59E0B 50%, #6B7280 100%);
}
.spinner {
border: 2px solid #f3f3f3;
border-top: 2px solid #3B82F6;
border-radius: 50%;
width: 20px;
height: 20px;
animation: spin 1s linear infinite;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
</style>
</head>
<body class="bg-gray-50">
<!-- Include Sidebar -->
<?php include 'includes/sidebar.php'; ?>
<!-- Main Content -->
<div class="md:ml-64">
<!-- Header -->
<header class="bg-white shadow-sm border-b">
<div class="px-6 py-4">
<h1 class="text-2xl font-bold text-gray-900">Infinite Scroll Test</h1>
</div>
</header>
<!-- Content -->
<main class="p-6">
<!-- Stats -->
<div class="grid grid-cols-1 md:grid-cols-3 gap-6 mb-8">
<div class="bg-white rounded-lg shadow p-6">
<div class="flex items-center">
<div class="p-2 bg-blue-100 rounded-lg">
<i class="fas fa-users text-blue-600 text-xl"></i>
</div>
<div class="ml-4">
<p class="text-sm font-medium text-gray-600">Total Records</p>
<p class="text-2xl font-bold text-gray-900"><?php echo number_format($total_records); ?></p>
</div>
</div>
</div>
<div class="bg-white rounded-lg shadow p-6">
<div class="flex items-center">
<div class="p-2 bg-green-100 rounded-lg">
<i class="fas fa-calendar text-green-600 text-xl"></i>
</div>
<div class="ml-4">
<p class="text-sm font-medium text-gray-600">Active Programs</p>
<p class="text-2xl font-bold text-gray-900"><?php echo number_format($total_programs); ?></p>
</div>
</div>
</div>
<div class="bg-white rounded-lg shadow p-6">
<div class="flex items-center">
<div class="p-2 bg-yellow-100 rounded-lg">
<i class="fas fa-cog text-yellow-600 text-xl"></i>
</div>
<div class="ml-4">
<p class="text-sm font-medium text-gray-600">Status</p>
<p class="text-lg font-bold text-green-600">Ready</p>
</div>
</div>
</div>
</div>
<!-- Test Buttons -->
<div class="bg-white rounded-lg shadow p-6 mb-8">
<h3 class="text-lg font-semibold text-gray-900 mb-4">
<i class="fas fa-flask mr-2 text-primary"></i>
API Tests
</h3>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
<button onclick="testDashboardAPI()"
class="bg-primary text-white px-4 py-2 rounded-lg hover:bg-blue-700 transition duration-300">
<i class="fas fa-tachometer-alt mr-2"></i>
Test Dashboard API
</button>
<button onclick="testReportsAPI()"
class="bg-secondary text-white px-4 py-2 rounded-lg hover:bg-yellow-600 transition duration-300">
<i class="fas fa-chart-bar mr-2"></i>
Test Reports API
</button>
</div>
</div>
<!-- Test Results -->
<div class="bg-white rounded-lg shadow p-6">
<h3 class="text-lg font-semibold text-gray-900 mb-4">
<i class="fas fa-terminal mr-2 text-primary"></i>
Test Results
</h3>
<div id="test-results" class="bg-gray-900 text-green-400 p-4 rounded-lg font-mono text-sm min-h-32">
<div class="text-gray-500">Ready for testing...</div>
</div>
</div>
<!-- Navigation Links -->
<div class="mt-8 grid grid-cols-1 md:grid-cols-2 gap-4">
<a href="dashboard.php" class="bg-white rounded-lg shadow p-4 hover:shadow-md transition duration-300 block">
<div class="flex items-center">
<div class="p-2 bg-blue-100 rounded-lg">
<i class="fas fa-tachometer-alt text-blue-600"></i>
</div>
<div class="ml-3">
<p class="font-medium text-gray-900">Test Dashboard</p>
<p class="text-sm text-gray-500">Check infinite scroll on dashboard</p>
</div>
</div>
</a>
<a href="reports.php" class="bg-white rounded-lg shadow p-4 hover:shadow-md transition duration-300 block">
<div class="flex items-center">
<div class="p-2 bg-green-100 rounded-lg">
<i class="fas fa-chart-bar text-green-600"></i>
</div>
<div class="ml-3">
<p class="font-medium text-gray-900">Test Reports</p>
<p class="text-sm text-gray-500">Check infinite scroll on reports</p>
</div>
</div>
</a>
</div>
</main>
</div>
<script>
function log(message, type = 'info') {
const results = document.getElementById('test-results');
const timestamp = new Date().toLocaleTimeString();
const color = type === 'error' ? 'text-red-400' : type === 'success' ? 'text-green-400' : 'text-blue-400';
results.innerHTML += `<div class="${color}">[${timestamp}] ${message}</div>`;
results.scrollTop = results.scrollHeight;
}
async function testDashboardAPI() {
log('Testing Dashboard API...', 'info');
try {
const response = await fetch('api/get_attendance.php?page=1&limit=5');
log(`Response status: ${response.status}`, response.ok ? 'success' : 'error');
if (!response.ok) {
throw new Error(`HTTP ${response.status}`);
}
const data = await response.json();
log(`Success: ${data.success}`, data.success ? 'success' : 'error');
log(`Records returned: ${data.records ? data.records.length : 0}`, 'info');
log(`Has more: ${data.pagination ? data.pagination.has_more : 'unknown'}`, 'info');
log(`Total records: ${data.pagination ? data.pagination.total_records : 'unknown'}`, 'info');
if (data.records && data.records.length > 0) {
log(`Sample record: ${data.records[0].full_name} - ${data.records[0].program_name}`, 'success');
}
} catch (error) {
log(`Error: ${error.message}`, 'error');
}
}
async function testReportsAPI() {
log('Testing Reports API...', 'info');
try {
const response = await fetch('api/get_reports_data.php?type=attendance&page=1&limit=5');
log(`Response status: ${response.status}`, response.ok ? 'success' : 'error');
if (!response.ok) {
throw new Error(`HTTP ${response.status}`);
}
const data = await response.json();
log(`Success: ${data.success}`, data.success ? 'success' : 'error');
log(`Records returned: ${data.records ? data.records.length : 0}`, 'info');
log(`Has more: ${data.pagination ? data.pagination.has_more : 'unknown'}`, 'info');
log(`Total records: ${data.pagination ? data.pagination.total_records : 'unknown'}`, 'info');
if (data.records && data.records.length > 0) {
log(`Sample record: ${data.records[0].full_name} - ${data.records[0].program_name}`, 'success');
}
} catch (error) {
log(`Error: ${error.message}`, 'error');
}
}
// Clear results
function clearResults() {
document.getElementById('test-results').innerHTML = '<div class="text-gray-500">Ready for testing...</div>';
}
// Auto-clear on page load
log('Infinite Scroll Test Page Loaded', 'success');
log('Click buttons above to test API endpoints', 'info');
</script>
</body>
</html>
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists