Download index.html from FZXC11/fz: direct link, hf CLI and curl.
- Browser
- Download file 41.7 kB
-
https://huggingface.co/spaces/FZXC11/fz/resolve/main/index.html
- Command line
-
hf download hf://spaces/FZXC11/fz/index.html
-
curl -L -o index.html https://huggingface.co/spaces/FZXC11/fz/resolve/main/index.html
41.7 kB
| <html lang="ar" dir="rtl"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>نظام إدارة الشركة</title> | |
| <script src="https://cdn.tailwindcss.com"></script> | |
| <script src="https://unpkg.com/feather-icons"></script> | |
| <script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script> | |
| <style> | |
| @import url('https://fonts.googleapis.com/css2?family=Tajawal:wght@400;500;700&display=swap'); | |
| body { | |
| font-family: 'Tajawal', sans-serif; | |
| } | |
| .bg-primary { | |
| background-color: #6d28d9; | |
| } | |
| .hover\:bg-primary:hover { | |
| background-color: #7c3aed; | |
| } | |
| .text-primary { | |
| color: #6d28d9; | |
| } | |
| .border-primary { | |
| border-color: #6d28d9; | |
| } | |
| .ring-primary { | |
| --tw-ring-color: #6d28d9; | |
| } | |
| </style> | |
| </head> | |
| <body class="bg-gray-100"> | |
| <div id="app" class="min-h-screen flex flex-col"> | |
| <!-- Login Section --> | |
| <div id="login-section" class="flex-grow flex items-center justify-center p-4"> | |
| <div class="bg-white rounded-lg shadow-xl p-8 w-full max-w-md"> | |
| <div class="text-center mb-8"> | |
| <h1 class="text-2xl font-bold text-gray-800">تسجيل الدخول</h1> | |
| <p class="text-gray-600">الرجاء إدخال بيانات الاعتماد الخاصة بك</p> | |
| </div> | |
| <form id="login-form" class="space-y-4"> | |
| <div> | |
| <label for="username" class="block text-sm font-medium text-gray-700 mb-1">اسم المستخدم</label> | |
| <input type="text" id="username" required class="w-full px-4 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"> | |
| </div> | |
| <div> | |
| <label for="password" class="block text-sm font-medium text-gray-700 mb-1">كلمة المرور</label> | |
| <input type="password" id="password" required class="w-full px-4 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"> | |
| </div> | |
| <button type="submit" class="w-full bg-blue-600 text-white py-2 px-4 rounded-md hover:bg-blue-700 transition duration-300">تسجيل الدخول</button> | |
| </form> | |
| </div> | |
| </div> | |
| <!-- Dashboard Section (Hidden by default) --> | |
| <div id="dashboard-section" class="hidden flex-grow"> | |
| <!-- Header --> | |
| <header class="bg-primary text-white shadow-md"> | |
| <div class="container mx-auto px-4 py-3 flex justify-between items-center"> | |
| <div class="flex items-center"> | |
| <img src="https://cdn.discordapp.com/attachments/1412920984587206736/1414449375740170372/8796728913.png?ex=68bf9c22&is=68be4aa2&hm=e23d7744e10e7b7a5fbb7c73b618f574dbedf6d2ef0d67d66599eb0b9b04fd89&" alt="شعار الشركة" class="h-10 w-10 mr-2"> | |
| <h1 class="text-xl font-bold">نظام الادارة</h1> | |
| </div> | |
| <div class="flex items-center space-x-4"> | |
| <span id="welcome-message" class="text-sm"></span> | |
| <button id="logout-btn" class="flex items-center text-sm hover:bg-blue-700 px-3 py-1 rounded"> | |
| <i data-feather="log-out" class="w-4 h-4 mr-1"></i> | |
| تسجيل الخروج | |
| </button> | |
| </div> | |
| </div> | |
| </header> | |
| <!-- Main Content --> | |
| <main class="container mx-auto px-4 py-6"> | |
| <div class="grid grid-cols-1 md:grid-cols-4 gap-6"> | |
| <!-- Sidebar --> | |
| <aside class="md:col-span-1 bg-white rounded-lg shadow-md p-4"> | |
| <nav> | |
| <ul class="space-y-2"> | |
| <li> | |
| <button id="dashboard-tab" class="w-full text-right flex items-center justify-end px-4 py-2 bg-purple-100 text-primary rounded-md"> | |
| <i data-feather="home" class="ml-2"></i> | |
| لوحة التحكم | |
| </button> | |
| </li> | |
| <li> | |
| <button id="employees-tab" class="w-full text-right flex items-center justify-end px-4 py-2 hover:bg-gray-100 rounded-md"> | |
| <i data-feather="users" class="ml-2"></i> | |
| الموظفين | |
| </button> | |
| </li> | |
| <li> | |
| <button id="add-employee-tab" class="w-full text-right flex items-center justify-end px-4 py-2 hover:bg-gray-100 rounded-md"> | |
| <i data-feather="user-plus" class="ml-2"></i> | |
| إضافة موظف | |
| </button> | |
| </li> | |
| <li> | |
| <button id="reports-tab" class="w-full text-right flex items-center justify-end px-4 py-2 hover:bg-gray-100 rounded-md"> | |
| <i data-feather="file-text" class="ml-2"></i> | |
| التقارير | |
| </button> | |
| </li> | |
| <li> | |
| <button id="generate-report-tab" class="w-full text-right flex items-center justify-end px-4 py-2 hover:bg-gray-100 rounded-md"> | |
| <i data-feather="file-plus" class="ml-2"></i> | |
| إنشاء تقرير | |
| </button> | |
| </li> | |
| </ul> | |
| </nav> | |
| </aside> | |
| <!-- Main Panel --> | |
| <div class="md:col-span-3 space-y-6"> | |
| <!-- Dashboard Panel --> | |
| <div id="dashboard-panel" class="bg-white rounded-lg shadow-md p-6"> | |
| <h2 class="text-xl font-bold text-gray-800 mb-4">لوحة التحكم</h2> | |
| <div class="grid grid-cols-1 md:grid-cols-3 gap-4 mb-6"> | |
| <div class="bg-blue-50 p-4 rounded-lg border border-blue-100"> | |
| <div class="flex justify-between items-center"> | |
| <div> | |
| <p class="text-sm text-gray-600">عدد الموظفين</p> | |
| <p id="employees-count" class="text-2xl font-bold">0</p> | |
| </div> | |
| <i data-feather="users" class="text-blue-500"></i> | |
| </div> | |
| </div> | |
| <div class="bg-green-50 p-4 rounded-lg border border-green-100"> | |
| <div class="flex justify-between items-center"> | |
| <div> | |
| <p class="text-sm text-gray-600">المديرين</p> | |
| <p id="managers-count" class="text-2xl font-bold">0</p> | |
| </div> | |
| <i data-feather="award" class="text-green-500"></i> | |
| </div> | |
| </div> | |
| <div class="bg-purple-50 p-4 rounded-lg border border-purple-100"> | |
| <div class="flex justify-between items-center"> | |
| <div> | |
| <p class="text-sm text-gray-600">إجمالي النقاط</p> | |
| <p id="total-points" class="text-2xl font-bold">0</p> | |
| </div> | |
| <i data-feather="star" class="text-purple-500"></i> | |
| </div> | |
| </div> | |
| </div> | |
| <div> | |
| <h3 class="text-lg font-semibold mb-3">آخر النشاطات</h3> | |
| <div id="recent-activities" class="space-y-3"> | |
| <!-- Activities will be added here dynamically --> | |
| </div> | |
| </div> | |
| </div> | |
| <!-- Employees Panel --> | |
| <div id="employees-panel" class="hidden bg-white rounded-lg shadow-md p-6"> | |
| <div class="flex justify-between items-center mb-4"> | |
| <h2 class="text-xl font-bold text-gray-800">قائمة الموظفين</h2> | |
| <div class="relative"> | |
| <input type="text" placeholder="بحث..." class="pr-10 pl-4 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"> | |
| <i data-feather="search" class="absolute right-3 top-2.5 text-gray-400"></i> | |
| </div> | |
| </div> | |
| <div class="overflow-x-auto"> | |
| <table class="min-w-full divide-y divide-gray-200"> | |
| <thead class="bg-gray-50"> | |
| <tr> | |
| <th class="px-6 py-3 text-right text-xs font-medium text-gray-500 uppercase tracking-wider">الاسم</th> | |
| <th class="px-6 py-3 text-right text-xs font-medium text-gray-500 uppercase tracking-wider">الوظيفة</th> | |
| <th class="px-6 py-3 text-right text-xs font-medium text-gray-500 uppercase tracking-wider">الرتبة</th> | |
| <th class="px-6 py-3 text-right text-xs font-medium text-gray-500 uppercase tracking-wider">النقاط</th> | |
| <th class="px-6 py-3 text-right text-xs font-medium text-gray-500 uppercase tracking-wider">الإجراءات</th> | |
| </tr> | |
| </thead> | |
| <tbody id="employees-table-body" class="bg-white divide-y divide-gray-200"> | |
| <!-- Employees will be added here dynamically --> | |
| </tbody> | |
| </table> | |
| </div> | |
| </div> | |
| <!-- Add Employee Panel --> | |
| <div id="add-employee-panel" class="hidden bg-white rounded-lg shadow-md p-6"> | |
| <h2 class="text-xl font-bold text-gray-800 mb-4">إضافة موظف جديد</h2> | |
| <form id="add-employee-form" class="space-y-4"> | |
| <div class="grid grid-cols-1 md:grid-cols-2 gap-4"> | |
| <div> | |
| <label for="new-name" class="block text-sm font-medium text-gray-700 mb-1">الاسم الكامل</label> | |
| <input type="text" id="new-name" required class="w-full px-4 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"> | |
| </div> | |
| <div> | |
| <label for="new-position" class="block text-sm font-medium text-gray-700 mb-1">الوظيفة</label> | |
| <input type="text" id="new-position" required class="w-full px-4 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"> | |
| </div> | |
| </div> | |
| <div class="grid grid-cols-1 md:grid-cols-2 gap-4"> | |
| <div> | |
| <label for="new-rank" class="block text-sm font-medium text-gray-700 mb-1">الرتبة</label> | |
| <select id="new-rank" required class="w-full px-4 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"> | |
| <option value="" disabled selected>اختر الرتبة</option> | |
| <option value="موظف">موظف</option> | |
| <option value="مدير">مدير</option> | |
| <option value="مدير قسم">مدير قسم</option> | |
| <option value="مدير عام">مدير عام</option> | |
| </select> | |
| </div> | |
| <div> | |
| <label for="new-points" class="block text-sm font-medium text-gray-700 mb-1">النقاط</label> | |
| <input type="number" id="new-points" required class="w-full px-4 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"> | |
| </div> | |
| </div> | |
| <div class="grid grid-cols-1 md:grid-cols-2 gap-4"> | |
| <div> | |
| <label for="new-username" class="block text-sm font-medium text-gray-700 mb-1">اسم المستخدم</label> | |
| <input type="text" id="new-username" required class="w-full px-4 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"> | |
| </div> | |
| <div> | |
| <label for="new-password" class="block text-sm font-medium text-gray-700 mb-1">كلمة المرور</label> | |
| <input type="password" id="new-password" required class="w-full px-4 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"> | |
| </div> | |
| </div> | |
| <button type="submit" class="w-full bg-blue-600 text-white py-2 px-4 rounded-md hover:bg-blue-700 transition duration-300">إضافة موظف</button> | |
| </form> | |
| </div> | |
| <!-- Reports Panel --> | |
| <div id="reports-panel" class="hidden bg-white rounded-lg shadow-md p-6"> | |
| <div class="flex justify-between items-center mb-4"> | |
| <h2 class="text-xl font-bold text-gray-800">التقارير</h2> | |
| <button id="generate-report-btn" class="bg-primary text-white py-2 px-4 rounded-md hover:bg-primary transition duration-300"> | |
| <i data-feather="file-plus" class="w-4 h-4 mr-1"></i> | |
| إنشاء تقرير جديد | |
| </button> | |
| </div> | |
| <h2 class="text-xl font-bold text-gray-800 mb-4">التقارير</h2> | |
| <div id="reports-list" class="space-y-4"> | |
| ${DB.activities | |
| .filter(a => a.type === 'report_generated') | |
| .map(report => ` | |
| <div class="bg-gray-50 p-4 rounded-lg border border-gray-200"> | |
| <div class="flex justify-between items-start"> | |
| <h3 class="font-semibold mb-2">${report.details.name}</h3> | |
| <span class="text-sm text-gray-500">${report.timestamp}</span> | |
| </div> | |
| <p class="text-gray-700 mb-2">${report.details.description}</p> | |
| <div class="text-sm"> | |
| <p><span class="font-medium">موجه إلى:</span> ${report.details.target}</p> | |
| <p class="mt-1"><span class="font-medium">حل المشاكل:</span> ${report.details.problems}</p> | |
| </div> | |
| </div> | |
| `).join('')} | |
| </div> | |
| </div> | |
| <!-- Generate Report Panel --> | |
| <div id="generate-report-panel" class="hidden bg-white rounded-lg shadow-md p-6"> | |
| <h2 class="text-xl font-bold text-gray-800 mb-4">إنشاء تقرير جديد</h2> | |
| <form id="report-form" class="space-y-4"> | |
| <div> | |
| <label for="report-name" class="block text-sm font-medium text-gray-700 mb-1">اسم التقرير</label> | |
| <input type="text" id="report-name" required class="w-full px-4 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"> | |
| </div> | |
| <div> | |
| <label for="report-description" class="block text-sm font-medium text-gray-700 mb-1">وصف التقرير</label> | |
| <textarea id="report-description" rows="3" required class="w-full px-4 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"></textarea> | |
| </div> | |
| <div> | |
| <label for="report-target" class="block text-sm font-medium text-gray-700 mb-1">موجه إلى</label> | |
| <select id="report-target" required class="w-full px-4 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"> | |
| <option value="" disabled selected>اختر الموظف</option> | |
| ${DB.employees.map(e => `<option value="${e.username}">${e.name} (${e.rank})</option>`).join('')} | |
| </select> | |
| </div> | |
| <div> | |
| <label for="report-problems" class="block text-sm font-medium text-gray-700 mb-1">حل المشاكل</label> | |
| <textarea id="report-problems" rows="3" required class="w-full px-4 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"></textarea> | |
| </div> | |
| <div class="flex justify-end space-x-3"> | |
| <button type="button" id="cancel-report" class="bg-gray-300 text-gray-800 py-2 px-4 rounded-md hover:bg-gray-400 transition duration-300">إلغاء</button> | |
| <button type="submit" class="bg-primary text-white py-2 px-4 rounded-md hover:bg-primary transition duration-300">حفظ التقرير</button> | |
| </div> | |
| </form> | |
| </div> | |
| </div> | |
| </div> | |
| </main> | |
| </div> | |
| </div> | |
| <script> | |
| // Simple database simulation using localStorage | |
| const DB = { | |
| users: JSON.parse(localStorage.getItem('company_users')) || [ | |
| { username: 'admin', password: '21232f297a57a5a743894a0e4a801fc3', name: 'مدير النظام', position: 'مدير عام', rank: 'مدير عام', points: 100, isAdmin: true }, | |
| { username: 'manager1', password: '1a1dc91c907325c69271ddf0c944bc72', name: 'مدير قسم', position: 'مدير قسم', rank: 'مدير قسم', points: 80, isAdmin: true }, | |
| { username: 'employee1', password: '5f4dcc3b5aa765d61d8327deb882cf99', name: 'موظف عادي', position: 'موظف', rank: 'موظف', points: 50, isAdmin: false }, | |
| { username: 'nn', password: 'c20ad4d76fe97759aa27a0c99bff6710', name: 'حساب جديد', position: 'موظف', rank: 'موظف', points: 30, isAdmin: false } | |
| ], | |
| employees: JSON.parse(localStorage.getItem('company_employees')) || [], | |
| activities: JSON.parse(localStorage.getItem('company_activities')) || [] | |
| }; | |
| // Save to localStorage | |
| function saveDB() { | |
| localStorage.setItem('company_users', JSON.stringify(DB.users)); | |
| localStorage.setItem('company_employees', JSON.stringify(DB.employees)); | |
| localStorage.setItem('company_activities', JSON.stringify(DB.activities)); | |
| } | |
| // MD5 function for password hashing (simple implementation) | |
| function md5(string) { | |
| return CryptoJS.MD5(string).toString(); | |
| } | |
| // Initialize the app | |
| document.addEventListener('DOMContentLoaded', function() { | |
| feather.replace(); | |
| // Login form submission | |
| document.getElementById('login-form').addEventListener('submit', function(e) { | |
| e.preventDefault(); | |
| const username = document.getElementById('username').value; | |
| const password = document.getElementById('password').value; | |
| // Find user | |
| const user = DB.users.find(u => u.username === username && (u.password === md5(password) || u.password === password)); | |
| if (user) { | |
| // Successful login | |
| document.getElementById('login-section').classList.add('hidden'); | |
| document.getElementById('dashboard-section').classList.remove('hidden'); | |
| document.getElementById('welcome-message').textContent = `مرحباً، ${user.name}`; | |
| // Load dashboard data | |
| loadDashboardData(); | |
| } else { | |
| alert('اسم المستخدم أو كلمة المرور غير صحيحة'); | |
| } | |
| }); | |
| // Logout button | |
| document.getElementById('logout-btn').addEventListener('click', function() { | |
| document.getElementById('dashboard-section').classList.add('hidden'); | |
| document.getElementById('login-section').classList.remove('hidden'); | |
| document.getElementById('login-form').reset(); | |
| }); | |
| // Tab switching | |
| document.getElementById('dashboard-tab').addEventListener('click', function() { | |
| switchTab('dashboard'); | |
| }); | |
| document.getElementById('employees-tab').addEventListener('click', function() { | |
| switchTab('employees'); | |
| loadEmployeesTable(); | |
| }); | |
| document.getElementById('add-employee-tab').addEventListener('click', function() { | |
| switchTab('add-employee'); | |
| }); | |
| document.getElementById('reports-tab').addEventListener('click', function() { | |
| switchTab('reports'); | |
| loadReports(); | |
| }); | |
| // Add/edit employee form | |
| document.getElementById('add-employee-form').addEventListener('submit', function(e) { | |
| e.preventDefault(); | |
| const isEditMode = this.dataset.editMode === 'true'; | |
| const username = this.dataset.username; | |
| const employeeData = { | |
| name: document.getElementById('new-name').value, | |
| position: document.getElementById('new-position').value, | |
| rank: document.getElementById('new-rank').value, | |
| points: parseInt(document.getElementById('new-points').value), | |
| username: document.getElementById('new-username').value, | |
| password: document.getElementById('new-password').value, | |
| isAdmin: document.getElementById('new-rank').value.includes('مدير') | |
| }; | |
| if (isEditMode) { | |
| // Update existing employee | |
| const employeeIndex = DB.employees.findIndex(e => e.username === username); | |
| const userIndex = DB.users.findIndex(u => u.username === username); | |
| if (employeeIndex !== -1 && userIndex !== -1) { | |
| // Update employee | |
| DB.employees[employeeIndex] = { | |
| ...DB.employees[employeeIndex], | |
| name: employeeData.name, | |
| position: employeeData.position, | |
| rank: employeeData.rank, | |
| points: employeeData.points, | |
| username: employeeData.username, | |
| password: employeeData.password ? md5(employeeData.password) : DB.employees[employeeIndex].password, | |
| isAdmin: employeeData.rank.includes('مدير') | |
| }; | |
| // Update user | |
| DB.users[userIndex] = { | |
| ...DB.users[userIndex], | |
| name: employeeData.name, | |
| position: employeeData.position, | |
| rank: employeeData.rank, | |
| points: employeeData.points, | |
| username: employeeData.username, | |
| password: employeeData.password ? md5(employeeData.password) : DB.users[userIndex].password, | |
| isAdmin: employeeData.rank.includes('مدير') | |
| }; | |
| // Add activity | |
| DB.activities.unshift({ | |
| type: 'employee_updated', | |
| message: `تم تحديث بيانات الموظف: ${employeeData.name}`, | |
| timestamp: new Date().toLocaleString() | |
| }); | |
| saveDB(); | |
| document.getElementById('add-employee-form').reset(); | |
| delete document.getElementById('add-employee-form').dataset.editMode; | |
| delete document.getElementById('add-employee-form').dataset.username; | |
| document.querySelector('#add-employee-form button[type="submit"]').textContent = 'إضافة موظف'; | |
| alert('تم تحديث بيانات الموظف بنجاح'); | |
| switchTab('employees'); | |
| loadEmployeesTable(); | |
| loadDashboardData(); | |
| } | |
| } else { | |
| // Add new employee | |
| const newEmployee = { | |
| name: employeeData.name, | |
| position: employeeData.position, | |
| rank: employeeData.rank, | |
| points: parseInt(employeeData.points), | |
| username: employeeData.username, | |
| password: md5(employeeData.password), | |
| isAdmin: employeeData.rank.includes('مدير') | |
| }; | |
| // Check if username already exists | |
| if (DB.users.some(u => u.username === newEmployee.username)) { | |
| alert('اسم المستخدم موجود مسبقاً، الرجاء اختيار اسم آخر'); | |
| return; | |
| } | |
| // Add to employees and users | |
| DB.employees.push(newEmployee); | |
| DB.users.push({ | |
| username: newEmployee.username, | |
| password: md5(newEmployee.password), | |
| name: newEmployee.name, | |
| position: newEmployee.position, | |
| rank: newEmployee.rank, | |
| points: newEmployee.points, | |
| isAdmin: newEmployee.isAdmin | |
| }); | |
| // Add activity | |
| DB.activities.unshift({ | |
| type: 'employee_added', | |
| message: `تم إضافة موظف جديد: ${newEmployee.name}`, | |
| timestamp: new Date().toLocaleString() | |
| }); | |
| saveDB(); | |
| document.getElementById('add-employee-form').reset(); | |
| alert('تم إضافة الموظف بنجاح'); | |
| switchTab('employees'); | |
| loadEmployeesTable(); | |
| loadDashboardData(); | |
| } | |
| }); | |
| }); | |
| function switchTab(tabName) { | |
| // Hide all panels | |
| document.getElementById('dashboard-panel').classList.add('hidden'); | |
| document.getElementById('employees-panel').classList.add('hidden'); | |
| document.getElementById('add-employee-panel').classList.add('hidden'); | |
| document.getElementById('reports-panel').classList.add('hidden'); | |
| document.getElementById('generate-report-panel').classList.add('hidden'); | |
| // Reset tab styles | |
| document.getElementById('dashboard-tab').classList.remove('bg-blue-100', 'text-blue-700'); | |
| document.getElementById('employees-tab').classList.remove('bg-blue-100', 'text-blue-700'); | |
| document.getElementById('add-employee-tab').classList.remove('bg-blue-100', 'text-blue-700'); | |
| document.getElementById('reports-tab').classList.remove('bg-blue-100', 'text-blue-700'); | |
| // Show selected panel and style its tab | |
| document.getElementById(`${tabName}-panel`).classList.remove('hidden'); | |
| document.getElementById(`${tabName}-tab`).classList.add('bg-purple-100', 'text-primary'); | |
| } | |
| function loadDashboardData() { | |
| // Update counts | |
| document.getElementById('employees-count').textContent = DB.employees.length; | |
| document.getElementById('managers-count').textContent = DB.employees.filter(e => e.rank.includes('مدير')).length; | |
| document.getElementById('total-points').textContent = DB.employees.reduce((sum, e) => sum + e.points, 0); | |
| // Load recent activities | |
| const activitiesContainer = document.getElementById('recent-activities'); | |
| activitiesContainer.innerHTML = ''; | |
| const recentActivities = DB.activities.slice(0, 5); | |
| if (recentActivities.length === 0) { | |
| activitiesContainer.innerHTML = '<p class="text-gray-500 text-center py-4">لا توجد نشاطات مسجلة</p>'; | |
| } else { | |
| recentActivities.forEach(activity => { | |
| const activityElement = document.createElement('div'); | |
| activityElement.className = 'flex items-start p-3 bg-gray-50 rounded-lg'; | |
| activityElement.innerHTML = ` | |
| <div class="flex-shrink-0 mt-1"> | |
| <i data-feather="${activity.type === 'employee_added' ? 'user-plus' : 'activity'}" class="text-blue-500"></i> | |
| </div> | |
| <div class="mr-3"> | |
| <p class="text-sm font-medium">${activity.message}</p> | |
| <p class="text-xs text-gray-500">${activity.timestamp}</p> | |
| </div> | |
| `; | |
| activitiesContainer.appendChild(activityElement); | |
| }); | |
| feather.replace(); | |
| } | |
| } | |
| function loadEmployeesTable() { | |
| const tableBody = document.getElementById('employees-table-body'); | |
| tableBody.innerHTML = ''; | |
| if (DB.employees.length === 0) { | |
| tableBody.innerHTML = ` | |
| <tr> | |
| <td colspan="5" class="px-6 py-4 text-center text-gray-500">لا يوجد موظفين مسجلين</td> | |
| </tr> | |
| `; | |
| } else { | |
| DB.employees.forEach(employee => { | |
| const row = document.createElement('tr'); | |
| row.innerHTML = ` | |
| <td class="px-6 py-4 whitespace-nowrap"> | |
| <div class="flex items-center"> | |
| <div class="ml-4"> | |
| <div class="text-sm font-medium text-gray-900">${employee.name}</div> | |
| <div class="text-sm text-gray-500">${employee.username}</div> | |
| </div> | |
| </div> | |
| </td> | |
| <td class="px-6 py-4 whitespace-nowrap"> | |
| <div class="text-sm text-gray-900">${employee.position}</div> | |
| </td> | |
| <td class="px-6 py-4 whitespace-nowrap"> | |
| <span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full ${employee.rank.includes('مدير') ? 'bg-green-100 text-green-800' : 'bg-purple-100 text-primary'}"> | |
| ${employee.rank} | |
| </span> | |
| </td> | |
| <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900"> | |
| ${employee.points} | |
| </td> | |
| <td class="px-6 py-4 whitespace-nowrap text-right text-sm font-medium"> | |
| <button onclick="editEmployee('${employee.username}')" class="text-blue-600 hover:text-blue-900 mr-3">تعديل</button> | |
| <button onclick="deleteEmployee('${employee.username}')" class="text-red-600 hover:text-red-900">حذف</button> | |
| </td> | |
| `; | |
| tableBody.appendChild(row); | |
| }); | |
| } | |
| } | |
| function deleteEmployee(username) { | |
| if (confirm('هل أنت متأكد من حذف هذا الموظف؟')) { | |
| DB.employees = DB.employees.filter(e => e.username !== username); | |
| DB.users = DB.users.filter(u => u.username !== username); | |
| // Add activity | |
| DB.activities.unshift({ | |
| type: 'employee_deleted', | |
| message: `تم حذف موظف: ${username}`, | |
| timestamp: new Date().toLocaleString() | |
| }); | |
| saveDB(); | |
| loadEmployeesTable(); | |
| loadDashboardData(); | |
| alert('تم حذف الموظف بنجاح'); | |
| } | |
| } | |
| function editEmployee(username) { | |
| const employee = DB.employees.find(e => e.username === username); | |
| if (!employee) return; | |
| // Fill the add employee form with existing data | |
| document.getElementById('new-name').value = employee.name; | |
| document.getElementById('new-position').value = employee.position; | |
| document.getElementById('new-rank').value = employee.rank; | |
| document.getElementById('new-points').value = employee.points; | |
| document.getElementById('new-username').value = employee.username; | |
| document.getElementById('new-password').value = ''; // Clear password field | |
| // Change form to edit mode | |
| const form = document.getElementById('add-employee-form'); | |
| form.dataset.editMode = 'true'; | |
| form.dataset.username = username; | |
| // Change button text | |
| form.querySelector('button[type="submit"]').textContent = 'تحديث الموظف'; | |
| // Switch to add employee tab | |
| switchTab('add-employee'); | |
| } | |
| function loadReports() { | |
| const reportsContainer = document.getElementById('reports-list'); | |
| reportsContainer.innerHTML = ''; | |
| const reports = DB.activities.filter(a => a.type === 'report_generated'); | |
| if (reports.length === 0) { | |
| reportsContainer.innerHTML = '<p class="text-center text-gray-500 py-10">لا توجد تقارير مسجلة</p>'; | |
| } else { | |
| reports.forEach(report => { | |
| const reportElement = document.createElement('div'); | |
| reportElement.className = 'bg-gray-50 p-4 rounded-lg border border-gray-200'; | |
| reportElement.innerHTML = ` | |
| <div class="flex justify-between items-start"> | |
| <h3 class="font-semibold mb-2">${report.details.name}</h3> | |
| <span class="text-sm text-gray-500">${report.timestamp}</span> | |
| </div> | |
| <p class="text-gray-700 mb-2">${report.details.description}</p> | |
| <div class="text-sm"> | |
| <p><span class="font-medium">موجه إلى:</span> ${report.details.target}</p> | |
| <p class="mt-1"><span class="font-medium">حل المشاكل:</span> ${report.details.problems}</p> | |
| </div> | |
| `; | |
| reportsContainer.appendChild(reportElement); | |
| }); | |
| } | |
| } | |
| // Generate Report Button | |
| document.getElementById('generate-report-btn').addEventListener('click', function() { | |
| document.getElementById('reports-panel').classList.add('hidden'); | |
| document.getElementById('generate-report-panel').classList.remove('hidden'); | |
| document.getElementById('report-form').reset(); | |
| }); | |
| // Generate Report Tab | |
| document.getElementById('generate-report-tab').addEventListener('click', function() { | |
| document.getElementById('reports-panel').classList.add('hidden'); | |
| document.getElementById('generate-report-panel').classList.remove('hidden'); | |
| document.getElementById('report-form').reset(); | |
| }); | |
| // Cancel Report | |
| document.getElementById('cancel-report').addEventListener('click', function() { | |
| document.getElementById('generate-report-panel').classList.add('hidden'); | |
| document.getElementById('reports-panel').classList.remove('hidden'); | |
| }); | |
| // Report Form Submission | |
| document.getElementById('report-form').addEventListener('submit', function(e) { | |
| e.preventDefault(); | |
| const reportData = { | |
| name: document.getElementById('report-name').value, | |
| description: document.getElementById('report-description').value, | |
| target: document.getElementById('report-target').value, | |
| problems: document.getElementById('report-problems').value, | |
| date: new Date().toLocaleString() | |
| }; | |
| // Add to activities | |
| DB.activities.unshift({ | |
| type: 'report_generated', | |
| message: `تم إنشاء تقرير جديد: ${reportData.name}`, | |
| details: reportData, | |
| timestamp: reportData.date | |
| }); | |
| saveDB(); | |
| document.getElementById('report-form').reset(); | |
| document.getElementById('generate-report-panel').classList.add('hidden'); | |
| document.getElementById('reports-panel').classList.remove('hidden'); | |
| loadDashboardData(); | |
| alert(`تم إنشاء التقرير "${reportData.name}" بنجاح`); | |
| }); | |
| </script> | |
| <script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.1.1/crypto-js.min.js"></script> | |
| </body> | |
| </html> | |