1
1
<?php namespace Thoughtco \Reports ;
2
2
3
- use DB ;
4
- use Event ;
5
- use Admin \Widgets \Form ;
3
+ use Admin \Controllers \Dashboard ;
4
+ use Admin \DashboardWidgets \Charts ;
5
+ use Admin \DashboardWidgets \Statistics ;
6
+ use Admin \Widgets \DashboardContainer ;
6
7
use System \Classes \BaseExtension ;
8
+ use Thoughtco \Reports \Classes \ReportsCache ;
7
9
8
10
/**
9
11
* Extension Information File
10
- **/
12
+ **/
11
13
class Extension extends BaseExtension
12
14
{
13
15
public function boot ()
14
16
{
15
-
17
+ Statistics::registerCards (function () {
18
+ return [
19
+ 'total_items ' => [
20
+ 'label ' => 'lang:thoughtco.reports::default.text_total_items ' ,
21
+ 'icon ' => ' bg-warning text-white fa fa-line-chart ' ,
22
+ 'valueFrom ' => [ReportsCache::class, 'getValue ' ],
23
+ ],
24
+ 'pickup_orders_value ' => [
25
+ 'label ' => 'lang:thoughtco.reports::default.text_collection_orders ' ,
26
+ 'icon ' => ' bg-blue text-white fa fa-store ' ,
27
+ 'valueFrom ' => [ReportsCache::class, 'getValue ' ],
28
+ ],
29
+ 'pickup_orders_count ' => [
30
+ 'label ' => 'lang:thoughtco.reports::default.text_collection_orders_count ' ,
31
+ 'icon ' => ' bg-blue text-white fa fa-store ' ,
32
+ 'valueFrom ' => [ReportsCache::class, 'getValue ' ],
33
+ ],
34
+ 'delivery_orders_value ' => [
35
+ 'label ' => 'lang:thoughtco.reports::default.text_delivery_orders ' ,
36
+ 'icon ' => ' bg-blue text-white fa fa-shipping-fast ' ,
37
+ 'valueFrom ' => [ReportsCache::class, 'getValue ' ],
38
+ ],
39
+ 'delivery_orders_count ' => [
40
+ 'label ' => 'lang:thoughtco.reports::default.text_delivery_orders_count ' ,
41
+ 'icon ' => ' bg-blue text-white fa fa-shipping-fast ' ,
42
+ 'valueFrom ' => [ReportsCache::class, 'getValue ' ],
43
+ ],
44
+ 'cancelled_orders_value ' => [
45
+ 'label ' => 'lang:thoughtco.reports::default.text_cancelled_orders ' ,
46
+ 'icon ' => ' bg-danger text-white fa fa-exclamation-circle ' ,
47
+ 'valueFrom ' => [ReportsCache::class, 'getValue ' ],
48
+ ],
49
+ 'cancelled_orders_count ' => [
50
+ 'label ' => 'lang:thoughtco.reports::default.text_cancelled_orders_count ' ,
51
+ 'icon ' => ' bg-danger text-white fa fa-exclamation-circle ' ,
52
+ 'valueFrom ' => [ReportsCache::class, 'getValue ' ],
53
+ ],
54
+ ];
55
+ });
56
+
57
+ Charts::registerDatasets (function () {
58
+ return [
59
+ 'orders_by_day_data ' => [
60
+ 'label ' => 'lang:thoughtco.reports::default.text_orders_by_day ' ,
61
+ 'type ' => 'doughnut ' ,
62
+ 'icon ' => ' fa fa-calendar ' ,
63
+ 'datasetFrom ' => [ReportsCache::class, 'getValue ' ],
64
+ ],
65
+ 'orders_by_hour_data ' => [
66
+ 'label ' => 'lang:thoughtco.reports::default.text_orders_by_hour ' ,
67
+ 'type ' => 'doughnut ' ,
68
+ 'icon ' => ' fa fa-clock ' ,
69
+ 'datasetFrom ' => [ReportsCache::class, 'getValue ' ],
70
+ ],
71
+ 'orders_by_category_data ' => [
72
+ 'label ' => 'lang:thoughtco.reports::default.text_orders_by_category ' ,
73
+ 'type ' => 'pie ' ,
74
+ 'icon ' => ' fa fa-stream ' ,
75
+ 'datasetFrom ' => [ReportsCache::class, 'getValue ' ],
76
+ ],
77
+ 'orders_by_payment_method_data ' => [
78
+ 'label ' => 'lang:thoughtco.reports::default.text_orders_by_payment_type ' ,
79
+ 'type ' => 'pie ' ,
80
+ 'icon ' => ' fa fa-money-check-alt ' ,
81
+ 'datasetFrom ' => [ReportsCache::class, 'getValue ' ],
82
+ ],
83
+ ];
84
+ });
85
+
86
+ Dashboard::extend (function (Dashboard $ dashboard ) {
87
+ $ dashboard ->extendDashboard (function (DashboardContainer $ widget ) {
88
+ $ widget ->defaultWidgets = array_merge ($ widget ->defaultWidgets , [
89
+ 'top_customers ' => [
90
+ 'widget ' => 'lists ' ,
91
+ 'priority ' => 40 ,
92
+ 'context ' => 'top_customers ' ,
93
+ 'width ' => '6 ' ,
94
+ ],
95
+ 'bottom_customers ' => [
96
+ 'widget ' => 'lists ' ,
97
+ 'priority ' => 40 ,
98
+ 'context ' => 'bottom_customers ' ,
99
+ 'width ' => '6 ' ,
100
+ ],
101
+ 'orders_by_day ' => [
102
+ 'widget ' => 'charts ' ,
103
+ 'priority ' => 50 ,
104
+ 'dataset ' => 'orders_by_day_data ' ,
105
+ 'width ' => '3 ' ,
106
+ ],
107
+ 'orders_by_hour ' => [
108
+ 'widget ' => 'charts ' ,
109
+ 'priority ' => 50 ,
110
+ 'dataset ' => 'orders_by_hour_data ' ,
111
+ 'width ' => '3 ' ,
112
+ ],
113
+ 'orders_by_category ' => [
114
+ 'widget ' => 'charts ' ,
115
+ 'priority ' => 50 ,
116
+ 'dataset ' => 'orders_by_category_data ' ,
117
+ 'width ' => '3 ' ,
118
+ ],
119
+ 'orders_by_payment_method ' => [
120
+ 'widget ' => 'charts ' ,
121
+ 'priority ' => 50 ,
122
+ 'dataset ' => 'orders_by_payment_method_data ' ,
123
+ 'width ' => '3 ' ,
124
+ ],
125
+ ]);
126
+ });
127
+ });
16
128
}
17
-
129
+
18
130
public function registerFormWidgets ()
19
131
{
20
132
return [
@@ -28,7 +140,17 @@ public function registerFormWidgets()
28
140
],
29
141
];
30
142
}
31
-
143
+
144
+ public function registerDashboardWidgets ()
145
+ {
146
+ return [
147
+ \Thoughtco \Reports \Widgets \Lists::class => [
148
+ 'code ' => 'lists ' ,
149
+ 'label ' => 'lang:thoughtco.reports::default.text_list_widget_title ' ,
150
+ ],
151
+ ];
152
+ }
153
+
32
154
public function registerNavigation ()
33
155
{
34
156
return [
@@ -54,8 +176,8 @@ public function registerNavigation()
54
176
],
55
177
],
56
178
];
57
- }
58
-
179
+ }
180
+
59
181
public function registerPermissions ()
60
182
{
61
183
return [
0 commit comments