diff --git a/app.html b/app.html index 767b778..c076569 100644 --- a/app.html +++ b/app.html @@ -4,7 +4,6 @@ ПАБ — Система - "+h+"");w.document.close()} function downloadSummaryHTML(){var a=getA(),all=allU(),t=a.length;var w=window.open("","_blank","width=800,height=600");w.document.write("Отчёт ПАБ

📊 Сводный отчёт ПАБ

Сформирован: "+new Date().toLocaleString("ru")+" | Всего аудитов: "+t+"

📋 Аудиты

"+a.map(function(x){return""}).join("")+"
ДатаМестоНаблюдательСтатусНарушений
"+(x.number||"—")+""+x.date+""+x.location+""+x.observer+""+(x.overallSafe?"Безопасно":"Нарушения")+""+(x.totalViolations||0)+"
");w.document.close()} diff --git a/index.html b/index.html index 8dbb287..7bd7478 100644 --- a/index.html +++ b/index.html @@ -57,20 +57,14 @@ document.getElementById('lb').onclick=function(){ var u=document.getElementById('lu').value.trim().toLowerCase(); var p=document.getElementById('lp').value.trim(); if(u==='admin'&&p==='admin'){sessionStorage.setItem('pab_user',JSON.stringify({login:'admin',name:'Администратор',role:'Руководитель',freq:'0,month',email:'admin@telecom.kz',branch:'АО «Казахтелеком»',dept:'ЦА',region:'Центральный',oblast:'—',city:'г. Астана'}));location.href='app.html';return} - var users={};try{users=JSON.parse(localStorage.getItem('pab_users')||'{}')}catch(e){} - if(users[u]&&users[u].pass===p){sessionStorage.setItem('pab_user',JSON.stringify({login:u,name:users[u].name,role:users[u].role,freq:users[u].freq||'',email:users[u].email||'',branch:users[u].branch||'',dept:users[u].dept||'',region:users[u].region||'',oblast:users[u].oblast||'',city:users[u].city||''}));location.href='app.html';return} - // Проверяем через Supabase - var SBU="https://znexbjafkvyjffffbhlf.supabase.co",SBK="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InpuZXhiamFma3Z5amZmZmZiaGxmIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImlhdCI6MTc4MDY0NDE4MiwiZXhwIjoyMDk2MjIwMTgyfQ.5pOYTkL5eCmpSHBY3EwKof6NVKt7tL4Fn8xUAKM8itE"; - fetch(SBU+"/rest/v1/users?login=eq."+encodeURIComponent(u),{headers:{"apikey":SBK,"Authorization":"Bearer "+SBK}}).then(function(r){return r.json()}).then(function(data){if(data.length>0&&data[0].pass===p){var ud=data[0];sessionStorage.setItem('pab_user',JSON.stringify({login:ud.login,name:ud.name,role:ud.role,freq:ud.freq||'',email:ud.email||'',branch:ud.branch||'',dept:ud.dept||'',region:ud.region||'',oblast:ud.oblast||'',city:ud.city||''}));location.href='app.html'}else{document.getElementById('lerr').style.display='block'}}).catch(function(){document.getElementById('lerr').style.display='block'}); + var users={};try{users=JSON.parse(localStorage.getItem('pab_users')||'{}')}catch(e){}if(users[u]&&users[u].pass===p){sessionStorage.setItem('pab_user',JSON.stringify({login:u,name:users[u].name,role:users[u].role,freq:users[u].freq||'',email:users[u].email||'',branch:users[u].branch||'',dept:users[u].dept||'',region:users[u].region||'',oblast:users[u].oblast||'',city:users[u].city||''}));location.href='app.html';return} + document.getElementById('lerr').style.display='block' }; document.getElementById('lp').onkeydown=function(e){if(e.key==='Enter')document.getElementById('lb').onclick()}; document.getElementById('rbb').onclick=function(){ var l=document.getElementById('rl').value.trim().toLowerCase(),p=document.getElementById('rp').value.trim(),n=document.getElementById('rn').value.trim(),em=document.getElementById('re').value.trim(),r=document.getElementById('rr').value,fr=document.getElementById('rf').value,br=document.getElementById('rb').value.trim(),dp=document.getElementById('rd').value.trim(),rg=document.getElementById('rg').value.trim(),ob=document.getElementById('ro').value.trim(),ct=document.getElementById('rc').value.trim(); var e=document.getElementById('rerr'),ok=document.getElementById('rok');ok.style.display='none';if(!l||l.length<2){e.textContent='Логин мин. 2 символа';e.style.display='block';return}if(!p||p.length<3){e.textContent='Пароль мин. 3 символа';e.style.display='block';return}if(!n){e.textContent='Укажите ФИО';e.style.display='block';return}if(!r){e.textContent='Выберите должность';e.style.display='block';return}if(!em||em.indexOf('@')<0){e.textContent='Укажите Email';e.style.display='block';return}if(!br){e.textContent='Укажите филиал';e.style.display='block';return}if(!rg){e.textContent='Укажите регион';e.style.display='block';return}if(!ct){e.textContent='Укажите город';e.style.display='block';return}if(!dp){e.textContent='Укажите подразделение';e.style.display='block';return}if(!fr){e.textContent='Укажите периодичность ПАБ';e.style.display='block';return} - var users={};try{users=JSON.parse(localStorage.getItem('pab_users')||'{}')}catch(e){}if(users[l]){e.textContent='Логин занят';e.style.display='block';return}e.style.display='none';users[l]={pass:p,name:n,email:em,role:r,freq:fr,branch:br,dept:dp,region:rg,oblast:ob,city:ct};localStorage.setItem('pab_users',JSON.stringify(users));ok.style.display='block'; - // Отправка в Supabase - try{var SBU="https://znexbjafkvyjffffbhlf.supabase.co",SBK="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InpuZXhiamFma3Z5amZmZmZiaGxmIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImlhdCI6MTc4MDY0NDE4MiwiZXhwIjoyMDk2MjIwMTgyfQ.5pOYTkL5eCmpSHBY3EwKof6NVKt7tL4Fn8xUAKM8itE";fetch(SBU+"/rest/v1/users",{method:"POST",headers:{"apikey":SBK,"Authorization":"Bearer "+SBK,"Content-Type":"application/json","Prefer":"resolution=merge-duplicates"},body:JSON.stringify({login:l,pass:p,name:n,email:em,role:r,freq:fr,branch:br,dept:dp,region:rg,oblast:ob,city:ct})}).then(function(r){console.log("SB reg:",r.ok?"OK":r.status)})}catch(e){} - document.getElementById('lu').value=l;setTimeout(function(){ok.style.display='none';document.getElementById('tL').onclick()},2000) + var users={};try{users=JSON.parse(localStorage.getItem('pab_users')||'{}')}catch(e){}if(users[l]){e.textContent='Логин занят';e.style.display='block';return}e.style.display='none';users[l]={pass:p,name:n,email:em,role:r,freq:fr,branch:br,dept:dp,region:rg,oblast:ob,city:ct};localStorage.setItem('pab_users',JSON.stringify(users));ok.style.display='block';document.getElementById('lu').value=l;setTimeout(function(){ok.style.display='none';document.getElementById('tL').onclick()},2000) };