![]() Server : Apache/2 System : Linux server-15-235-50-60 5.15.0-164-generic #174-Ubuntu SMP Fri Nov 14 20:25:16 UTC 2025 x86_64 User : gositeme ( 1004) PHP Version : 8.2.29 Disable Function : exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname Directory : /home/gositeme/domains/lavocat.quebec/private_html/php-migration/ |
<?php
/**
* Dashboard Page
* Migrated from React dashboard component
*/
require_once 'config/config.php';
require_once 'auth/Auth.php';
require_once 'models/User.php';
require_once 'models/LegalCase.php';
require_once 'config/database.php';
$auth = new Auth();
// Check if user is logged in
if (!$auth->isLoggedIn()) {
header('Location: /login.php');
exit;
}
$user = $auth->getCurrentUser();
$database = new Database();
$db = $database->getConnection();
// Get user details
$userModel = new User($db);
$userModel->findById($user['id']);
// Get user's cases
$caseModel = new LegalCase($db);
$userCases = [];
$caseStats = [];
if ($user['role'] === 'LAWYER' || $user['role'] === 'ADMIN' || $user['role'] === 'SUPER_ADMIN') {
$userCases = $caseModel->getByLawyerId($user['id'], 1, 5);
$caseStats = [
'total' => $caseModel->count(['lawyerId' => $user['id'], 'isArchived' => 0]),
'open' => $caseModel->count(['lawyerId' => $user['id'], 'status' => 'OPEN', 'isArchived' => 0]),
'closed' => $caseModel->count(['lawyerId' => $user['id'], 'status' => 'CLOSED', 'isArchived' => 0])
];
} else {
$userCases = $caseModel->getByClientId($user['id'], 1, 5);
$caseStats = [
'total' => $caseModel->count(['clientId' => $user['id'], 'isArchived' => 0]),
'open' => $caseModel->count(['clientId' => $user['id'], 'status' => 'OPEN', 'isArchived' => 0]),
'closed' => $caseModel->count(['clientId' => $user['id'], 'status' => 'CLOSED', 'isArchived' => 0])
];
}
// Get language from user preference
$language = $user['language'] ?? DEFAULT_LANGUAGE;
// Bilingual content
$content = [
'fr' => [
'title' => 'Tableau de bord - avocat.quebec',
'welcome' => 'Bienvenue',
'dashboard' => 'Tableau de bord',
'myCases' => 'Mes dossiers',
'recentCases' => 'Dossiers récents',
'caseStats' => 'Statistiques des dossiers',
'totalCases' => 'Total des dossiers',
'openCases' => 'Dossiers ouverts',
'closedCases' => 'Dossiers fermés',
'viewAllCases' => 'Voir tous les dossiers',
'createCase' => 'Créer un dossier',
'profile' => 'Profil',
'settings' => 'Paramètres',
'logout' => 'Déconnexion',
'noCases' => 'Aucun dossier trouvé',
'caseNumber' => 'Numéro de dossier',
'status' => 'Statut',
'priority' => 'Priorité',
'created' => 'Créé le',
'dueDate' => 'Échéance'
],
'en' => [
'title' => 'Dashboard - avocat.quebec',
'welcome' => 'Welcome',
'dashboard' => 'Dashboard',
'myCases' => 'My Cases',
'recentCases' => 'Recent Cases',
'caseStats' => 'Case Statistics',
'totalCases' => 'Total Cases',
'openCases' => 'Open Cases',
'closedCases' => 'Closed Cases',
'viewAllCases' => 'View All Cases',
'createCase' => 'Create Case',
'profile' => 'Profile',
'settings' => 'Settings',
'logout' => 'Logout',
'noCases' => 'No cases found',
'caseNumber' => 'Case Number',
'status' => 'Status',
'priority' => 'Priority',
'created' => 'Created',
'dueDate' => 'Due Date'
]
];
$currentContent = $content[$language];
// Status and priority translations
$statusTranslations = [
'fr' => [
'OPEN' => 'Ouvert',
'IN_PROGRESS' => 'En cours',
'CLOSED' => 'Fermé',
'CANCELLED' => 'Annulé'
],
'en' => [
'OPEN' => 'Open',
'IN_PROGRESS' => 'In Progress',
'CLOSED' => 'Closed',
'CANCELLED' => 'Cancelled'
]
];
$priorityTranslations = [
'fr' => [
'LOW' => 'Faible',
'MEDIUM' => 'Moyenne',
'HIGH' => 'Élevée',
'URGENT' => 'Urgente'
],
'en' => [
'LOW' => 'Low',
'MEDIUM' => 'Medium',
'HIGH' => 'High',
'URGENT' => 'Urgent'
]
];
?>
<!DOCTYPE html>
<html lang="<?php echo $language; ?>">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title><?php echo $currentContent['title']; ?></title>
<!-- Tailwind CSS -->
<script src="https://cdn.tailwindcss.com"></script>
<!-- Chart.js for statistics -->
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<style>
.gradient-bg {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}
</style>
</head>
<body class="bg-gray-50">
<!-- Navigation -->
<nav class="bg-white shadow-lg">
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
<div class="flex justify-between h-16">
<div class="flex items-center">
<a href="/" class="flex-shrink-0">
<h1 class="text-2xl font-bold text-blue-600">avocat.quebec</h1>
</a>
</div>
<div class="hidden md:flex items-center space-x-8">
<a href="/dashboard.php" class="text-blue-600 px-3 py-2 rounded-md text-sm font-medium">
<?php echo $currentContent['dashboard']; ?>
</a>
<a href="/cases.php" class="text-gray-700 hover:text-blue-600 px-3 py-2 rounded-md text-sm font-medium">
<?php echo $currentContent['myCases']; ?>
</a>
<a href="/profile.php" class="text-gray-700 hover:text-blue-600 px-3 py-2 rounded-md text-sm font-medium">
<?php echo $currentContent['profile']; ?>
</a>
</div>
<div class="flex items-center space-x-4">
<span class="text-sm text-gray-700"><?php echo $currentContent['welcome']; ?>, <?php echo htmlspecialchars($user['name']); ?></span>
<a href="/logout.php" class="bg-red-600 text-white px-4 py-2 rounded-md text-sm font-medium hover:bg-red-700">
<?php echo $currentContent['logout']; ?>
</a>
</div>
</div>
</div>
</nav>
<!-- Main Content -->
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
<!-- Welcome Section -->
<div class="mb-8">
<h1 class="text-3xl font-bold text-gray-900">
<?php echo $currentContent['welcome']; ?>, <?php echo htmlspecialchars($user['name']); ?>!
</h1>
<p class="text-gray-600 mt-2">
<?php echo $user['role'] === 'LAWYER' ? 'Manage your legal practice and cases' : 'Track your legal cases and communications'; ?>
</p>
</div>
<!-- Statistics Cards -->
<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="flex-shrink-0">
<div class="w-8 h-8 bg-blue-500 rounded-md flex items-center justify-center">
<svg class="w-5 h-5 text-white" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"></path>
</svg>
</div>
</div>
<div class="ml-4">
<p class="text-sm font-medium text-gray-500"><?php echo $currentContent['totalCases']; ?></p>
<p class="text-2xl font-semibold text-gray-900"><?php echo $caseStats['total']; ?></p>
</div>
</div>
</div>
<div class="bg-white rounded-lg shadow p-6">
<div class="flex items-center">
<div class="flex-shrink-0">
<div class="w-8 h-8 bg-green-500 rounded-md flex items-center justify-center">
<svg class="w-5 h-5 text-white" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"></path>
</svg>
</div>
</div>
<div class="ml-4">
<p class="text-sm font-medium text-gray-500"><?php echo $currentContent['openCases']; ?></p>
<p class="text-2xl font-semibold text-gray-900"><?php echo $caseStats['open']; ?></p>
</div>
</div>
</div>
<div class="bg-white rounded-lg shadow p-6">
<div class="flex items-center">
<div class="flex-shrink-0">
<div class="w-8 h-8 bg-gray-500 rounded-md flex items-center justify-center">
<svg class="w-5 h-5 text-white" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7"></path>
</svg>
</div>
</div>
<div class="ml-4">
<p class="text-sm font-medium text-gray-500"><?php echo $currentContent['closedCases']; ?></p>
<p class="text-2xl font-semibold text-gray-900"><?php echo $caseStats['closed']; ?></p>
</div>
</div>
</div>
</div>
<!-- Recent Cases -->
<div class="bg-white rounded-lg shadow">
<div class="px-6 py-4 border-b border-gray-200">
<div class="flex justify-between items-center">
<h2 class="text-lg font-medium text-gray-900"><?php echo $currentContent['recentCases']; ?></h2>
<div class="flex space-x-2">
<a href="/cases.php" class="text-blue-600 hover:text-blue-500 text-sm font-medium">
<?php echo $currentContent['viewAllCases']; ?>
</a>
<?php if ($user['role'] === 'LAWYER' || $user['role'] === 'ADMIN' || $user['role'] === 'SUPER_ADMIN'): ?>
<a href="/create-case.php" class="bg-blue-600 text-white px-3 py-1 rounded text-sm font-medium hover:bg-blue-700">
<?php echo $currentContent['createCase']; ?>
</a>
<?php endif; ?>
</div>
</div>
</div>
<div class="p-6">
<?php if (empty($userCases)): ?>
<div class="text-center py-8">
<svg class="mx-auto h-12 w-12 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"></path>
</svg>
<h3 class="mt-2 text-sm font-medium text-gray-900"><?php echo $currentContent['noCases']; ?></h3>
</div>
<?php else: ?>
<div class="overflow-hidden">
<table class="min-w-full divide-y divide-gray-200">
<thead class="bg-gray-50">
<tr>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
<?php echo $currentContent['caseNumber']; ?>
</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
Title
</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
<?php echo $currentContent['status']; ?>
</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
<?php echo $currentContent['priority']; ?>
</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
<?php echo $currentContent['created']; ?>
</th>
</tr>
</thead>
<tbody class="bg-white divide-y divide-gray-200">
<?php foreach ($userCases as $case): ?>
<tr class="hover:bg-gray-50">
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">
<?php echo htmlspecialchars($case['caseNumber'] ?: substr($case['id'], 0, 8)); ?>
</td>
<td class="px-6 py-4 whitespace-nowrap">
<div class="text-sm font-medium text-gray-900">
<?php echo htmlspecialchars($case['title']); ?>
</div>
</td>
<td class="px-6 py-4 whitespace-nowrap">
<span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full
<?php
switch($case['status']) {
case 'OPEN': echo 'bg-green-100 text-green-800'; break;
case 'IN_PROGRESS': echo 'bg-yellow-100 text-yellow-800'; break;
case 'CLOSED': echo 'bg-gray-100 text-gray-800'; break;
case 'CANCELLED': echo 'bg-red-100 text-red-800'; break;
default: echo 'bg-gray-100 text-gray-800';
}
?>">
<?php echo $statusTranslations[$language][$case['status']] ?? $case['status']; ?>
</span>
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">
<?php echo $priorityTranslations[$language][$case['priority']] ?? $case['priority']; ?>
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
<?php echo date('M j, Y', strtotime($case['createdAt'])); ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<?php endif; ?>
</div>
</div>
</div>
<!-- Language Toggle -->
<div class="fixed bottom-4 right-4">
<button onclick="toggleLanguage()" class="bg-blue-600 text-white px-4 py-2 rounded-lg shadow-lg hover:bg-blue-700">
<?php echo $language === 'fr' ? 'English' : 'Français'; ?>
</button>
</div>
<script>
function toggleLanguage() {
const currentLang = '<?php echo $language; ?>';
const newLang = currentLang === 'fr' ? 'en' : 'fr';
window.location.href = `?lang=${newLang}`;
}
</script>
</body>
</html>