Compare commits
No commits in common. "47793b680de31c115fa95f24714cec383a28812b" and "408beaa42cef31a534a70652c74adeabcba58307" have entirely different histories.
47793b680d
...
408beaa42c
@ -8,51 +8,14 @@ use App\Exports\DashboardExport;
|
|||||||
use App\Exports\DashboardJawabanExport;
|
use App\Exports\DashboardJawabanExport;
|
||||||
use App\Models\Jawaban;
|
use App\Models\Jawaban;
|
||||||
use App\Models\JawabanDetail;
|
use App\Models\JawabanDetail;
|
||||||
use App\Models\MappingUnitPegawai;
|
|
||||||
use App\Models\SoalDetail;
|
use App\Models\SoalDetail;
|
||||||
use App\Models\UnitKerja;
|
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
use Maatwebsite\Excel\Facades\Excel;
|
use Maatwebsite\Excel\Facades\Excel;
|
||||||
use Yajra\DataTables\DataTables;
|
use Yajra\DataTables\DataTables;
|
||||||
use Illuminate\Support\Str;
|
|
||||||
|
|
||||||
class AdminController extends Controller
|
class AdminController extends Controller
|
||||||
{
|
{
|
||||||
private function unitKey(?string $s):string
|
|
||||||
{
|
|
||||||
if (!$s) return '';
|
|
||||||
|
|
||||||
$s = Str::of($s)->lower()->trim();
|
|
||||||
|
|
||||||
// buang teks dalam kurung: (SIMRS) dll
|
|
||||||
$s = $s->replaceMatches('/\s*\([^)]*\)\s*/u', ' ');
|
|
||||||
|
|
||||||
// expand singkatan penting
|
|
||||||
$s = $s->replaceMatches('/\bksm\b/u', 'kelompok staf medik');
|
|
||||||
$s = $s->replaceMatches('/\btimker\b/u', 'tim kerja');
|
|
||||||
$s = $s->replaceMatches('/\bhumas\b/u', 'hubungan masyarakat');
|
|
||||||
$s = $s->replaceMatches('/\bipt\b/u', 'instalasi perinatal terpadu');
|
|
||||||
$s = $s->replaceMatches('/\bissb\b/u', 'instalasi sterilisasi sentral dan binatu');
|
|
||||||
$s = $s->replaceMatches('/\bipsprs\b/u', 'instalasi pemeliharaan sarana prasarana rumah sakit');
|
|
||||||
$s = $s->replaceMatches('/\binstalasi\s+rawat\s+intensif\s*\/\s*icu\b/u', 'instalasi rawat intensif');
|
|
||||||
$s = $s->replaceMatches(
|
|
||||||
'/\binstalasi\s+kl\s*(?:&|\/)?\s*k3rs\b/u',
|
|
||||||
'instalasi kesehatan lingkungan dan keselamatan dan kesehatan kerja rumah sakit'
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
// samakan simbol
|
|
||||||
$s = $s->replace(['&', '/', '-', '.', ',', ':', ';'], ' ');
|
|
||||||
|
|
||||||
// samakan kata penghubung
|
|
||||||
$s = $s->replace(' dan ', ' ');
|
|
||||||
|
|
||||||
// rapikan spasi
|
|
||||||
$s = $s->replaceMatches('/\s+/u', ' ')->trim();
|
|
||||||
|
|
||||||
return (string) $s;
|
|
||||||
}
|
|
||||||
//
|
//
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
@ -123,7 +86,10 @@ class AdminController extends Controller
|
|||||||
"Komite Medik",
|
"Komite Medik",
|
||||||
"Komite Keperawatan",
|
"Komite Keperawatan",
|
||||||
"Komite PPI & PRA",
|
"Komite PPI & PRA",
|
||||||
"KTKL", "KFT", "KEH", "ULP",
|
"KTKL",
|
||||||
|
"KFT",
|
||||||
|
"KEH",
|
||||||
|
"ULP",
|
||||||
"Timker Yankep",
|
"Timker Yankep",
|
||||||
"Timker Yanjang",
|
"Timker Yanjang",
|
||||||
"Timker Perencanaan, Evaluasi dan Program",
|
"Timker Perencanaan, Evaluasi dan Program",
|
||||||
@ -150,7 +116,12 @@ class AdminController extends Controller
|
|||||||
"Instalasi Gawat Darurat",
|
"Instalasi Gawat Darurat",
|
||||||
"Instalasi Verifikasi dan Penjaminan Pasien",
|
"Instalasi Verifikasi dan Penjaminan Pasien",
|
||||||
"Instalasi KL & K3RS",
|
"Instalasi KL & K3RS",
|
||||||
"ISSB", "IPT", "IPJNI", "IPSPRS", "IPPB", "IPPISGB",
|
"ISSB",
|
||||||
|
"IPT",
|
||||||
|
"IPJNI",
|
||||||
|
"IPSPRS",
|
||||||
|
"IPPB",
|
||||||
|
"IPPISGB",
|
||||||
"Instalasi Rawat Jalan Eksekutif",
|
"Instalasi Rawat Jalan Eksekutif",
|
||||||
"Instalasi Teknologi Berbantu (TRB)",
|
"Instalasi Teknologi Berbantu (TRB)",
|
||||||
"Klinik Utama Bintaro",
|
"Klinik Utama Bintaro",
|
||||||
@ -161,84 +132,35 @@ class AdminController extends Controller
|
|||||||
"KSM Gigi & Mulut",
|
"KSM Gigi & Mulut",
|
||||||
"KSM Spesialis Lain",
|
"KSM Spesialis Lain",
|
||||||
"KSM Umum",
|
"KSM Umum",
|
||||||
"Lainnya",
|
"Lainnya"
|
||||||
];
|
];
|
||||||
|
|
||||||
// 1) Total karyawan per UnitKerja (unik pegawai)
|
|
||||||
$unitPegawai = UnitKerja::query()
|
|
||||||
->where('statusenabled', true)
|
|
||||||
->with([
|
|
||||||
'mappingPegawai' => function ($q) {
|
|
||||||
$q->where('statusenabled', true)
|
|
||||||
->whereHas('pegawai', fn ($p) => $p->where('statusenabled', true)->where('kedudukanfk', 1))
|
|
||||||
->with([
|
|
||||||
'pegawai' => fn ($p) => $p->where('statusenabled', true)->where('kedudukanfk', 1)
|
|
||||||
->select('id', 'namalengkap')
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
])
|
|
||||||
->get();
|
|
||||||
|
|
||||||
$unitTotals = $unitPegawai->map(function ($unit) {
|
|
||||||
$pegawaiUnik = $unit->mappingPegawai
|
|
||||||
->pluck('pegawai')
|
|
||||||
->filter()
|
|
||||||
->unique('id');
|
|
||||||
|
|
||||||
return [
|
|
||||||
'name' => $unit->name,
|
|
||||||
'total_karyawan' => $pegawaiUnik->count(),
|
|
||||||
];
|
|
||||||
});
|
|
||||||
|
|
||||||
// map: key(normalized unit) => total_karyawan
|
|
||||||
$unitTotalMaps = $unitTotals->mapWithKeys(function ($item) {
|
|
||||||
return [$this->unitKey($item['name']) => (int)$item['total_karyawan']];
|
|
||||||
});
|
|
||||||
|
|
||||||
// 2) Query Jawaban (ini yang nanti difilter)
|
|
||||||
$query = Jawaban::query()
|
$query = Jawaban::query()
|
||||||
->select('unit', DB::raw('COUNT(*) as total_unit'))
|
->select([
|
||||||
->whereNotNull('unit');
|
'unit',
|
||||||
|
DB::raw('COUNT(*) as total_unit'),
|
||||||
|
])->whereNotNull('unit');
|
||||||
|
|
||||||
|
|
||||||
if ($request->unit_kerja) {
|
if ($request->unit_kerja) {
|
||||||
$query->whereIn('unit', (array) $request->unit_kerja);
|
$query->whereIn('unit', (array) $request->unit_kerja);
|
||||||
|
$masterUnits = array_intersect($masterUnits, $request->unit_kerja);
|
||||||
}
|
}
|
||||||
|
$query->groupBy('unit')
|
||||||
|
->havingRaw('COUNT(*) > 0');
|
||||||
|
$rekap = $query->get()->pluck('total_unit', 'unit');
|
||||||
|
|
||||||
$jawabanCounts = $query->groupBy('unit')->get();
|
$data = collect($masterUnits)
|
||||||
|
->filter(fn($unit) => ($rekap[$unit] ?? 0) > 0)
|
||||||
// Map total karyawan: key(normalized) => total_karyawan (ini dari UnitKerja)
|
->map(fn($unit) => [
|
||||||
$unitTotalMaps = $unitTotals->mapWithKeys(function ($item) {
|
'unit' => $unit,
|
||||||
return [$this->unitKey($item['name']) => (int) $item['total_karyawan']];
|
'total_unit' => $rekap[$unit],
|
||||||
});
|
])
|
||||||
|
|
||||||
// Build data dari JAWABAN langsung (bukan masterUnits)
|
|
||||||
$data = $jawabanCounts->map(function ($row) use ($unitTotalMaps) {
|
|
||||||
|
|
||||||
$key = $this->unitKey($row->unit);
|
|
||||||
$sudahIsi = (int) $row->total_unit;
|
|
||||||
|
|
||||||
if (isset($unitTotalMaps[$key]) && (int)$unitTotalMaps[$key] > 0) {
|
|
||||||
$totalKaryawan = (int) $unitTotalMaps[$key];
|
|
||||||
$progress = $sudahIsi . ' / ' . $totalKaryawan;
|
|
||||||
} else {
|
|
||||||
$totalKaryawan = null; // tidak diketahui
|
|
||||||
$progress = (string) $sudahIsi; // hanya angka, tanpa /0
|
|
||||||
}
|
|
||||||
|
|
||||||
return [
|
|
||||||
'unit' => $row->unit,
|
|
||||||
'total_unit' => $progress
|
|
||||||
];
|
|
||||||
})
|
|
||||||
->values();
|
->values();
|
||||||
|
|
||||||
return DataTables::of($data)->make(true);
|
return DataTables::of($data)->make(true);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function download_report_data_pegawai_sudah_survey(Request $request)
|
public function download_report_data_pegawai_sudah_survey(Request $request)
|
||||||
{
|
{
|
||||||
$masterUnits = [
|
$masterUnits = [
|
||||||
@ -971,9 +893,6 @@ class AdminController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
return DataTables::of($query)
|
return DataTables::of($query)
|
||||||
->addColumn('nama_pegawai', function($row){
|
|
||||||
return $row?->pegawai?->nama ?? '-';
|
|
||||||
})
|
|
||||||
->addColumn('action', function ($row) {
|
->addColumn('action', function ($row) {
|
||||||
return '
|
return '
|
||||||
<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#detail_jawaban" data-id="'. $row->id .'">
|
<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#detail_jawaban" data-id="'. $row->id .'">
|
||||||
|
|||||||
@ -194,7 +194,7 @@ class SoalController extends Controller
|
|||||||
$namaResponden = $answer;
|
$namaResponden = $answer;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Str::contains($pertanyaan, 'apa unit/area kerja anda saat ini')) {
|
if (Str::contains($pertanyaan, 'unit/area kerja anda saat ini')) {
|
||||||
$unitKerja = $answer;
|
$unitKerja = $answer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -244,8 +244,6 @@ class SoalController extends Controller
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return redirect()->route('soal.thankyou')
|
return redirect()->route('soal.thankyou')
|
||||||
->with('success', 'Jawaban berhasil disimpan.');
|
->with('success', 'Jawaban berhasil disimpan.');
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,15 +9,11 @@ class Jawaban extends Model
|
|||||||
protected $connection = 'dbLmsMutu';
|
protected $connection = 'dbLmsMutu';
|
||||||
protected $table = 'public.lms_mutu_jawaban';
|
protected $table = 'public.lms_mutu_jawaban';
|
||||||
protected $guarded = ['id'];
|
protected $guarded = ['id'];
|
||||||
protected $with = ['jawabanDetail', 'pegawai'];
|
protected $with = ['jawabanDetail'];
|
||||||
|
|
||||||
public $timestamps = false;
|
public $timestamps = false;
|
||||||
|
|
||||||
public function jawabanDetail(){
|
public function jawabanDetail(){
|
||||||
return $this->hasMany(JawabanDetail::class, 'lms_mutu_jawaban_id', 'id');
|
return $this->hasMany(JawabanDetail::class, 'lms_mutu_jawaban_id', 'id');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function pegawai(){
|
|
||||||
return $this->belongsTo(Pegawai::class, 'pegawai_id', 'id');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,18 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Models;
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Model;
|
|
||||||
|
|
||||||
class MappingUnitPegawai extends Model
|
|
||||||
{
|
|
||||||
protected $connection = 'dbSmartv1'; // nama connection di config/database.php
|
|
||||||
protected $table = 'mappegawaijabatantounitkerja_m'; // atau 'public.pegawai_m' kalau pakai schema
|
|
||||||
protected $primaryKey = 'id';
|
|
||||||
protected $with = ['pegawai'];
|
|
||||||
|
|
||||||
public function pegawai(){
|
|
||||||
return $this->belongsTo(Pegawai::class, 'objectpegawaifk', 'id');
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,15 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Models;
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Model;
|
|
||||||
|
|
||||||
class Pegawai extends Model
|
|
||||||
{
|
|
||||||
protected $connection = 'dbSmartv1'; // nama connection di config/database.php
|
|
||||||
protected $table = 'pegawai_m'; // atau 'public.pegawai_m' kalau pakai schema
|
|
||||||
protected $primaryKey = 'id';
|
|
||||||
public $timestamps = false;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,18 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Models;
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Model;
|
|
||||||
|
|
||||||
class UnitKerja extends Model
|
|
||||||
{
|
|
||||||
protected $connection = 'dbSmartv1'; // nama connection di config/database.php
|
|
||||||
protected $table = 'unitkerjapegawai_m'; // atau 'public.pegawai_m' kalau pakai schema
|
|
||||||
protected $primaryKey = 'id';
|
|
||||||
protected $with = ['mappingPegawai'];
|
|
||||||
|
|
||||||
public function mappingPegawai(){
|
|
||||||
return $this->hasMany(MappingUnitPegawai::class, 'objectunitkerjapegawaifk', 'id');
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -44,7 +44,6 @@
|
|||||||
<thead class="bg-primary" id="table_header">
|
<thead class="bg-primary" id="table_header">
|
||||||
<tr>
|
<tr>
|
||||||
<th class="text-white fs-5">Nama Pegawai</th>
|
<th class="text-white fs-5">Nama Pegawai</th>
|
||||||
<th class="text-white fs-5">Inisial Pegawai</th>
|
|
||||||
<th class="text-white fs-5">Unit Kerja</th>
|
<th class="text-white fs-5">Unit Kerja</th>
|
||||||
<th class="text-white fs-5">Action</th>
|
<th class="text-white fs-5">Action</th>
|
||||||
</tr>
|
</tr>
|
||||||
@ -116,7 +115,6 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
columns: [
|
columns: [
|
||||||
{ data: 'nama_pegawai' },
|
|
||||||
{ data: 'nama' },
|
{ data: 'nama' },
|
||||||
{ data: 'unit' },
|
{ data: 'unit' },
|
||||||
{ data: 'action' }
|
{ data: 'action' }
|
||||||
|
|||||||
@ -17,7 +17,7 @@ Route::middleware('ceklogin')->group(function () {
|
|||||||
Route::get('/admin', [AdminController::class, 'index']);
|
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_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::post('/admin/get_data_pegawai_tidak_mau_survey', [AdminController::class, 'data_tidak_mau_survey']);
|
||||||
// Route::get('/admin/dashboard_jawaban', [AdminController::class, 'dashboard_analisis']);
|
Route::get('/admin/dashboard_jawaban', [AdminController::class, 'dashboard_analisis']);
|
||||||
Route::post('/admin/get_data_dashboard_jawaban', [AdminController::class, 'get_data_dashboard_analisis']);
|
Route::post('/admin/get_data_dashboard_jawaban', [AdminController::class, 'get_data_dashboard_analisis']);
|
||||||
Route::post('/admin/report', [AdminController::class, 'download_report_data_pegawai_sudah_survey']);
|
Route::post('/admin/report', [AdminController::class, 'download_report_data_pegawai_sudah_survey']);
|
||||||
Route::get('/admin/dashboard_analisis', [AdminController::class, 'dashboard_analisis']);
|
Route::get('/admin/dashboard_analisis', [AdminController::class, 'dashboard_analisis']);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user