Spaces:
Running
Running
Add 2 files
Browse files- index.html +920 -537
- prompts.txt +4 -7
index.html
CHANGED
|
@@ -66,7 +66,6 @@
|
|
| 66 |
transform: scale(0.9);
|
| 67 |
pointer-events: none;
|
| 68 |
}
|
| 69 |
-
/* New style for hover effect on table rows */
|
| 70 |
.employee-row {
|
| 71 |
transition: background-color 0.2s ease;
|
| 72 |
}
|
|
@@ -74,6 +73,27 @@
|
|
| 74 |
background-color: #f8fafc;
|
| 75 |
cursor: pointer;
|
| 76 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 77 |
</style>
|
| 78 |
</head>
|
| 79 |
<body class="bg-gray-100">
|
|
@@ -123,6 +143,7 @@
|
|
| 123 |
</div>
|
| 124 |
<div class="ml-3 nav-text">
|
| 125 |
<div class="text-sm font-medium">Admin User</div>
|
|
|
|
| 126 |
</div>
|
| 127 |
</div>
|
| 128 |
</div>
|
|
@@ -138,6 +159,22 @@
|
|
| 138 |
<i class="fas fa-plus mr-2"></i>
|
| 139 |
<span>Add Employee</span>
|
| 140 |
</button>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 141 |
<button id="clearAllBtn" class="bg-red-600 hover:bg-red-700 text-white px-4 py-2 rounded-lg flex items-center">
|
| 142 |
<i class="fas fa-trash-alt mr-2"></i>
|
| 143 |
<span>Clear All</span>
|
|
@@ -160,152 +197,135 @@
|
|
| 160 |
|
| 161 |
<!-- Employee Modal -->
|
| 162 |
<div id="employeeModal" class="fixed inset-0 bg-gray-600 bg-opacity-50 flex items-center justify-center z-50 hidden">
|
| 163 |
-
<div class="bg-white rounded-lg shadow-xl w-full max-w-4xl">
|
| 164 |
<div class="flex justify-between items-center border-b px-6 py-4">
|
| 165 |
-
<h3 class="text-
|
| 166 |
<button id="closeModal" class="text-gray-500 hover:text-gray-700">
|
| 167 |
<i class="fas fa-times"></i>
|
| 168 |
</button>
|
| 169 |
</div>
|
| 170 |
-
<
|
|
|
|
|
|
|
| 171 |
<div class="flex border-b mb-4">
|
| 172 |
-
<button class="tab-button px-4 py-2 font-medium
|
| 173 |
-
<button class="tab-button px-4 py-2 font-medium
|
|
|
|
| 174 |
</div>
|
| 175 |
|
| 176 |
-
<
|
| 177 |
-
<
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
<div class="grid grid-cols-1 md:grid-cols-2 gap-4 mb-4">
|
| 182 |
-
<div>
|
| 183 |
-
<label for="employeeIdInput" class="block text-sm font-medium text-gray-700 mb-1">Employee ID</label>
|
| 184 |
-
<input type="text" id="employeeIdInput" class="w-full border rounded-lg px-3 py-2 focus:outline-none focus:ring-2 focus:ring-blue-500" required>
|
| 185 |
-
</div>
|
| 186 |
-
<div>
|
| 187 |
-
<label for="firstName" class="block text-sm font-medium text-gray-700 mb-1">First Name</label>
|
| 188 |
-
<input type="text" id="firstName" class="w-full border rounded-lg px-3 py-2 focus:outline-none focus:ring-2 focus:ring-blue-500" required>
|
| 189 |
-
</div>
|
| 190 |
</div>
|
| 191 |
-
<div
|
| 192 |
-
<
|
| 193 |
-
|
| 194 |
-
<input type="text" id="lastName", class="w-full border rounded-lg px-3 py-2 focus:outline-none focus:ring-2 focus:ring-blue-500" required>
|
| 195 |
-
</div>
|
| 196 |
-
<div>
|
| 197 |
-
<label for="email" class="table text-sm font-medium text-gray-700 mb-1">Email</label>
|
| 198 |
-
<input type="email" id="email" class="w-full border rounded-lg px-3 py-2 focus:outline-none focus:ring-2 focus:ring-blue-500">
|
| 199 |
-
</div>
|
| 200 |
</div>
|
| 201 |
-
<div
|
| 202 |
-
<
|
| 203 |
-
|
| 204 |
-
<input type="tel" id="phone" class="w-full border rounded-lg px-3 py-2 focus:outline-none focus:ring-2 focus:ring-blue-500">
|
| 205 |
-
</div>
|
| 206 |
-
<div>
|
| 207 |
-
<label for="birthDate" class="block text-sm font-medium text-gray-700 mb-1">Birth Date</label>
|
| 208 |
-
<input type="date" id="birthDate" class="w-full border rounded-lg px-3 py-2 focus:outline-none focus:ring-2 focus:ring-blue-500">
|
| 209 |
-
</div>
|
| 210 |
</div>
|
| 211 |
-
<div
|
| 212 |
-
<
|
| 213 |
-
|
| 214 |
-
<select id="civilStatus", class="w-full border rounded-lg px-3 py-2 focus:outline-none focus:ring-2 focus:ring-blue-500">
|
| 215 |
-
<option value="">Select Civil Status</option>
|
| 216 |
-
<option value="Single">Single</option>
|
| 217 |
-
<option value="Married">Married</option>
|
| 218 |
-
<option value="Widowed">Widowed</option>
|
| 219 |
-
<option value="Separated">Separated</option>
|
| 220 |
-
<option value="Divorced">Divorced</option>
|
| 221 |
-
</select>
|
| 222 |
-
</div>
|
| 223 |
-
<div class="relative">
|
| 224 |
-
<label for="departmentInput" class="block text-sm font-medium text-gray-700 mb-1">Department</label>
|
| 225 |
-
<input type="text" id="departmentInput" class="w-full border rounded-lg px-3 py-2 focus:outline-none focus:ring-2 focus:ring-blue-500" placeholder="Type or select department">
|
| 226 |
-
<ul id="departmentSuggestions", class="absolute z-10 mt-1 bg-white border rounded-lg shadow w-full max-h-40 overflow-y-auto hidden custom-scrollbar"></ul>
|
| 227 |
-
</div>
|
| 228 |
</div>
|
| 229 |
-
<div
|
| 230 |
-
<
|
| 231 |
-
|
| 232 |
-
<input type="text" id="position" class="w-full border rounded-lg px-3 py-2 focus:outline-none focus:ring-2 focus:ring-blue-500">
|
| 233 |
-
</div>
|
| 234 |
-
<div>
|
| 235 |
-
<label for="hireDate" class="block text-sm font-medium text-gray-700 mb-1">Hire Date</label>
|
| 236 |
-
<input type="date", id="hireDate" class="w-full border rounded-lg px-3 py-2 focus:outline-none focus:ring-2 focus:ring-blue-500">
|
| 237 |
-
</div>
|
| 238 |
</div>
|
| 239 |
-
<div
|
| 240 |
-
<
|
| 241 |
-
|
| 242 |
-
|
| 243 |
-
|
| 244 |
-
<
|
| 245 |
-
|
| 246 |
-
<
|
| 247 |
-
|
| 248 |
-
|
| 249 |
-
|
| 250 |
-
</
|
| 251 |
-
</
|
| 252 |
</div>
|
| 253 |
</div>
|
| 254 |
-
|
| 255 |
-
|
| 256 |
-
|
| 257 |
-
|
| 258 |
-
|
| 259 |
-
|
| 260 |
-
|
| 261 |
-
</div>
|
| 262 |
-
<div>
|
| 263 |
-
<label for="philhealthNumber" class="block text-sm font-medium text-gray-700 mb-1">PhilHealth Number</label>
|
| 264 |
-
<input type="text" id="philhealthNumber", class="w-full border rounded-lg px-3 py-2 focus:outline-none focus:ring-2 focus:ring-blue-500" placeholder="XX-XXXXXXXXX-X">
|
| 265 |
-
</div>
|
| 266 |
</div>
|
| 267 |
-
<div
|
| 268 |
-
<
|
| 269 |
-
|
| 270 |
-
<input type="text" id="pagibigNumber", class="w-full border rounded-lg px-3 py-2 focus:outline-none focus:ring-2 focus:ring-blue-500" placeholder="XXXX-XXXX-XXXX">
|
| 271 |
-
</div>
|
| 272 |
-
<div>
|
| 273 |
-
<label for="tinNumber" class="block text-sm font-medium text-gray-700 mb-1">TIN Number</label>
|
| 274 |
-
<input type="text" id="tinNumber", class="w-full border rounded-lg px-3 py-2 focus:outline-none focus:ring-2 focus:ring-blue-500" placeholder="XXX-XXX-XXX-XXX">
|
| 275 |
-
</div>
|
| 276 |
</div>
|
| 277 |
-
<div
|
| 278 |
-
<
|
| 279 |
-
|
| 280 |
-
<input type="text" id="passportNumber", class="w-full border rounded-lg px-3 py-2 focus:outline-none focus:ring-2 focus:ring-blue-500" placeholder="XX1234567">
|
| 281 |
-
</div>
|
| 282 |
-
<div>
|
| 283 |
-
<label for="passportExpiry" class="block text-sm font-medium text-gray-700 mb-1">Passport Expiry</label>
|
| 284 |
-
<input type="date" id="passportExpiry", class="w-full border rounded-lg px-3 py-2 focus:outline-none focus:ring-2 focus:ring-blue-500">
|
| 285 |
-
</div>
|
| 286 |
</div>
|
| 287 |
-
<div
|
| 288 |
-
<
|
| 289 |
-
|
| 290 |
-
|
| 291 |
-
|
| 292 |
-
<
|
| 293 |
-
|
| 294 |
-
|
| 295 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 296 |
</div>
|
| 297 |
</div>
|
| 298 |
-
|
| 299 |
-
|
| 300 |
-
|
| 301 |
-
|
| 302 |
-
<
|
| 303 |
-
|
| 304 |
-
|
| 305 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 306 |
</div>
|
| 307 |
-
</
|
| 308 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 309 |
</div>
|
| 310 |
</div>
|
| 311 |
|
|
@@ -313,58 +333,93 @@
|
|
| 313 |
<div id="importConfirmationModal" class="fixed inset-0 bg-gray-600 bg-opacity-50 flex items-center justify-center z-50 confirmation-modal hidden">
|
| 314 |
<div class="bg-white rounded-lg shadow-xl w-full max-w-md">
|
| 315 |
<div class="flex justify-between items-center border-b px-6 py-4">
|
| 316 |
-
<h3 class="text-lg font-semibold">Import
|
| 317 |
<button id="closeImportConfirmationModal" class="text-gray-500 hover:text-gray-700">
|
| 318 |
<i class="fas fa-times"></i>
|
| 319 |
</button>
|
| 320 |
</div>
|
| 321 |
<div class="p-6">
|
| 322 |
-
<p class="mb-
|
| 323 |
-
|
| 324 |
-
|
| 325 |
-
|
| 326 |
-
<
|
| 327 |
-
|
| 328 |
-
|
| 329 |
-
|
| 330 |
-
|
| 331 |
-
|
| 332 |
-
<
|
| 333 |
-
|
| 334 |
-
|
| 335 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 336 |
</div>
|
| 337 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 338 |
</div>
|
| 339 |
</div>
|
| 340 |
|
| 341 |
<!-- Clear All Confirmation Modal -->
|
| 342 |
-
<div id="clearAllConfirmationModal"
|
| 343 |
<div class="bg-white rounded-lg shadow-xl w-full max-w-md">
|
| 344 |
<div class="flex justify-between items-center border-b px-6 py-4">
|
| 345 |
-
<h3 class="text-lg font-semibold">Confirm Clear All</h3>
|
| 346 |
<button id="closeClearAllConfirmationModal" class="text-gray-500 hover:text-gray-700">
|
| 347 |
<i class="fas fa-times"></i>
|
| 348 |
</button>
|
| 349 |
</div>
|
| 350 |
<div class="p-6">
|
| 351 |
-
<
|
| 352 |
-
|
| 353 |
-
|
| 354 |
-
|
| 355 |
-
<
|
| 356 |
-
|
| 357 |
-
|
| 358 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 359 |
</div>
|
| 360 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 361 |
</div>
|
| 362 |
</div>
|
| 363 |
|
| 364 |
<!-- Employee List -->
|
| 365 |
<div class="bg-white p-6 rounded-xl shadow-sm border border-gray-200 mb-6">
|
| 366 |
<div class="flex justify-between items-center mb-4">
|
| 367 |
-
<
|
|
|
|
|
|
|
|
|
|
| 368 |
<div class="flex items-center space-x-2">
|
| 369 |
<select id="departmentFilter" class="border rounded-lg px-3 py-1 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500">
|
| 370 |
<option value="">All Departments</option>
|
|
@@ -380,15 +435,8 @@
|
|
| 380 |
<div class="overflow-x-auto">
|
| 381 |
<table class="min-w-full divide-y divide-gray-200">
|
| 382 |
<thead class="bg-gray-50">
|
| 383 |
-
<tr>
|
| 384 |
-
<
|
| 385 |
-
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Name</th>
|
| 386 |
-
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Department</th>
|
| 387 |
-
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Position</th>
|
| 388 |
-
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">SSS</th>
|
| 389 |
-
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">PhilHealth</th>
|
| 390 |
-
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Status</th>
|
| 391 |
-
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Actions</th>
|
| 392 |
</tr>
|
| 393 |
</thead>
|
| 394 |
<tbody class="bg-white divide-y divide-gray-200" id="employeeTableBody">
|
|
@@ -400,11 +448,11 @@
|
|
| 400 |
<div class="text-sm text-gray-500">
|
| 401 |
Showing <span id="startEmployee">1</span> to <span id="endEmployee">10</span> of <span id="totalEmployees">0</span> employees
|
| 402 |
</div>
|
| 403 |
-
<div class="flex space-x
|
| 404 |
<button id="prevEmployeePage" class="px-3 py-1 border rounded-lg text-sm hover:bg-gray-50 disabled:opacity-50" disabled>
|
| 405 |
Previous
|
| 406 |
</button>
|
| 407 |
-
<button id="nextEmployeePage"
|
| 408 |
Next
|
| 409 |
</button>
|
| 410 |
</div>
|
|
@@ -414,13 +462,163 @@
|
|
| 414 |
</div>
|
| 415 |
|
| 416 |
<script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 417 |
// Storage keys
|
| 418 |
const STORAGE_KEY = 'steelcraft_payroll_employees';
|
| 419 |
const DEPARTMENTS_KEY = 'steelcraft_payroll_departments';
|
|
|
|
| 420 |
|
| 421 |
// Employee data - initially load from localStorage
|
| 422 |
let employees = loadEmployees();
|
| 423 |
let allDepartments = loadDepartments();
|
|
|
|
| 424 |
|
| 425 |
// If no data in localStorage, initialize with default values
|
| 426 |
if (employees.length === 0) {
|
|
@@ -437,7 +635,12 @@
|
|
| 437 |
hireDate: "2020-05-15",
|
| 438 |
birthDate: "1985-03-12",
|
| 439 |
salary: 25000,
|
| 440 |
-
status: "Active"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 441 |
}
|
| 442 |
];
|
| 443 |
saveEmployees();
|
|
@@ -459,6 +662,7 @@
|
|
| 459 |
|
| 460 |
// DOM elements
|
| 461 |
const employeeTableBody = document.getElementById('employeeTableBody');
|
|
|
|
| 462 |
const departmentInput = document.getElementById('departmentInput');
|
| 463 |
const departmentSuggestions = document.getElementById('departmentSuggestions');
|
| 464 |
const departmentFilter = document.getElementById('departmentFilter');
|
|
@@ -483,6 +687,10 @@
|
|
| 483 |
const totalEmployees = document.getElementById('totalEmployees');
|
| 484 |
const tabButtons = document.querySelectorAll('.tab-button');
|
| 485 |
const tabContents = document.querySelectorAll('.tab-content');
|
|
|
|
|
|
|
|
|
|
|
|
|
| 486 |
|
| 487 |
// Import confirmation modal elements
|
| 488 |
const importConfirmationModal = document.getElementById('importConfirmationModal');
|
|
@@ -490,6 +698,7 @@
|
|
| 490 |
const appendDataBtn = document.getElementById('appendDataBtn');
|
| 491 |
const mergeDataBtn = document.getElementById('mergeDataBtn');
|
| 492 |
const replaceDataBtn = document.getElementById('replaceDataBtn');
|
|
|
|
| 493 |
|
| 494 |
// Clear all confirmation modal elements
|
| 495 |
const clearAllConfirmationModal = document.getElementById('clearAllConfirmationModal');
|
|
@@ -497,7 +706,172 @@
|
|
| 497 |
const cancelClearAll = document.getElementById('cancelClearAll');
|
| 498 |
const confirmClearAll = document.getElementById('confirmClearAll');
|
| 499 |
|
| 500 |
-
//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 501 |
function saveEmployees() {
|
| 502 |
localStorage.setItem(STORAGE_KEY, JSON.stringify(employees));
|
| 503 |
}
|
|
@@ -519,6 +893,7 @@
|
|
| 519 |
// Initialize
|
| 520 |
document.addEventListener('DOMContentLoaded', () => {
|
| 521 |
updateDepartmentFilterOptions();
|
|
|
|
| 522 |
renderEmployeeTable();
|
| 523 |
setupEventListeners();
|
| 524 |
setupTabs();
|
|
@@ -546,8 +921,10 @@
|
|
| 546 |
|
| 547 |
function extractDepartmentsFromEmployees() {
|
| 548 |
const departmentsSet = new Set();
|
| 549 |
-
employees.forEach(emp =>
|
| 550 |
-
|
|
|
|
|
|
|
| 551 |
}
|
| 552 |
|
| 553 |
function updateDepartmentFilterOptions() {
|
|
@@ -562,7 +939,6 @@
|
|
| 562 |
|
| 563 |
function setupEventListeners() {
|
| 564 |
addEmployeeBtn.addEventListener('click', () => openEmployeeModal());
|
| 565 |
-
|
| 566 |
clearAllBtn.addEventListener('click', () => openClearAllConfirmationModal());
|
| 567 |
exportCSVBtn.addEventListener('click', exportToCSV);
|
| 568 |
importCSVBtn.addEventListener('click', () => fileInput.click());
|
|
@@ -584,14 +960,17 @@
|
|
| 584 |
}
|
| 585 |
});
|
| 586 |
nextEmployeePage.addEventListener('click', () => {
|
| 587 |
-
|
|
|
|
| 588 |
currentPage++;
|
| 589 |
renderEmployeeTable();
|
| 590 |
}
|
| 591 |
});
|
|
|
|
| 592 |
|
| 593 |
// Import confirmation modal events
|
| 594 |
closeImportConfirmationModal.addEventListener('click', () => importConfirmationModal.classList.add('hidden'));
|
|
|
|
| 595 |
appendDataBtn.addEventListener('click', () => processImport('append'));
|
| 596 |
mergeDataBtn.addEventListener('click', () => processImport('merge'));
|
| 597 |
replaceDataBtn.addEventListener('click', () => processImport('replace'));
|
|
@@ -600,6 +979,19 @@
|
|
| 600 |
closeClearAllConfirmationModal.addEventListener('click', () => clearAllConfirmationModal.classList.add('hidden'));
|
| 601 |
cancelClearAll.addEventListener('click', () => clearAllConfirmationModal.classList.add('hidden'));
|
| 602 |
confirmClearAll.addEventListener('click', clearAllEmployees);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 603 |
}
|
| 604 |
|
| 605 |
function handleDepartmentInput(e) {
|
|
@@ -651,7 +1043,10 @@
|
|
| 651 |
|
| 652 |
filteredEmployees = employees.filter(emp => {
|
| 653 |
const fullName = `${emp.firstName} ${emp.lastName}`.toLowerCase();
|
| 654 |
-
const matchesSearch = fullName.includes(searchTerm) ||
|
|
|
|
|
|
|
|
|
|
| 655 |
const matchesDepartment = department ? emp.department === department : true;
|
| 656 |
const matchesStatus = status ? emp.status === status : true;
|
| 657 |
|
|
@@ -667,12 +1062,16 @@
|
|
| 667 |
const end = start + rowsPerPage;
|
| 668 |
const paginatedEmployees = filteredEmployees.slice(start, end);
|
| 669 |
|
|
|
|
|
|
|
|
|
|
| 670 |
employeeTableBody.innerHTML = '';
|
| 671 |
|
| 672 |
if (paginatedEmployees.length === 0) {
|
|
|
|
| 673 |
employeeTableBody.innerHTML = `
|
| 674 |
<tr>
|
| 675 |
-
<td colspan="
|
| 676 |
</tr>
|
| 677 |
`;
|
| 678 |
} else {
|
|
@@ -680,33 +1079,7 @@
|
|
| 680 |
const row = document.createElement('tr');
|
| 681 |
row.className = 'employee-row';
|
| 682 |
row.dataset.id = emp.id;
|
| 683 |
-
row.innerHTML =
|
| 684 |
-
<td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900">${emp.employeeId}</td>
|
| 685 |
-
<td class="px=6 py-4 whitespace-nowrap">
|
| 686 |
-
<div class="flex items-center">
|
| 687 |
-
<div class="flex-shrink-0 h-10 w-10 rounded-full bg-blue-100 flex items-center justify-center">
|
| 688 |
-
<i class="fas fa-user text-blue-600"></i>
|
| 689 |
-
</div>
|
| 690 |
-
<div class="ml-4">
|
| 691 |
-
<div class="text-sm font-medium text-gray-900">${emp.firstName} ${emp.lastName}</div>
|
| 692 |
-
<div class="text-sm text-gray-500">${emp.email || 'No email'}</div>
|
| 693 |
-
</div>
|
| 694 |
-
</div>
|
| 695 |
-
</td>
|
| 696 |
-
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">${emp.department}</td>
|
| 697 |
-
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">${emp.position}</td>
|
| 698 |
-
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">${emp.sssNumber || 'N/A'}</td>
|
| 699 |
-
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">${emp.philhealthNumber || 'N/A'}</td>
|
| 700 |
-
<td class="px-6 py-4 whitespace-nowrap">
|
| 701 |
-
<span class="px-2 inline-flex text-xs leading-5 font-semibell rounded-full ${getStatusClass(emp.status)}">
|
| 702 |
-
${emp.status}
|
| 703 |
-
</span>
|
| 704 |
-
</td>
|
| 705 |
-
<td class="px-6 py-4 whitespace-nowrap text-sm font-medium">
|
| 706 |
-
<button class="text-blue-600 hover:text-blue-900 mr-3 edit-btn" data-id="${emp.id}">Edit</button>
|
| 707 |
-
<button class="text-red-600 hover:text-red-900 delete-btn" data-id="${emp.id}">Delete</button>
|
| 708 |
-
</td>
|
| 709 |
-
`;
|
| 710 |
employeeTableBody.appendChild(row);
|
| 711 |
|
| 712 |
// Add double click listener to the row
|
|
@@ -735,11 +1108,15 @@
|
|
| 735 |
});
|
| 736 |
}
|
| 737 |
|
| 738 |
-
|
| 739 |
-
|
| 740 |
-
|
| 741 |
-
|
| 742 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 743 |
}
|
| 744 |
|
| 745 |
function deleteEmployee(id) {
|
|
@@ -759,11 +1136,8 @@
|
|
| 759 |
}
|
| 760 |
|
| 761 |
function openEmployeeModal(id = null) {
|
| 762 |
-
console.log('Opening modal for employee ID:', id);
|
| 763 |
-
|
| 764 |
if (id) {
|
| 765 |
const employee = employees.find(e => e.id === id);
|
| 766 |
-
console.log('Found employee:', employee);
|
| 767 |
|
| 768 |
if (employee) {
|
| 769 |
modalTitle.textContent = 'Edit Employee';
|
|
@@ -774,12 +1148,12 @@
|
|
| 774 |
document.getElementById('email').value = employee.email || '';
|
| 775 |
document.getElementById('phone').value = employee.phone || '';
|
| 776 |
document.getElementById('birthDate').value = employee.birthDate || '';
|
| 777 |
-
document.getElementById('civilStatus').value = employee.civilStatus || '';
|
| 778 |
-
departmentInput.value = employee.department;
|
| 779 |
-
document.getElementById('position').value = employee.position;
|
| 780 |
-
document.getElementById('hireDate').value = employee.hireDate;
|
| 781 |
-
document.getElementById('salary').value = employee.salary;
|
| 782 |
-
document.getElementById('status').value = employee.status;
|
| 783 |
|
| 784 |
// Philippine Government data
|
| 785 |
document.getElementById('sssNumber').value = employee.sssNumber || '';
|
|
@@ -797,12 +1171,22 @@
|
|
| 797 |
employeeIdInput.value = '';
|
| 798 |
employeeIdDisplayInput.value = '';
|
| 799 |
departmentInput.value = '';
|
|
|
|
|
|
|
| 800 |
|
| 801 |
// Generate new employee ID for new employees
|
| 802 |
const newId = employees.length > 0 ? Math.max(...employees.map(e => e.id)) + 1 : 1;
|
| 803 |
employeeIdDisplayInput.value = `EMP-${1000 + newId}`;
|
| 804 |
}
|
| 805 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 806 |
employeeModal.classList.remove('hidden');
|
| 807 |
}
|
| 808 |
|
|
@@ -813,27 +1197,27 @@
|
|
| 813 |
function saveEmployee() {
|
| 814 |
const id = employeeIdInput.value ? parseInt(employeeIdInput.value) : null;
|
| 815 |
const employeeId = employeeIdDisplayInput.value.trim();
|
| 816 |
-
const firstName = document.getElementById('firstName').value;
|
| 817 |
-
const lastName = document.getElementById('lastName').value;
|
| 818 |
-
const email = document.getElementById('email').value || null;
|
| 819 |
-
const phone = document.getElementById('phone').value || null;
|
| 820 |
const birthDate = document.getElementById('birthDate').value || null;
|
| 821 |
const civilStatus = document.getElementById('civilStatus').value || null;
|
| 822 |
const department = departmentInput.value.trim();
|
| 823 |
-
const position = document.getElementById('position').value || null;
|
| 824 |
const hireDate = document.getElementById('hireDate').value || null;
|
| 825 |
const salary = document.getElementById('salary').value ? parseFloat(document.getElementById('salary').value) : 0;
|
| 826 |
const status = document.getElementById('status').value || 'Active';
|
| 827 |
|
| 828 |
// Philippine Government data
|
| 829 |
-
const sssNumber = document.getElementById('sssNumber').value || null;
|
| 830 |
-
const philhealthNumber = document.getElementById('philhealthNumber').value || null;
|
| 831 |
-
const pagibigNumber = document.getElementById('pagibigNumber').value || null;
|
| 832 |
-
const tinNumber = document.getElementById('tinNumber').value || null;
|
| 833 |
-
const passportNumber = document.getElementById('passportNumber').value || null;
|
| 834 |
const passportExpiry = document.getElementById('passportExpiry').value || null;
|
| 835 |
-
const nationalId = document.getElementById('nationalId').value || null;
|
| 836 |
-
const driversLicense = document.getElementById('driversLicense').value || null;
|
| 837 |
|
| 838 |
if (!employeeId || !firstName || !lastName) {
|
| 839 |
alert("Employee ID, first name and last name are required.");
|
|
@@ -844,7 +1228,7 @@
|
|
| 844 |
// Editing existing employee
|
| 845 |
const index = employees.findIndex(e => e.id === id);
|
| 846 |
employees[index] = {
|
| 847 |
-
|
| 848 |
employeeId,
|
| 849 |
firstName,
|
| 850 |
lastName,
|
|
@@ -894,353 +1278,352 @@
|
|
| 894 |
driversLicense
|
| 895 |
});
|
| 896 |
|
| 897 |
-
if (!allDepartments.includes(department)) {
|
| 898 |
-
|
| 899 |
-
|
| 900 |
-
|
|
|
|
| 901 |
}
|
| 902 |
-
}
|
| 903 |
-
|
| 904 |
-
// Save to localStorage
|
| 905 |
-
saveEmployees();
|
| 906 |
-
closeEmployeeModal();
|
| 907 |
-
extractDepartmentsFromEmployees();
|
| 908 |
-
updateDepartmentFilterOptions();
|
| 909 |
-
filterEmployees();
|
| 910 |
-
}
|
| 911 |
|
| 912 |
-
|
| 913 |
-
|
| 914 |
-
|
| 915 |
-
|
| 916 |
-
|
| 917 |
-
|
| 918 |
}
|
| 919 |
-
}
|
| 920 |
|
| 921 |
-
|
| 922 |
-
|
| 923 |
-
|
| 924 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 925 |
|
| 926 |
-
|
| 927 |
-
|
| 928 |
-
|
| 929 |
-
|
| 930 |
-
|
| 931 |
-
...employees.map(emp => [
|
| 932 |
-
`"${emp.id}"`,
|
| 933 |
-
`"${emp.employeeId}"`,
|
| 934 |
-
`"${emp.firstName}"`,
|
| 935 |
-
`"${emp.lastName}"`,
|
| 936 |
-
`"${emp.email || ''}"`,
|
| 937 |
-
`"${emp.phone || ''}"`,
|
| 938 |
-
`"${emp.birthDate || ''}"`,
|
| 939 |
-
`"${emp.civilStatus || ''}"`,
|
| 940 |
-
`"${emp.department}"`,
|
| 941 |
-
`"${emp.position || ''}"`,
|
| 942 |
-
`"${emp.hireDate || ''}"`,
|
| 943 |
-
emp.salary,
|
| 944 |
-
`"${emp.status}"`,
|
| 945 |
-
`"${emp.sssNumber || ''}"`,
|
| 946 |
-
`"${emp.philhealthNumber || ''}"`,
|
| 947 |
-
`"${emp.pagibigNumber || ''}"`,
|
| 948 |
-
`"${emp.tinNumber || ''}"`,
|
| 949 |
-
`"${emp.passportNumber || ''}"`,
|
| 950 |
-
`"${emp.passportExpiry || ''}"`,
|
| 951 |
-
`"${emp.nationalId || ''}"`,
|
| 952 |
-
`"${emp.driversLicense || ''}"`
|
| 953 |
-
].join(','))
|
| 954 |
-
].join('\n');
|
| 955 |
-
|
| 956 |
-
// Create download link
|
| 957 |
-
const blob = new Blob([csvContent], { type: 'text/csv;charset=utf-8;' });
|
| 958 |
-
const url = URL.createObjectURL(blob);
|
| 959 |
-
const link = document.createElement('a');
|
| 960 |
-
link.setAttribute('href', url);
|
| 961 |
-
link.setAttribute('download', `steelcraft_employees_${new Date().toISOString().slice(0, 10)}.csv`);
|
| 962 |
-
link.style.visibility = 'hidden';
|
| 963 |
-
document.body.appendChild(link);
|
| 964 |
-
link.click();
|
| 965 |
-
document.body.removeChild(link);
|
| 966 |
-
}
|
| 967 |
|
| 968 |
-
|
| 969 |
-
|
| 970 |
-
|
| 971 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 972 |
|
| 973 |
-
|
| 974 |
-
|
| 975 |
-
|
| 976 |
-
importConfirmationModal.classList.remove('hidden');
|
| 977 |
-
};
|
| 978 |
-
reader.readAsText(file);
|
| 979 |
-
}
|
| 980 |
|
| 981 |
-
|
| 982 |
-
|
| 983 |
-
|
| 984 |
-
|
| 985 |
-
|
|
|
|
| 986 |
}
|
| 987 |
-
|
| 988 |
-
// Improved CSV parsing
|
| 989 |
-
const lines = importFileContent.split(/\r?\n/).filter(line => line.trim() !== '');
|
| 990 |
-
|
| 991 |
-
if (lines.length < 2) {
|
| 992 |
-
alert("CSV file must contain at least one header row and one data row");
|
| 993 |
-
return;
|
| 994 |
-
}
|
| 995 |
-
|
| 996 |
-
// Parse headers and create mapping
|
| 997 |
-
const headers = parseCSVLine(lines[0]).map(h => h.trim());
|
| 998 |
-
const headerMap = createHeaderMap();
|
| 999 |
-
|
| 1000 |
-
// Skip header row and process data
|
| 1001 |
-
const importedEmployees = [];
|
| 1002 |
-
for (let i = 1; i < lines.length; i++) {
|
| 1003 |
-
if (!lines[i].trim()) continue;
|
| 1004 |
-
|
| 1005 |
-
try {
|
| 1006 |
-
const values = parseCSVLine(lines[i]);
|
| 1007 |
-
if (values.length !== headers.length) {
|
| 1008 |
-
console.warn(`Skipping line ${i+1}: number of values doesn't match headers`);
|
| 1009 |
-
continue;
|
| 1010 |
-
}
|
| 1011 |
-
|
| 1012 |
-
const employee = mapValuesToEmployee(values, headers, headerMap);
|
| 1013 |
-
if (!employee.firstName || !employee.lastName) {
|
| 1014 |
-
console.warn(`Skipping line ${i+1}: missing required fields (firstName or lastName)`);
|
| 1015 |
-
continue;
|
| 1016 |
-
}
|
| 1017 |
|
| 1018 |
-
|
| 1019 |
-
|
| 1020 |
-
|
| 1021 |
-
|
| 1022 |
-
}
|
| 1023 |
-
|
| 1024 |
-
importedEmployees.push(employee);
|
| 1025 |
-
} catch (error) {
|
| 1026 |
-
console.error(`Error processing line ${i+1}:`, error);
|
| 1027 |
}
|
| 1028 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1029 |
|
| 1030 |
-
|
| 1031 |
-
|
| 1032 |
-
let updated = 0;
|
| 1033 |
-
|
| 1034 |
-
switch(mode) {
|
| 1035 |
-
case 'append':
|
| 1036 |
-
// Add all imported employees as new records
|
| 1037 |
-
importedEmployees.forEach(importedEmp => {
|
| 1038 |
-
// Check if an employee with the same employeeId already exists
|
| 1039 |
-
const existingIndex = employees.findIndex(e => e.employeeId === importedEmp.employeeId);
|
| 1040 |
-
if (existingIndex >= 0) {
|
| 1041 |
-
// If it exists, generate a new unique employeeId
|
| 1042 |
const newId = employees.length > 0 ? Math.max(...employees.map(e => e.id)) + 1 : 1;
|
| 1043 |
-
|
| 1044 |
}
|
| 1045 |
|
| 1046 |
-
|
| 1047 |
-
|
| 1048 |
-
|
| 1049 |
-
|
| 1050 |
-
|
| 1051 |
-
|
| 1052 |
-
|
| 1053 |
-
|
| 1054 |
-
|
| 1055 |
-
|
| 1056 |
-
|
| 1057 |
-
|
| 1058 |
-
|
| 1059 |
-
|
| 1060 |
-
|
| 1061 |
-
|
| 1062 |
-
|
| 1063 |
-
|
| 1064 |
-
|
| 1065 |
-
|
| 1066 |
-
|
|
|
|
|
|
|
| 1067 |
importedEmp.id = employees.length > 0 ? Math.max(...employees.map(e => e.id)) + 1 : 1;
|
| 1068 |
employees.push(importedEmp);
|
| 1069 |
added++;
|
| 1070 |
-
}
|
| 1071 |
-
|
| 1072 |
-
|
| 1073 |
-
|
| 1074 |
-
|
| 1075 |
-
|
| 1076 |
-
|
| 1077 |
-
|
| 1078 |
-
|
| 1079 |
-
|
| 1080 |
-
|
| 1081 |
-
|
| 1082 |
-
|
| 1083 |
-
|
| 1084 |
-
|
| 1085 |
-
|
| 1086 |
-
|
| 1087 |
-
|
| 1088 |
-
|
| 1089 |
-
|
| 1090 |
-
|
| 1091 |
-
|
| 1092 |
-
|
| 1093 |
-
|
| 1094 |
-
|
| 1095 |
-
|
| 1096 |
-
|
| 1097 |
-
|
| 1098 |
-
|
| 1099 |
-
|
| 1100 |
-
|
| 1101 |
-
|
| 1102 |
-
|
| 1103 |
-
|
| 1104 |
-
|
| 1105 |
-
|
| 1106 |
-
|
| 1107 |
-
alert(message);
|
| 1108 |
-
}
|
| 1109 |
-
|
| 1110 |
-
// FIXED: Updated createHeaderMap to include the internal ID
|
| 1111 |
-
function createHeaderMap() {
|
| 1112 |
-
return {
|
| 1113 |
-
'ID': 'id',
|
| 1114 |
-
'Employee ID': 'employeeId',
|
| 1115 |
-
'First Name': 'firstName',
|
| 1116 |
-
'Last Name': 'lastName',
|
| 1117 |
-
'Email': 'email',
|
| 1118 |
-
'Phone': 'phone',
|
| 1119 |
-
'Birth Date': 'birthDate',
|
| 1120 |
-
'Civil Status': 'civilStatus',
|
| 1121 |
-
'Department': 'department',
|
| 1122 |
-
'Position': 'position',
|
| 1123 |
-
'Hire Date': 'hireDate',
|
| 1124 |
-
'Salary': 'salary',
|
| 1125 |
-
'Status': 'status',
|
| 1126 |
-
'SSS Number': 'sssNumber',
|
| 1127 |
-
'PhilHealth Number': 'philhealthNumber',
|
| 1128 |
-
'Pag-IBIG Number': 'pagibigNumber',
|
| 1129 |
-
'TIN Number': 'tinNumber',
|
| 1130 |
-
'Passport Number': 'passportNumber',
|
| 1131 |
-
'Passport Expiry': 'passportExpiry',
|
| 1132 |
-
'National ID': 'nationalId',
|
| 1133 |
-
'Driver\'s License': 'driversLicense',
|
| 1134 |
-
'EmployeeId': 'employeeId',
|
| 1135 |
-
'Firstname': 'firstName',
|
| 1136 |
-
'Lastname': 'lastName',
|
| 1137 |
-
'SSS': 'sssNumber',
|
| 1138 |
-
'Philhealth': 'philhealthNumber',
|
| 1139 |
-
'Pag-ibig': 'pagibigNumber',
|
| 1140 |
-
'TIN': 'tinNumber'
|
| 1141 |
-
};
|
| 1142 |
-
}
|
| 1143 |
-
|
| 1144 |
-
// FIXED: Updated mapValuesToEmployee function to handle the ID properly
|
| 1145 |
-
function mapValuesToEmployee(values, headers, headerMap) {
|
| 1146 |
-
const employee = {};
|
| 1147 |
-
|
| 1148 |
-
for (let j = 0; j < headers.length; j++) {
|
| 1149 |
-
const header = headers[j].trim();
|
| 1150 |
-
let value = values[j] || '';
|
| 1151 |
|
| 1152 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1153 |
|
| 1154 |
-
|
|
|
|
|
|
|
|
|
|
| 1155 |
|
| 1156 |
-
//
|
| 1157 |
-
|
| 1158 |
-
|
| 1159 |
-
|
| 1160 |
-
|
| 1161 |
-
|
| 1162 |
-
} else if (propName === 'hireDate' || propName === 'birthDate' || propName === 'passportExpiry') {
|
| 1163 |
-
// Date formatting
|
| 1164 |
-
if (/^\d{1,2}\/\d{1,2}\/\d{4}$/.test(value)) {
|
| 1165 |
-
const [month, day, year] = value.split('/');
|
| 1166 |
-
value = `${year}-${month.padStart(2, '0')}-${day.padStart(2, '0')}`;
|
| 1167 |
-
}
|
| 1168 |
-
const date = new Date(value);
|
| 1169 |
-
if (!isNaN(date.getTime())) {
|
| 1170 |
-
value = date.toISOString().split('T')[0];
|
| 1171 |
-
}
|
| 1172 |
}
|
| 1173 |
|
| 1174 |
-
|
| 1175 |
}
|
| 1176 |
|
| 1177 |
-
|
| 1178 |
-
|
| 1179 |
-
|
| 1180 |
-
|
| 1181 |
-
|
| 1182 |
-
|
| 1183 |
-
|
| 1184 |
-
|
| 1185 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1186 |
|
| 1187 |
-
|
| 1188 |
-
const
|
| 1189 |
|
| 1190 |
-
|
| 1191 |
-
|
| 1192 |
-
|
| 1193 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1194 |
}
|
| 1195 |
|
| 1196 |
-
|
| 1197 |
-
|
| 1198 |
-
continue;
|
| 1199 |
-
}
|
| 1200 |
|
| 1201 |
-
|
| 1202 |
-
|
| 1203 |
-
|
| 1204 |
-
|
|
|
|
| 1205 |
|
| 1206 |
-
|
| 1207 |
-
|
| 1208 |
-
current = '';
|
| 1209 |
-
continue;
|
| 1210 |
-
}
|
| 1211 |
|
| 1212 |
-
|
| 1213 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1214 |
|
| 1215 |
-
|
| 1216 |
-
|
|
|
|
|
|
|
|
|
|
| 1217 |
|
| 1218 |
-
|
| 1219 |
-
return values.map(val => {
|
| 1220 |
-
val = val.trim();
|
| 1221 |
-
if (val.startsWith('"') && val.endsWith('"')) {
|
| 1222 |
-
return val.slice(1, -1);
|
| 1223 |
}
|
| 1224 |
-
return val;
|
| 1225 |
-
});
|
| 1226 |
-
}
|
| 1227 |
|
| 1228 |
-
|
| 1229 |
-
|
| 1230 |
-
clearAllConfirmationModal.classList.remove('hidden');
|
| 1231 |
-
}
|
| 1232 |
|
| 1233 |
-
|
| 1234 |
-
|
| 1235 |
-
|
| 1236 |
-
|
| 1237 |
-
|
| 1238 |
-
|
| 1239 |
-
|
| 1240 |
-
|
| 1241 |
-
|
| 1242 |
-
|
| 1243 |
-
|
| 1244 |
-
|
| 1245 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1246 |
</html>
|
|
|
|
| 66 |
transform: scale(0.9);
|
| 67 |
pointer-events: none;
|
| 68 |
}
|
|
|
|
| 69 |
.employee-row {
|
| 70 |
transition: background-color 0.2s ease;
|
| 71 |
}
|
|
|
|
| 73 |
background-color: #f8fafc;
|
| 74 |
cursor: pointer;
|
| 75 |
}
|
| 76 |
+
.dropdown-content {
|
| 77 |
+
display: none;
|
| 78 |
+
position: absolute;
|
| 79 |
+
min-width: 200px;
|
| 80 |
+
background-color: white;
|
| 81 |
+
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
| 82 |
+
border-radius: 0.5rem;
|
| 83 |
+
z-index: 50;
|
| 84 |
+
max-height: 300px;
|
| 85 |
+
overflow-y: auto;
|
| 86 |
+
}
|
| 87 |
+
.dropdown:hover .dropdown-content {
|
| 88 |
+
display: block;
|
| 89 |
+
}
|
| 90 |
+
.col-employeeId { width: 120px; min-width: 120px; }
|
| 91 |
+
.col-name { width: 180px; min-width: 180px; }
|
| 92 |
+
.col-department { width: 140px; min-width: 140px; }
|
| 93 |
+
.col-position { width: 140px; min-width: 140px; }
|
| 94 |
+
.col-status { width: 100px; min-width: 100px; }
|
| 95 |
+
.col-actions { width: 120px; min-width: 120px; }
|
| 96 |
+
.col-default { width: 140px; min-width: 140px; }
|
| 97 |
</style>
|
| 98 |
</head>
|
| 99 |
<body class="bg-gray-100">
|
|
|
|
| 143 |
</div>
|
| 144 |
<div class="ml-3 nav-text">
|
| 145 |
<div class="text-sm font-medium">Admin User</div>
|
| 146 |
+
<div class="text-xs">Administrator</div>
|
| 147 |
</div>
|
| 148 |
</div>
|
| 149 |
</div>
|
|
|
|
| 159 |
<i class="fas fa-plus mr-2"></i>
|
| 160 |
<span>Add Employee</span>
|
| 161 |
</button>
|
| 162 |
+
<div class="dropdown relative">
|
| 163 |
+
<button id="columnsBtn" class="bg-gray-600 hover:bg-gray-700 text-white px-4 py-2 rounded-lg flex items-center">
|
| 164 |
+
<i class="fas fa-columns mr-2"></i>
|
| 165 |
+
<span>Columns</span>
|
| 166 |
+
<i class="fas fa-chevron-down ml-2 text-xs"></i>
|
| 167 |
+
</button>
|
| 168 |
+
<div class="dropdown-content right-0 mt-1 p-2 w-64">
|
| 169 |
+
<div class="font-medium text-gray-700 mb-2">Select columns to display:</div>
|
| 170 |
+
<div class="space-y-2">
|
| 171 |
+
<!-- Columns will be added dynamically by JavaScript -->
|
| 172 |
+
</div>
|
| 173 |
+
<div class="flex mt-3 pt-2 border-t">
|
| 174 |
+
<button id="resetColumnsBtn" class="text-xs text-gray-500 hover:text-blue-600">Reset to Default</button>
|
| 175 |
+
</div>
|
| 176 |
+
</div>
|
| 177 |
+
</div>
|
| 178 |
<button id="clearAllBtn" class="bg-red-600 hover:bg-red-700 text-white px-4 py-2 rounded-lg flex items-center">
|
| 179 |
<i class="fas fa-trash-alt mr-2"></i>
|
| 180 |
<span>Clear All</span>
|
|
|
|
| 197 |
|
| 198 |
<!-- Employee Modal -->
|
| 199 |
<div id="employeeModal" class="fixed inset-0 bg-gray-600 bg-opacity-50 flex items-center justify-center z-50 hidden">
|
| 200 |
+
<div class="bg-white rounded-lg shadow-xl w-full max-w-4xl max-h-[90vh] overflow-y-auto">
|
| 201 |
<div class="flex justify-between items-center border-b px-6 py-4">
|
| 202 |
+
<h3 id="modalTitle" class="text-xl font-semibold text-gray-800">Add New Employee</h3>
|
| 203 |
<button id="closeModal" class="text-gray-500 hover:text-gray-700">
|
| 204 |
<i class="fas fa-times"></i>
|
| 205 |
</button>
|
| 206 |
</div>
|
| 207 |
+
<form id="employeeForm" class="p-6">
|
| 208 |
+
<input type="hidden" id="employeeId">
|
| 209 |
+
|
| 210 |
<div class="flex border-b mb-4">
|
| 211 |
+
<button type="button" class="tab-button active px-4 py-2 font-medium" data-tab="basic">Basic Info</button>
|
| 212 |
+
<button type="button" class="tab-button px-4 py-2 font-medium" data-tab="government">Gov't Records</button>
|
| 213 |
+
<button type="button" class="tab-button px-4 py-2 font-medium" data-tab="employment">Employment</button>
|
| 214 |
</div>
|
| 215 |
|
| 216 |
+
<div id="basic-tab" class="tab-content active">
|
| 217 |
+
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
|
| 218 |
+
<div>
|
| 219 |
+
<label for="employeeIdInput" class="block text-sm font-medium text-gray-700 mb-1">Employee ID</label>
|
| 220 |
+
<input type="text" id="employeeIdInput" class="w-full px-3 py-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500" required>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 221 |
</div>
|
| 222 |
+
<div>
|
| 223 |
+
<label for="firstName" class="block text-sm font-medium text-gray-700 mb-1">First Name</label>
|
| 224 |
+
<input type="text" id="firstName" class="w-full px-3 py-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500" required>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 225 |
</div>
|
| 226 |
+
<div>
|
| 227 |
+
<label for="lastName" class="block text-sm font-medium text-gray-700 mb-1">Last Name</label>
|
| 228 |
+
<input type="text" id="lastName" class="w-full px-3 py-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500" required>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 229 |
</div>
|
| 230 |
+
<div>
|
| 231 |
+
<label for="email" class="block text-sm font-medium text-gray-700 mb-1">Email</label>
|
| 232 |
+
<input type="email" id="email" class="w-full px-3 py-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 233 |
</div>
|
| 234 |
+
<div>
|
| 235 |
+
<label for="phone" class="block text-sm font-medium text-gray-700 mb-1">Phone</label>
|
| 236 |
+
<input type="tel" id="phone" class="w-full px-3 py-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 237 |
</div>
|
| 238 |
+
<div>
|
| 239 |
+
<label for="birthDate" class="block text-sm font-medium text-gray-700 mb-1">Birth Date</label>
|
| 240 |
+
<input type="date" id="birthDate" class="w-full px-3 py-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500">
|
| 241 |
+
</div>
|
| 242 |
+
<div>
|
| 243 |
+
<label for="civilStatus" class="block text-sm font-medium text-gray-700 mb-1">Civil Status</label>
|
| 244 |
+
<select id="civilStatus" class="w-full px-3 py-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500">
|
| 245 |
+
<option value="">Select</option>
|
| 246 |
+
<option value="Single">Single</option>
|
| 247 |
+
<option value="Married">Married</option>
|
| 248 |
+
<option value="Separated">Separated</option>
|
| 249 |
+
<option value="Widowed">Widowed</option>
|
| 250 |
+
</select>
|
| 251 |
</div>
|
| 252 |
</div>
|
| 253 |
+
</div>
|
| 254 |
+
|
| 255 |
+
<div id="government-tab" class="tab-content">
|
| 256 |
+
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
|
| 257 |
+
<div>
|
| 258 |
+
<label for="sssNumber" class="block text-sm font-medium text-gray-700 mb-1">SSS Number</label>
|
| 259 |
+
<input type="text" id="sssNumber" class="w-full px-3 py-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 260 |
</div>
|
| 261 |
+
<div>
|
| 262 |
+
<label for="philhealthNumber" class="block text-sm font-medium text-gray-700 mb-1">PhilHealth Number</label>
|
| 263 |
+
<input type="text" id="philhealthNumber" class="w-full px-3 py-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 264 |
</div>
|
| 265 |
+
<div>
|
| 266 |
+
<label for="pagibigNumber" class="block text-sm font-medium text-gray-700 mb-1">Pag-IBIG Number</label>
|
| 267 |
+
<input type="text" id="pagibigNumber" class="w-full px-3 py-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 268 |
</div>
|
| 269 |
+
<div>
|
| 270 |
+
<label for="tinNumber" class="block text-sm font-medium text-gray-700 mb-1">TIN Number</label>
|
| 271 |
+
<input type="text" id="tinNumber" class="w-full px-3 py-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500">
|
| 272 |
+
</div>
|
| 273 |
+
<div>
|
| 274 |
+
<label for="passportNumber" class="block text-sm font-medium text-gray-700 mb-1">Passport Number</label>
|
| 275 |
+
<input type="text" id="passportNumber" class="w-full px-3 py-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500">
|
| 276 |
+
</div>
|
| 277 |
+
<div>
|
| 278 |
+
<label for="passportExpiry" class="block text-sm font-medium text-gray-700 mb-1">Passport Expiry</label>
|
| 279 |
+
<input type="date" id="passportExpiry" class="w-full px-3 py-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500">
|
| 280 |
+
</div>
|
| 281 |
+
<div>
|
| 282 |
+
<label for="nationalId" class="block text-sm font-medium text-gray-700 mb-1">National ID</label>
|
| 283 |
+
<input type="text" id="nationalId" class="w-full px-3 py-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500">
|
| 284 |
+
</div>
|
| 285 |
+
<div>
|
| 286 |
+
<label for="driversLicense" class="block text-sm font-medium text-gray-700 mb-1">Driver's License</label>
|
| 287 |
+
<input type="text" id="driversLicense" class="w-full px-3 py-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500">
|
| 288 |
</div>
|
| 289 |
</div>
|
| 290 |
+
</div>
|
| 291 |
+
|
| 292 |
+
<div id="employment-tab" class="tab-content">
|
| 293 |
+
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
|
| 294 |
+
<div>
|
| 295 |
+
<label for="departmentInput" class="block text-sm font-medium text-gray-700 mb-1">Department</label>
|
| 296 |
+
<div class="relative">
|
| 297 |
+
<input type="text" id="departmentInput" list="departmentSuggestions" class="w-full px-3 py-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500" required>
|
| 298 |
+
<ul id="departmentSuggestions" class="hidden absolute z-10 w-full mt-1 bg-white border border-gray-300 rounded-lg shadow-lg"></ul>
|
| 299 |
+
</div>
|
| 300 |
+
</div>
|
| 301 |
+
<div>
|
| 302 |
+
<label for="position" class="block text-sm font-medium text-gray-700 mb-1">Position</label>
|
| 303 |
+
<input type="text" id="position" class="w-full px-3 py-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500" required>
|
| 304 |
+
</div>
|
| 305 |
+
<div>
|
| 306 |
+
<label for="hireDate" class="block text-sm font-medium text-gray-700 mb-1">Hire Date</label>
|
| 307 |
+
<input type="date" id="hireDate" class="w-full px-3 py-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500">
|
| 308 |
+
</div>
|
| 309 |
+
<div>
|
| 310 |
+
<label for="salary" class="block text-sm font-medium text-gray-700 mb-1">Basic Salary (₱)</label>
|
| 311 |
+
<input type="number" id="salary" class="w-full px-3 py-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500">
|
| 312 |
+
</div>
|
| 313 |
+
<div>
|
| 314 |
+
<label for="status" class="block text-sm font-medium text-gray-700 mb-1">Employment Status</label>
|
| 315 |
+
<select id="status" class="w-full px-3 py-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500" required>
|
| 316 |
+
<option value="Active">Active</option>
|
| 317 |
+
<option value="Inactive">Inactive</option>
|
| 318 |
+
<option value="On Leave">On Leave</option>
|
| 319 |
+
</select>
|
| 320 |
+
</div>
|
| 321 |
</div>
|
| 322 |
+
</div>
|
| 323 |
+
|
| 324 |
+
<div class="flex justify-end space-x-3 mt-6 pt-4 border-t">
|
| 325 |
+
<button type="button" id="cancelEmployee" class="px-4 py-2 border border-gray-300 rounded-lg text-gray-700 hover:bg-gray-50">Cancel</button>
|
| 326 |
+
<button type="submit" class="px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700">Save Employee</button>
|
| 327 |
+
</div>
|
| 328 |
+
</form>
|
| 329 |
</div>
|
| 330 |
</div>
|
| 331 |
|
|
|
|
| 333 |
<div id="importConfirmationModal" class="fixed inset-0 bg-gray-600 bg-opacity-50 flex items-center justify-center z-50 confirmation-modal hidden">
|
| 334 |
<div class="bg-white rounded-lg shadow-xl w-full max-w-md">
|
| 335 |
<div class="flex justify-between items-center border-b px-6 py-4">
|
| 336 |
+
<h3 class="text-lg font-semibold text-gray-800">Import Employees</h3>
|
| 337 |
<button id="closeImportConfirmationModal" class="text-gray-500 hover:text-gray-700">
|
| 338 |
<i class="fas fa-times"></i>
|
| 339 |
</button>
|
| 340 |
</div>
|
| 341 |
<div class="p-6">
|
| 342 |
+
<p class="text-gray-700 mb-6">How would you like to import the employee data?</p>
|
| 343 |
+
|
| 344 |
+
<div class="space-y-4">
|
| 345 |
+
<div class="flex">
|
| 346 |
+
<div>
|
| 347 |
+
<button id="appendDataBtn" type="button" class="font-semibold text-left hover:text-blue-700 text-blue-600 mb-1">
|
| 348 |
+
Append New Records
|
| 349 |
+
</button>
|
| 350 |
+
<p class="text-sm text-gray-500">Import all records as new employees. Will generate new IDs for duplicates.</p>
|
| 351 |
+
</div>
|
| 352 |
+
</div>
|
| 353 |
+
|
| 354 |
+
<div class="flex">
|
| 355 |
+
<div>
|
| 356 |
+
<button id="mergeDataBtn" type="button" class="font-semibold text-left hover:text-blue-700 text-blue-600 mb-1">
|
| 357 |
+
Merge with Existing
|
| 358 |
+
</button>
|
| 359 |
+
<p class="text-sm text-gray-500">Update existing employees (matched by ID) and add new ones.</p>
|
| 360 |
+
</div>
|
| 361 |
+
</div>
|
| 362 |
+
|
| 363 |
+
<div class="flex">
|
| 364 |
+
<div>
|
| 365 |
+
<button id="replaceDataBtn" type="button" class="font-semibold text-left hover:text-blue-700 text-blue-600 mb-1">
|
| 366 |
+
Replace All Data
|
| 367 |
+
</button>
|
| 368 |
+
<p class="text-sm text-gray-500">Replace all existing employees with the imported data.</p>
|
| 369 |
+
</div>
|
| 370 |
+
</div>
|
| 371 |
</div>
|
| 372 |
</div>
|
| 373 |
+
<div class="flex justify-end border-t px-6 py-3">
|
| 374 |
+
<button type="button" id="cancelImportBtn" class="px-4 py-2 text-gray-700 hover:text-gray-900 mr-3">
|
| 375 |
+
Cancel
|
| 376 |
+
</button>
|
| 377 |
+
</div>
|
| 378 |
</div>
|
| 379 |
</div>
|
| 380 |
|
| 381 |
<!-- Clear All Confirmation Modal -->
|
| 382 |
+
<div id="clearAllConfirmationModal" class="fixed inset-0 bg-gray-600 bg-opacity-50 flex items-center justify-center z-50 confirmation-modal hidden">
|
| 383 |
<div class="bg-white rounded-lg shadow-xl w-full max-w-md">
|
| 384 |
<div class="flex justify-between items-center border-b px-6 py-4">
|
| 385 |
+
<h3 class="text-lg font-semibold text-gray-800">Confirm Clear All</h3>
|
| 386 |
<button id="closeClearAllConfirmationModal" class="text-gray-500 hover:text-gray-700">
|
| 387 |
<i class="fas fa-times"></i>
|
| 388 |
</button>
|
| 389 |
</div>
|
| 390 |
<div class="p-6">
|
| 391 |
+
<div class="flex items-start">
|
| 392 |
+
<div class="flex-shrink-0 pt-0.5">
|
| 393 |
+
<i class="fas fa-exclamation-circle text-red-500 text-xl"></i>
|
| 394 |
+
</div>
|
| 395 |
+
<div class="ml-3">
|
| 396 |
+
<h3 class="text-lg font-medium text-gray-900">Are you sure?</h3>
|
| 397 |
+
<div class="mt-2">
|
| 398 |
+
<p class="text-sm text-gray-500">
|
| 399 |
+
This will permanently delete all employee records. This action cannot be undone.
|
| 400 |
+
</p>
|
| 401 |
+
</div>
|
| 402 |
+
</div>
|
| 403 |
</div>
|
| 404 |
</div>
|
| 405 |
+
<div class="flex justify-end border-t px-6 py-3">
|
| 406 |
+
<button type="button" id="cancelClearAll" class="px-4 py-2 text-gray-700 hover:text-gray-900 mr-3">
|
| 407 |
+
Cancel
|
| 408 |
+
</button>
|
| 409 |
+
<button type="button" id="confirmClearAll" class="px-4 py-2 bg-red-600 text-white rounded-lg hover:bg-red-700">
|
| 410 |
+
Delete All
|
| 411 |
+
</button>
|
| 412 |
+
</div>
|
| 413 |
</div>
|
| 414 |
</div>
|
| 415 |
|
| 416 |
<!-- Employee List -->
|
| 417 |
<div class="bg-white p-6 rounded-xl shadow-sm border border-gray-200 mb-6">
|
| 418 |
<div class="flex justify-between items-center mb-4">
|
| 419 |
+
<div>
|
| 420 |
+
<h2 class="text-lg font-semibold inline-block mr-4">All Employees</h2>
|
| 421 |
+
<span id="columnsDisplayInfo" class="text-sm text-gray-500">Showing 7 of 15 columns</span>
|
| 422 |
+
</div>
|
| 423 |
<div class="flex items-center space-x-2">
|
| 424 |
<select id="departmentFilter" class="border rounded-lg px-3 py-1 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500">
|
| 425 |
<option value="">All Departments</option>
|
|
|
|
| 435 |
<div class="overflow-x-auto">
|
| 436 |
<table class="min-w-full divide-y divide-gray-200">
|
| 437 |
<thead class="bg-gray-50">
|
| 438 |
+
<tr id="employeeTableHeader">
|
| 439 |
+
<!-- Headers will be inserted by JavaScript based on column selection -->
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 440 |
</tr>
|
| 441 |
</thead>
|
| 442 |
<tbody class="bg-white divide-y divide-gray-200" id="employeeTableBody">
|
|
|
|
| 448 |
<div class="text-sm text-gray-500">
|
| 449 |
Showing <span id="startEmployee">1</span> to <span id="endEmployee">10</span> of <span id="totalEmployees">0</span> employees
|
| 450 |
</div>
|
| 451 |
+
<div class="flex space-x-2">
|
| 452 |
<button id="prevEmployeePage" class="px-3 py-1 border rounded-lg text-sm hover:bg-gray-50 disabled:opacity-50" disabled>
|
| 453 |
Previous
|
| 454 |
</button>
|
| 455 |
+
<button id="nextEmployeePage" class="px-3 py-1 border rounded-lg text-sm hover:bg-gray-50 disabled:opacity-50">
|
| 456 |
Next
|
| 457 |
</button>
|
| 458 |
</div>
|
|
|
|
| 462 |
</div>
|
| 463 |
|
| 464 |
<script>
|
| 465 |
+
// ====== Column Configuration ======
|
| 466 |
+
const COLUMNS_CONFIG = {
|
| 467 |
+
employeeId: {
|
| 468 |
+
key: 'employeeId',
|
| 469 |
+
label: 'Employee ID',
|
| 470 |
+
visible: true,
|
| 471 |
+
locked: true,
|
| 472 |
+
className: 'col-employeeId',
|
| 473 |
+
order: 1,
|
| 474 |
+
default: true
|
| 475 |
+
},
|
| 476 |
+
name: {
|
| 477 |
+
key: 'name',
|
| 478 |
+
label: 'Name',
|
| 479 |
+
visible: true,
|
| 480 |
+
locked: true,
|
| 481 |
+
className: 'col-name',
|
| 482 |
+
order: 2,
|
| 483 |
+
default: true
|
| 484 |
+
},
|
| 485 |
+
department: {
|
| 486 |
+
key: 'department',
|
| 487 |
+
label: 'Department',
|
| 488 |
+
visible: true,
|
| 489 |
+
locked: false,
|
| 490 |
+
className: 'col-department',
|
| 491 |
+
order: 3,
|
| 492 |
+
default: true
|
| 493 |
+
},
|
| 494 |
+
position: {
|
| 495 |
+
key: 'position',
|
| 496 |
+
label: 'Position',
|
| 497 |
+
visible: true,
|
| 498 |
+
locked: false,
|
| 499 |
+
className: 'col-position',
|
| 500 |
+
order: 4,
|
| 501 |
+
default: true
|
| 502 |
+
},
|
| 503 |
+
status: {
|
| 504 |
+
key: 'status',
|
| 505 |
+
label: 'Status',
|
| 506 |
+
visible: true,
|
| 507 |
+
locked: false,
|
| 508 |
+
className: 'col-status',
|
| 509 |
+
order: 5,
|
| 510 |
+
default: true
|
| 511 |
+
},
|
| 512 |
+
salary: {
|
| 513 |
+
key: 'salary',
|
| 514 |
+
label: 'Salary',
|
| 515 |
+
visible: false,
|
| 516 |
+
locked: false,
|
| 517 |
+
className: 'col-default',
|
| 518 |
+
order: 6,
|
| 519 |
+
default: false
|
| 520 |
+
},
|
| 521 |
+
sssNumber: {
|
| 522 |
+
key: 'sssNumber',
|
| 523 |
+
label: 'SSS Number',
|
| 524 |
+
visible: false,
|
| 525 |
+
locked: false,
|
| 526 |
+
className: 'col-default',
|
| 527 |
+
order: 7,
|
| 528 |
+
default: false
|
| 529 |
+
},
|
| 530 |
+
philhealthNumber: {
|
| 531 |
+
key: 'philhealthNumber',
|
| 532 |
+
label: 'PhilHealth',
|
| 533 |
+
visible: false,
|
| 534 |
+
locked: false,
|
| 535 |
+
className: 'col-default',
|
| 536 |
+
order: 8,
|
| 537 |
+
default: false
|
| 538 |
+
},
|
| 539 |
+
pagibigNumber: {
|
| 540 |
+
key: 'pagibigNumber',
|
| 541 |
+
label: 'Pag-IBIG',
|
| 542 |
+
visible: false,
|
| 543 |
+
locked: false,
|
| 544 |
+
className: 'col-default',
|
| 545 |
+
order: 9,
|
| 546 |
+
default: false
|
| 547 |
+
},
|
| 548 |
+
tinNumber: {
|
| 549 |
+
key: 'tinNumber',
|
| 550 |
+
label: 'TIN',
|
| 551 |
+
visible: false,
|
| 552 |
+
locked: false,
|
| 553 |
+
className: 'col-default',
|
| 554 |
+
order: 10,
|
| 555 |
+
default: false
|
| 556 |
+
},
|
| 557 |
+
email: {
|
| 558 |
+
key: 'email',
|
| 559 |
+
label: 'Email',
|
| 560 |
+
visible: false,
|
| 561 |
+
locked: false,
|
| 562 |
+
className: 'col-default',
|
| 563 |
+
order: 11,
|
| 564 |
+
default: false
|
| 565 |
+
},
|
| 566 |
+
phone: {
|
| 567 |
+
key: 'phone',
|
| 568 |
+
label: 'Phone',
|
| 569 |
+
visible: false,
|
| 570 |
+
locked: false,
|
| 571 |
+
className: 'col-default',
|
| 572 |
+
order: 12,
|
| 573 |
+
default: false
|
| 574 |
+
},
|
| 575 |
+
hireDate: {
|
| 576 |
+
key: 'hireDate',
|
| 577 |
+
label: 'Hire Date',
|
| 578 |
+
visible: false,
|
| 579 |
+
locked: false,
|
| 580 |
+
className: 'col-default',
|
| 581 |
+
order: 13,
|
| 582 |
+
default: false
|
| 583 |
+
},
|
| 584 |
+
birthDate: {
|
| 585 |
+
key: 'birthDate',
|
| 586 |
+
label: 'Birth Date',
|
| 587 |
+
visible: false,
|
| 588 |
+
locked: false,
|
| 589 |
+
className: 'col-default',
|
| 590 |
+
order: 14,
|
| 591 |
+
default: false
|
| 592 |
+
},
|
| 593 |
+
civilStatus: {
|
| 594 |
+
key: 'civilStatus',
|
| 595 |
+
label: 'Civil Status',
|
| 596 |
+
visible: false,
|
| 597 |
+
locked: false,
|
| 598 |
+
className: 'col-default',
|
| 599 |
+
order: 15,
|
| 600 |
+
default: false
|
| 601 |
+
},
|
| 602 |
+
actions: {
|
| 603 |
+
key: 'actions',
|
| 604 |
+
label: 'Actions',
|
| 605 |
+
visible: true,
|
| 606 |
+
locked: true,
|
| 607 |
+
className: 'col-actions',
|
| 608 |
+
order: 99,
|
| 609 |
+
default: true
|
| 610 |
+
}
|
| 611 |
+
};
|
| 612 |
+
|
| 613 |
// Storage keys
|
| 614 |
const STORAGE_KEY = 'steelcraft_payroll_employees';
|
| 615 |
const DEPARTMENTS_KEY = 'steelcraft_payroll_departments';
|
| 616 |
+
const COLUMNS_PREFERENCES_KEY = 'steelcraft_payroll_columns_prefs';
|
| 617 |
|
| 618 |
// Employee data - initially load from localStorage
|
| 619 |
let employees = loadEmployees();
|
| 620 |
let allDepartments = loadDepartments();
|
| 621 |
+
let columnsConfig = loadColumnsPreferences();
|
| 622 |
|
| 623 |
// If no data in localStorage, initialize with default values
|
| 624 |
if (employees.length === 0) {
|
|
|
|
| 635 |
hireDate: "2020-05-15",
|
| 636 |
birthDate: "1985-03-12",
|
| 637 |
salary: 25000,
|
| 638 |
+
status: "Active",
|
| 639 |
+
sssNumber: "34-1234567-8",
|
| 640 |
+
philhealthNumber: "34-123456789-0",
|
| 641 |
+
pagibigNumber: "1234-5678-9012",
|
| 642 |
+
tinNumber: "123-456-789-000",
|
| 643 |
+
civilStatus: "Married"
|
| 644 |
}
|
| 645 |
];
|
| 646 |
saveEmployees();
|
|
|
|
| 662 |
|
| 663 |
// DOM elements
|
| 664 |
const employeeTableBody = document.getElementById('employeeTableBody');
|
| 665 |
+
const employeeTableHeader = document.getElementById('employeeTableHeader');
|
| 666 |
const departmentInput = document.getElementById('departmentInput');
|
| 667 |
const departmentSuggestions = document.getElementById('departmentSuggestions');
|
| 668 |
const departmentFilter = document.getElementById('departmentFilter');
|
|
|
|
| 687 |
const totalEmployees = document.getElementById('totalEmployees');
|
| 688 |
const tabButtons = document.querySelectorAll('.tab-button');
|
| 689 |
const tabContents = document.querySelectorAll('.tab-content');
|
| 690 |
+
const columnsBtn = document.getElementById('columnsBtn');
|
| 691 |
+
const columnsDisplayInfo = document.getElementById('columnsDisplayInfo');
|
| 692 |
+
const resetColumnsBtn = document.getElementById('resetColumnsBtn');
|
| 693 |
+
const columnsDropdownContent = document.querySelector('.dropdown-content');
|
| 694 |
|
| 695 |
// Import confirmation modal elements
|
| 696 |
const importConfirmationModal = document.getElementById('importConfirmationModal');
|
|
|
|
| 698 |
const appendDataBtn = document.getElementById('appendDataBtn');
|
| 699 |
const mergeDataBtn = document.getElementById('mergeDataBtn');
|
| 700 |
const replaceDataBtn = document.getElementById('replaceDataBtn');
|
| 701 |
+
const cancelImportBtn = document.getElementById('cancelImportBtn');
|
| 702 |
|
| 703 |
// Clear all confirmation modal elements
|
| 704 |
const clearAllConfirmationModal = document.getElementById('clearAllConfirmationModal');
|
|
|
|
| 706 |
const cancelClearAll = document.getElementById('cancelClearAll');
|
| 707 |
const confirmClearAll = document.getElementById('confirmClearAll');
|
| 708 |
|
| 709 |
+
// ====== Column Management Functions ======
|
| 710 |
+
function loadColumnsPreferences() {
|
| 711 |
+
const savedPrefs = localStorage.getItem(COLUMNS_PREFERENCES_KEY);
|
| 712 |
+
if (savedPrefs) {
|
| 713 |
+
try {
|
| 714 |
+
const prefs = JSON.parse(savedPrefs);
|
| 715 |
+
// Merge with default config
|
| 716 |
+
const mergedConfig = JSON.parse(JSON.stringify(COLUMNS_CONFIG));
|
| 717 |
+
|
| 718 |
+
for (const key in prefs) {
|
| 719 |
+
if (mergedConfig[key]) {
|
| 720 |
+
mergedConfig[key].visible = prefs[key].visible;
|
| 721 |
+
}
|
| 722 |
+
}
|
| 723 |
+
|
| 724 |
+
return mergedConfig;
|
| 725 |
+
} catch (e) {
|
| 726 |
+
console.error("Error loading column preferences:", e);
|
| 727 |
+
}
|
| 728 |
+
}
|
| 729 |
+
return JSON.parse(JSON.stringify(COLUMNS_CONFIG)); // Return a deep copy
|
| 730 |
+
}
|
| 731 |
+
|
| 732 |
+
function saveColumnsPreferences() {
|
| 733 |
+
const saveData = {};
|
| 734 |
+
for (const key in columnsConfig) {
|
| 735 |
+
saveData[key] = { visible: columnsConfig[key].visible };
|
| 736 |
+
}
|
| 737 |
+
localStorage.setItem(COLUMNS_PREFERENCES_KEY, JSON.stringify(saveData));
|
| 738 |
+
}
|
| 739 |
+
|
| 740 |
+
function resetColumnsToDefault() {
|
| 741 |
+
for (const key in columnsConfig) {
|
| 742 |
+
columnsConfig[key].visible = columnsConfig[key].default;
|
| 743 |
+
}
|
| 744 |
+
saveColumnsPreferences();
|
| 745 |
+
renderColumnSelector();
|
| 746 |
+
renderEmployeeTable();
|
| 747 |
+
}
|
| 748 |
+
|
| 749 |
+
function toggleColumnVisibility(columnKey) {
|
| 750 |
+
if (columnsConfig[columnKey] && !columnsConfig[columnKey].locked) {
|
| 751 |
+
columnsConfig[columnKey].visible = !columnsConfig[columnKey].visible;
|
| 752 |
+
saveColumnsPreferences();
|
| 753 |
+
renderColumnSelector();
|
| 754 |
+
renderEmployeeTable();
|
| 755 |
+
}
|
| 756 |
+
}
|
| 757 |
+
|
| 758 |
+
function renderColumnSelector() {
|
| 759 |
+
const container = columnsDropdownContent.querySelector('.space-y-2');
|
| 760 |
+
container.innerHTML = '';
|
| 761 |
+
|
| 762 |
+
// Get all columns ordered by their display order
|
| 763 |
+
const orderedColumns = Object.values(columnsConfig).sort((a, b) => a.order - b.order);
|
| 764 |
+
|
| 765 |
+
orderedColumns.forEach(col => {
|
| 766 |
+
if (col.locked) return; // Skip locked columns
|
| 767 |
+
|
| 768 |
+
const div = document.createElement('div');
|
| 769 |
+
div.className = 'flex items-center';
|
| 770 |
+
|
| 771 |
+
const checkbox = document.createElement('input');
|
| 772 |
+
checkbox.type = 'checkbox';
|
| 773 |
+
checkbox.id = `col-${col.key}`;
|
| 774 |
+
checkbox.checked = col.visible;
|
| 775 |
+
checkbox.className = 'mr-2 rounded text-blue-600 focus:ring-blue-500';
|
| 776 |
+
checkbox.addEventListener('change', () => toggleColumnVisibility(col.key));
|
| 777 |
+
|
| 778 |
+
const label = document.createElement('label');
|
| 779 |
+
label.htmlFor = `col-${col.key}`;
|
| 780 |
+
label.className = 'text-sm text-gray-700';
|
| 781 |
+
label.textContent = col.label;
|
| 782 |
+
|
| 783 |
+
div.appendChild(checkbox);
|
| 784 |
+
div.appendChild(label);
|
| 785 |
+
container.appendChild(div);
|
| 786 |
+
});
|
| 787 |
+
|
| 788 |
+
// Update the "Showing X of Y columns" info
|
| 789 |
+
const visibleCount = Object.values(columnsConfig).filter(c => c.visible).length;
|
| 790 |
+
const totalCount = Object.keys(columnsConfig).length;
|
| 791 |
+
columnsDisplayInfo.textContent = `Showing ${visibleCount} of ${totalCount} columns`;
|
| 792 |
+
}
|
| 793 |
+
|
| 794 |
+
function getTableHeaders() {
|
| 795 |
+
// Get visible columns in correct order
|
| 796 |
+
const visibleColumns = Object.values(columnsConfig)
|
| 797 |
+
.filter(col => col.visible)
|
| 798 |
+
.sort((a, b) => a.order - b.order);
|
| 799 |
+
|
| 800 |
+
let headers = '';
|
| 801 |
+
visibleColumns.forEach(col => {
|
| 802 |
+
headers += `
|
| 803 |
+
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider ${col.className}">
|
| 804 |
+
${col.label}
|
| 805 |
+
</th>
|
| 806 |
+
`;
|
| 807 |
+
});
|
| 808 |
+
|
| 809 |
+
return headers;
|
| 810 |
+
}
|
| 811 |
+
|
| 812 |
+
function getTableRow(employee) {
|
| 813 |
+
// Get visible columns in correct order
|
| 814 |
+
const visibleColumns = Object.values(columnsConfig)
|
| 815 |
+
.filter(col => col.visible)
|
| 816 |
+
.sort((a, b) => a.order - b.order);
|
| 817 |
+
|
| 818 |
+
let rowCells = '';
|
| 819 |
+
|
| 820 |
+
visibleColumns.forEach(col => {
|
| 821 |
+
if (col.key === 'name') {
|
| 822 |
+
rowCells += `
|
| 823 |
+
<td class="px-6 py-4 whitespace-nowrap ${col.className}">
|
| 824 |
+
<div class="flex items-center">
|
| 825 |
+
<div class="flex-shrink-0 h-10 w-10 rounded-full bg-blue-100 flex items-center justify-center">
|
| 826 |
+
<i class="fas fa-user text-blue-600"></i>
|
| 827 |
+
</div>
|
| 828 |
+
<div class="ml-4">
|
| 829 |
+
<div class="text-sm font-medium text-gray-900">${employee.firstName} ${employee.lastName}</div>
|
| 830 |
+
<div class="text-sm text-gray-500">${employee.email || 'No email'}</div>
|
| 831 |
+
</div>
|
| 832 |
+
</div>
|
| 833 |
+
</td>
|
| 834 |
+
`;
|
| 835 |
+
} else if (col.key === 'status') {
|
| 836 |
+
rowCells += `
|
| 837 |
+
<td class="px-6 py-4 whitespace-nowrap ${col.className}">
|
| 838 |
+
<span class="px-2 inline-flex text-xs leading-5 font-semibell rounded-full ${getStatusClass(employee.status)}">
|
| 839 |
+
${employee.status}
|
| 840 |
+
</span>
|
| 841 |
+
</td>
|
| 842 |
+
`;
|
| 843 |
+
} else if (col.key === 'actions') {
|
| 844 |
+
rowCells += `
|
| 845 |
+
<td class="px-6 py-4 whitespace-nowrap text-sm font-medium ${col.className}">
|
| 846 |
+
<button class="text-blue-600 hover:text-blue-900 mr-3 edit-btn" data-id="${employee.id}">Edit</button>
|
| 847 |
+
<button class="text-red-600 hover:text-red-900 delete-btn" data-id="${employee.id}">Delete</button>
|
| 848 |
+
</td>
|
| 849 |
+
`;
|
| 850 |
+
} else if (col.key === 'salary') {
|
| 851 |
+
rowCells += `
|
| 852 |
+
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900 ${col.className}">
|
| 853 |
+
₱${employee.salary ? employee.salary.toLocaleString('en-PH', { minimumFractionDigits: 2, maximumFractionDigits: 2 }) : '0.00'}
|
| 854 |
+
</td>
|
| 855 |
+
`;
|
| 856 |
+
} else if (col.key === 'hireDate' || col.key === 'birthDate') {
|
| 857 |
+
rowCells += `
|
| 858 |
+
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500 ${col.className}">
|
| 859 |
+
${employee[col.key] ? formatDate(employee[col.key]) : 'N/A'}
|
| 860 |
+
</td>
|
| 861 |
+
`;
|
| 862 |
+
} else {
|
| 863 |
+
rowCells += `
|
| 864 |
+
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500 ${col.className}">
|
| 865 |
+
${employee[col.key] || 'N/A'}
|
| 866 |
+
</td>
|
| 867 |
+
`;
|
| 868 |
+
}
|
| 869 |
+
});
|
| 870 |
+
|
| 871 |
+
return rowCells;
|
| 872 |
+
}
|
| 873 |
+
|
| 874 |
+
// ====== Core Functions ======
|
| 875 |
function saveEmployees() {
|
| 876 |
localStorage.setItem(STORAGE_KEY, JSON.stringify(employees));
|
| 877 |
}
|
|
|
|
| 893 |
// Initialize
|
| 894 |
document.addEventListener('DOMContentLoaded', () => {
|
| 895 |
updateDepartmentFilterOptions();
|
| 896 |
+
renderColumnSelector(); // Initialize column selector
|
| 897 |
renderEmployeeTable();
|
| 898 |
setupEventListeners();
|
| 899 |
setupTabs();
|
|
|
|
| 921 |
|
| 922 |
function extractDepartmentsFromEmployees() {
|
| 923 |
const departmentsSet = new Set();
|
| 924 |
+
employees.forEach(emp => {
|
| 925 |
+
if (emp.department) departmentsSet.add(emp.department);
|
| 926 |
+
});
|
| 927 |
+
allDepartments = Array.from(departmentsSet).sort();
|
| 928 |
}
|
| 929 |
|
| 930 |
function updateDepartmentFilterOptions() {
|
|
|
|
| 939 |
|
| 940 |
function setupEventListeners() {
|
| 941 |
addEmployeeBtn.addEventListener('click', () => openEmployeeModal());
|
|
|
|
| 942 |
clearAllBtn.addEventListener('click', () => openClearAllConfirmationModal());
|
| 943 |
exportCSVBtn.addEventListener('click', exportToCSV);
|
| 944 |
importCSVBtn.addEventListener('click', () => fileInput.click());
|
|
|
|
| 960 |
}
|
| 961 |
});
|
| 962 |
nextEmployeePage.addEventListener('click', () => {
|
| 963 |
+
const maxPage = Math.ceil(filteredEmployees.length / rowsPerPage);
|
| 964 |
+
if (currentPage < maxPage) {
|
| 965 |
currentPage++;
|
| 966 |
renderEmployeeTable();
|
| 967 |
}
|
| 968 |
});
|
| 969 |
+
resetColumnsBtn.addEventListener('click', resetColumnsToDefault);
|
| 970 |
|
| 971 |
// Import confirmation modal events
|
| 972 |
closeImportConfirmationModal.addEventListener('click', () => importConfirmationModal.classList.add('hidden'));
|
| 973 |
+
cancelImportBtn.addEventListener('click', () => importConfirmationModal.classList.add('hidden'));
|
| 974 |
appendDataBtn.addEventListener('click', () => processImport('append'));
|
| 975 |
mergeDataBtn.addEventListener('click', () => processImport('merge'));
|
| 976 |
replaceDataBtn.addEventListener('click', () => processImport('replace'));
|
|
|
|
| 979 |
closeClearAllConfirmationModal.addEventListener('click', () => clearAllConfirmationModal.classList.add('hidden'));
|
| 980 |
cancelClearAll.addEventListener('click', () => clearAllConfirmationModal.classList.add('hidden'));
|
| 981 |
confirmClearAll.addEventListener('click', clearAllEmployees);
|
| 982 |
+
|
| 983 |
+
// Close dropdown when clicking outside
|
| 984 |
+
document.addEventListener('click', (e) => {
|
| 985 |
+
if (!columnsBtn.contains(e.target) && !columnsDropdownContent.contains(e.target)) {
|
| 986 |
+
columnsDropdownContent.style.display = 'none';
|
| 987 |
+
}
|
| 988 |
+
});
|
| 989 |
+
|
| 990 |
+
// Toggle dropdown when clicking the columns button
|
| 991 |
+
columnsBtn.addEventListener('click', () => {
|
| 992 |
+
const isOpen = columnsDropdownContent.style.display === 'block';
|
| 993 |
+
columnsDropdownContent.style.display = isOpen ? 'none' : 'block';
|
| 994 |
+
});
|
| 995 |
}
|
| 996 |
|
| 997 |
function handleDepartmentInput(e) {
|
|
|
|
| 1043 |
|
| 1044 |
filteredEmployees = employees.filter(emp => {
|
| 1045 |
const fullName = `${emp.firstName} ${emp.lastName}`.toLowerCase();
|
| 1046 |
+
const matchesSearch = fullName.includes(searchTerm) ||
|
| 1047 |
+
emp.employeeId.toLowerCase().includes(searchTerm) ||
|
| 1048 |
+
(emp.email && emp.email.toLowerCase().includes(searchTerm)) ||
|
| 1049 |
+
(emp.position && emp.position.toLowerCase().includes(searchTerm));
|
| 1050 |
const matchesDepartment = department ? emp.department === department : true;
|
| 1051 |
const matchesStatus = status ? emp.status === status : true;
|
| 1052 |
|
|
|
|
| 1062 |
const end = start + rowsPerPage;
|
| 1063 |
const paginatedEmployees = filteredEmployees.slice(start, end);
|
| 1064 |
|
| 1065 |
+
// Set table headers based on visible columns
|
| 1066 |
+
employeeTableHeader.innerHTML = getTableHeaders();
|
| 1067 |
+
|
| 1068 |
employeeTableBody.innerHTML = '';
|
| 1069 |
|
| 1070 |
if (paginatedEmployees.length === 0) {
|
| 1071 |
+
const colSpan = Object.values(columnsConfig).filter(col => col.visible).length;
|
| 1072 |
employeeTableBody.innerHTML = `
|
| 1073 |
<tr>
|
| 1074 |
+
<td colspan="${colSpan}" class="px-6 py-4 text-center text-gray-500">No employees found</td>
|
| 1075 |
</tr>
|
| 1076 |
`;
|
| 1077 |
} else {
|
|
|
|
| 1079 |
const row = document.createElement('tr');
|
| 1080 |
row.className = 'employee-row';
|
| 1081 |
row.dataset.id = emp.id;
|
| 1082 |
+
row.innerHTML = getTableRow(emp);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1083 |
employeeTableBody.appendChild(row);
|
| 1084 |
|
| 1085 |
// Add double click listener to the row
|
|
|
|
| 1108 |
});
|
| 1109 |
}
|
| 1110 |
|
| 1111 |
+
const totalVisible = filteredEmployees.length;
|
| 1112 |
+
const maxPage = Math.ceil(totalVisible / rowsPerPage);
|
| 1113 |
+
|
| 1114 |
+
startEmployee.textContent = totalVisible > 0 ? start + 1 : 0;
|
| 1115 |
+
endEmployee.textContent = Math.min(end, totalVisible);
|
| 1116 |
+
totalEmployees.textContent = totalVisible;
|
| 1117 |
+
|
| 1118 |
+
prevEmployeePage.disabled = currentPage <= 1;
|
| 1119 |
+
nextEmployeePage.disabled = currentPage >= maxPage || maxPage === 0;
|
| 1120 |
}
|
| 1121 |
|
| 1122 |
function deleteEmployee(id) {
|
|
|
|
| 1136 |
}
|
| 1137 |
|
| 1138 |
function openEmployeeModal(id = null) {
|
|
|
|
|
|
|
| 1139 |
if (id) {
|
| 1140 |
const employee = employees.find(e => e.id === id);
|
|
|
|
| 1141 |
|
| 1142 |
if (employee) {
|
| 1143 |
modalTitle.textContent = 'Edit Employee';
|
|
|
|
| 1148 |
document.getElementById('email').value = employee.email || '';
|
| 1149 |
document.getElementById('phone').value = employee.phone || '';
|
| 1150 |
document.getElementById('birthDate').value = employee.birthDate || '';
|
| 1151 |
+
document.getElementById('civilStatus').value = employee.civilStatus || 'Single';
|
| 1152 |
+
departmentInput.value = employee.department || '';
|
| 1153 |
+
document.getElementById('position').value = employee.position || '';
|
| 1154 |
+
document.getElementById('hireDate').value = employee.hireDate || '';
|
| 1155 |
+
document.getElementById('salary').value = employee.salary || '';
|
| 1156 |
+
document.getElementById('status').value = employee.status || 'Active';
|
| 1157 |
|
| 1158 |
// Philippine Government data
|
| 1159 |
document.getElementById('sssNumber').value = employee.sssNumber || '';
|
|
|
|
| 1171 |
employeeIdInput.value = '';
|
| 1172 |
employeeIdDisplayInput.value = '';
|
| 1173 |
departmentInput.value = '';
|
| 1174 |
+
document.getElementById('status').value = 'Active';
|
| 1175 |
+
document.getElementById('civilStatus').value = 'Single';
|
| 1176 |
|
| 1177 |
// Generate new employee ID for new employees
|
| 1178 |
const newId = employees.length > 0 ? Math.max(...employees.map(e => e.id)) + 1 : 1;
|
| 1179 |
employeeIdDisplayInput.value = `EMP-${1000 + newId}`;
|
| 1180 |
}
|
| 1181 |
|
| 1182 |
+
// Reset tabs to first tab
|
| 1183 |
+
tabButtons.forEach((btn, index) => {
|
| 1184 |
+
btn.classList.toggle('active', index === 0);
|
| 1185 |
+
});
|
| 1186 |
+
tabContents.forEach((content, index) => {
|
| 1187 |
+
content.classList.toggle('active', index === 0);
|
| 1188 |
+
});
|
| 1189 |
+
|
| 1190 |
employeeModal.classList.remove('hidden');
|
| 1191 |
}
|
| 1192 |
|
|
|
|
| 1197 |
function saveEmployee() {
|
| 1198 |
const id = employeeIdInput.value ? parseInt(employeeIdInput.value) : null;
|
| 1199 |
const employeeId = employeeIdDisplayInput.value.trim();
|
| 1200 |
+
const firstName = document.getElementById('firstName').value.trim();
|
| 1201 |
+
const lastName = document.getElementById('lastName').value.trim();
|
| 1202 |
+
const email = document.getElementById('email').value.trim() || null;
|
| 1203 |
+
const phone = document.getElementById('phone').value.trim() || null;
|
| 1204 |
const birthDate = document.getElementById('birthDate').value || null;
|
| 1205 |
const civilStatus = document.getElementById('civilStatus').value || null;
|
| 1206 |
const department = departmentInput.value.trim();
|
| 1207 |
+
const position = document.getElementById('position').value.trim() || null;
|
| 1208 |
const hireDate = document.getElementById('hireDate').value || null;
|
| 1209 |
const salary = document.getElementById('salary').value ? parseFloat(document.getElementById('salary').value) : 0;
|
| 1210 |
const status = document.getElementById('status').value || 'Active';
|
| 1211 |
|
| 1212 |
// Philippine Government data
|
| 1213 |
+
const sssNumber = document.getElementById('sssNumber').value.trim() || null;
|
| 1214 |
+
const philhealthNumber = document.getElementById('philhealthNumber').value.trim() || null;
|
| 1215 |
+
const pagibigNumber = document.getElementById('pagibigNumber').value.trim() || null;
|
| 1216 |
+
const tinNumber = document.getElementById('tinNumber').value.trim() || null;
|
| 1217 |
+
const passportNumber = document.getElementById('passportNumber').value.trim() || null;
|
| 1218 |
const passportExpiry = document.getElementById('passportExpiry').value || null;
|
| 1219 |
+
const nationalId = document.getElementById('nationalId').value.trim() || null;
|
| 1220 |
+
const driversLicense = document.getElementById('driversLicense').value.trim() || null;
|
| 1221 |
|
| 1222 |
if (!employeeId || !firstName || !lastName) {
|
| 1223 |
alert("Employee ID, first name and last name are required.");
|
|
|
|
| 1228 |
// Editing existing employee
|
| 1229 |
const index = employees.findIndex(e => e.id === id);
|
| 1230 |
employees[index] = {
|
| 1231 |
+
...employees[index], // Preserve existing data
|
| 1232 |
employeeId,
|
| 1233 |
firstName,
|
| 1234 |
lastName,
|
|
|
|
| 1278 |
driversLicense
|
| 1279 |
});
|
| 1280 |
|
| 1281 |
+
if (!allDepartments.includes(department) && department) {
|
| 1282 |
+
allDepartments.push(department);
|
| 1283 |
+
saveDepartments();
|
| 1284 |
+
updateDepartmentFilterOptions();
|
| 1285 |
+
}
|
| 1286 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1287 |
|
| 1288 |
+
// Save to localStorage
|
| 1289 |
+
saveEmployees();
|
| 1290 |
+
closeEmployeeModal();
|
| 1291 |
+
extractDepartmentsFromEmployees();
|
| 1292 |
+
updateDepartmentFilterOptions();
|
| 1293 |
+
filterEmployees();
|
| 1294 |
}
|
|
|
|
| 1295 |
|
| 1296 |
+
function getStatusClass(status) {
|
| 1297 |
+
switch(status) {
|
| 1298 |
+
case 'Active': return 'bg-green-100 text-green-800';
|
| 1299 |
+
case 'Inactive': return 'bg-red-100 text-red-800';
|
| 1300 |
+
case 'On Leave': return 'bg-yellow-100 text-yellow-800';
|
| 1301 |
+
default: return 'bg-gray-100 text-gray-800';
|
| 1302 |
+
}
|
| 1303 |
+
}
|
| 1304 |
|
| 1305 |
+
function formatDate(dateString) {
|
| 1306 |
+
if (!dateString) return 'N/A';
|
| 1307 |
+
const options = { year: 'numeric', month: 'short', day: 'numeric' };
|
| 1308 |
+
return new Date(dateString).toLocaleDateString('en-US', options);
|
| 1309 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1310 |
|
| 1311 |
+
function exportToCSV() {
|
| 1312 |
+
// Get visible columns ordered by their display order
|
| 1313 |
+
const visibleColumns = Object.values(columnsConfig)
|
| 1314 |
+
.filter(col => col.visible && col.key !== 'actions') // Don't export actions column
|
| 1315 |
+
.sort((a, b) => a.order - b.order);
|
| 1316 |
+
|
| 1317 |
+
// Create headers
|
| 1318 |
+
const headers = visibleColumns.map(col => {
|
| 1319 |
+
if (col.key === 'name') return 'First Name,Last Name';
|
| 1320 |
+
return col.label;
|
| 1321 |
+
}).join(',');
|
| 1322 |
+
|
| 1323 |
+
// Create CSV rows
|
| 1324 |
+
const csvContent = [
|
| 1325 |
+
headers,
|
| 1326 |
+
...employees.map(emp => {
|
| 1327 |
+
return visibleColumns.map(col => {
|
| 1328 |
+
let value = '';
|
| 1329 |
+
|
| 1330 |
+
if (col.key === 'name') {
|
| 1331 |
+
value = `"${emp.firstName}","${emp.lastName}"`;
|
| 1332 |
+
} else if (col.key === 'salary') {
|
| 1333 |
+
value = emp.salary || 0;
|
| 1334 |
+
} else {
|
| 1335 |
+
value = emp[col.key] || '';
|
| 1336 |
+
// Escape quotes and wrap in quotes if the value contains commas
|
| 1337 |
+
if (typeof value === 'string' && (value.includes(',') || value.includes('"'))) {
|
| 1338 |
+
value = `"${value.replace(/"/g, '""')}"`;
|
| 1339 |
+
}
|
| 1340 |
+
}
|
| 1341 |
+
|
| 1342 |
+
return value;
|
| 1343 |
+
}).join(',');
|
| 1344 |
+
})
|
| 1345 |
+
].join('\n');
|
| 1346 |
+
|
| 1347 |
+
// Create download link
|
| 1348 |
+
const blob = new Blob([csvContent], { type: 'text/csv;charset=utf-8;' });
|
| 1349 |
+
const url = URL.createObjectURL(blob);
|
| 1350 |
+
const link = document.createElement('a');
|
| 1351 |
+
link.setAttribute('href', url);
|
| 1352 |
+
link.setAttribute('download', `steelcraft_employees_${new Date().toISOString().slice(0, 10)}.csv`);
|
| 1353 |
+
link.style.visibility = 'hidden';
|
| 1354 |
+
document.body.appendChild(link);
|
| 1355 |
+
link.click();
|
| 1356 |
+
document.body.removeChild(link);
|
| 1357 |
+
}
|
| 1358 |
|
| 1359 |
+
function handleFileImport(event) {
|
| 1360 |
+
const file = event.target.files[0];
|
| 1361 |
+
if (!file) return;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1362 |
|
| 1363 |
+
const reader = new FileReader();
|
| 1364 |
+
reader.onload = function(e) {
|
| 1365 |
+
importFileContent = e.target.result;
|
| 1366 |
+
importConfirmationModal.classList.remove('hidden');
|
| 1367 |
+
};
|
| 1368 |
+
reader.readAsText(file);
|
| 1369 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1370 |
|
| 1371 |
+
function processImport(mode) {
|
| 1372 |
+
if (!importFileContent) {
|
| 1373 |
+
alert('No file content to import');
|
| 1374 |
+
return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1375 |
}
|
| 1376 |
+
|
| 1377 |
+
const lines = importFileContent.split(/\r?\n/).filter(line => line.trim() !== '');
|
| 1378 |
+
|
| 1379 |
+
if (lines.length < 2) {
|
| 1380 |
+
alert("CSV file must contain at least one header row and one data row");
|
| 1381 |
+
return;
|
| 1382 |
+
}
|
| 1383 |
+
|
| 1384 |
+
// Parse headers and create mapping
|
| 1385 |
+
const headers = parseCSVLine(lines[0]).map(h => h.trim());
|
| 1386 |
+
const headerMap = createHeaderMap();
|
| 1387 |
+
|
| 1388 |
+
// Skip header row and process data
|
| 1389 |
+
const importedEmployees = [];
|
| 1390 |
+
for (let i = 1; i < lines.length; i++) {
|
| 1391 |
+
if (!lines[i].trim()) continue;
|
| 1392 |
+
|
| 1393 |
+
try {
|
| 1394 |
+
const values = parseCSVLine(lines[i]);
|
| 1395 |
+
if (values.length !== headers.length) {
|
| 1396 |
+
console.warn(`Skipping line ${i+1}: number of values doesn't match headers`);
|
| 1397 |
+
continue;
|
| 1398 |
+
}
|
| 1399 |
+
|
| 1400 |
+
const employee = mapValuesToEmployee(values, headers, headerMap);
|
| 1401 |
+
if (!employee.firstName || !employee.lastName) {
|
| 1402 |
+
console.warn(`Skipping line ${i+1}: missing required fields (firstName or lastName)`);
|
| 1403 |
+
continue;
|
| 1404 |
+
}
|
| 1405 |
|
| 1406 |
+
// Generate employee ID if not provided
|
| 1407 |
+
if (!employee.employeeId) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1408 |
const newId = employees.length > 0 ? Math.max(...employees.map(e => e.id)) + 1 : 1;
|
| 1409 |
+
employee.employeeId = `EMP-${1000 + newId}`;
|
| 1410 |
}
|
| 1411 |
|
| 1412 |
+
importedEmployees.push(employee);
|
| 1413 |
+
} catch (error) {
|
| 1414 |
+
console.error(`Error processing line ${i+1}:`, error);
|
| 1415 |
+
}
|
| 1416 |
+
}
|
| 1417 |
+
|
| 1418 |
+
// Process based on selected mode
|
| 1419 |
+
let added = 0;
|
| 1420 |
+
let updated = 0;
|
| 1421 |
+
|
| 1422 |
+
switch(mode) {
|
| 1423 |
+
case 'append':
|
| 1424 |
+
// Add all imported employees as new records
|
| 1425 |
+
importedEmployees.forEach(importedEmp => {
|
| 1426 |
+
// Check if an employee with the same employeeId already exists
|
| 1427 |
+
const existingIndex = employees.findIndex(e => e.employeeId === importedEmp.employeeId);
|
| 1428 |
+
if (existingIndex >= 0) {
|
| 1429 |
+
// If it exists, generate a new unique employeeId
|
| 1430 |
+
const newId = employees.length > 0 ? Math.max(...employees.map(e => e.id)) + 1 : 1;
|
| 1431 |
+
importedEmp.employeeId = `EMP-${1000 + newId}`;
|
| 1432 |
+
}
|
| 1433 |
+
|
| 1434 |
+
// Assign a new unique id
|
| 1435 |
importedEmp.id = employees.length > 0 ? Math.max(...employees.map(e => e.id)) + 1 : 1;
|
| 1436 |
employees.push(importedEmp);
|
| 1437 |
added++;
|
| 1438 |
+
});
|
| 1439 |
+
break;
|
| 1440 |
+
|
| 1441 |
+
case 'merge':
|
| 1442 |
+
// Merge - update existing and add new
|
| 1443 |
+
importedEmployees.forEach(importedEmp => {
|
| 1444 |
+
const existingIndex = employees.findIndex(e => e.employeeId === importedEmp.employeeId);
|
| 1445 |
+
if (existingIndex >= 0) {
|
| 1446 |
+
// Update existing, preserve the internal ID
|
| 1447 |
+
const originalId = employees[existingIndex].id;
|
| 1448 |
+
employees[existingIndex] = {
|
| 1449 |
+
...importedEmp,
|
| 1450 |
+
id: originalId // Preserve internal ID
|
| 1451 |
+
};
|
| 1452 |
+
updated++;
|
| 1453 |
+
} else {
|
| 1454 |
+
// Add new with a fresh internal ID
|
| 1455 |
+
importedEmp.id = employees.length > 0 ? Math.max(...employees.map(e => e.id)) + 1 : 1;
|
| 1456 |
+
employees.push(importedEmp);
|
| 1457 |
+
added++;
|
| 1458 |
+
}
|
| 1459 |
+
});
|
| 1460 |
+
break;
|
| 1461 |
+
|
| 1462 |
+
case 'replace':
|
| 1463 |
+
// Replace all existing with imported, assigning new IDs
|
| 1464 |
+
let idCounter = 1;
|
| 1465 |
+
importedEmployees.forEach(emp => {
|
| 1466 |
+
if (!emp.id) {
|
| 1467 |
+
emp.id = idCounter++;
|
| 1468 |
+
}
|
| 1469 |
+
});
|
| 1470 |
+
employees = importedEmployees;
|
| 1471 |
+
added = importedEmployees.length;
|
| 1472 |
+
break;
|
| 1473 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1474 |
|
| 1475 |
+
// Save to localStorage and update UI
|
| 1476 |
+
saveEmployees();
|
| 1477 |
+
extractDepartmentsFromEmployees();
|
| 1478 |
+
saveDepartments();
|
| 1479 |
+
updateDepartmentFilterOptions();
|
| 1480 |
+
filterEmployees();
|
| 1481 |
|
| 1482 |
+
// Close modal and reset
|
| 1483 |
+
importConfirmationModal.classList.add('hidden');
|
| 1484 |
+
fileInput.value = '';
|
| 1485 |
+
importFileContent = null;
|
| 1486 |
|
| 1487 |
+
// Show results
|
| 1488 |
+
let message = `Import completed successfully. `;
|
| 1489 |
+
if (mode === 'merge') {
|
| 1490 |
+
message += `${added} new employees added, ${updated} existing employees updated.`;
|
| 1491 |
+
} else {
|
| 1492 |
+
message += `${added} employees imported.`;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1493 |
}
|
| 1494 |
|
| 1495 |
+
alert(message);
|
| 1496 |
}
|
| 1497 |
|
| 1498 |
+
function createHeaderMap() {
|
| 1499 |
+
return {
|
| 1500 |
+
'ID': 'id',
|
| 1501 |
+
'Employee ID': 'employeeId',
|
| 1502 |
+
'First Name': 'firstName',
|
| 1503 |
+
'Last Name': 'lastName',
|
| 1504 |
+
'Email': 'email',
|
| 1505 |
+
'Phone': 'phone',
|
| 1506 |
+
'Birth Date': 'birthDate',
|
| 1507 |
+
'Civil Status': 'civilStatus',
|
| 1508 |
+
'Department': 'department',
|
| 1509 |
+
'Position': 'position',
|
| 1510 |
+
'Hire Date': 'hireDate',
|
| 1511 |
+
'Salary': 'salary',
|
| 1512 |
+
'Status': 'status',
|
| 1513 |
+
'SSS Number': 'sssNumber',
|
| 1514 |
+
'PhilHealth Number': 'philhealthNumber',
|
| 1515 |
+
'Pag-IBIG Number': 'pagibigNumber',
|
| 1516 |
+
'TIN Number': 'tinNumber',
|
| 1517 |
+
'Passport Number': 'passportNumber',
|
| 1518 |
+
'Passport Expiry': 'passportExpiry',
|
| 1519 |
+
'National ID': 'nationalId',
|
| 1520 |
+
'Driver\'s License': 'driversLicense',
|
| 1521 |
+
'EmployeeId': 'employeeId',
|
| 1522 |
+
'Firstname': 'firstName',
|
| 1523 |
+
'Lastname': 'lastName',
|
| 1524 |
+
'SSS': 'sssNumber',
|
| 1525 |
+
'Philhealth': 'philhealthNumber',
|
| 1526 |
+
'Pag-ibig': 'pagibigNumber',
|
| 1527 |
+
'TIN': 'tinNumber'
|
| 1528 |
+
};
|
| 1529 |
+
}
|
| 1530 |
|
| 1531 |
+
function mapValuesToEmployee(values, headers, headerMap) {
|
| 1532 |
+
const employee = {};
|
| 1533 |
|
| 1534 |
+
for (let j = 0; j < headers.length; j++) {
|
| 1535 |
+
const header = headers[j].trim();
|
| 1536 |
+
let value = values[j] || '';
|
| 1537 |
+
|
| 1538 |
+
if (!headerMap[header] || value === '') continue;
|
| 1539 |
+
|
| 1540 |
+
const propName = headerMap[header];
|
| 1541 |
+
|
| 1542 |
+
// Type conversion
|
| 1543 |
+
if (propName === 'salary') {
|
| 1544 |
+
value = parseFloat(value.replace(/[^\d.]/g, '')) || 0;
|
| 1545 |
+
} else if (propName === 'id') {
|
| 1546 |
+
// Convert id to integer
|
| 1547 |
+
value = parseInt(value) || null;
|
| 1548 |
+
} else if (propName === 'hireDate' || propName === 'birthDate' || propName === 'passportExpiry') {
|
| 1549 |
+
// Date formatting
|
| 1550 |
+
if (/^\d{1,2}\/\d{1,2}\/\d{4}$/.test(value)) {
|
| 1551 |
+
const [month, day, year] = value.split('/');
|
| 1552 |
+
value = `${year}-${month.padStart(2, '0')}-${day.padStart(2, '0')}`;
|
| 1553 |
+
}
|
| 1554 |
+
const date = new Date(value);
|
| 1555 |
+
if (!isNaN(date.getTime())) {
|
| 1556 |
+
value = date.toISOString().split('T')[0];
|
| 1557 |
+
}
|
| 1558 |
+
}
|
| 1559 |
+
|
| 1560 |
+
employee[propName] = value;
|
| 1561 |
}
|
| 1562 |
|
| 1563 |
+
return employee;
|
| 1564 |
+
}
|
|
|
|
|
|
|
| 1565 |
|
| 1566 |
+
function parseCSVLine(line) {
|
| 1567 |
+
const values = [];
|
| 1568 |
+
let current = '';
|
| 1569 |
+
let inQuotes = false;
|
| 1570 |
+
let inEscape = false;
|
| 1571 |
|
| 1572 |
+
for (let i = 0; i < line.length; i++) {
|
| 1573 |
+
const char = line[i];
|
|
|
|
|
|
|
|
|
|
| 1574 |
|
| 1575 |
+
if (inEscape) {
|
| 1576 |
+
current += char;
|
| 1577 |
+
inEscape = false;
|
| 1578 |
+
continue;
|
| 1579 |
+
}
|
| 1580 |
+
|
| 1581 |
+
if (char === '\\') {
|
| 1582 |
+
inEscape = true;
|
| 1583 |
+
continue;
|
| 1584 |
+
}
|
| 1585 |
+
|
| 1586 |
+
if (char === '"') {
|
| 1587 |
+
inQuotes = !inQuotes;
|
| 1588 |
+
continue;
|
| 1589 |
+
}
|
| 1590 |
|
| 1591 |
+
if (char === ',' && !inQuotes) {
|
| 1592 |
+
values.push(current);
|
| 1593 |
+
current = '';
|
| 1594 |
+
continue;
|
| 1595 |
+
}
|
| 1596 |
|
| 1597 |
+
current += char;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1598 |
}
|
|
|
|
|
|
|
|
|
|
| 1599 |
|
| 1600 |
+
// Add the last value
|
| 1601 |
+
values.push(current);
|
|
|
|
|
|
|
| 1602 |
|
| 1603 |
+
// Trim whitespace and remove surrounding quotes if present
|
| 1604 |
+
return values.map(val => {
|
| 1605 |
+
val = val.trim();
|
| 1606 |
+
if (val.startsWith('"') && val.endsWith('"')) {
|
| 1607 |
+
return val.slice(1, -1);
|
| 1608 |
+
}
|
| 1609 |
+
return val;
|
| 1610 |
+
});
|
| 1611 |
+
}
|
| 1612 |
+
|
| 1613 |
+
function openClearAllConfirmationModal() {
|
| 1614 |
+
clearAllConfirmationModal.classList.remove('hidden');
|
| 1615 |
+
}
|
| 1616 |
+
|
| 1617 |
+
function clearAllEmployees() {
|
| 1618 |
+
employees = [];
|
| 1619 |
+
saveEmployees();
|
| 1620 |
+
allDepartments = [];
|
| 1621 |
+
saveDepartments();
|
| 1622 |
+
updateDepartmentFilterOptions();
|
| 1623 |
+
filterEmployees();
|
| 1624 |
+
clearAllConfirmationModal.classList.add('hidden');
|
| 1625 |
+
alert('All employee data has been cleared.');
|
| 1626 |
+
}
|
| 1627 |
+
</script>
|
| 1628 |
+
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=poluser/hr-test" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p><p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=poluser/Employee-Management" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
|
| 1629 |
</html>
|
prompts.txt
CHANGED
|
@@ -1,7 +1,4 @@
|
|
| 1 |
-
make
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
this code works, except for the edit function that only edits the top of the row data. it should not do that. retain the rest of the code the fix the Edit Function for each row not for a single row
|
| 6 |
-
I want to add a capability to double click an entry and immediately enter edit mode
|
| 7 |
-
retain all code, implement double-click row functionality for your SteelCraft Payroll System. This feature will allow users to edit an employee record by simply double-clicking anywhere on the row.
|
|
|
|
| 1 |
+
retain all code. make it so that the user is capable to select the data that will be shown in the columns
|
| 2 |
+
code is not working , redo it please
|
| 3 |
+
i want to make this site more dynamic but enabling user to select data that will be shown based on the employee data information. All codes here works and is perfect.
|
| 4 |
+
its incomplete, please complete the code, its working already on some of the codes
|
|
|
|
|
|
|
|
|