O'ZBEKISTON HARBIYLASHTIRILGAN QISMI
Ta'minot va Ombor Boshqaruvi Tizimi
Ta'minot va Ombor Tizimi
O'zbekiston Harbiylashtirilgan Qismi (UzVCh)
Bo'linma yoki xizmat
Parol
Kirish
function fillFromCat() { const c = STATE.catalog.find(x => String(x.id) === document.getElementById("catPick").value); if (c) { document.getElementById("itName").value = c.name; document.getElementById("itUnit").value = c.unit; } } function addDraftItem() { const n = document.getElementById("itName").value.trim(), u = document.getElementById("itUnit").value.trim()||"dona", q = Number(document.getElementById("itQty").value); if (n && q>0) { DRAFT_ITEMS.push({name:n,unit:u,qty:q}); renderView(); } } async function submitReq() { if (!DRAFT_ITEMS.length) return; await api("/api/request/create", { urgency: document.getElementById("reqUrg").value, reason: document.getElementById("reqReason").value, items: DRAFT_ITEMS }); DRAFT_ITEMS = []; loadAll(); } async function setReqStatus(id, status) { await api("/api/request/status", { id, status }); loadAll(); } async function addStockIn() { const n = document.getElementById("stName").value.trim(), q = Number(document.getElementById("stQty").value); if (n && q>0) { await api("/api/stock/in", { category: document.getElementById("stCat").value, name: n, unit: document.getElementById("stUnit").value||"dona", qty: q, doc: document.getElementById("stDoc").value }); loadAll(); } } async function createContract() { const n = document.getElementById("cItem").value.trim(); if (n) { await api("/api/contract/create", { itemName: n, unit: document.getElementById("cUnit").value||"dona", qty: document.getElementById("cQty").value, estPrice: document.getElementById("cPrice").value, supplier: document.getElementById("cSup").value }); loadAll(); } } async function decideContract(id, status) { await api("/api/contract/decide", { id, status }); loadAll(); } async function addUser() { const r = await api("/api/users/manage", { action: "add", login: document.getElementById("uLogin").value, name: document.getElementById("uName").value, role: document.getElementById("uRole").value }); if (r && r.error) return alert(r.error); await loadAll(); const b = document.getElementById("newPassBox"); b.style.display="block"; b.innerText="Parol: "+r.newPass; } async function resetPass(login) { const r = await api("/api/users/manage", { action: "reset", login }); const b = document.getElementById("newPassBox"); b.style.display="block"; b.innerText=login+" yangi parol: "+r.newPass; } async function toggleUser(login) { await api("/api/users/manage", { action: "toggle", login }); loadAll(); } function exportCSV() { let csv = "\uFEFFZayavka;Sana;Bolinma;Tovarlar;Holati\n"; STATE.requests.forEach(r => csv += `${r.id};${r.date};${r.unitName};"${r.items.map(i=>i.name+" ("+i.qty+" "+i.unit+")").join(", ")}";${r.status}\n`); const a = document.createElement("a"); a.href = URL.createObjectURL(new Blob([csv], {type:"text/csv"})); a.download = "Taminot.csv"; a.click(); } loadUnits(); loadAll();