From 52dc255c628b36aadbd1a885b90e32dddf803bd1 Mon Sep 17 00:00:00 2001 From: Muhammad Thoriq Date: Fri, 5 Dec 2025 14:09:06 +0700 Subject: [PATCH] fix category dan tambah total tidak mau survey --- app/Http/Controllers/AdminController.php | 27 +++++++++++++++--- resources/views/admin/dashboard.blade.php | 25 +++++++++++++++++ .../views/admin/dashboard_demografi.blade.php | 28 ++++++++++++------- .../views/layouts/template_admin.blade.php | 10 +++---- routes/web.php | 1 + 5 files changed, 72 insertions(+), 19 deletions(-) diff --git a/app/Http/Controllers/AdminController.php b/app/Http/Controllers/AdminController.php index 2736903..0fa5d19 100644 --- a/app/Http/Controllers/AdminController.php +++ b/app/Http/Controllers/AdminController.php @@ -253,6 +253,19 @@ class AdminController extends Controller } + public function data_tidak_mau_survey(Request $request) + { + $total_tidak = DB::table('lms_mutu_jawaban_detail as a') + ->where('a.lms_mutu_soal_detail_id', 51) + ->where('a.jawaban', 'TIDAK') + ->count(); + + return response()->json([ + 'msg' => 'Berhasil', + 'data' => $total_tidak + ], 200); + } + public function dashboard_analisis() { $data['list_unit_kerja'] = [ @@ -1304,7 +1317,7 @@ class AdminController extends Controller $category = [ [ - 'name' => '0 - 2 Tahun', + 'name' => '0 - 1 Tahun', 'total' => $total, 'percent' => 0, 'value' => 0 @@ -1331,11 +1344,17 @@ class AdminController extends Controller // set value foreach ($value['jawaban'] as $v) { - $tahun = intval($v['name']); + $teks = $v['name']; - if($tahun <= 2){ + $parts = explode(" ", $teks); + $tahun = $parts[0] ?? 0; + $bulan = $parts[2] ?? 0; + + $tahun = $tahun . '.' . $bulan; + + if($tahun <= 1){ $category[0]['value'] += $v['value']; - } else if($tahun >= 3 && $tahun <= 5){ + } else if($tahun >= 2 && $tahun <= 5){ $category[1]['value'] += $v['value']; } else if($tahun >= 6 && $tahun <= 10) { $category[2]['value'] += $v['value']; diff --git a/resources/views/admin/dashboard.blade.php b/resources/views/admin/dashboard.blade.php index 231d926..cb34ab1 100644 --- a/resources/views/admin/dashboard.blade.php +++ b/resources/views/admin/dashboard.blade.php @@ -13,6 +13,16 @@
Dashboard
+
+
+
+
+
Total Tidak Mau Survey
+
-
+
+
+
+
@@ -72,6 +82,7 @@ }) generateTable(); + getTotalTidakMauSurvey(); }); function generateTable() { @@ -92,5 +103,19 @@ ] }); } + + function getTotalTidakMauSurvey() { + $.ajax({ + url: "{{ url('/admin/get_data_pegawai_tidak_mau_survey') }}", + type: "POST", + data: { + unit_kerja: $('#select_unit_kerja').val(), + _token: "{{ csrf_token() }}" + }, + success: function(res) { + $('#total_tidak_mau').html((res.data ?? '-') + ' Orang'); + } + }); + } @endsection diff --git a/resources/views/admin/dashboard_demografi.blade.php b/resources/views/admin/dashboard_demografi.blade.php index 0ecd7f8..ce6a1c5 100644 --- a/resources/views/admin/dashboard_demografi.blade.php +++ b/resources/views/admin/dashboard_demografi.blade.php @@ -85,13 +85,13 @@ const jawabanCategory = [ { - name: '0 - 2 Tahun', + name: '0 - 1 Tahun', total: totalJawaban, percent: 0, value: 0 }, { - name: '3 - 5 Tahun', + name: '2 - 5 Tahun', total: totalJawaban, percent: 0, value: 0 @@ -112,11 +112,15 @@ // set value dataMappingLamaKerjaFaskes.jawaban.map(val => { - const tahun = parseInt(val.name); + const parts = val.name.split(" "); + const tahunParts = parts[0] ?? 0; + const bulanParts = parts[2] >> 0; - if(tahun <= 2){ + const tahun = `${tahunParts}.${bulanParts}`; + + if(tahun <= 1){ jawabanCategory[0]['value'] += val.value; - } else if(tahun >= 3 && tahun <= 5){ + } else if(tahun >= 2 && tahun <= 5){ jawabanCategory[1]['value'] += val.value; } else if(tahun >= 6 && tahun <= 10) { jawabanCategory[2]['value'] += val.value; @@ -153,13 +157,13 @@ const jawabanCategory = [ { - name: '0 - 2 Tahun', + name: '0 - 1 Tahun', total: totalJawaban, percent: 0, value: 0 }, { - name: '3 - 5 Tahun', + name: '2 - 5 Tahun', total: totalJawaban, percent: 0, value: 0 @@ -180,11 +184,15 @@ // set value dataMappingLamaKerjaUnit.jawaban.map(val => { - const tahun = parseInt(val.name); + const parts = val.name.split(" "); + const tahunParts = parts[0] ?? 0; + const bulanParts = parts[2] >> 0; - if(tahun <= 2){ + const tahun = `${tahunParts}.${bulanParts}`; + + if(tahun <= 1){ jawabanCategory[0]['value'] += val.value; - } else if(tahun >= 3 && tahun <= 5){ + } else if(tahun >= 2 && tahun <= 5){ jawabanCategory[1]['value'] += val.value; } else if(tahun >= 6 && tahun <= 10) { jawabanCategory[2]['value'] += val.value; diff --git a/resources/views/layouts/template_admin.blade.php b/resources/views/layouts/template_admin.blade.php index e3be3e8..6f304bf 100644 --- a/resources/views/layouts/template_admin.blade.php +++ b/resources/views/layouts/template_admin.blade.php @@ -113,16 +113,16 @@ Dashboard Per Unit
- -
- Analisis Per Soal -
-
Analisis Demografi
+ +
+ Analisis Per Soal +
+
Detail Jawaban Pegawai diff --git a/routes/web.php b/routes/web.php index b4daa1d..7589968 100644 --- a/routes/web.php +++ b/routes/web.php @@ -11,6 +11,7 @@ Route::post('/jawaban', [SoalController::class, 'store'])->name('soal.store'); Route::get('/jawaban/terima-kasih', [SoalController::class, 'thankYou'])->name('soal.thankyou'); Route::get('/admin', [AdminController::class, 'index']); Route::post('/admin/get_data_pegawai_sudah_survey', [AdminController::class, 'get_data_pegawai_sudah_survey']); +Route::post('/admin/get_data_pegawai_tidak_mau_survey', [AdminController::class, 'data_tidak_mau_survey']); Route::get('/admin/dashboard_jawaban', [AdminController::class, 'dashboard_analisis']); Route::post('/admin/get_data_dashboard_jawaban', [AdminController::class, 'get_data_dashboard_analisis']); Route::get('/redirect-smart', [SoalController::class, 'redirectSmart']);