Spaces:
Sleeping

doluong6 commited on
Commit
85d66d0
·
verified ·
1 Parent(s): b14745b

Update static/script.js

Browse files
Files changed (1) hide show
  1. static/script.js +55 -0
static/script.js CHANGED
@@ -73,6 +73,10 @@ function chonMuc(muc) {
73
  document.getElementById("dtdichvu").style.display = "block";
74
  hienThiDoanhThuDichVu(); // Gọi API để hiển thị bảng
75
  }
 
 
 
 
76
  }
77
 
78
 
@@ -315,3 +319,54 @@ async function hienThiDoanhThuDichVu() {
315
  $('#bangDoanhThuDichVu').html("<p style='color:red'>Lỗi kết nối tới máy chủ.</p>");
316
  }
317
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
73
  document.getElementById("dtdichvu").style.display = "block";
74
  hienThiDoanhThuDichVu(); // Gọi API để hiển thị bảng
75
  }
76
+ if (muc === "dtnoibo") {
77
+ document.getElementById("dtnoibo").style.display = "block";
78
+ hienThiDoanhThuNoiBo();
79
+ }
80
  }
81
 
82
 
 
319
  $('#bangDoanhThuDichVu').html("<p style='color:red'>Lỗi kết nối tới máy chủ.</p>");
320
  }
321
  }
322
+ async function hienThiDoanhThuNoiBo() {
323
+ try {
324
+ const res = await fetch("/doanh_thu_noi_bo");
325
+ const result = await res.json();
326
+
327
+ console.log("📊 Kết quả doanh thu nội bộ:", result);
328
+
329
+ const data = result.data || [];
330
+ const tong = result.tong || {};
331
+
332
+ const table = $('#bangDoanhThuNoiBo');
333
+ if ($.fn.dataTable.isDataTable('#bangDoanhThuNoiBo')) {
334
+ table.DataTable().clear().rows.add(data).draw();
335
+ } else {
336
+ table.DataTable({
337
+ data: data,
338
+ columns: [
339
+ { title: "Phòng", data: "Phòng" },
340
+ {
341
+ title: "Chuyển đến",
342
+ data: "Chuyển đến",
343
+ render: function (data, type) {
344
+ return type === 'display' && typeof data === 'number'
345
+ ? data.toLocaleString('vi-VN') + " ₫"
346
+ : data;
347
+ }
348
+ },
349
+ {
350
+ title: "Chuyển đi",
351
+ data: "Chuyển đi",
352
+ render: function (data, type) {
353
+ return type === 'display' && typeof data === 'number'
354
+ ? data.toLocaleString('vi-VN') + " ₫"
355
+ : data;
356
+ }
357
+ }
358
+ ],
359
+ paging: false,
360
+ searching: false,
361
+ info: false
362
+ });
363
+ }
364
+
365
+ document.getElementById("tongDoanhThuNoiBo").innerHTML =
366
+ `Tổng chuyển đến: <span style="color:green">${tong["Tổng chuyển đến"].toLocaleString('vi-VN')} ₫</span><br>` +
367
+ `Tổng chuyển đi: <span style="color:red">${tong["Tổng chuyển đi"].toLocaleString('vi-VN')} ₫</span>`;
368
+ } catch (err) {
369
+ console.error("❌ Lỗi khi tải doanh thu nội bộ:", err);
370
+ $('#bangDoanhThuNoiBo').html("<p style='color:red'>Không thể tải dữ liệu.</p>");
371
+ }
372
+ }