Spaces:
Sleeping

doluong6 commited on
Commit
b2cf417
·
verified ·
1 Parent(s): 0c07591

Update static/script.js

Browse files
Files changed (1) hide show
  1. static/script.js +68 -0
static/script.js CHANGED
@@ -18,6 +18,7 @@ function hienThiTongQuan() {
18
  hienThiDoanhThuPYC();
19
  veBieuDoDoanhThuThang();
20
  veBieuDoDichVu();
 
21
  }
22
 
23
  async function hienThiDanhSachPYC() {
@@ -190,7 +191,74 @@ async function veBieuDoDichVu() {
190
  document.addEventListener("DOMContentLoaded", function () {
191
  veBieuDoDichVu();
192
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
193
 
 
 
 
 
194
 
195
  function chonMuc(muc) {
196
  const bang = document.getElementById("bangChiTiet");
 
18
  hienThiDoanhThuPYC();
19
  veBieuDoDoanhThuThang();
20
  veBieuDoDichVu();
21
+ veBieuDoTongHopDoanhThu();
22
  }
23
 
24
  async function hienThiDanhSachPYC() {
 
191
  document.addEventListener("DOMContentLoaded", function () {
192
  veBieuDoDichVu();
193
  });
194
+ async function veBieuDoTongHopDoanhThu() {
195
+ try {
196
+ const res = await fetch("/doanh_thu_tong_hop");
197
+ const data = await res.json();
198
+
199
+ if (data.error) {
200
+ console.error("Lỗi từ API:", data.error);
201
+ return;
202
+ }
203
+
204
+ const labels = [
205
+ "Tổng doanh thu",
206
+ "Nợ hóa đơn",
207
+ "NB chuyển đi",
208
+ "NB chuyển đến",
209
+ "Tổng NB"
210
+ ];
211
+
212
+ const values = [
213
+ data.tong_doanh_thu,
214
+ data.no_hoa_don,
215
+ data.noi_bo_chuyen_di,
216
+ data.noi_bo_chuyen_den,
217
+ data.tong_noi_bo
218
+ ];
219
+
220
+ const ctx = document.getElementById("chartTongHopDoanhThu").getContext("2d");
221
+
222
+ new Chart(ctx, {
223
+ type: "bar",
224
+ data: {
225
+ labels: labels,
226
+ datasets: [{
227
+ label: "VNĐ",
228
+ data: values,
229
+ backgroundColor: [
230
+ "#4caf50",
231
+ "#ff9800",
232
+ "#2196f3",
233
+ "#9c27b0",
234
+ "#f44336"
235
+ ]
236
+ }]
237
+ },
238
+ options: {
239
+ responsive: true,
240
+ plugins: {
241
+ legend: { display: false },
242
+ tooltip: {
243
+ callbacks: {
244
+ label: context => context.raw.toLocaleString("vi-VN") + " ₫"
245
+ }
246
+ }
247
+ },
248
+ scales: {
249
+ y: {
250
+ ticks: {
251
+ callback: value => value.toLocaleString("vi-VN") + " ₫"
252
+ }
253
+ }
254
+ }
255
+ }
256
+ });
257
 
258
+ } catch (err) {
259
+ console.error("Lỗi khi vẽ biểu đồ tổng hợp doanh thu:", err);
260
+ }
261
+ }
262
 
263
  function chonMuc(muc) {
264
  const bang = document.getElementById("bangChiTiet");