v10: Отчеты — фильтры по ФИО, филиалу, месту дислокации, статистика пересчитывается

This commit is contained in:
aliya_kairzhanova 2026-06-04 11:02:19 +00:00
parent de425d80fd
commit d64f547ae9

View File

@ -660,6 +660,19 @@ tr:hover td { background: var(--cyan-50); }
<!-- TAB: Отчеты --> <!-- TAB: Отчеты -->
<div class="panel" id="tab-reports"> <div class="panel" id="tab-reports">
<div class="toolbar">
<input type="text" id="repFilterName" placeholder="🔍 Фамилия работника..." oninput="renderReports()">
<select id="repFilterBranch" onchange="renderReports()">
<option value="">Все филиалы</option>
<option>ДКБ</option><option>ДРБ</option><option>ДТК</option><option>ДЦБСФ</option><option>ОДС</option>
</select>
<select id="repFilterLocation" onchange="renderReports()">
<option value="">Все локации</option>
<option>Акмолинская область</option><option>г. Астана</option><option>г. Шымкент</option>
<option>Жамбылская область</option><option>Карагандинская область</option><option>Туркестанская область</option>
</select>
<button class="btn btn-outline" onclick="document.getElementById('repFilterName').value='';document.getElementById('repFilterBranch').value='';document.getElementById('repFilterLocation').value='';renderReports();">Сброс</button>
</div>
<div class="stats"> <div class="stats">
<div class="stat-card"> <div class="stat-card">
<div class="stat-label">Работников</div> <div class="stat-label">Работников</div>
@ -687,7 +700,7 @@ tr:hover td { background: var(--cyan-50); }
<div class="table-wrap" style="margin-top:20px;"> <div class="table-wrap" style="margin-top:20px;">
<table> <table>
<thead> <thead>
<tr><th>Работник</th><th>Должность</th><th>Выдано позиций</th><th>Из них просрочено</th></tr> <tr><th>Работник</th><th>Филиал</th><th>Дислокация</th><th>Должность</th><th>Выдано позиций</th><th>Из них просрочено</th></tr>
</thead> </thead>
<tbody id="repTable"></tbody> <tbody id="repTable"></tbody>
</table> </table>
@ -1723,26 +1736,35 @@ function renderControl() {
// ===================== REPORTS ===================== // ===================== REPORTS =====================
function renderReports() { function renderReports() {
const employees = DB.employees; let employees = DB.employees;
const sizList = DB.siz; const sizList = DB.siz;
const warehouse = DB.warehouse; const warehouse = DB.warehouse;
const issuances = DB.issuances; const issuances = DB.issuances;
const q = (document.getElementById('repFilterName').value || '').toLowerCase();
const fb = document.getElementById('repFilterBranch').value;
const fl = document.getElementById('repFilterLocation').value;
if (q) employees = employees.filter(e => (e.fullName || '').toLowerCase().includes(q));
if (fb) employees = employees.filter(e => e.branch === fb);
if (fl) employees = employees.filter(e => e.location === fl);
const empIds = new Set(employees.map(e => e.id));
document.getElementById('repEmployees').textContent = employees.length; document.getElementById('repEmployees').textContent = employees.length;
document.getElementById('repSiz').textContent = sizList.length; document.getElementById('repSiz').textContent = sizList.length;
let totalStock = 0, totalIssued = 0, totalExpired = 0; let totalStock = 0;
sizList.forEach(s => { sizList.forEach(s => { totalStock += getStockBalance(s.id); });
totalStock += getStockBalance(s.id);
}); let totalIssued = 0, totalExpired = 0;
issuances.forEach(i => { issuances.forEach(i => {
if (i.status !== 'returned') { if (!empIds.has(i.employeeId)) return;
totalIssued += i.quantity; const qty = i.quantity;
if (getIssStatus(i) === 'expired') totalExpired += i.quantity; totalIssued += qty;
} else { if (getIssStatus(i) === 'expired') totalExpired += qty;
totalIssued += i.quantity;
}
}); });
document.getElementById('repStock').textContent = totalStock; document.getElementById('repStock').textContent = totalStock;
document.getElementById('repIssued').textContent = totalIssued; document.getElementById('repIssued').textContent = totalIssued;
document.getElementById('repExpired').textContent = totalExpired; document.getElementById('repExpired').textContent = totalExpired;
@ -1753,6 +1775,8 @@ function renderReports() {
const expiredCount = empIss.filter(i => getIssStatus(i) === 'expired').length; const expiredCount = empIss.filter(i => getIssStatus(i) === 'expired').length;
return `<tr> return `<tr>
<td><span class="emp-name-link" onclick="showEmpHistory('${e.id}')">${e.fullName}</span></td> <td><span class="emp-name-link" onclick="showEmpHistory('${e.id}')">${e.fullName}</span></td>
<td>${e.branch || '—'}</td>
<td>${e.location || '—'}</td>
<td>${e.position}</td> <td>${e.position}</td>
<td>${issuedCount}</td> <td>${issuedCount}</td>
<td>${expiredCount ? '<span class="badge badge-red">' + expiredCount + '</span>' : '<span class="badge badge-green">0</span>'}</td> <td>${expiredCount ? '<span class="badge badge-red">' + expiredCount + '</span>' : '<span class="badge badge-green">0</span>'}</td>