Browse Source

fix: dashboard

Muhammad Iqbal Afandi 3 years ago
parent
commit
2b735b1ee3

+ 3
- 0
app/Services/DashboardService.php View File

63
     {
63
     {
64
         return [
64
         return [
65
             "title" => __("words.sale_and_purchase"),
65
             "title" => __("words.sale_and_purchase"),
66
+            "description" => __("words.period", [
67
+                "number" => now()->translatedFormat("Y"),
68
+            ]),
66
             "data" => [
69
             "data" => [
67
                 __("words.sale") => QueryService::amountStatistic("sales"),
70
                 __("words.sale") => QueryService::amountStatistic("sales"),
68
                 __("words.purchase") => QueryService::amountStatistic(
71
                 __("words.purchase") => QueryService::amountStatistic(

+ 2
- 1
app/Services/QueryService.php View File

20
                  FROM
20
                  FROM
21
                     products
21
                     products
22
                  WHERE
22
                  WHERE
23
-                    DATE(updated_at) = CURDATE()) AS amountToday"
23
+                    DATE(created_at) = CURDATE()) AS amountToday"
24
             )
24
             )
25
             ->get()
25
             ->get()
26
             ->transform(
26
             ->transform(
41
                 "COUNT(*) AS amount,
41
                 "COUNT(*) AS amount,
42
                  DATE_FORMAT(created_at, '%b') AS month"
42
                  DATE_FORMAT(created_at, '%b') AS month"
43
             )
43
             )
44
+            ->whereRaw("YEAR(created_at) = YEAR(CURDATE())")
44
             ->groupByRaw("month")
45
             ->groupByRaw("month")
45
             ->orderByRaw("created_at")
46
             ->orderByRaw("created_at")
46
             ->get()
47
             ->get()

+ 1
- 0
lang/en/words.php View File

43
     "stock_product" => "Stock Product",
43
     "stock_product" => "Stock Product",
44
     "best_product" => "Best Product",
44
     "best_product" => "Best Product",
45
     "sale_and_purchase" => "Sale and Purchase",
45
     "sale_and_purchase" => "Sale and Purchase",
46
+    "period" => "Period :number",
46
 ];
47
 ];

+ 1
- 0
lang/id/words.php View File

43
     "stock_product" => "Stok Produk",
43
     "stock_product" => "Stok Produk",
44
     "best_product" => "Produk Terlaris",
44
     "best_product" => "Produk Terlaris",
45
     "sale_and_purchase" => "Penjualan dan Pembelian",
45
     "sale_and_purchase" => "Penjualan dan Pembelian",
46
+    "period" => "Periode :number",
46
 ];
47
 ];

+ 5
- 2
resources/js/pages/Dashboards/Components/CardCart.vue View File

1
 <script setup>
1
 <script setup>
2
 defineProps({
2
 defineProps({
3
   title: {
3
   title: {
4
-    required: true,
4
+    type: String,
5
+  },
6
+  description: {
5
     type: String,
7
     type: String,
6
   },
8
   },
7
 })
9
 })
9
 
11
 
10
 <template>
12
 <template>
11
   <div class="card">
13
   <div class="card">
12
-    <h5>{{ title }}</h5>
14
+    <h5 class="mb-1">{{ title }}</h5>
15
+    <span>{{ description }}</span>
13
 
16
 
14
     <Chart v-bind="$attrs" />
17
     <Chart v-bind="$attrs" />
15
   </div>
18
   </div>

+ 2
- 1
resources/js/pages/Dashboards/Components/CardProductFavorite.vue View File

10
 <template>
10
 <template>
11
   <div class="card">
11
   <div class="card">
12
     <div class="flex justify-content-between align-items-center">
12
     <div class="flex justify-content-between align-items-center">
13
-      <h5>{{ data.title }}</h5>
13
+      <h5 class="mb-1">{{ data.title }}</h5>
14
+      <span>{{ data.description }}</span>
14
     </div>
15
     </div>
15
 
16
 
16
     <ul class="list-none p-0 m-0">
17
     <ul class="list-none p-0 m-0">

+ 5
- 1
resources/js/pages/Dashboards/Composables/useStatistic.js View File

30
     index++
30
     index++
31
   }
31
   }
32
 
32
 
33
-  return { title: chartData.title, data: chartSettings }
33
+  return {
34
+    title: chartData.title,
35
+    description: chartData.description,
36
+    data: chartSettings,
37
+  }
34
 }
38
 }

+ 5
- 1
resources/js/pages/Dashboards/Composables/useStatisticDualYear.js View File

30
     index++
30
     index++
31
   }
31
   }
32
 
32
 
33
-  return { title: chartData.title, data: chartSettings }
33
+  return {
34
+    title: chartData.title,
35
+    description: chartData.description,
36
+    data: chartSettings,
37
+  }
34
 }
38
 }

+ 3
- 0
resources/js/pages/Dashboards/Index.vue View File

44
             <CardCart
44
             <CardCart
45
               type="line"
45
               type="line"
46
               :title="salePurchaseAmountStatistic.title"
46
               :title="salePurchaseAmountStatistic.title"
47
+              :description="salePurchaseAmountStatistic.description"
47
               :data="salePurchaseAmountStatistic.data"
48
               :data="salePurchaseAmountStatistic.data"
48
             />
49
             />
49
           </div>
50
           </div>
56
             <CardCart
57
             <CardCart
57
               type="bar"
58
               type="bar"
58
               :title="salePriceStatistic.title"
59
               :title="salePriceStatistic.title"
60
+              :description="salePriceStatistic.description"
59
               :data="salePriceStatistic.data"
61
               :data="salePriceStatistic.data"
60
             />
62
             />
61
           </div>
63
           </div>
64
             <CardCart
66
             <CardCart
65
               type="bar"
67
               type="bar"
66
               :title="purchasePriceStatistic.title"
68
               :title="purchasePriceStatistic.title"
69
+              :description="purchasePriceStatistic.description"
67
               :data="purchasePriceStatistic.data"
70
               :data="purchasePriceStatistic.data"
68
             />
71
             />
69
           </div>
72
           </div>