release 2.0

This commit is contained in:
2025-12-23 03:09:27 +03:00
parent 16c2622d13
commit f99fd8118c
9 changed files with 115 additions and 47 deletions
+5 -5
View File
@@ -27,7 +27,7 @@
/* Таблица сотрудников */
.table-responsive {
max-height: 800px;
max-height: 950px;
overflow-y: auto;
}
@@ -77,22 +77,22 @@
}
.status-enabled {
background-color: rgba(25, 135, 84, 0.1);
background-color: rgba(25, 135, 84, 0.5);
color: #198754;
}
.status-disabled {
background-color: rgba(108, 117, 125, 0.1);
background-color: rgba(108, 117, 125, 0.2);
color: #6c757d;
}
.status-data {
background-color: rgba(13, 110, 253, 0.1);
background-color: rgba(13, 110, 253, 0.5);
color: #0d6efd;
}
.status-nodata {
background-color: rgba(220, 53, 69, 0.1);
background-color: rgba(220, 53, 69, 0.5);
color: #dc3545;
}
+56 -7
View File
@@ -7,6 +7,8 @@ let schedulerFormChanged = false;
let originalUserData = null;
let originalSchedulerData = null;
let pendingUserSwitch = null;
const monthNames = ['января', 'февраля', 'марта', 'апреля', 'мая', 'июня', 'июля', 'августа', 'сентября', 'октября', 'ноября', 'декабря'];
// Инициализация при загрузке страницы
document.addEventListener('DOMContentLoaded', function () {
@@ -18,6 +20,7 @@ document.addEventListener('DOMContentLoaded', function () {
// Устанавливаем обработчики событий
setupEventListeners();
});
// Загрузка списка сотрудников
@@ -28,6 +31,8 @@ async function loadUsersList() {
if (data.status === 'ok') {
usersData = data.users;
// Определение ближайшего дня рождения
findNearestBirthday();
renderUsersTable();
} else {
showAlert('danger', 'Ошибка загрузки списка сотрудников');
@@ -39,6 +44,53 @@ async function loadUsersList() {
}
}
function findNearestBirthday() {
const today = new Date();
today.setHours(0, 0, 0, 0);
let nextBirthday = null;
let nextBirthdayUserData = null;
for (const user of usersData) {
if (!user.enabled || !user.birthdate) continue;
const birthdate = new Date(user.birthdate);
// День рождения в текущем году
let candidate = new Date(
today.getFullYear(),
birthdate.getMonth(),
birthdate.getDate()
);
// Если уже прошёл — переносим на следующий год
if (candidate < today) {
candidate.setFullYear(today.getFullYear() + 1);
}
if (!nextBirthday || candidate < nextBirthday) {
nextBirthday = candidate;
const age = candidate.getFullYear() - birthdate.getFullYear();
nextBirthdayUserData = {
date: new Intl.DateTimeFormat('ru-RU', { month: 'long', day: 'numeric' })
.format(new Date(user.birthdate)),
name: user.name,
age
};
}
}
const nextBirthdayElement = document.getElementById('nextBirthday');
if (nextBirthdayUserData) {
nextBirthdayElement.textContent = `${nextBirthdayUserData.date} ${nextBirthdayUserData.name} исполнится ${nextBirthdayUserData.age} лет 🎉`;
}
return nextBirthdayUserData;
}
// Отображение таблицы сотрудников
function renderUsersTable() {
const tbody = document.getElementById('usersTableBody');
@@ -81,14 +133,11 @@ function renderUsersTable() {
const birthdate = new Date(user.birthdate);
const now = new Date();
const age = now.getFullYear() - birthdate.getFullYear();
const month = birthdate.getMonth() + 1;
const day = birthdate.getDate();
const fullDate = birthdate.toLocaleDateString('ru-RU');
// Форматируем месяц и день (двузначные)
const monthNames = ['января', 'февраля', 'марта', 'апреля', 'мая', 'июня', 'июля', 'августа', 'сентября', 'октября', 'ноября', 'декабря'];
const monthStr = monthNames[month - 1];
const dayStr = day.toString().padStart(2, '0');
const dateText = new Intl.DateTimeFormat('ru-RU', { month: 'long', day: 'numeric' })
.format(new Date(user.birthdate));
// Определяем пол
const sexBadge = user.sex === 'male' ?
@@ -121,7 +170,7 @@ function renderUsersTable() {
<tr class="${isSelected}" onclick="selectUser(${user.id})" data-user-id="${user.id}">
<td>
<div class="birthdate-cell">
<span class="month-day">${dayStr} ${monthStr}</span>
<span class="month-day">${dateText}</span>
</div>
</td>
<td>
@@ -134,7 +183,7 @@ function renderUsersTable() {
</td>
<td>${sexBadge}</td>
<td>${specialtiesHtml}</td>
<td class="text-center">${enabledStatus} ${dataStatus}</td>
<td class="text-center">${enabledStatus} ${user.enabled ? dataStatus : ''}</td>
</tr>
`;
});