first commit

This commit is contained in:
r2xrzh9q2z-lab
2026-02-02 11:07:09 +07:00
commit d1b931d547
286 changed files with 53992 additions and 0 deletions

View File

@@ -0,0 +1,98 @@
<!-- Header section -->
<div class="container">
<div class="d-flex justify-content-between align-items-center mt-4 mb-4">
<div>
<h1 class="h3 mb-0" style="color: var(--primary-dark);">Create New Department</h1>
<p class="text-muted mb-0">Add a new department to the system</p>
</div>
<div>
<a href="/admin/department" class="btn btn-outline-secondary">
<i class="fas fa-arrow-left me-1"></i>Back to Department Management
</a>
</div>
</div>
<div class="row">
<div class="col-md-8 mx-auto">
<div class="card border-0 shadow-sm">
<div class="card-body p-4">
<form action="/admin/department/create" method="POST" id="createForm">
<div class="mb-4">
<label for="name" class="form-label fw-medium">Department Name</label>
<input type="text" class="form-control" id="name" name="name" required
placeholder="Enter department name">
<div class="form-text">
<i class="fas fa-info-circle me-1"></i>
Enter the full name of the department (e.g. Business, Engineering)
</div>
</div>
<div class="alert alert-info">
<i class="fas fa-lightbulb me-2"></i>
<strong>Tips:</strong>
<ul class="mb-0 mt-2">
<li>Department name should be clear and descriptive</li>
<li>Use proper capitalization</li>
<li>Avoid abbreviations unless commonly known</li>
</ul>
</div>
<div class="d-grid gap-2 mt-4">
<button type="submit" class="btn btn-primary">
<i class="fas fa-plus-circle me-1"></i>Create Department
</button>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
<!-- Custom Modal -->
<div id="customModal" class="custom-modal">
<div class="custom-modal-content">
<div class="custom-modal-header">
<h5 class="custom-modal-title">Notification</h5>
<button type="button" class="custom-modal-close">&times;</button>
</div>
<div class="custom-modal-body">
<p id="modalMessage">Content of the notification will appear here.</p>
</div>
<div class="custom-modal-footer">
<button type="button" class="btn btn-primary custom-modal-ok">OK</button>
</div>
</div>
</div>
<!-- Import custom modal CSS -->
<link rel="stylesheet" href="/css/custom-modal.css">
<script>
document.addEventListener('DOMContentLoaded', function() {
// Initialize custom modal
CustomModal.init('customModal', {
closeOnOutsideClick: true,
animationDuration: 300
});
const form = document.getElementById('createForm');
const nameInput = document.getElementById('name');
form.addEventListener('submit', function(e) {
// Validate department name
if (!nameInput.value.trim()) {
e.preventDefault();
CustomModal.alert('Please enter a department name.');
return;
}
// Check for special characters
if (/[^a-zA-Z0-9\s-]/.test(nameInput.value.trim())) {
e.preventDefault();
CustomModal.alert('Department name can only contain letters, numbers, spaces and hyphens.');
return;
}
});
});
</script>

View File

@@ -0,0 +1,100 @@
<!-- Header section -->
<div class="container">
<div class="d-flex justify-content-between align-items-center mt-4 mb-4">
<div>
<h1 class="h3 mb-0" style="color: var(--primary-dark);">Edit Department</h1>
<p class="text-muted mb-0">
Editing department: <span class="badge bg-primary"><%= department.name %></span>
</p>
</div>
<div>
<a href="/admin/department" class="btn btn-outline-secondary">
<i class="fas fa-arrow-left me-1"></i>Back to Department Management
</a>
</div>
</div>
<div class="row">
<div class="col-md-8 mx-auto">
<div class="card border-0 shadow-sm">
<div class="card-body p-4">
<form action="/admin/department/edit/<%= department._id %>" method="POST" id="editForm">
<div class="mb-4">
<label for="name" class="form-label fw-medium">Department Name</label>
<input type="text" class="form-control" id="name" name="name" required
value="<%= department.name %>" placeholder="Enter department name">
<div class="form-text">
<i class="fas fa-info-circle me-1"></i>
Enter the full name of the department (e.g. Business, Engineering)
</div>
</div>
<div class="alert alert-info">
<i class="fas fa-lightbulb me-2"></i>
<strong>Tips:</strong>
<ul class="mb-0 mt-2">
<li>Department name should be clear and descriptive</li>
<li>Use proper capitalization</li>
<li>Avoid abbreviations unless commonly known</li>
</ul>
</div>
<div class="d-grid gap-2 mt-4">
<button type="submit" class="btn btn-primary">
<i class="fas fa-save me-1"></i>Save Changes
</button>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
<!-- Custom Modal -->
<div id="customModal" class="custom-modal">
<div class="custom-modal-content">
<div class="custom-modal-header">
<h5 class="custom-modal-title">Notification</h5>
<button type="button" class="custom-modal-close">&times;</button>
</div>
<div class="custom-modal-body">
<p id="modalMessage">Content of the notification will appear here.</p>
</div>
<div class="custom-modal-footer">
<button type="button" class="btn btn-primary custom-modal-ok">OK</button>
</div>
</div>
</div>
<!-- Import custom modal CSS -->
<link rel="stylesheet" href="/css/custom-modal.css">
<script>
document.addEventListener('DOMContentLoaded', function() {
// Initialize custom modal
CustomModal.init('customModal', {
closeOnOutsideClick: true,
animationDuration: 300
});
const form = document.getElementById('editForm');
const nameInput = document.getElementById('name');
form.addEventListener('submit', function(e) {
// Validate department name
if (!nameInput.value.trim()) {
e.preventDefault();
CustomModal.alert('Please enter a department name.');
return;
}
// Check for special characters
if (/[^a-zA-Z0-9\s-]/.test(nameInput.value.trim())) {
e.preventDefault();
CustomModal.alert('Department name can only contain letters, numbers, spaces and hyphens.');
return;
}
});
});
</script>

