File size: 3,336 Bytes
22d3ef3 9abfd3b 22d3ef3 9abfd3b 58b6b71 9abfd3b 58b6b71 9abfd3b 22d3ef3 9abfd3b 58b6b71 22d3ef3 9abfd3b 58b6b71 22d3ef3 9abfd3b 58b6b71 22d3ef3 9abfd3b 58b6b71 22d3ef3 9abfd3b 58b6b71 22d3ef3 9abfd3b 22d3ef3 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 | function login() {
const u = document.getElementById("username").value;
const p = document.getElementById("password").value;
if (u === "admin" && p === "1234") {
document.getElementById("login").style.display = "none";
document.getElementById("dashboard").style.display = "block";
chonMuc("pyc");
} else {
alert("Sai tên đăng nhập hoặc mật khẩu!");
}
}
function toggleSubmenu(id) {
const submenu = document.getElementById(id);
const arrow = document.getElementById("arrow-" + id);
if (submenu.style.display === "block") {
submenu.style.display = "none";
arrow.innerText = "►";
} else {
submenu.style.display = "block";
arrow.innerText = "▼";
}
}
function anTatCa() {
document.querySelectorAll(".fade-in").forEach(el => el.style.display = "none");
}
function chonMuc(muc) {
anTatCa();
if (muc === "cho_xu_ly") hienThiPYCChoXuLy();
if (muc === "pyc") hienThiDanhSachPYC();
if (muc === "completedRequests") hienThiPYCCompleted();
if (muc === "requestRevenue") hienThiDoanhThuPYC();
}
// ===== HIỂN THỊ =====
async function hienThiPYCChoXuLy() {
try {
const res = await fetch("/ds_pyc_cho_xu_ly");
const data = await res.json();
const tbody = document.querySelector("#tablePYCChoXuLy tbody");
tbody.innerHTML = "";
data.forEach(row => {
tbody.innerHTML += `<tr><td>${row["Khách hàng"]}</td><td>${row["File PYC"]}</td></tr>`;
});
document.getElementById("bangPYCChoXuLy").style.display = "block";
if (!$.fn.DataTable.isDataTable("#tablePYCChoXuLy")) {
$("#tablePYCChoXuLy").DataTable();
}
} catch (err) {
console.error("Lỗi chờ xử lý:", err);
}
}
async function hienThiDanhSachPYC() {
try {
const res = await fetch("/pyc_chua_hoan_thanh");
const data = await res.json();
let html = `
<table class="display" id="bangPYC">
<thead><tr><th>Mã phiếu</th><th>Khách hàng</th><th>Ngày tạo</th></tr></thead>
<tbody>`;
data.forEach(item => {
html += `<tr><td>${item["Phiếu yêu cầu"]}</td><td>${item["Khách hàng"]}</td><td>${item["Ngày tạo phiếu"]}</td></tr>`;
});
html += "</tbody></table>";
document.getElementById("noiDungBang").innerHTML = html;
$("#bangPYC").DataTable();
document.getElementById("bangChiTiet").style.display = "block";
document.getElementById("tieuDeBang").innerText = "Danh sách phiếu chưa hoàn thành";
} catch (err) {
console.error("Lỗi chưa hoàn thành:", err);
}
}
async function hienThiPYCCompleted() {
try {
const res = await fetch("/dem_pyc_hoan_thanh");
const data = await res.json();
const so = data.tong_so_hoan_thanh || 0;
document.getElementById("completedRequests").innerText = so;
document.getElementById("daHoanThanh").style.display = "block";
} catch (err) {
console.error("Lỗi hoàn thành:", err);
}
}
async function hienThiDoanhThuPYC() {
try {
const res = await fetch("/doanh_thu_theo_pyc"); // Cần xác nhận API này có tồn tại
const data = await res.json();
const dt = data.doanh_thu || 0;
document.getElementById("requestRevenue").innerText = dt;
document.getElementById("doanhThuPYC").style.display = "block";
} catch (err) {
console.error("Lỗi doanh thu:", err);
}
}
|