jauhar54 2 anni fa
parent
commit
909df0fccc

+ 28
- 51
app/Http/Controllers/Admin/DashboardController.php Vedi File

@@ -16,13 +16,8 @@ use Auth;
16 16
 use App\Utils\DashboardUtil;
17 17
 
18 18
 //MODEL
19
-use App\Model\Logistik\ManajemenKantong;
20
-use App\Model\Master\Reagen;
21
-use App\Model\Master\ItemKantongs;
22
-use App\Model\Master\MasterJenisKantong;
23
-use App\Model\Master\MerkReagen;
24
-use App\Model\Master\Reagens;
25
-use GuzzleHttp\Psr7\Request;
19
+use App\User;
20
+
26 21
 
27 22
 class DashboardController extends Controller
28 23
 {
@@ -41,56 +36,38 @@ class DashboardController extends Controller
41 36
 
42 37
     public function index()
43 38
     {
44
-        // $petugas_udd_id                 = Auth::user()->petugas->unit_donor_darah_id;
45
-        // $kantongLogistik_last_30_days   = ManajemenKantong::getData30Days($status_kantongs = 1, $status_kantong_item = 1, $petugas_udd_id, $param_order = 'created_at', $imltd = null, $kgd = null);
46
-        // $kantongAftap_last_30_days      = ManajemenKantong::getData30Days($status_kantongs = 1, $status_kantong_item = 2, $petugas_udd_id, $param_order = 'created_at', $imltd = null, $kgd = null);
47
-        // $kantongBelumImltd_last_30_days = ManajemenKantong::getData30Days($status_kantongs = 3, $status_kantong_item = 3, $petugas_udd_id, $param_order = 'updated_at', $imltd = 'is_lulus_imltd', $kgd = null);
48
-        // $kantongBelumKgd_last_30_days   = ManajemenKantong::getData30Days($status_kantongs = 3, $status_kantong_item = 3, $petugas_udd_id, $param_order = 'updated_at', $imltd = null, $kgd = 'is_konfirmasi_golongan_darah');
49
-        // $kantongRelease_last_1_years    = $this->DashboardUtil->getDataLast1Years(9, $petugas_udd_id, 'updated_at');                                                                                                            //param, status id 9 release
50
-
51
-        // $kantongLogistik   = ManajemenKantong::getKantong($status_kantongs = 1,$status_kantong_item = 1, $petugas_udd_id, $imtld = null, $kgd = null);
52
-        // $kantongAftap      =  ManajemenKantong::where('kantong_items.status_id', '=', 2)
53
-        //                         ->where('kantong_items.is_pemindahan_aftap', '=', 1)
54
-        //                         ->where('kantongs.status_id', '=', 1)
55
-        //                         ->where('kantong_items.unit_donor_darah_id', Auth::user()->petugas->unit_donor_darah_id)
56
-        //                         ->join('kantong_items', 'kantongs.id', 'kantong_items.kantong_id')
57
-        //                         ->groupBy('kantong_id')
58
-        //                         ->get();
59
-        // $kantongBelumImltd =  ItemKantongs::selectRaw('
60
-        //                     kantong_items.id,
61
-        //                     kantong_items.no_kantong,
62
-        //                     kantong_items.kantong_id
63
-        //                     ')
64
-        //                     ->leftjoin('hasil_imltds', 'hasil_imltds.kantong_item_id','=','kantong_items.id')
65
-        //                     ->join('kantongs', 'kantongs.id','kantong_items.kantong_id')
66
-        //                     ->where('hasil_imltds.id',null)
67
-        //                     ->where('kantongs.status_id',3)
68
-        //                     ->where('kantong_items.is_sah', 1 )
69
-        //                     ->whereNull('is_lulus_imltd')
70
-        //                     ->where('kantong_items.unit_donor_darah_id', Auth::user()->petugas->unit_donor_darah_id)
71
-        //                     ->groupBy('kantong_items.kantong_id')->orderBy('kantong_items.created_at', 'asc')->get();
72
-        // $kantongBelumKgd   = ManajemenKantong::getKantong($status_kantongs = 3,$status_kantong_item = null, $petugas_udd_id, $imltd = null, $kgd = 'is_konfirmasi_golongan_darah');
73
-        // $belum_aftap       = ManajemenKantong::getKantong($status_kantongs = 1,$status_kantong_item = 11, $petugas_udd_id, $imltd = null, $kgd = null);
39
+        $reguler_points = User::select('users.name', DB::raw('SUM(point_logs.point) as total_point'))->rightJoin('point_logs', 'point_logs.user_id', 'users.id')->where('event_id', '=', 0)->groupBy('point_logs.user_id')->orderBy('total_point', 'desc')->limit(5)->get();
40
+
41
+        $reguler_point_all = [];
42
+
43
+        $reguler_user_all = [];
44
+
45
+        foreach($reguler_points as $key => $value){
46
+            array_push($reguler_point_all , intval($value->total_point));
47
+            array_push($reguler_user_all , $value->name);
48
+        }
49
+
50
+        $event_points = User::select('users.name', DB::raw('SUM(point_logs.point) as total_point'))->rightJoin('point_logs', 'point_logs.user_id', 'users.id')->where('event_id', '=', 1)->groupBy('point_logs.user_id')->orderBy('total_point', 'desc')->limit(5)->get();
51
+
52
+        $event_point_all = [];
53
+
54
+        $event_user_all = [];
55
+
56
+        foreach($event_points as $key => $value){
57
+            array_push($event_point_all , intval($value->total_point));
58
+            array_push($event_user_all , $value->name);
59
+        }
74 60
 
75 61
         $data = [
76 62
             //bawaan
77 63
             'title'             => $this->title,
78 64
             'route'             => $this->route,
79
-            // 'kantongLogistik'   => count($kantongLogistik),
80
-            // 'kantongAftap'      => count($kantongAftap),
81
-            // 'kantongBelumImltd' => count($kantongBelumImltd),
82
-            // 'kantongBelumKgd'   => count($kantongBelumKgd),
83
-            // 'count_logistik'    => $kantongLogistik,
84
-            // 'count_aftap'       => $kantongAftap,
85
-            // 'belum_aftap'       => $belum_aftap,
86
-            // 'jenis_kantong'     => MasterJenisKantong::All(),
87
-            // 'master_reagen'     => Reagen::where('unit_donor_darah_id', Auth::user()->petugas->unit_donor_darah_id)->get(),
88
-            // 'reagens'           => Reagens::where('reagens.unit_donor_darah_id', Auth::user()->petugas->unit_donor_darah_id)
89
-            //                     ->join('master_reagens', 'reagens.master_reagen_id', 'master_reagens.id')
90
-            //                     ->get(),
91
-            // 'merk_reagen' => MerkReagen::all(),
65
+            'reguler_user_all'  => $reguler_user_all,
66
+            'reguler_point_all' => $reguler_point_all,
67
+            'event_user_all'    => $event_user_all,
68
+            'event_point_all'   => $event_point_all,
92 69
         ];
93
-        // dd($data['reagens']);
70
+        // dd($data['log_points']);
94 71
         return view($this->route . 'index', $data);
95 72
     }
96 73
 }

