diff --git a/app.html b/app.html
index 9de3099..974b078 100644
--- a/app.html
+++ b/app.html
@@ -87,7 +87,7 @@ body{font:15px/1.5 -apple-system,BlinkMacSystemFont,"Segoe UI",Inter,system-ui,s
✅ ВСЕ БЕЗОПАСНО
☐ ЕСТЬ ОПАСНО
📄 Несоответствия и меры
№НесоответствиеИсполнительВидМерыОтветственныйДатаЗавершение
-💬 Итог диалога
Результаты беседы
📎 Фото и документы — приложите к бумажному бланку.
+💬 Итог диалога
Результаты беседы
📎 Фото и документы
✅
Аудит успешно отправлен!
@@ -132,6 +132,8 @@ var vioHTML="";for(var i=0;i0?"📄 "+names.join(", "):""}
+
function setO(t){var os=document.getElementById("os"),od=document.getElementById("od");if(!os||!od)return;if(t==="safe"){os.style.background="#EDF7F0";os.style.borderColor="#2D6A4F";os.style.color="#2D6A4F";os.textContent="✅ ВСЕ БЕЗОПАСНО";od.style.background="#fff";od.style.borderColor="#E2E6EB";od.style.color="#5B6573";od.textContent="☐ ЕСТЬ ОПАСНО"}else{os.style.background="#fff";os.style.borderColor="#E2E6EB";os.style.color="#5B6573";os.textContent="☐ ВСЕ БЕЗОПАСНО";od.style.background="#FFEBED";od.style.borderColor="#E63946";od.style.color="#E63946";od.textContent="⚠️ ЕСТЬ ОПАСНО"}}
function toggleAllSafe(id){var cb=document.getElementById("ascb-"+id),tog=document.getElementById("as-"+id);if(!cb||!tog)return;var is=!cb.checked;cb.checked=is;if(is){tog.classList.add("ac2");var cat=CATS.find(function(c){return c.id===id});if(cat)cat.items.forEach(function(_,i){var e=document.getElementById("cb-"+id+"-"+i);if(e){e.checked=false;e.parentElement.classList.remove("ck")}var o=document.getElementById("other-"+id);if(o){o.style.display="none";o.classList.remove("vs")}})}else{tog.classList.remove("ac2")}updateCatTotal(id)}
function onCheckItem(id,idx){var cb=document.getElementById("cb-"+id+"-"+idx);if(!cb)return;if(cb.checked){cb.parentElement.classList.add("ck");document.getElementById("ascb-"+id).checked=false;document.getElementById("as-"+id).classList.remove("ac2")}else{cb.parentElement.classList.remove("ck")}var cat=CATS.find(function(c){return c.id===id});if(cat&&cat.items[idx]==="Другое"){var o=document.getElementById("other-"+id);if(o){if(cb.checked){o.style.display="block";o.classList.add("vs")}else{o.style.display="none";o.classList.remove("vs")}}}updateCatTotal(id)}
@@ -143,8 +145,8 @@ function getVR(){var rs=[];document.querySelectorAll("#vr .vg").forEach(function
function getDL(){var r=[];["Работник привёл примеры безопасных действий","Были обсуждены риски / проблемы","Определены корректирующие меры","Предложения работника зафиксированы","Другое"].forEach(function(l,i){var cb=document.getElementById("d"+i);if(cb&&cb.checked)r.push({item:l,other:l==="Другое"?document.getElementById("do").value.trim()||"":null})});return r}
function setDL(items){for(var i=0;i<5;i++){var cb=document.getElementById("d"+i);if(cb)cb.checked=false}var o=document.getElementById("do");if(o){o.value="";o.style.display="none";o.classList.remove("vs")}items.forEach(function(di){var idx=["Работник привёл примеры безопасных действий","Были обсуждены риски / проблемы","Определены корректирующие меры","Предложения работника зафиксированы","Другое"].indexOf(di.item);if(idx>=0){var cb=document.getElementById("d"+idx);if(cb){cb.checked=true;if(di.item==="Другое"&&di.other){var oo=document.getElementById("do");oo.value=di.other;oo.style.display="block";oo.classList.add("vs")}}}})}
-function submitAudit(){if(editId&&!isA()){alert("Только администратор");return}var loc=document.getElementById("pl").value.trim();if(!loc){alert("Укажите место");return}var cats={},tv=0;CATS.forEach(function(cat){var ch=[];cat.items.forEach(function(item,i){var cb=document.getElementById("cb-"+cat.id+"-"+i);if(cb&&cb.checked){var ov=item==="Другое"?(document.getElementById("other-"+cat.id).value.trim()||""):null;ch.push({item:item,other:ov})}});cats[cat.id]={items:ch,allSafe:ch.length===0};tv+=ch.length});var e={id:editId||Date.now(),number:document.getElementById("pn").value.trim(),date:document.getElementById("pd").value,timeStart:document.getElementById("ps").value,timeEnd:document.getElementById("pe").value,location:loc,region:document.getElementById("pr").value,workType:document.getElementById("pw").value.trim(),workerCount:parseInt(document.getElementById("pc").value)||1,observer:document.getElementById("po").value.trim()||U.name,observerRole:document.getElementById("por").value.trim(),supervisor:document.getElementById("psv").value.trim(),supervisorRole:document.getElementById("psr").value.trim(),email:document.getElementById("pem").value.trim()||U.email||"",overallSafe:document.getElementById("os").classList.contains("sel"),categories:cats,totalViolations:tv,violations:getVR(),dialogue:getDL(),createdBy:U.login,createdAt:new Date().toISOString()};var audits=getA();if(editId){audits=audits.map(function(a){return a.id===editId?e:a});editId=null}else{audits.unshift(e)}saveA(audits);lastSubmitted=e;resetF();document.getElementById("sd").innerHTML="Бланк №"+(e.number||"—")+" | "+e.date+" | "+(e.overallSafe?"БЕЗОПАСНО":"НАРУШЕНИЙ: "+e.totalViolations)+"";document.getElementById("fs").style.display="block";setTimeout(function(){document.getElementById("fs").style.display="none"},30000);if(!isA())checkSA()}
-function resetF(){document.getElementById("pn").value="";document.getElementById("pd").value=new Date().toISOString().split("T")[0];document.getElementById("ps").value="";document.getElementById("pe").value="";document.getElementById("pl").value="";document.getElementById("pr").value=U.region||"";document.getElementById("pw").value="";document.getElementById("pc").value="1";document.getElementById("po").value=U.name;document.getElementById("por").value="";document.getElementById("psv").value="";document.getElementById("psr").value="";document.getElementById("pem").value=U.email||"";setO("safe");editId=null;CATS.forEach(function(cat){document.getElementById("ascb-"+cat.id).checked=true;document.getElementById("as-"+cat.id).classList.add("ac2");cat.items.forEach(function(_,i){var cb=document.getElementById("cb-"+cat.id+"-"+i);if(cb){cb.checked=false;cb.parentElement.classList.remove("ck")}var o=document.getElementById("other-"+cat.id);if(o){o.value="";o.style.display="none";o.classList.remove("vs")}});updateCatTotal(cat.id)});document.getElementById("vr").innerHTML="";vrc=6;for(var i=0;iБланк №"+(e.number||"—")+" | "+e.date+" | "+(e.overallSafe?"БЕЗОПАСНО":"НАРУШЕНИЙ: "+e.totalViolations)+"";document.getElementById("fs").style.display="block";setTimeout(function(){document.getElementById("fs").style.display="none"},30000);if(!isA())checkSA()}
+function resetF(){document.getElementById("pn").value="";document.getElementById("pd").value=new Date().toISOString().split("T")[0];document.getElementById("ps").value="";document.getElementById("pe").value="";document.getElementById("pl").value="";document.getElementById("pr").value=U.region||"";document.getElementById("pw").value="";document.getElementById("pc").value="1";document.getElementById("po").value=U.name;document.getElementById("por").value="";document.getElementById("psv").value="";document.getElementById("psr").value="";document.getElementById("pem").value=U.email||"";document.getElementById("pdoc").value="";document.getElementById("pfiles").value="";document.getElementById("fileNames").textContent="";setO("safe");editId=null;CATS.forEach(function(cat){document.getElementById("ascb-"+cat.id).checked=true;document.getElementById("as-"+cat.id).classList.add("ac2");cat.items.forEach(function(_,i){var cb=document.getElementById("cb-"+cat.id+"-"+i);if(cb){cb.checked=false;cb.parentElement.classList.remove("ck")}var o=document.getElementById("other-"+cat.id);if(o){o.value="";o.style.display="none";o.classList.remove("vs")}});updateCatTotal(cat.id)});document.getElementById("vr").innerHTML="";vrc=6;for(var i=0;iПАББЛАНК ПАБ №"+(e.number||"—")+" от "+e.date+"
Место: "+e.location+" | Наблюдатель: "+e.observer+" | Статус: "+(e.overallSafe?"БЕЗОПАСНО":"НАРУШЕНИЙ: "+e.totalViolations)+"
");w.document.close()}
@@ -158,7 +160,7 @@ function rVL(){var c=document.getElementById("vlc");if(!c)return;var audits=getA
function rHT(){var audits=getA();var fs=document.getElementById("hfs"),fd=document.getElementById("hfd"),fl=document.getElementById("hfl");if(fs&&fs.value==="safe")audits=audits.filter(function(a){return a.overallSafe});if(fs&&fs.value==="danger")audits=audits.filter(function(a){return !a.overallSafe});if(fd&&fd.value)audits=audits.filter(function(a){return a.date===fd.value});if(fl&&fl.value)audits=audits.filter(function(a){var v=fl.value.toLowerCase();return a.location.toLowerCase().indexOf(v)>=0});var tb=document.getElementById("hbd");if(!tb)return;tb.innerHTML=audits.length===0?"| Нет записей |
":audits.map(function(a){var ab=isA()?"✏️ ":"чтение";return"| "+(a.number||"—")+" | "+a.date+" | "+(a.timeStart||"—")+" — "+(a.timeEnd||"—")+" | "+a.location+" | "+a.observer+" | "+(a.overallSafe?"Безопасно":"Нарушения")+" | "+(a.totalViolations||0)+" | "+ab+" |
"}).join("")}
function exportCSV(){var audits=getA();if(audits.length===0){alert("Нет данных");return}var all=allU();var h="Бланк №;Дата;Время;Место;Наблюдатель;Должность;Филиал;Регион;Область;Город;Статус;Нарушений";var rows=audits.map(function(a){var u=all[a.createdBy]||{};return(a.number||"")+";"+a.date+";"+(a.timeStart||"")+"-"+(a.timeEnd||"")+";\""+a.location+"\";\""+a.observer+"\";\""+(a.observerRole||"")+"\";\""+(u.branch||"")+"\";\""+(u.region||"")+"\";\""+(u.oblast||"")+"\";\""+(u.city||"")+"\";"+(a.overallSafe?"Безопасно":"Нарушения")+";"+(a.totalViolations||0)});var csv="\uFEFF"+h+"\n"+rows.join("\n");var blob=new Blob([csv],{type:"text/csv"});var url=URL.createObjectURL(blob);var dl=document.createElement("a");dl.href=url;dl.download="pab.csv";dl.click();URL.revokeObjectURL(url)}
-function editA(id){if(!isA()){alert("Только администратор");return}var a=getA().find(function(x){return x.id===id});if(!a)return;editId=id;swP("NA");setTimeout(function(){document.getElementById("pn").value=a.number||"";document.getElementById("pd").value=a.date||"";document.getElementById("ps").value=a.timeStart||"";document.getElementById("pe").value=a.timeEnd||"";document.getElementById("pl").value=a.location||"";document.getElementById("pr").value=a.region||"";document.getElementById("pw").value=a.workType||"";document.getElementById("pc").value=a.workerCount||1;document.getElementById("po").value=a.observer||"";document.getElementById("por").value=a.observerRole||"";document.getElementById("psv").value=a.supervisor||"";document.getElementById("psr").value=a.supervisorRole||"";document.getElementById("pem").value=a.email||"";setO(a.overallSafe?"safe":"danger");CATS.forEach(function(cat){var cd=a.categories&&a.categories[cat.id];var it=cd?cd.items:[];it.forEach(function(i){var idx=cat.items.indexOf(i.item);if(idx>=0){var cb=document.getElementById("cb-"+cat.id+"-"+idx);if(cb){cb.checked=true;cb.parentElement.classList.add("ck")}if(i.other){var o=document.getElementById("other-"+cat.id);if(o){o.value=i.other;o.style.display="block";o.classList.add("vs")}}}});document.getElementById("ascb-"+cat.id).checked=it.length===0;document.getElementById("as-"+cat.id).classList.toggle("ac2",it.length===0);updateCatTotal(cat.id)});document.getElementById("vr").innerHTML="";if(a.violations&&a.violations.length>0){vrc=a.violations.length;document.getElementById("vr").innerHTML=a.violations.map(function(v,i){return mkV(i+1,v)}).join("")}else{vrc=1;document.getElementById("vr").innerHTML=mkV(1)}setDL(a.dialogue||[])},200)}
+function editA(id){if(!isA()){alert("Только администратор");return}var a=getA().find(function(x){return x.id===id});if(!a)return;editId=id;swP("NA");setTimeout(function(){document.getElementById("pn").value=a.number||"";document.getElementById("pd").value=a.date||"";document.getElementById("ps").value=a.timeStart||"";document.getElementById("pe").value=a.timeEnd||"";document.getElementById("pl").value=a.location||"";document.getElementById("pr").value=a.region||"";document.getElementById("pw").value=a.workType||"";document.getElementById("pc").value=a.workerCount||1;document.getElementById("po").value=a.observer||"";document.getElementById("por").value=a.observerRole||"";document.getElementById("psv").value=a.supervisor||"";document.getElementById("psr").value=a.supervisorRole||"";document.getElementById("pem").value=a.email||"";document.getElementById("pdoc").value=a.docs||"";setO(a.overallSafe?"safe":"danger");CATS.forEach(function(cat){var cd=a.categories&&a.categories[cat.id];var it=cd?cd.items:[];it.forEach(function(i){var idx=cat.items.indexOf(i.item);if(idx>=0){var cb=document.getElementById("cb-"+cat.id+"-"+idx);if(cb){cb.checked=true;cb.parentElement.classList.add("ck")}if(i.other){var o=document.getElementById("other-"+cat.id);if(o){o.value=i.other;o.style.display="block";o.classList.add("vs")}}}});document.getElementById("ascb-"+cat.id).checked=it.length===0;document.getElementById("as-"+cat.id).classList.toggle("ac2",it.length===0);updateCatTotal(cat.id)});document.getElementById("vr").innerHTML="";if(a.violations&&a.violations.length>0){vrc=a.violations.length;document.getElementById("vr").innerHTML=a.violations.map(function(v,i){return mkV(i+1,v)}).join("")}else{vrc=1;document.getElementById("vr").innerHTML=mkV(1)}setDL(a.dialogue||[])},200)}
function delA(id){if(!isA()){alert("Только администратор");return}if(!confirm("Удалить?"))return;saveA(getA().filter(function(a){return a.id!==id}));rHT()}
function downloadFullCSV(){var audits=getA();if(audits.length===0){alert("Нет данных");return}var all=allU();var h="Бланк №;Дата;Время;Место;Тип;Наблюдатель;Должность;Руководитель;Филиал;Подразделение;Регион;Область;Город;Статус;Нарушений";var rows=audits.map(function(a){var u=all[a.createdBy]||{};return(a.number||"")+";"+a.date+";"+(a.timeStart||"")+"-"+(a.timeEnd||"")+";\""+a.location+"\";\""+(a.workType||"")+"\";\""+a.observer+"\";\""+(a.observerRole||"")+"\";\""+(a.supervisor||"")+"\";\""+(u.branch||"")+"\";\""+(u.dept||"")+"\";\""+(u.region||"")+"\";\""+(u.oblast||"")+"\";\""+(u.city||"")+"\";"+(a.overallSafe?"Безопасно":"Нарушения")+";"+(a.totalViolations||0)});var csv="\uFEFF"+h+"\n"+rows.join("\n");var blob=new Blob([csv],{type:"text/csv"});var url=URL.createObjectURL(blob);var dl=document.createElement("a");dl.href=url;dl.download="pab-full.csv";dl.click();URL.revokeObjectURL(url)}
function downloadWorkerReport(){var audits=getA();var all=allU();var ul=[];for(var k in all)if(k!=="admin")ul.push({login:k,name:all[k].name,role:all[k].role,branch:all[k].branch||"",dept:all[k].dept||"",region:all[k].region||"",oblast:all[k].oblast||"",city:all[k].city||"",email:all[k].email||""});if(ul.length===0){alert("Нет работников");return}var h="Логин;ФИО;Должность;Филиал;Подразделение;Регион;Область;Город;Email;График;Период;Выполнено;Нужно;Статус";var rows=ul.map(function(u){var q=getUserQuota(u);if(!q.p)return u.login+";\""+u.name+"\";\""+u.role+"\";\""+u.branch+"\";\""+u.dept+"\";\""+u.region+"\";\""+u.oblast+"\";\""+u.city+"\";\""+u.email+"\";Без графика;;;0;—";var p=gp(q.p);var done=audits.filter(function(a){return a.createdBy===u.login&&new Date(a.date)>=p.s}).length;var st=done>=q.c?"Выполнен":"Отстаёт ("+(q.c-done)+")";return u.login+";\""+u.name+"\";\""+u.role+"\";\""+u.branch+"\";\""+u.dept+"\";\""+u.region+"\";\""+u.oblast+"\";\""+u.city+"\";\""+u.email+"\";\""+q.l+"\";\""+p.l+"\";"+done+";"+q.c+";\""+st+"\""});var csv="\uFEFF"+h+"\n"+rows.join("\n");var blob=new Blob([csv],{type:"text/csv"});var url=URL.createObjectURL(blob);var dl=document.createElement("a");dl.href=url;dl.download="pab-workers.csv";dl.click();URL.revokeObjectURL(url)}