Integrated employee management
This commit is contained in:
@@ -61,9 +61,13 @@
|
||||
<span class="menu-text">Projects</span>
|
||||
</a>
|
||||
<a href="{{ url_for('users') }}" class="menu-item">
|
||||
<i class="fas fa-users"></i>
|
||||
<i class="fas fa-user-cog"></i>
|
||||
<span class="menu-text">Users</span>
|
||||
</a>
|
||||
<a href="{{ url_for('employees') }}" class="menu-item">
|
||||
<i class="fas fa-user"></i>
|
||||
<span class="menu-text">Employees</span>
|
||||
</a>
|
||||
<a href="{{ url_for('attendance_report') }}" class="menu-item">
|
||||
<i class="fas fa-chart-line"></i>
|
||||
<span class="menu-text">Reports</span>
|
||||
|
||||
@@ -0,0 +1,324 @@
|
||||
{% extends "base_authenticated.html" %}
|
||||
{% set page_title = "Add New Employee" %}
|
||||
|
||||
{% block title %}{{ page_title }}{% endblock %}
|
||||
|
||||
{% block extra_head %}
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='css/employees.css') }}">
|
||||
<style>
|
||||
.form-container {
|
||||
max-width: 600px;
|
||||
margin: 0 auto;
|
||||
background: #ffffff;
|
||||
border-radius: 0.75rem;
|
||||
box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.form-header {
|
||||
background: #f8fafc;
|
||||
padding: 1.5rem;
|
||||
border-bottom: 1px solid #e2e8f0;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.form-header::before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
height: 4px;
|
||||
background: linear-gradient(90deg, #10b981, #059669);
|
||||
}
|
||||
|
||||
.form-header h2 {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.75rem;
|
||||
font-size: 1.5rem;
|
||||
font-weight: 600;
|
||||
color: #0f172a;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.form-header h2 i {
|
||||
color: #10b981;
|
||||
}
|
||||
|
||||
.form-body {
|
||||
padding: 2rem;
|
||||
}
|
||||
|
||||
.form-group {
|
||||
margin-bottom: 1.5rem;
|
||||
}
|
||||
|
||||
.form-group:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.form-label {
|
||||
display: block;
|
||||
font-weight: 600;
|
||||
color: #374151;
|
||||
margin-bottom: 0.5rem;
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
|
||||
.form-label.required::after {
|
||||
content: " *";
|
||||
color: #dc2626;
|
||||
}
|
||||
|
||||
.form-input {
|
||||
width: 100%;
|
||||
padding: 0.75rem 1rem;
|
||||
border: 2px solid #e2e8f0;
|
||||
border-radius: 0.5rem;
|
||||
font-size: 1rem;
|
||||
transition: border-color 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
|
||||
background: #ffffff;
|
||||
}
|
||||
|
||||
.form-input:focus {
|
||||
outline: none;
|
||||
border-color: #10b981;
|
||||
box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
|
||||
}
|
||||
|
||||
.form-input.error {
|
||||
border-color: #dc2626;
|
||||
}
|
||||
|
||||
.form-help {
|
||||
font-size: 0.875rem;
|
||||
color: #6b7280;
|
||||
margin-top: 0.25rem;
|
||||
}
|
||||
|
||||
.form-actions {
|
||||
display: flex;
|
||||
gap: 1rem;
|
||||
justify-content: flex-end;
|
||||
padding-top: 1.5rem;
|
||||
border-top: 1px solid #e2e8f0;
|
||||
}
|
||||
|
||||
.form-row {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
@media (max-width: 640px) {
|
||||
.form-row {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.form-actions {
|
||||
flex-direction: column;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="employees-page">
|
||||
<!-- Page Header -->
|
||||
<div class="employees-header">
|
||||
<div class="header-content">
|
||||
<div class="header-navigation">
|
||||
<a href="{{ url_for('employees') }}" class="back-button">
|
||||
<i class="fas fa-arrow-left"></i>
|
||||
Back to Employees
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<h1><i class="fas fa-user-plus"></i> Add New Employee</h1>
|
||||
<p class="header-description">
|
||||
Create a new employee record in the system
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Form Container -->
|
||||
<div class="form-container">
|
||||
<div class="form-header">
|
||||
<h2>
|
||||
<i class="fas fa-user-plus"></i>
|
||||
Employee Information
|
||||
</h2>
|
||||
</div>
|
||||
|
||||
<div class="form-body">
|
||||
<form method="POST" id="createEmployeeForm">
|
||||
<!-- Employee ID and Contract ID Row -->
|
||||
<div class="form-row">
|
||||
<div class="form-group">
|
||||
<label for="employee_id" class="form-label required">Employee ID</label>
|
||||
<input
|
||||
type="number"
|
||||
id="employee_id"
|
||||
name="employee_id"
|
||||
class="form-input"
|
||||
required
|
||||
min="1"
|
||||
placeholder="Enter unique employee ID"
|
||||
value="{{ request.form.get('employee_id', '') }}"
|
||||
>
|
||||
<div class="form-help">
|
||||
Must be a unique numeric identifier
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="contract_id" class="form-label">Contract ID</label>
|
||||
<input
|
||||
type="number"
|
||||
id="contract_id"
|
||||
name="contract_id"
|
||||
class="form-input"
|
||||
min="1"
|
||||
value="{{ request.form.get('contract_id', '1') }}"
|
||||
placeholder="Enter contract ID"
|
||||
>
|
||||
<div class="form-help">
|
||||
Default is 1 if not specified
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- First Name and Last Name Row -->
|
||||
<div class="form-row">
|
||||
<div class="form-group">
|
||||
<label for="first_name" class="form-label required">First Name</label>
|
||||
<input
|
||||
type="text"
|
||||
id="first_name"
|
||||
name="first_name"
|
||||
class="form-input"
|
||||
required
|
||||
maxlength="50"
|
||||
placeholder="Enter first name"
|
||||
value="{{ request.form.get('first_name', '') }}"
|
||||
>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="last_name" class="form-label required">Last Name</label>
|
||||
<input
|
||||
type="text"
|
||||
id="last_name"
|
||||
name="last_name"
|
||||
class="form-input"
|
||||
required
|
||||
maxlength="50"
|
||||
placeholder="Enter last name"
|
||||
value="{{ request.form.get('last_name', '') }}"
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Job Title -->
|
||||
<div class="form-group">
|
||||
<label for="title" class="form-label">Job Title</label>
|
||||
<input
|
||||
type="text"
|
||||
id="title"
|
||||
name="title"
|
||||
class="form-input"
|
||||
maxlength="20"
|
||||
placeholder="Enter job title (optional)"
|
||||
value="{{ request.form.get('title', '') }}"
|
||||
>
|
||||
<div class="form-help">
|
||||
Optional field, maximum 20 characters
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Form Actions -->
|
||||
<div class="form-actions">
|
||||
<a href="{{ url_for('employees') }}" class="btn btn-secondary">
|
||||
<i class="fas fa-times"></i>
|
||||
Cancel
|
||||
</a>
|
||||
<button type="submit" class="btn btn-primary">
|
||||
<i class="fas fa-save"></i>
|
||||
Create Employee
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% block extra_scripts %}
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
const form = document.getElementById('createEmployeeForm');
|
||||
const employeeIdInput = document.getElementById('employee_id');
|
||||
const firstNameInput = document.getElementById('first_name');
|
||||
const lastNameInput = document.getElementById('last_name');
|
||||
|
||||
// Form validation
|
||||
form.addEventListener('submit', function(e) {
|
||||
let isValid = true;
|
||||
|
||||
// Clear previous error states
|
||||
document.querySelectorAll('.form-input').forEach(input => {
|
||||
input.classList.remove('error');
|
||||
});
|
||||
|
||||
// Validate Employee ID
|
||||
if (!employeeIdInput.value.trim()) {
|
||||
employeeIdInput.classList.add('error');
|
||||
isValid = false;
|
||||
}
|
||||
|
||||
// Validate First Name
|
||||
if (!firstNameInput.value.trim()) {
|
||||
firstNameInput.classList.add('error');
|
||||
isValid = false;
|
||||
}
|
||||
|
||||
// Validate Last Name
|
||||
if (!lastNameInput.value.trim()) {
|
||||
lastNameInput.classList.add('error');
|
||||
isValid = false;
|
||||
}
|
||||
|
||||
if (!isValid) {
|
||||
e.preventDefault();
|
||||
alert('Please fill in all required fields.');
|
||||
}
|
||||
});
|
||||
|
||||
// Auto-capitalize names
|
||||
[firstNameInput, lastNameInput].forEach(input => {
|
||||
input.addEventListener('input', function() {
|
||||
const words = this.value.split(' ');
|
||||
const capitalizedWords = words.map(word => {
|
||||
if (word.length > 0) {
|
||||
return word.charAt(0).toUpperCase() + word.slice(1).toLowerCase();
|
||||
}
|
||||
return word;
|
||||
});
|
||||
this.value = capitalizedWords.join(' ');
|
||||
});
|
||||
});
|
||||
|
||||
// Employee ID validation
|
||||
employeeIdInput.addEventListener('input', function() {
|
||||
// Remove any non-numeric characters
|
||||
this.value = this.value.replace(/[^0-9]/g, '');
|
||||
|
||||
// Remove leading zeros
|
||||
if (this.value.length > 1) {
|
||||
this.value = this.value.replace(/^0+/, '');
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
@@ -0,0 +1,374 @@
|
||||
{% extends "base_authenticated.html" %}
|
||||
{% set page_title = "Employee Management" %}
|
||||
|
||||
{% block title %}{{ page_title }}{% endblock %}
|
||||
|
||||
{% block extra_head %}
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='css/employees.css') }}">
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="employees-page">
|
||||
<!-- Page Header -->
|
||||
<div class="employees-header">
|
||||
<div class="header-content">
|
||||
<div class="header-navigation">
|
||||
<a href="{{ url_for('dashboard') }}" class="back-button">
|
||||
<i class="fas fa-arrow-left"></i>
|
||||
Back to Dashboard
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<h1><i class="fas fa-users"></i> Employee Management</h1>
|
||||
<p class="header-description">
|
||||
Manage employee records and view attendance statistics
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="header-actions">
|
||||
{% if session.user_role == 'admin' %}
|
||||
<a href="{{ url_for('create_employee') }}" class="btn btn-primary">
|
||||
<i class="fas fa-plus"></i>
|
||||
Add Employee
|
||||
</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Statistics Cards -->
|
||||
<div class="stats-grid">
|
||||
<div class="stat-card">
|
||||
<div class="stat-icon">
|
||||
<i class="fas fa-users"></i>
|
||||
</div>
|
||||
<div class="stat-info">
|
||||
<h3>{{ stats.total_employees }}</h3>
|
||||
<p>Total Employees</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="stat-card">
|
||||
<div class="stat-icon">
|
||||
<i class="fas fa-id-badge"></i>
|
||||
</div>
|
||||
<div class="stat-info">
|
||||
<h3>{{ stats.employees_with_title }}</h3>
|
||||
<p>With Job Titles</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="stat-card">
|
||||
<div class="stat-icon">
|
||||
<i class="fas fa-briefcase"></i>
|
||||
</div>
|
||||
<div class="stat-info">
|
||||
<h3>{{ stats.unique_titles }}</h3>
|
||||
<p>Unique Job Titles</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% if search %}
|
||||
<div class="stat-card search-results">
|
||||
<div class="stat-icon">
|
||||
<i class="fas fa-search"></i>
|
||||
</div>
|
||||
<div class="stat-info">
|
||||
<h3>{{ stats.search_results }}</h3>
|
||||
<p>Search Results</p>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<!-- Search and Filter Section -->
|
||||
<div class="search-section">
|
||||
<form method="GET" class="search-form">
|
||||
<div class="search-input-group">
|
||||
<input
|
||||
type="text"
|
||||
name="search"
|
||||
value="{{ search }}"
|
||||
placeholder="Search by name, employee ID, or job title..."
|
||||
class="search-input"
|
||||
autocomplete="off"
|
||||
>
|
||||
<button type="submit" class="search-btn">
|
||||
<i class="fas fa-search"></i>
|
||||
</button>
|
||||
{% if search %}
|
||||
<a href="{{ url_for('employees') }}" class="clear-search-btn" title="Clear search">
|
||||
<i class="fas fa-times"></i>
|
||||
</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<!-- Employee Table -->
|
||||
<div class="employees-table-container">
|
||||
<div class="table-header">
|
||||
<h2>
|
||||
{% if search %}
|
||||
Search Results for "{{ search }}"
|
||||
{% else %}
|
||||
All Employees
|
||||
{% endif %}
|
||||
</h2>
|
||||
<div class="table-info">
|
||||
Showing {{ employees.items|length }} of {{ employees.total }} employees
|
||||
{% if employees.pages > 1 %}
|
||||
(Page {{ employees.page }} of {{ employees.pages }})
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="table-responsive">
|
||||
<table class="employees-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>#</th>
|
||||
<th>Employee ID</th>
|
||||
<th>Name</th>
|
||||
<th>Job Title</th>
|
||||
<th>Contract ID</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for employee in employees.items %}
|
||||
<tr class="employee-row" data-employee-id="{{ employee.id }}">
|
||||
<td class="row-number">{{ loop.index + (employees.page - 1) * employees.per_page }}</td>
|
||||
|
||||
<td class="employee-id">
|
||||
<span class="id-badge">{{ employee.id }}</span>
|
||||
</td>
|
||||
|
||||
<td class="employee-name">
|
||||
<div class="name-container">
|
||||
<div class="avatar">
|
||||
<i class="fas fa-user-circle"></i>
|
||||
</div>
|
||||
<div class="name-details">
|
||||
<h4>{{ employee.full_name }}</h4>
|
||||
<p>{{ employee.firstName }} {{ employee.lastName }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
|
||||
<td class="employee-title">
|
||||
{% if employee.title %}
|
||||
<span class="title-badge">{{ employee.title }}</span>
|
||||
{% else %}
|
||||
<span class="no-title">No Title</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
|
||||
<td class="contract-id">
|
||||
<span class="contract-badge">{{ employee.contractId }}</span>
|
||||
</td>
|
||||
|
||||
<td class="actions">
|
||||
<div class="action-buttons">
|
||||
<a href="{{ url_for('employee_detail', employee_index=employee.index) }}"
|
||||
class="btn btn-sm btn-info"
|
||||
title="View Details">
|
||||
<i class="fas fa-eye"></i>
|
||||
</a>
|
||||
|
||||
{% if session.user_role == 'admin' %}
|
||||
<a href="{{ url_for('edit_employee', employee_index=employee.index) }}"
|
||||
class="btn btn-sm btn-warning"
|
||||
title="Edit Employee">
|
||||
<i class="fas fa-edit"></i>
|
||||
</a>
|
||||
|
||||
<button class="btn btn-sm btn-danger delete-btn"
|
||||
data-employee-index="{{ employee.index }}"
|
||||
data-employee-name="{{ employee.full_name }}"
|
||||
title="Delete Employee">
|
||||
<i class="fas fa-trash"></i>
|
||||
</button>
|
||||
{% endif %}
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<!-- Pagination -->
|
||||
{% if employees.pages > 1 %}
|
||||
<div class="pagination-container">
|
||||
<nav class="pagination-nav">
|
||||
<ul class="pagination">
|
||||
<!-- Previous Page -->
|
||||
{% if employees.has_prev %}
|
||||
<li>
|
||||
<a href="{{ url_for('employees', page=employees.prev_num, search=search) }}"
|
||||
class="pagination-link">
|
||||
<i class="fas fa-chevron-left"></i>
|
||||
Previous
|
||||
</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
|
||||
<!-- Page Numbers -->
|
||||
{% for page_num in employees.iter_pages() %}
|
||||
{% if page_num %}
|
||||
{% if page_num != employees.page %}
|
||||
<li>
|
||||
<a href="{{ url_for('employees', page=page_num, search=search) }}"
|
||||
class="pagination-link">
|
||||
{{ page_num }}
|
||||
</a>
|
||||
</li>
|
||||
{% else %}
|
||||
<li>
|
||||
<span class="pagination-link current">{{ page_num }}</span>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% else %}
|
||||
<li>
|
||||
<span class="pagination-link">…</span>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
<!-- Next Page -->
|
||||
{% if employees.has_next %}
|
||||
<li>
|
||||
<a href="{{ url_for('employees', page=employees.next_num, search=search) }}"
|
||||
class="pagination-link">
|
||||
Next
|
||||
<i class="fas fa-chevron-right"></i>
|
||||
</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
</nav>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<!-- Empty State -->
|
||||
{% if employees.total == 0 %}
|
||||
<div class="empty-state">
|
||||
<div class="empty-icon">
|
||||
<i class="fas fa-users-slash"></i>
|
||||
</div>
|
||||
<h3>
|
||||
{% if search %}
|
||||
No employees found for "{{ search }}"
|
||||
{% else %}
|
||||
No employees found
|
||||
{% endif %}
|
||||
</h3>
|
||||
<p>
|
||||
{% if search %}
|
||||
Try adjusting your search terms or <a href="{{ url_for('employees') }}">view all employees</a>.
|
||||
{% else %}
|
||||
Get started by <a href="{{ url_for('create_employee') }}">adding your first employee</a>.
|
||||
{% endif %}
|
||||
</p>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Delete Confirmation Modal -->
|
||||
<div id="deleteModal" class="modal">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h3><i class="fas fa-exclamation-triangle"></i> Confirm Deletion</h3>
|
||||
<button class="close-modal" data-modal="deleteModal">
|
||||
<i class="fas fa-times"></i>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p>Are you sure you want to delete employee <strong id="deleteEmployeeName"></strong>?</p>
|
||||
<p class="warning-text">
|
||||
<i class="fas fa-warning"></i>
|
||||
This action cannot be undone. The employee will be permanently removed from the system.
|
||||
</p>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button class="btn btn-secondary" data-modal="deleteModal">Cancel</button>
|
||||
<form id="deleteForm" method="POST" style="display: inline;">
|
||||
<button type="submit" class="btn btn-danger">
|
||||
<i class="fas fa-trash"></i>
|
||||
Delete Employee
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% block extra_scripts %}
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
// Delete button functionality
|
||||
const deleteButtons = document.querySelectorAll('.delete-btn');
|
||||
const deleteModal = document.getElementById('deleteModal');
|
||||
const deleteForm = document.getElementById('deleteForm');
|
||||
const deleteEmployeeName = document.getElementById('deleteEmployeeName');
|
||||
|
||||
deleteButtons.forEach(button => {
|
||||
button.addEventListener('click', function() {
|
||||
const employeeIndex = this.getAttribute('data-employee-index');
|
||||
const employeeName = this.getAttribute('data-employee-name');
|
||||
|
||||
deleteEmployeeName.textContent = employeeName;
|
||||
deleteForm.action = `/employees/${employeeIndex}/delete`;
|
||||
deleteModal.style.display = 'flex';
|
||||
});
|
||||
});
|
||||
|
||||
// Modal close functionality
|
||||
document.querySelectorAll('[data-modal]').forEach(element => {
|
||||
element.addEventListener('click', function() {
|
||||
const modalId = this.getAttribute('data-modal');
|
||||
document.getElementById(modalId).style.display = 'none';
|
||||
});
|
||||
});
|
||||
|
||||
// Close modal when clicking outside
|
||||
deleteModal.addEventListener('click', function(e) {
|
||||
if (e.target === this) {
|
||||
this.style.display = 'none';
|
||||
}
|
||||
});
|
||||
|
||||
// Search form auto-submit with debouncing
|
||||
const searchInput = document.querySelector('.search-input');
|
||||
let searchTimeout;
|
||||
|
||||
searchInput.addEventListener('input', function() {
|
||||
clearTimeout(searchTimeout);
|
||||
searchTimeout = setTimeout(() => {
|
||||
if (this.value.length >= 3 || this.value.length === 0) {
|
||||
this.form.submit();
|
||||
}
|
||||
}, 500);
|
||||
});
|
||||
|
||||
// Highlight search terms
|
||||
const searchTerm = "{{ search }}";
|
||||
if (searchTerm) {
|
||||
highlightSearchTerms(searchTerm);
|
||||
}
|
||||
|
||||
function highlightSearchTerms(term) {
|
||||
const elements = document.querySelectorAll('.employee-name h4, .employee-name p, .employee-title .title-badge, .employee-id .id-badge');
|
||||
const regex = new RegExp(`(${term})`, 'gi');
|
||||
|
||||
elements.forEach(element => {
|
||||
const text = element.textContent;
|
||||
if (text.toLowerCase().includes(term.toLowerCase())) {
|
||||
element.innerHTML = text.replace(regex, '<mark>$1</mark>');
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
@@ -0,0 +1,521 @@
|
||||
{% extends "base_authenticated.html" %}
|
||||
{% set page_title = "Employee Details - " + employee.full_name %}
|
||||
|
||||
{% block title %}{{ page_title }}{% endblock %}
|
||||
|
||||
{% block extra_head %}
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='css/employees.css') }}">
|
||||
<style>
|
||||
.employee-detail-page {
|
||||
max-width: 1200px;
|
||||
margin: 0 auto;
|
||||
padding: 2rem;
|
||||
min-height: 100vh;
|
||||
background: #f8fafc;
|
||||
}
|
||||
|
||||
.employee-profile {
|
||||
background: #ffffff;
|
||||
border-radius: 0.75rem;
|
||||
box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
|
||||
overflow: hidden;
|
||||
margin-bottom: 2rem;
|
||||
}
|
||||
|
||||
.profile-header {
|
||||
background: linear-gradient(135deg, #2563eb, #1d4ed8);
|
||||
color: #ffffff;
|
||||
padding: 2rem;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.profile-header::before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><pattern id="grid" width="10" height="10" patternUnits="userSpaceOnUse"><path d="M 10 0 L 0 0 0 10" fill="none" stroke="rgba(255,255,255,0.1)" stroke-width="0.5"/></pattern></defs><rect width="100" height="100" fill="url(%23grid)"/></svg>');
|
||||
}
|
||||
|
||||
.profile-content {
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 1.5rem;
|
||||
}
|
||||
|
||||
.profile-avatar {
|
||||
width: 80px;
|
||||
height: 80px;
|
||||
background: rgba(255, 255, 255, 0.2);
|
||||
border-radius: 50%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 2rem;
|
||||
backdrop-filter: blur(10px);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.profile-info h1 {
|
||||
font-size: 1.875rem;
|
||||
font-weight: 700;
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
|
||||
.profile-meta {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
||||
gap: 0.75rem;
|
||||
opacity: 0.9;
|
||||
}
|
||||
|
||||
.meta-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
|
||||
.meta-item i {
|
||||
width: 16px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.employee-actions {
|
||||
position: absolute;
|
||||
top: 1.5rem;
|
||||
right: 1.5rem;
|
||||
display: flex;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.profile-body {
|
||||
padding: 2rem;
|
||||
}
|
||||
|
||||
.info-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
|
||||
gap: 1.5rem;
|
||||
}
|
||||
|
||||
.info-card {
|
||||
background: #f8fafc;
|
||||
border: 1px solid #e2e8f0;
|
||||
border-radius: 0.5rem;
|
||||
padding: 1.5rem;
|
||||
}
|
||||
|
||||
.info-card h3 {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
font-size: 1rem;
|
||||
font-weight: 600;
|
||||
color: #0f172a;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.info-value {
|
||||
font-size: 0.875rem;
|
||||
color: #64748b;
|
||||
}
|
||||
|
||||
.info-value strong {
|
||||
color: #0f172a;
|
||||
}
|
||||
|
||||
.attendance-stats {
|
||||
margin-top: 2rem;
|
||||
}
|
||||
|
||||
.stats-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 1.5rem;
|
||||
}
|
||||
|
||||
.stats-header h2 {
|
||||
font-size: 1.25rem;
|
||||
font-weight: 600;
|
||||
color: #0f172a;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.stats-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
||||
gap: 1.5rem;
|
||||
margin-bottom: 2rem;
|
||||
}
|
||||
|
||||
.stat-card {
|
||||
background: #ffffff;
|
||||
border-radius: 0.75rem;
|
||||
padding: 1.5rem;
|
||||
box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 1rem;
|
||||
transition: transform 0.2s ease-in-out;
|
||||
}
|
||||
|
||||
.stat-card:hover {
|
||||
transform: translateY(-2px);
|
||||
}
|
||||
|
||||
.stat-icon {
|
||||
width: 50px;
|
||||
height: 50px;
|
||||
border-radius: 0.75rem;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 1.25rem;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.stat-icon.total {
|
||||
background: linear-gradient(135deg, #2563eb, #1d4ed8);
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.stat-icon.recent {
|
||||
background: linear-gradient(135deg, #10b981, #059669);
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.stat-icon.projects {
|
||||
background: linear-gradient(135deg, #f59e0b, #d97706);
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.stat-icon.latest {
|
||||
background: linear-gradient(135deg, #8b5cf6, #7c3aed);
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.stat-info h3 {
|
||||
font-size: 1.75rem;
|
||||
font-weight: 700;
|
||||
color: #0f172a;
|
||||
margin-bottom: 0.25rem;
|
||||
}
|
||||
|
||||
.stat-info p {
|
||||
color: #64748b;
|
||||
font-size: 0.875rem;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.projects-list {
|
||||
background: #ffffff;
|
||||
border-radius: 0.75rem;
|
||||
box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.projects-header {
|
||||
background: #f8fafc;
|
||||
padding: 1rem 1.5rem;
|
||||
border-bottom: 1px solid #e2e8f0;
|
||||
}
|
||||
|
||||
.projects-header h3 {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
font-size: 1rem;
|
||||
font-weight: 600;
|
||||
color: #0f172a;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.projects-body {
|
||||
padding: 1.5rem;
|
||||
}
|
||||
|
||||
.project-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 1rem;
|
||||
padding: 1rem;
|
||||
border: 1px solid #e2e8f0;
|
||||
border-radius: 0.5rem;
|
||||
margin-bottom: 0.75rem;
|
||||
transition: all 0.2s ease-in-out;
|
||||
}
|
||||
|
||||
.project-item:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.project-item:hover {
|
||||
border-color: #2563eb;
|
||||
background: #f8fafc;
|
||||
}
|
||||
|
||||
.project-icon {
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
background: linear-gradient(135deg, #2563eb, #1d4ed8);
|
||||
color: #ffffff;
|
||||
border-radius: 0.5rem;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.project-info h4 {
|
||||
font-weight: 600;
|
||||
color: #0f172a;
|
||||
margin-bottom: 0.25rem;
|
||||
}
|
||||
|
||||
.project-info p {
|
||||
font-size: 0.875rem;
|
||||
color: #64748b;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.no-projects {
|
||||
text-align: center;
|
||||
padding: 2rem;
|
||||
color: #64748b;
|
||||
}
|
||||
|
||||
.no-projects i {
|
||||
font-size: 3rem;
|
||||
margin-bottom: 1rem;
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.employee-detail-page {
|
||||
padding: 1rem;
|
||||
}
|
||||
|
||||
.profile-content {
|
||||
flex-direction: column;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.employee-actions {
|
||||
position: static;
|
||||
justify-content: center;
|
||||
margin-top: 1rem;
|
||||
}
|
||||
|
||||
.info-grid,
|
||||
.stats-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.profile-meta {
|
||||
grid-template-columns: 1fr;
|
||||
text-align: left;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="employee-detail-page">
|
||||
<!-- Navigation -->
|
||||
<div class="employees-header" style="margin-bottom: 1rem;">
|
||||
<div class="header-content">
|
||||
<div class="header-navigation">
|
||||
<a href="{{ url_for('employees') }}" class="back-button">
|
||||
<i class="fas fa-arrow-left"></i>
|
||||
Back to Employees
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Employee Profile -->
|
||||
<div class="employee-profile">
|
||||
<div class="profile-header">
|
||||
<div class="profile-content">
|
||||
<div class="profile-avatar">
|
||||
<i class="fas fa-user"></i>
|
||||
</div>
|
||||
<div class="profile-info">
|
||||
<h1>{{ employee.full_name }}</h1>
|
||||
<div class="profile-meta">
|
||||
<div class="meta-item">
|
||||
<i class="fas fa-id-card"></i>
|
||||
Employee ID: {{ employee.id }}
|
||||
</div>
|
||||
<div class="meta-item">
|
||||
<i class="fas fa-briefcase"></i>
|
||||
{{ employee.display_title }}
|
||||
</div>
|
||||
<div class="meta-item">
|
||||
<i class="fas fa-file-contract"></i>
|
||||
Contract ID: {{ employee.contractId }}
|
||||
</div>
|
||||
{% if attendance_stats.latest_attendance %}
|
||||
<div class="meta-item">
|
||||
<i class="fas fa-clock"></i>
|
||||
Last seen: {{ attendance_stats.latest_attendance.check_in_date.strftime('%B %d, %Y') }}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% if session.role == 'admin' %}
|
||||
<div class="employee-actions">
|
||||
<a href="{{ url_for('edit_employee', employee_index=employee.index) }}"
|
||||
class="btn btn-warning btn-sm">
|
||||
<i class="fas fa-edit"></i>
|
||||
Edit
|
||||
</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<div class="profile-body">
|
||||
<div class="info-grid">
|
||||
<div class="info-card">
|
||||
<h3>
|
||||
<i class="fas fa-user"></i>
|
||||
Personal Information
|
||||
</h3>
|
||||
<div class="info-value">
|
||||
<p><strong>First Name:</strong> {{ employee.firstName }}</p>
|
||||
<p><strong>Last Name:</strong> {{ employee.lastName }}</p>
|
||||
<p><strong>Full Name:</strong> {{ employee.full_name }}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="info-card">
|
||||
<h3>
|
||||
<i class="fas fa-id-badge"></i>
|
||||
Employment Details
|
||||
</h3>
|
||||
<div class="info-value">
|
||||
<p><strong>Employee ID:</strong> {{ employee.id }}</p>
|
||||
<p><strong>Job Title:</strong> {{ employee.display_title }}</p>
|
||||
<p><strong>Contract ID:</strong> {{ employee.contractId }}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="info-card">
|
||||
<h3>
|
||||
<i class="fas fa-database"></i>
|
||||
System Information
|
||||
</h3>
|
||||
<div class="info-value">
|
||||
<p><strong>Database Index:</strong> {{ employee.index }}</p>
|
||||
<p><strong>Record Status:</strong> Active</p>
|
||||
<p><strong>Attendance Records:</strong> {{ attendance_stats.total_attendance }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Attendance Statistics -->
|
||||
<div class="attendance-stats">
|
||||
<div class="stats-header">
|
||||
<h2>
|
||||
<i class="fas fa-chart-bar"></i>
|
||||
Attendance Statistics
|
||||
</h2>
|
||||
</div>
|
||||
|
||||
<div class="stats-grid">
|
||||
<div class="stat-card">
|
||||
<div class="stat-icon total">
|
||||
<i class="fas fa-calendar-check"></i>
|
||||
</div>
|
||||
<div class="stat-info">
|
||||
<h3>{{ attendance_stats.total_attendance }}</h3>
|
||||
<p>Total Attendance</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="stat-card">
|
||||
<div class="stat-icon recent">
|
||||
<i class="fas fa-calendar-week"></i>
|
||||
</div>
|
||||
<div class="stat-info">
|
||||
<h3>{{ attendance_stats.recent_attendance }}</h3>
|
||||
<p>Last 30 Days</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="stat-card">
|
||||
<div class="stat-icon projects">
|
||||
<i class="fas fa-project-diagram"></i>
|
||||
</div>
|
||||
<div class="stat-info">
|
||||
<h3>{{ attendance_stats.unique_projects }}</h3>
|
||||
<p>Unique Projects</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% if attendance_stats.latest_attendance %}
|
||||
<div class="stat-card">
|
||||
<div class="stat-icon latest">
|
||||
<i class="fas fa-clock"></i>
|
||||
</div>
|
||||
<div class="stat-info">
|
||||
<h3>{{ attendance_stats.latest_attendance.check_in_date.strftime('%m/%d') }}</h3>
|
||||
<p>Latest Check-in</p>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<!-- Projects List -->
|
||||
{% if attendance_stats.projects %}
|
||||
<div class="projects-list">
|
||||
<div class="projects-header">
|
||||
<h3>
|
||||
<i class="fas fa-project-diagram"></i>
|
||||
Projects Participated ({{ attendance_stats.unique_projects }})
|
||||
</h3>
|
||||
</div>
|
||||
<div class="projects-body">
|
||||
{% for project in attendance_stats.projects %}
|
||||
<div class="project-item">
|
||||
<div class="project-icon">
|
||||
<i class="fas fa-folder"></i>
|
||||
</div>
|
||||
<div class="project-info">
|
||||
<h4>{{ project.name }}</h4>
|
||||
<p>
|
||||
{% if project.description %}
|
||||
{{ project.description[:100] }}{% if project.description|length > 100 %}...{% endif %}
|
||||
{% else %}
|
||||
No description available
|
||||
{% endif %}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="projects-list">
|
||||
<div class="projects-body">
|
||||
<div class="no-projects">
|
||||
<i class="fas fa-folder-open"></i>
|
||||
<h3>No Projects Yet</h3>
|
||||
<p>This employee hasn't participated in any projects yet.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
@@ -0,0 +1,374 @@
|
||||
{% extends "base_authenticated.html" %}
|
||||
{% set page_title = "Employee Management" %}
|
||||
|
||||
{% block title %}{{ page_title }}{% endblock %}
|
||||
|
||||
{% block extra_head %}
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='css/employees.css') }}">
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="employees-page">
|
||||
<!-- Page Header -->
|
||||
<div class="employees-header">
|
||||
<div class="header-content">
|
||||
<div class="header-navigation">
|
||||
<a href="{{ url_for('dashboard') }}" class="back-button">
|
||||
<i class="fas fa-arrow-left"></i>
|
||||
Back to Dashboard
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<h1><i class="fas fa-users"></i> Employee Management</h1>
|
||||
<p class="header-description">
|
||||
Manage employee records and view attendance statistics
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="header-actions">
|
||||
{% if session.role == 'admin' %}
|
||||
<a href="{{ url_for('create_employee') }}" class="btn btn-primary">
|
||||
<i class="fas fa-plus"></i>
|
||||
Add Employee
|
||||
</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Statistics Cards -->
|
||||
<div class="stats-grid">
|
||||
<div class="stat-card">
|
||||
<div class="stat-icon">
|
||||
<i class="fas fa-users"></i>
|
||||
</div>
|
||||
<div class="stat-info">
|
||||
<h3>{{ stats.total_employees }}</h3>
|
||||
<p>Total Employees</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="stat-card">
|
||||
<div class="stat-icon">
|
||||
<i class="fas fa-id-badge"></i>
|
||||
</div>
|
||||
<div class="stat-info">
|
||||
<h3>{{ stats.employees_with_title }}</h3>
|
||||
<p>With Job Titles</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="stat-card">
|
||||
<div class="stat-icon">
|
||||
<i class="fas fa-briefcase"></i>
|
||||
</div>
|
||||
<div class="stat-info">
|
||||
<h3>{{ stats.unique_titles }}</h3>
|
||||
<p>Unique Job Titles</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% if search %}
|
||||
<div class="stat-card search-results">
|
||||
<div class="stat-icon">
|
||||
<i class="fas fa-search"></i>
|
||||
</div>
|
||||
<div class="stat-info">
|
||||
<h3>{{ stats.search_results }}</h3>
|
||||
<p>Search Results</p>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<!-- Search and Filter Section -->
|
||||
<div class="search-section">
|
||||
<form method="GET" class="search-form">
|
||||
<div class="search-input-group">
|
||||
<input
|
||||
type="text"
|
||||
name="search"
|
||||
value="{{ search }}"
|
||||
placeholder="Search by name, employee ID, or job title..."
|
||||
class="search-input"
|
||||
autocomplete="off"
|
||||
>
|
||||
<button type="submit" class="search-btn">
|
||||
<i class="fas fa-search"></i>
|
||||
</button>
|
||||
{% if search %}
|
||||
<a href="{{ url_for('employees') }}" class="clear-search-btn" title="Clear search">
|
||||
<i class="fas fa-times"></i>
|
||||
</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<!-- Employee Table -->
|
||||
<div class="employees-table-container">
|
||||
<div class="table-header">
|
||||
<h2>
|
||||
{% if search %}
|
||||
Search Results for "{{ search }}"
|
||||
{% else %}
|
||||
All Employees
|
||||
{% endif %}
|
||||
</h2>
|
||||
<div class="table-info">
|
||||
Showing {{ employees.items|length }} of {{ employees.total }} employees
|
||||
{% if employees.pages > 1 %}
|
||||
(Page {{ employees.page }} of {{ employees.pages }})
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="table-responsive">
|
||||
<table class="employees-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>#</th>
|
||||
<th>Employee ID</th>
|
||||
<th>Name</th>
|
||||
<th>Job Title</th>
|
||||
<th>Contract ID</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for employee in employees.items %}
|
||||
<tr class="employee-row" data-employee-id="{{ employee.id }}">
|
||||
<td class="row-number">{{ loop.index + (employees.page - 1) * employees.per_page }}</td>
|
||||
|
||||
<td class="employee-id">
|
||||
<span class="id-badge">{{ employee.id }}</span>
|
||||
</td>
|
||||
|
||||
<td class="employee-name">
|
||||
<div class="name-container">
|
||||
<div class="avatar">
|
||||
<i class="fas fa-user-circle"></i>
|
||||
</div>
|
||||
<div class="name-details">
|
||||
<h4>{{ employee.full_name }}</h4>
|
||||
<p>{{ employee.firstName }} {{ employee.lastName }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
|
||||
<td class="employee-title">
|
||||
{% if employee.title %}
|
||||
<span class="title-badge">{{ employee.title }}</span>
|
||||
{% else %}
|
||||
<span class="no-title">No Title</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
|
||||
<td class="contract-id">
|
||||
<span class="contract-badge">{{ employee.contractId }}</span>
|
||||
</td>
|
||||
|
||||
<td class="actions">
|
||||
<div class="action-buttons">
|
||||
<a href="{{ url_for('employee_detail', employee_index=employee.index) }}"
|
||||
class="btn btn-sm btn-info"
|
||||
title="View Details">
|
||||
<i class="fas fa-eye"></i>
|
||||
</a>
|
||||
|
||||
{% if session.role == 'admin' %}
|
||||
<a href="{{ url_for('edit_employee', employee_index=employee.index) }}"
|
||||
class="btn btn-sm btn-warning"
|
||||
title="Edit Employee">
|
||||
<i class="fas fa-edit"></i>
|
||||
</a>
|
||||
|
||||
<button class="btn btn-sm btn-danger delete-btn"
|
||||
data-employee-index="{{ employee.index }}"
|
||||
data-employee-name="{{ employee.full_name }}"
|
||||
title="Delete Employee">
|
||||
<i class="fas fa-trash"></i>
|
||||
</button>
|
||||
{% endif %}
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<!-- Pagination -->
|
||||
{% if employees.pages > 1 %}
|
||||
<div class="pagination-container">
|
||||
<nav class="pagination-nav">
|
||||
<ul class="pagination">
|
||||
<!-- Previous Page -->
|
||||
{% if employees.has_prev %}
|
||||
<li>
|
||||
<a href="{{ url_for('employees', page=employees.prev_num, search=search) }}"
|
||||
class="pagination-link">
|
||||
<i class="fas fa-chevron-left"></i>
|
||||
Previous
|
||||
</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
|
||||
<!-- Page Numbers -->
|
||||
{% for page_num in employees.iter_pages() %}
|
||||
{% if page_num %}
|
||||
{% if page_num != employees.page %}
|
||||
<li>
|
||||
<a href="{{ url_for('employees', page=page_num, search=search) }}"
|
||||
class="pagination-link">
|
||||
{{ page_num }}
|
||||
</a>
|
||||
</li>
|
||||
{% else %}
|
||||
<li>
|
||||
<span class="pagination-link current">{{ page_num }}</span>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% else %}
|
||||
<li>
|
||||
<span class="pagination-link">…</span>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
<!-- Next Page -->
|
||||
{% if employees.has_next %}
|
||||
<li>
|
||||
<a href="{{ url_for('employees', page=employees.next_num, search=search) }}"
|
||||
class="pagination-link">
|
||||
Next
|
||||
<i class="fas fa-chevron-right"></i>
|
||||
</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
</nav>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<!-- Empty State -->
|
||||
{% if employees.total == 0 %}
|
||||
<div class="empty-state">
|
||||
<div class="empty-icon">
|
||||
<i class="fas fa-users-slash"></i>
|
||||
</div>
|
||||
<h3>
|
||||
{% if search %}
|
||||
No employees found for "{{ search }}"
|
||||
{% else %}
|
||||
No employees found
|
||||
{% endif %}
|
||||
</h3>
|
||||
<p>
|
||||
{% if search %}
|
||||
Try adjusting your search terms or <a href="{{ url_for('employees') }}">view all employees</a>.
|
||||
{% else %}
|
||||
Get started by <a href="{{ url_for('create_employee') }}">adding your first employee</a>.
|
||||
{% endif %}
|
||||
</p>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Delete Confirmation Modal -->
|
||||
<div id="deleteModal" class="modal">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h3><i class="fas fa-exclamation-triangle"></i> Confirm Deletion</h3>
|
||||
<button class="close-modal" data-modal="deleteModal">
|
||||
<i class="fas fa-times"></i>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p>Are you sure you want to delete employee <strong id="deleteEmployeeName"></strong>?</p>
|
||||
<p class="warning-text">
|
||||
<i class="fas fa-warning"></i>
|
||||
This action cannot be undone. The employee will be permanently removed from the system.
|
||||
</p>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button class="btn btn-secondary" data-modal="deleteModal">Cancel</button>
|
||||
<form id="deleteForm" method="POST" style="display: inline;">
|
||||
<button type="submit" class="btn btn-danger">
|
||||
<i class="fas fa-trash"></i>
|
||||
Delete Employee
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% block extra_scripts %}
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
// Delete button functionality
|
||||
const deleteButtons = document.querySelectorAll('.delete-btn');
|
||||
const deleteModal = document.getElementById('deleteModal');
|
||||
const deleteForm = document.getElementById('deleteForm');
|
||||
const deleteEmployeeName = document.getElementById('deleteEmployeeName');
|
||||
|
||||
deleteButtons.forEach(button => {
|
||||
button.addEventListener('click', function() {
|
||||
const employeeIndex = this.getAttribute('data-employee-index');
|
||||
const employeeName = this.getAttribute('data-employee-name');
|
||||
|
||||
deleteEmployeeName.textContent = employeeName;
|
||||
deleteForm.action = `/employees/${employeeIndex}/delete`;
|
||||
deleteModal.style.display = 'flex';
|
||||
});
|
||||
});
|
||||
|
||||
// Modal close functionality
|
||||
document.querySelectorAll('[data-modal]').forEach(element => {
|
||||
element.addEventListener('click', function() {
|
||||
const modalId = this.getAttribute('data-modal');
|
||||
document.getElementById(modalId).style.display = 'none';
|
||||
});
|
||||
});
|
||||
|
||||
// Close modal when clicking outside
|
||||
deleteModal.addEventListener('click', function(e) {
|
||||
if (e.target === this) {
|
||||
this.style.display = 'none';
|
||||
}
|
||||
});
|
||||
|
||||
// Search form auto-submit with debouncing
|
||||
const searchInput = document.querySelector('.search-input');
|
||||
let searchTimeout;
|
||||
|
||||
searchInput.addEventListener('input', function() {
|
||||
clearTimeout(searchTimeout);
|
||||
searchTimeout = setTimeout(() => {
|
||||
if (this.value.length >= 3 || this.value.length === 0) {
|
||||
this.form.submit();
|
||||
}
|
||||
}, 500);
|
||||
});
|
||||
|
||||
// Highlight search terms
|
||||
const searchTerm = "{{ search }}";
|
||||
if (searchTerm) {
|
||||
highlightSearchTerms(searchTerm);
|
||||
}
|
||||
|
||||
function highlightSearchTerms(term) {
|
||||
const elements = document.querySelectorAll('.employee-name h4, .employee-name p, .employee-title .title-badge, .employee-id .id-badge');
|
||||
const regex = new RegExp(`(${term})`, 'gi');
|
||||
|
||||
elements.forEach(element => {
|
||||
const text = element.textContent;
|
||||
if (text.toLowerCase().includes(term.toLowerCase())) {
|
||||
element.innerHTML = text.replace(regex, '<mark>$1</mark>');
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user