+ 107
- 13
resources/views/admin/dashboard/index.blade.php Vedi File

@@ -1,20 +1,19 @@
1 1
 @extends('admin.layouts.app')
2 2
 
3 3
 @section('content')
4
-    <style>
5
-                .box-dashboard-kantong{
6
-            padding: 1rem;
7
-            border-radius: 0.5rem;
8
-        }
9
-        .box-dashboard-kantong h5{
10
-            margin: 0;
11
-            color: #32325d;
12
-        }
13
-        .box-dashboard-kantong:hover{
14
-            box-shadow: 0 3px 6px 0 rgba(0,0,0,0.2), 0 6px 15px 0 rgba(0,0,0,0.19);
15
-        }
16
-    </style>
17 4
 
5
+<div class="row">
6
+    <div class="col-md-6">
7
+        <figure class="highcharts-figure">
8
+            <div id="reguler-points"></div>
9
+        </figure>
10
+    </div>
11
+    <div class="col-md-6">
12
+        <figure class="highcharts-figure">
13
+            <div id="event-points"></div>
14
+        </figure>
15
+    </div>
16
+</div>
18 17
 
19 18
 
20 19
 
@@ -35,5 +34,100 @@
35 34
     <script src="{{ asset('assets') }}/js/highchart/accessibility.js"></script>
