From a1cafbcd2f29923523033abfc04ac11aaa608085 Mon Sep 17 00:00:00 2001
From: Jepp9350 <2jepp9350@gmail.com>
Date: Tue, 4 Mar 2025 11:39:16 +0100
Subject: [PATCH] Add detailed daily report functionalities to department
dashboard
Implemented new components for product sales and daily report form. Enhanced existing report displays with dynamic transaction and product count data. Introduced backend integration for fetching product and transaction details and updated UI to display relevant metrics.
---
.../Objects/DepartmentDailyReports.vue | 12 +++
.../daily-report/DepartmentDailyReport.vue | 96 ++++++++++++++++---
.../DepartmentDashboardDailyReportCount.vue | 7 +-
...rtmentDashboardDailyReportProductSales.vue | 84 ++++++++++++++++
...epartmentDashboardDailyReportTodayForm.vue | 53 ++++++++++
5 files changed, 236 insertions(+), 16 deletions(-)
create mode 100644 src/views/dashboards/departmentDashboard/modules/daily-report/displays/DepartmentDashboardDailyReportProductSales.vue
create mode 100644 src/views/dashboards/departmentDashboard/modules/daily-report/displays/DepartmentDashboardDailyReportTodayForm.vue
diff --git a/src/components/session/token/SessionUser/Objects/DepartmentDailyReports.vue b/src/components/session/token/SessionUser/Objects/DepartmentDailyReports.vue
index b1797eae..0f63ca6a 100644
--- a/src/components/session/token/SessionUser/Objects/DepartmentDailyReports.vue
+++ b/src/components/session/token/SessionUser/Objects/DepartmentDailyReports.vue
@@ -113,6 +113,18 @@ import {ref} from "vue";
showDeleteObjectForm: (id, onAfterSubmit = null) => {
return ObjectsGlobal.showDeleteObjectForm(DepartmentDailyReports, id, onAfterSubmit);
},
+ getProductCount: async (department_id,product_id, date) => {
+ return authenticatedRequest(
+ "/departments/daily-reports/product-count?product_id=" + product_id + "&date=" + date + "&department_id=" + department_id,
+ "GET"
+ );
+ },
+ getTransactionCount: async (department_id, date) => {
+ return authenticatedRequest(
+ "/departments/daily-reports/transaction-count?date=" + date + "&department_id=" + department_id,
+ "GET"
+ );
+ },
},
/**
* Show the create object form
diff --git a/src/views/dashboards/departmentDashboard/modules/daily-report/DepartmentDailyReport.vue b/src/views/dashboards/departmentDashboard/modules/daily-report/DepartmentDailyReport.vue
index baef6ac2..3a8ffa9e 100644
--- a/src/views/dashboards/departmentDashboard/modules/daily-report/DepartmentDailyReport.vue
+++ b/src/views/dashboards/departmentDashboard/modules/daily-report/DepartmentDailyReport.vue
@@ -7,10 +7,23 @@ import RestrictedPageWrapper from "@/components/page/wrappers/RestrictedPageWrap
import { SessionUser } from "@/components/session/token/SessionUser.vue";
import BookingsPagination from "@/components/displays/pagination/models/UserDashboard/BookingsPagination.vue";
import DepartmentDashboardPageWrapper from "@/views/dashboards/departmentDashboard/DepartmentDashboardPageWrapper.vue";
-import DepartmentDashboardDailyReportCount
- from "@/views/dashboards/departmentDashboard/modules/daily-report/displays/DepartmentDashboardDailyReportCount.vue";
+import DepartmentDashboardDailyReportCount from "@/views/dashboards/departmentDashboard/modules/daily-report/displays/DepartmentDashboardDailyReportCount.vue";
import {ref} from "vue";
import { useRouter } from "vue-router";
+import DepartmentDashboardDailyReportProductSales
+ from "@/views/dashboards/departmentDashboard/modules/daily-report/displays/DepartmentDashboardDailyReportProductSales.vue";
+import DepartmentDashboardDailyReportTodayForm
+ from "@/views/dashboards/departmentDashboard/modules/daily-report/displays/DepartmentDashboardDailyReportTodayForm.vue";
+import { Colors } from "@/ThemeConfig.vue";
+
+/**
+ * Get the current date
+ * @returns {string} The current date (YYYY-MM-DD)
+ */
+const getDate = () => {
+ const date = new Date();
+ return date.toISOString().split('T')[0];
+};
// Get the department ID from the route
const router = useRouter();
@@ -19,24 +32,66 @@ console.log(department_id.value);
// Define the reactive variables
const daily_reports = ref(null);
+const transactions = ref(null);
+const products_sold = ref(null);
+
+
+
+// Get the transactions for the current day
+const getTransactions = async () => {
+ await SessionUser.objects.department_daily_reports.functions.getTransactionCount(department_id.value, getDate())
+ .then(response => {
+ transactions.value = response.data.data.quantity;
+ products_sold.value = response.data.data.products;
+ });
+};
+
+// Get the transactions
+getTransactions();
const reports = ref([
{
title: 'Transaktioner',
subtitle: 'Dagens transaktioner',
- count: 10,
- icon: 'fas fa-money-bill-wave',
- color: 'primary',
- buttons: [
- {
- id: 1,
- href: '#',
- icon: 'fas fa-list',
- text: 'Se alle'
- }
- ]
+ count: transactions,
+ icon: 'fas fa-exchange-alt',
+ color: Colors.global.primaryColor,
+ buttons: []
+ },
+ {
+ title: 'Produkter solgt',
+ subtitle: 'Dagens produkter solgt',
+ count: products_sold,
+ icon: 'fas fa-shopping-cart',
+ color: Colors.global.primaryColor,
+ buttons: []
}
]);
+
+const product_ids = ref([
+ /** Add the product IDs here */
+ // Undervognsskyld pr. enhed
+ {
+ id: 21,
+ out_of: 100,
+ },
+ // Spot Free (Varevogn)
+ {
+ id: 23,
+ out_of: 100,
+ },
+ // Spot Free (Lastbil)
+ {
+ id: 24,
+ out_of: 100,
+ },
+ // Fælg flex pr. enhed
+ {
+ id: 25,
+ out_of: 100,
+ },
+]);
+
@@ -59,6 +114,16 @@ const reports = ref([
{{ count }}
-Antal
+{{ count }} / {{ out_of }}
+Antal solgte / Mulige solgte