@@ -1299,6 +1333,7 @@ function renderNorms() {
${n.quantity} ${(DB.siz.find(s=>s.id===n.sizId)||{}).unit||'шт.'} |
${n.note || '—'} |
+
|
@@ -1306,6 +1341,61 @@ function renderNorms() {
document.getElementById('normEmpty').style.display = list.length ? 'none' : 'block';
}
+function normPickEmployee(normId) {
+ const norm = DB.norms.find(n => n.id === normId);
+ if (!norm) return;
+ const siz = DB.siz.find(s => s.id === norm.sizId);
+ const sizName = siz ? siz.name : '—';
+ const unit = siz ? siz.unit : 'шт.';
+ const zone = norm.climateZone || '0';
+
+ document.getElementById('normIssueTitle').textContent = 'Выдать СИЗ';
+ document.getElementById('normIssueInfo').innerHTML = `
${sizName} × ${norm.quantity} ${unit} — ${monthsToText(norm.wearMonths)}
Должность: ${norm.position}, ${climateZoneLabel(zone)}`;
+
+ let employees = DB.employees;
+ if (zone !== '0') {
+ employees = employees.filter(e => e.position === norm.position && (e.climateZone || '0') === zone);
+ if (employees.length === 0) employees = DB.employees.filter(e => e.position === norm.position && (e.climateZone || '0') === '0');
+ if (employees.length === 0) employees = DB.employees.filter(e => e.position === norm.position);
+ } else {
+ employees = DB.employees.filter(e => e.position === norm.position);
+ }
+
+ document.getElementById('normIssueList').innerHTML = employees.length
+ ? employees.map(e => `
+
+
${e.fullName}
+
Таб. № ${e.tabNum} • ${e.department} • ${climateZoneLabel(e.climateZone||'0')}
+
+
+
`).join('')
+ : `
Нет работников с должностью «${norm.position}»${zone!=='0'?' в поясе '+climateZoneLabel(zone):''}.
`;
+
+ openModal('normIssueModal');
+}
+
+function normDoIssue(normId, empId) {
+ const norm = DB.norms.find(n => n.id === normId);
+ if (!norm) return;
+ const dateIssued = todayStr();
+ const expireDate = new Date(dateIssued);
+ expireDate.setMonth(expireDate.getMonth() + norm.wearMonths);
+ const dateExpire = expireDate.toISOString().slice(0, 10);
+ let status = dateExpire < todayStr() ? 'expired' : 'active';
+ DB.issuances = [...DB.issuances, {
+ id: uid(),
+ employeeId: empId,
+ sizId: norm.sizId,
+ quantity: norm.quantity,
+ dateIssued,
+ dateExpire,
+ status,
+ notes: norm.note || '',
+ }];
+ closeModal('normIssueModal');
+ renderIssuances();
+}
+
// ===================== ISSUANCE — SHOW NORMS =====================
function showNormsForEmployee() {
const empId = document.getElementById('issEmployeeId').value;