36 35
     <script src="{{ asset('assets') }}/js/custom.js"></script>
37 36
     <script src="{{ asset('assets') }}/js/custom-graph.js"></script>
37
+
38
+    <script>
39
+        var users = {!! json_encode($reguler_user_all) !!};
40
+        var points = {!! json_encode($reguler_point_all) !!};
41
+
42
+        Highcharts.chart('reguler-points', {
43
+            chart: {
44
+                type: 'column'
45
+            },
46
+            title: {
47
+                text: 'Kelasmen Reguler Point'
48
+            },
49
+            subtitle: {
50
+                text: 'Kelasmen Reguler Point'
51
+            },
52
+            xAxis: {
53
+                categories: users,
54
+                crosshair: true
55
+            },
56
+            yAxis: {
57
+                min: 0,
58
+                title: {
59
+                text: 'points'
60
+                }
61
+            },
62
+            tooltip: {
63
+                headerFormat: '<span style="font-size:10px">{point.key}</span><table>',
64
+                pointFormat: '<tr><td style="color:{series.color};padding:0">{series.name}: </td>' +
65
+                '<td style="padding:0"><b>{point.y:.1f} mm</b></td></tr>',
66
+                footerFormat: '</table>',
67
+                shared: true,
68
+                useHTML: true
69
+            },
70
+            plotOptions: {
71
+                column: {
72
+                pointPadding: 0.2,
73
+                borderWidth: 0
74
+                }
75
+            },
76
+            series: [
77
+                    {
78
+                        name: 'Reguler Point',
79
+                        data: points
80
+                    }
81
+                ]
82
+        });
83
+    </script>
84
+
85
+<script>
86
+        var users = {!! json_encode($event_user_all) !!};
87
+        var points = {!! json_encode($event_point_all) !!};
88
+
89
+        Highcharts.chart('event-points', {
90
+            chart: {
91
+                type: 'column'
92
+            },
93
+            title: {
94
+                text: 'Kelasmen Event Point'
95
+            },
96
+            subtitle: {
97
+                text: 'Kelasmen Event Point'
98
+            },
99
+            xAxis: {
100
+                categories: users,
101
+                crosshair: true
102
+            },
103
+            yAxis: {
104
+                min: 0,
105
+                title: {
106
+                text: 'points'
107
+                }
108
+            },
109
+            tooltip: {
110
+                headerFormat: '<span style="font-size:10px">{point.key}</span><table>',
111
+                pointFormat: '<tr><td style="color:{series.color};padding:0">{series.name}: </td>' +
112
+                '<td style="padding:0"><b>{point.y:.1f} mm</b></td></tr>',
113
+                footerFormat: '</table>',
114
+                shared: true,
115
+                useHTML: true
116
+            },
117
+            plotOptions: {
118
+                column: {
119
+                pointPadding: 0.2,
120
+                borderWidth: 0
121
+                }
122
+            },
123
+            series: [
124
+                    {   
125
+                        color: '#F7A35C',
126
+                        name: 'Event Point',
127
+                        data: points
128
+                    }
129
+                ]
130
+        });
131
+    </script>
38 132
     
39 133
 @endpush

Loading…
Annulla
Salva