View File

@@ -0,0 +1,126 @@
<!-- Header section -->
<div class="container">
<div class="d-flex justify-content-between align-items-center mt-4 mb-4">
<div>
<h1 class="h3 mb-0" style="color: var(--primary-dark);">Department Management</h1>
<p class="text-muted mb-0">Manage all departments in the system</p>
</div>
<div>
<a href="/admin/department/create" class="btn btn-primary">
<i class="fas fa-plus-circle me-1"></i>Create New Department
</a>
</div>
</div>
<div class="row">
<div class="col-12">
<div class="card border-0 shadow-sm">
<div class="card-body p-4">
<% if (departments && departments.length > 0) { %>
<div class="table-responsive">
<table class="table table-hover align-middle">
<thead>
<tr>
<th scope="col" style="width: 50px">#</th>
<th scope="col">Department Name</th>
<th scope="col">Slug</th>
<th scope="col" style="width: 200px">Actions</th>
</tr>
</thead>
<tbody>
<% departments.forEach((department, index) => { %>
<tr>
<td><%= index + 1 %></td>
<td>
<span class="fw-medium"><%= department.name %></span>
</td>
<td>
<code class="text-muted"><%= department.slug %></code>
</td>
<td>
<div class="btn-group" role="group">
<a href="/admin/department/edit/<%= department._id %>" class="btn btn-sm btn-outline-primary">
<i class="fas fa-edit me-1"></i>Edit
</a>
<button type="button" class="btn btn-sm btn-outline-danger"
data-custom-modal="open"
data-id="<%= department._id %>"
data-name="<%= department.name %>">
<i class="fas fa-trash-alt me-1"></i>Delete
</button>
</div>
</td>
</tr>
<% }); %>
</tbody>
</table>
</div>
<% } else { %>
<div class="text-center py-5">
<i class="fas fa-folder-open text-muted mb-3" style="font-size: 3rem;"></i>
<h5 class="text-muted mb-3">No Departments Found</h5>
<a href="/admin/department/create" class="btn btn-primary">
<i class="fas fa-plus-circle me-1"></i>Create First Department
</a>
</div>
<% } %>
</div>
</div>
</div>
</div>
</div>
<!-- Custom Modal -->
<div id="customModal" class="custom-modal">
<div class="custom-modal-content">
<div class="custom-modal-header">
<h5 class="custom-modal-title">Delete Confirmation</h5>
<button type="button" class="custom-modal-close">&times;</button>
</div>
<div class="custom-modal-body">
<p id="modalMessage">Are you sure you want to delete this department?</p>
</div>
<div class="custom-modal-footer">
<button type="button" class="btn btn-secondary custom-modal-cancel">Cancel</button>
<button type="button" class="btn btn-danger custom-modal-ok">Delete Permanently</button>
</div>
</div>
</div>
<!-- Import custom modal CSS -->
<link rel="stylesheet" href="/css/custom-modal.css">
<script>
document.addEventListener('DOMContentLoaded', function() {
// Khởi tạo modal tùy chỉnh
CustomModal.init('customModal', {
closeOnOutsideClick: true,
animationDuration: 300
});
// Lắng nghe click vào nút xóa
document.addEventListener('click', function(e) {
if (e.target.getAttribute('data-custom-modal') === 'open' ||
e.target.parentElement.getAttribute('data-custom-modal') === 'open') {
// Lấy button hoặc icon parent nếu click vào icon
const button = e.target.getAttribute('data-custom-modal') === 'open' ?
e.target : e.target.parentElement;
const id = button.getAttribute('data-id');
const name = button.getAttribute('data-name');
// Sử dụng CustomModal.confirm thay vì xử lý trực tiếp
CustomModal.confirm(
`Are you sure you want to delete department "${name}"? This action cannot be undone.`,
function() {
// Hành động khi xác nhận
window.location.href = `/admin/department/delete/${id}`;
},
null,
'Delete Confirmation'
);
}
});
});
</script>