Compare commits
21 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 90ebd7c545 | |||
| 1b1aed2858 | |||
| 114c7fbcc9 | |||
| 751a4f9283 | |||
| 56b9f227a0 | |||
| e4b089b695 | |||
| 0da23d7f12 | |||
| bbbe40afb3 | |||
| 8963668618 | |||
| c21910fb7c | |||
| 11d7ed7eb1 | |||
| d01d4b090c | |||
| c10cdf39ca | |||
| 6672f34adc | |||
| 70c796d230 | |||
| 1d58c66a7a | |||
| a1462095a7 | |||
| dcf57bcfdc | |||
| 05ab6fee35 | |||
| f2aeb9c695 | |||
| 261fa7ff8f |
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Pegawai;
|
||||
|
||||
use App\Models\Verifikator\Dosen;
|
||||
use App\Models\Verifikator\Tendik;
|
||||
use App\Services\SiskaService;
|
||||
use Exception;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class UpdateNoHpPimpinanCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'pegawai:update-no-hp-pimpinan';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Update nomor HP dosen dan tendik dari SISKA API (api/v2/user/pimpinan)';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
public function handle(SiskaService $siskaService)
|
||||
{
|
||||
$this->info('Mengambil data pimpinan dari SISKA...');
|
||||
|
||||
$pimpinan = $siskaService->daftarPimpinan();
|
||||
|
||||
if ($pimpinan === null) {
|
||||
$this->error('Gagal mengambil data dari SISKA');
|
||||
|
||||
return Command::FAILURE;
|
||||
}
|
||||
|
||||
$this->info('Total data pimpinan: '.count($pimpinan));
|
||||
|
||||
// NIP bisa muncul berkali-kali dengan no_hp berbeda, ambil yang terakhir
|
||||
$noHpByNip = [];
|
||||
foreach ($pimpinan as $item) {
|
||||
$nip = $item['nip'] ?? null;
|
||||
$noHp = $item['no_hp'] ?? null;
|
||||
|
||||
if (! $nip || ! $noHp) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$noHpByNip[$nip] = $noHp;
|
||||
}
|
||||
|
||||
$this->info('Total NIP unik: '.count($noHpByNip));
|
||||
$this->newLine();
|
||||
|
||||
$updatedDosen = 0;
|
||||
$updatedTendik = 0;
|
||||
|
||||
try {
|
||||
$nipList = array_keys($noHpByNip);
|
||||
|
||||
$dosens = Dosen::whereIn('nip', $nipList)->get(['id', 'nip', 'no_hp']);
|
||||
foreach ($dosens as $dosen) {
|
||||
$noHp = $noHpByNip[$dosen->nip];
|
||||
if ($dosen->no_hp !== $noHp) {
|
||||
$dosen->update(['no_hp' => $noHp]);
|
||||
$updatedDosen++;
|
||||
}
|
||||
}
|
||||
|
||||
$tendiks = Tendik::whereIn('nip', $nipList)->get(['id', 'nip', 'no_hp']);
|
||||
foreach ($tendiks as $tendik) {
|
||||
$noHp = $noHpByNip[$tendik->nip];
|
||||
if ($tendik->no_hp !== $noHp) {
|
||||
$tendik->update(['no_hp' => $noHp]);
|
||||
$updatedTendik++;
|
||||
}
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
$this->error('Terjadi error: '.$e->getMessage());
|
||||
Log::error('Error saat update no_hp pimpinan', [
|
||||
'error' => $e->getMessage(),
|
||||
'trace' => $e->getTraceAsString(),
|
||||
]);
|
||||
|
||||
return Command::FAILURE;
|
||||
}
|
||||
|
||||
$this->info("Dosen diupdate: {$updatedDosen}");
|
||||
$this->info("Tendik diupdate: {$updatedTendik}");
|
||||
$this->info('Selesai.');
|
||||
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,152 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use App\Exports\Concerns\ForcesTextColumns;
|
||||
use App\Http\Controllers\Perhitungan\Remunerasi\KeseluruhanController;
|
||||
use Maatwebsite\Excel\Concerns\FromArray;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
|
||||
use Maatwebsite\Excel\Concerns\WithCustomValueBinder;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use PhpOffice\PhpSpreadsheet\Cell\Coordinate;
|
||||
use PhpOffice\PhpSpreadsheet\Style\Alignment;
|
||||
use PhpOffice\PhpSpreadsheet\Style\Fill;
|
||||
|
||||
class KeseluruhanExport implements FromArray, ShouldAutoSize, WithColumnFormatting, WithCustomValueBinder, WithEvents, WithMapping
|
||||
{
|
||||
use ForcesTextColumns;
|
||||
|
||||
/**
|
||||
* Jumlah kolom tetap di depan (No., Nama, NIP, Jenis Pegawai, Unit Kerja) sebelum kolom
|
||||
* bulanan P1 dimulai.
|
||||
*/
|
||||
private const FIXED_COLUMNS = ['No.', 'Nama', 'NIP', 'Jenis Pegawai', 'Unit Kerja'];
|
||||
|
||||
/**
|
||||
* Kolom setelah blok bulanan P1 (tidak ikut di-expand per bulan).
|
||||
*/
|
||||
private const TRAILING_COLUMNS = ['Jumlah P2', 'Jumlah THR', 'Jumlah R13', 'Jumlah Publikasi', 'Total'];
|
||||
|
||||
private const BULAN_NAMES = [
|
||||
1 => 'Januari', 2 => 'Februari', 3 => 'Maret', 4 => 'April', 5 => 'Mei', 6 => 'Juni',
|
||||
7 => 'Juli', 8 => 'Agustus', 9 => 'September', 10 => 'Oktober', 11 => 'November', 12 => 'Desember',
|
||||
];
|
||||
|
||||
private array $rows;
|
||||
|
||||
private int $bulanTerakhir;
|
||||
|
||||
protected function nipColumns(): array
|
||||
{
|
||||
return ['C'];
|
||||
}
|
||||
|
||||
public function __construct(int $tahun, ?string $jenisPegawai, mixed $unit, bool $includePppk2025 = false, bool $includeP1Zero = false)
|
||||
{
|
||||
$controller = app(KeseluruhanController::class);
|
||||
|
||||
$this->rows = $controller->getRekapRows($tahun, $jenisPegawai, $unit, $includePppk2025, $includeP1Zero);
|
||||
$this->bulanTerakhir = $controller->getBulanTerakhir($tahun);
|
||||
}
|
||||
|
||||
public function array(): array
|
||||
{
|
||||
return $this->rows;
|
||||
}
|
||||
|
||||
public function map($row): array
|
||||
{
|
||||
static $no = 0;
|
||||
$no++;
|
||||
|
||||
$bulananValues = [];
|
||||
for ($bulan = 1; $bulan <= $this->bulanTerakhir; $bulan++) {
|
||||
$bulananValues[] = $row['jumlah_p1_bulanan'][$bulan] ?? 0;
|
||||
}
|
||||
|
||||
return array_merge([
|
||||
$no,
|
||||
$row['nama'],
|
||||
$row['nip'],
|
||||
$row['jenis_pegawai'] === 'dosen' ? 'Dosen' : ($row['jenis_pegawai'] === 'tendik' ? 'Tendik' : '-'),
|
||||
$row['nama_unit'],
|
||||
], $bulananValues, [
|
||||
$row['jumlah_p2'],
|
||||
$row['jumlah_thr'],
|
||||
$row['jumlah_r13'],
|
||||
$row['jumlah_publikasi'],
|
||||
$row['total'],
|
||||
]);
|
||||
}
|
||||
|
||||
public function columnFormats(): array
|
||||
{
|
||||
$accountingFormat = '_("Rp"\ * #,##0.00_);_("Rp"\ * \-#,##0.00_);_("Rp"\ * "-"??_);_(@_)';
|
||||
$fixedCount = count(self::FIXED_COLUMNS);
|
||||
$lastIndex = $fixedCount + $this->bulanTerakhir + count(self::TRAILING_COLUMNS);
|
||||
|
||||
$formats = ['C' => '@'];
|
||||
for ($i = $fixedCount + 1; $i <= $lastIndex; $i++) {
|
||||
$formats[Coordinate::stringFromColumnIndex($i)] = $accountingFormat;
|
||||
}
|
||||
|
||||
return $formats;
|
||||
}
|
||||
|
||||
/**
|
||||
* Data (via array()+map()) ditulis mulai baris 1 karena export ini sengaja tidak memakai
|
||||
* WithHeadings biasa. Di sini baris 1-2 disisipkan di atasnya untuk header 2 tingkat: baris 1
|
||||
* berisi label grup ("Jumlah P1 (Januari - Sekarang)" yang di-merge selebar kolom bulanannya,
|
||||
* dan label lain yang di-merge vertikal 2 baris), baris 2 berisi nama tiap bulan.
|
||||
*/
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function (AfterSheet $event) {
|
||||
$sheet = $event->sheet->getDelegate();
|
||||
$sheet->insertNewRowBefore(1, 2);
|
||||
|
||||
$fixedCount = count(self::FIXED_COLUMNS);
|
||||
|
||||
foreach (self::FIXED_COLUMNS as $i => $label) {
|
||||
$col = Coordinate::stringFromColumnIndex($i + 1);
|
||||
$sheet->setCellValue($col.'1', $label);
|
||||
$sheet->mergeCells($col.'1:'.$col.'2');
|
||||
}
|
||||
|
||||
$p1StartCol = Coordinate::stringFromColumnIndex($fixedCount + 1);
|
||||
$p1EndCol = Coordinate::stringFromColumnIndex($fixedCount + $this->bulanTerakhir);
|
||||
$sheet->setCellValue($p1StartCol.'1', 'Jumlah P1 (Januari - Sekarang)');
|
||||
$sheet->mergeCells($p1StartCol.'1:'.$p1EndCol.'1');
|
||||
|
||||
for ($bulan = 1; $bulan <= $this->bulanTerakhir; $bulan++) {
|
||||
$col = Coordinate::stringFromColumnIndex($fixedCount + $bulan);
|
||||
$sheet->setCellValue($col.'2', self::BULAN_NAMES[$bulan]);
|
||||
}
|
||||
|
||||
foreach (self::TRAILING_COLUMNS as $i => $label) {
|
||||
$col = Coordinate::stringFromColumnIndex($fixedCount + $this->bulanTerakhir + $i + 1);
|
||||
$sheet->setCellValue($col.'1', $label);
|
||||
$sheet->mergeCells($col.'1:'.$col.'2');
|
||||
}
|
||||
|
||||
$lastCol = Coordinate::stringFromColumnIndex($fixedCount + $this->bulanTerakhir + count(self::TRAILING_COLUMNS));
|
||||
$sheet->getStyle('A1:'.$lastCol.'2')->applyFromArray([
|
||||
'font' => ['bold' => true, 'color' => ['rgb' => 'FFFFFF']],
|
||||
'fill' => [
|
||||
'fillType' => Fill::FILL_SOLID,
|
||||
'startColor' => ['rgb' => '4472C4'],
|
||||
],
|
||||
'alignment' => [
|
||||
'horizontal' => Alignment::HORIZONTAL_CENTER,
|
||||
'vertical' => Alignment::VERTICAL_CENTER,
|
||||
'wrapText' => true,
|
||||
],
|
||||
]);
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,284 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Perhitungan\Remunerasi;
|
||||
|
||||
use App\Exports\KeseluruhanExport;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Rekapitulasi\P1;
|
||||
use App\Models\Verifikator\Periode;
|
||||
use App\Models\Verifikator\Publikasi;
|
||||
use App\Models\Verifikator\UnitKerja;
|
||||
use App\Models\Verifikator\View\Pegawai;
|
||||
use App\Services\DawaiService;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\View\View;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
||||
use Yajra\DataTables\Facades\DataTables;
|
||||
|
||||
class KeseluruhanController extends Controller
|
||||
{
|
||||
private function authorizeAccess(): void
|
||||
{
|
||||
abort_unless(auth()->user()->hasRole('Superuser'), 403);
|
||||
}
|
||||
|
||||
public function index(): View
|
||||
{
|
||||
$this->authorizeAccess();
|
||||
|
||||
$title = 'Keseluruhan';
|
||||
|
||||
return view('perhitungan.remunerasi.keseluruhan.index', compact('title'));
|
||||
}
|
||||
|
||||
public function data(Request $request): JsonResponse
|
||||
{
|
||||
$this->authorizeAccess();
|
||||
|
||||
$tahun = (int) ($request->tahun ?: now()->year);
|
||||
$jenisPegawai = $request->jenis_pegawai ?: null;
|
||||
$unit = $request->unit;
|
||||
$includePppk2025 = $request->boolean('include_pppk_2025');
|
||||
$includeP1Zero = $request->boolean('include_p1_zero');
|
||||
|
||||
$rows = collect($this->getRekapRows($tahun, $jenisPegawai, $unit, $includePppk2025, $includeP1Zero));
|
||||
|
||||
return DataTables::of($rows)
|
||||
->editColumn('jenis_pegawai', fn ($row) => $row['jenis_pegawai'] === 'dosen' ? 'Dosen' : ($row['jenis_pegawai'] === 'tendik' ? 'Tendik' : '-'))
|
||||
->editColumn('jumlah_p1', fn ($row) => 'Rp. '.number_format($row['jumlah_p1'], 2, ',', '.'))
|
||||
->editColumn('jumlah_p2', fn ($row) => 'Rp. '.number_format($row['jumlah_p2'], 2, ',', '.'))
|
||||
->editColumn('jumlah_thr', fn ($row) => 'Rp. '.number_format($row['jumlah_thr'], 2, ',', '.'))
|
||||
->editColumn('jumlah_r13', fn ($row) => 'Rp. '.number_format($row['jumlah_r13'], 2, ',', '.'))
|
||||
->editColumn('jumlah_publikasi', fn ($row) => 'Rp. '.number_format($row['jumlah_publikasi'], 2, ',', '.'))
|
||||
->editColumn('total', fn ($row) => 'Rp. '.number_format($row['total'], 2, ',', '.'))
|
||||
->with([
|
||||
'jumlahPegawai' => $rows->count(),
|
||||
'totalKeseluruhan' => number_format($rows->sum('total'), 2, ',', '.'),
|
||||
])
|
||||
->make();
|
||||
}
|
||||
|
||||
public function export(Request $request): BinaryFileResponse
|
||||
{
|
||||
$this->authorizeAccess();
|
||||
|
||||
set_time_limit(300);
|
||||
|
||||
$tahun = (int) ($request->tahun ?: now()->year);
|
||||
$jenisPegawai = $request->jenis_pegawai ?: null;
|
||||
$unit = $request->unit;
|
||||
$includePppk2025 = $request->boolean('include_pppk_2025');
|
||||
$includeP1Zero = $request->boolean('include_p1_zero');
|
||||
|
||||
$unitName = '_Semua_Unit_Kerja';
|
||||
if ($unit !== null && $unit !== '') {
|
||||
$unitKerja = UnitKerja::find((int) $unit === 99 ? 0 : (int) $unit);
|
||||
if ($unitKerja) {
|
||||
$unitName = '_'.str_replace(['/', ' ', '.'], '_', $unitKerja->nama);
|
||||
}
|
||||
}
|
||||
|
||||
$filename = "Remunerasi_Keseluruhan_{$tahun}{$unitName}.xlsx";
|
||||
|
||||
return Excel::download(new KeseluruhanExport($tahun, $jenisPegawai, $unit, $includePppk2025, $includeP1Zero), $filename);
|
||||
}
|
||||
|
||||
/**
|
||||
* Bangun daftar rekap per pegawai (Pegawai, Unit Kerja, Jumlah P1/P2/THR/R13/Publikasi) untuk
|
||||
* tahun terpilih. Dipakai bersama oleh data() (DataTables) dan KeseluruhanExport supaya kedua
|
||||
* sisi (tampilan web & export Excel) selalu konsisten.
|
||||
*/
|
||||
public function getRekapRows(int $tahun, ?string $jenisPegawai, mixed $unit, bool $includePppk2025 = false, bool $includeP1Zero = false): array
|
||||
{
|
||||
$rows = $this->buildRekap($tahun, $jenisPegawai);
|
||||
|
||||
if ($unit !== null && $unit !== '') {
|
||||
$unitBucket = (int) $unit;
|
||||
$rows = $rows->filter(function ($row) use ($unitBucket) {
|
||||
if ($unitBucket === 99) {
|
||||
return $row['unit_kerja_id'] === null || ! in_array((int) $row['unit_kerja_id'], range(1, 9), true);
|
||||
}
|
||||
|
||||
return (int) $row['unit_kerja_id'] === $unitBucket;
|
||||
})->values();
|
||||
}
|
||||
|
||||
if (! $includePppk2025) {
|
||||
$rows = $rows->filter(fn ($row) => ! str_contains($row['nip'] ?? '', '202521'))->values();
|
||||
}
|
||||
|
||||
if (! $includeP1Zero) {
|
||||
$rows = $rows->filter(fn ($row) => ($row['jumlah_p1'] ?? 0) > 0)->values();
|
||||
}
|
||||
|
||||
return $rows->sortBy('nama', SORT_NATURAL | SORT_FLAG_CASE)->values()->all();
|
||||
}
|
||||
|
||||
private function buildRekap(int $tahun, ?string $jenisPegawai): Collection
|
||||
{
|
||||
$cacheKey = 'remunerasi_keseluruhan_v4_'.$tahun.'_'.($jenisPegawai ?: 'semua');
|
||||
|
||||
return collect(Cache::remember($cacheKey, now()->addHours(6), fn () => $this->computeRekap($tahun, $jenisPegawai)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Bulan terakhir yang diikutkan dalam akumulasi P1 "Januari - Sekarang": bulan berjalan kalau
|
||||
* tahun yang dipilih adalah tahun sekarang, atau Desember kalau tahun yang dipilih sudah lewat.
|
||||
* Dipakai bersama oleh computeRekap() dan KeseluruhanExport supaya jumlah kolom bulanan konsisten.
|
||||
*/
|
||||
public function getBulanTerakhir(int $tahun): int
|
||||
{
|
||||
return $tahun === (int) now()->year ? (int) now()->month : 12;
|
||||
}
|
||||
|
||||
private function computeRekap(int $tahun, ?string $jenisPegawai): array
|
||||
{
|
||||
$normalize = fn ($nip) => preg_replace("/['.\-]/", '', (string) $nip);
|
||||
|
||||
// 1. P1 = akumulasi Januari s.d. bulan berjalan (atau Desember untuk tahun yang sudah lewat)
|
||||
$bulanTerakhir = $this->getBulanTerakhir($tahun);
|
||||
|
||||
$p1Rows = P1::query()
|
||||
->where('tahun', $tahun)
|
||||
->whereBetween('bulan', [1, $bulanTerakhir])
|
||||
->when($jenisPegawai, fn ($q) => $q->whereRaw('LOWER(jenis_pegawai) = ?', [strtolower($jenisPegawai)]))
|
||||
->get()
|
||||
->groupBy(fn ($row) => $normalize($row->nip));
|
||||
|
||||
$p1 = $p1Rows->map(fn ($rows) => (float) $rows->sum('gaji_yang_dibayarkan'));
|
||||
|
||||
// Rincian per bulan (dipakai untuk breakdown kolom bulanan di export Excel).
|
||||
$p1Bulanan = $p1Rows->map(fn ($rows) => $rows->groupBy('bulan')->map(fn ($bulanRows) => (float) $bulanRows->sum('gaji_yang_dibayarkan')));
|
||||
|
||||
// 2. P2 = Semester 1 tahun terpilih
|
||||
$periodeSemester1 = Periode::where('nama', 'LIKE', "%{$tahun} Semester 1%")->value('id_periode');
|
||||
|
||||
$p2 = collect();
|
||||
if ($periodeSemester1) {
|
||||
$p2 = Pegawai::withoutGlobalScopes()
|
||||
->join('verifikator.jabatan_pegawais as jp', 'verifikator.pegawais.nip', '=', 'jp.nip')
|
||||
->join('verifikator.jabatan_pegawai_details as jpd', 'jp.id', '=', 'jpd.jabatan_pegawai_id')
|
||||
->join('verifikator.remunerasi_per_bulans as rpb', 'jpd.id', '=', 'rpb.jabatan_pegawai_detail_id')
|
||||
->select('verifikator.pegawais.nip')
|
||||
->selectRaw('SUM(rpb.p2_bruto) as total')
|
||||
->whereNull('rpb.deleted_at')
|
||||
->where('jp.periode', $periodeSemester1)
|
||||
->when($jenisPegawai, fn ($q) => $q->where('jpd.jenis_pegawai', $jenisPegawai))
|
||||
->groupBy('verifikator.pegawais.nip')
|
||||
->havingRaw('SUM(rpb.p2_bruto) > 0')
|
||||
->get()
|
||||
->keyBy(fn ($row) => $normalize($row->nip))
|
||||
->map(fn ($row) => (float) $row->total);
|
||||
}
|
||||
|
||||
// 3. THR & 4. R13 = data eksternal (API Dawai), untuk seluruh unit sekaligus lalu di-cache
|
||||
// per hari seperti pola THRController/R13Controller.
|
||||
$jenisPegawaiParam = $jenisPegawai ?? '';
|
||||
|
||||
$thrData = Cache::remember(
|
||||
"keseluruhan_thr_{$jenisPegawaiParam}_{$tahun}",
|
||||
now()->addDay(),
|
||||
fn () => (new DawaiService)->getDataThr($jenisPegawaiParam, $tahun, null, false)
|
||||
);
|
||||
$thr = collect($thrData)->keyBy(fn ($row) => $normalize($row['nip'] ?? ''))->map(fn ($row) => (float) ($row['total_thr'] ?? 0));
|
||||
|
||||
$r13Data = Cache::remember(
|
||||
"keseluruhan_r13_{$jenisPegawaiParam}_{$tahun}",
|
||||
now()->addDay(),
|
||||
fn () => (new DawaiService)->getDataR13($jenisPegawaiParam, $tahun, null, false)
|
||||
);
|
||||
$r13 = collect($r13Data)->keyBy(fn ($row) => $normalize($row['nip'] ?? ''))->map(fn ($row) => (float) ($row['total_r13'] ?? 0));
|
||||
|
||||
// 5. Publikasi = seluruh periode yang namanya memuat tahun terpilih (mis. "2026 Semester 1"
|
||||
// maupun "2025/2026 Ganjil"), karena publikasi tidak terikat pada satu format periode tertentu.
|
||||
$periodeIds = Periode::where('nama', 'LIKE', "%{$tahun}%")->pluck('id_periode');
|
||||
|
||||
$publikasiQuery = Publikasi::query()
|
||||
->whereIn('periode', $periodeIds)
|
||||
->where('poin_total', '>', 0)
|
||||
->select('nip')
|
||||
->selectRaw('SUM(biaya_remunerasi) as total');
|
||||
|
||||
if ($jenisPegawai) {
|
||||
$publikasiQuery->whereHas('pegawai', function ($q) use ($jenisPegawai) {
|
||||
$q->withoutGlobalScopes()->where('jenis_pegawai', $jenisPegawai);
|
||||
});
|
||||
}
|
||||
|
||||
$publikasi = $publikasiQuery->groupBy('nip')->get()
|
||||
->keyBy(fn ($row) => $normalize($row->nip))
|
||||
->map(fn ($row) => (float) $row->total);
|
||||
|
||||
$allNips = $p1->keys()
|
||||
->merge($p2->keys())
|
||||
->merge($thr->keys())
|
||||
->merge($r13->keys())
|
||||
->merge($publikasi->keys())
|
||||
->unique()
|
||||
->values();
|
||||
|
||||
if ($allNips->isEmpty()) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$pegawaiInfo = Pegawai::withoutGlobalScopes()
|
||||
->leftJoin('verifikator.unit_kerja_pegawais as ukp', 'verifikator.pegawais.unit_kerja_id', '=', 'ukp.id')
|
||||
->select([
|
||||
'verifikator.pegawais.nip',
|
||||
'verifikator.pegawais.nama',
|
||||
'verifikator.pegawais.jenis_pegawai',
|
||||
'verifikator.pegawais.unit_kerja_id',
|
||||
'ukp.nama as nama_unit',
|
||||
])
|
||||
->get()
|
||||
->keyBy(fn ($row) => $normalize($row->nip));
|
||||
|
||||
return $allNips->map(function ($nip) use ($pegawaiInfo, $p1, $p1Bulanan, $bulanTerakhir, $p2, $thr, $r13, $publikasi, $jenisPegawai) {
|
||||
$info = $pegawaiInfo->get($nip);
|
||||
|
||||
if (! $info) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if ($jenisPegawai && strtolower((string) $info->jenis_pegawai) !== strtolower($jenisPegawai)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$jumlahP1 = $p1->get($nip, 0.0);
|
||||
$jumlahP2 = $p2->get($nip, 0.0);
|
||||
$jumlahThr = $thr->get($nip, 0.0);
|
||||
$jumlahR13 = $r13->get($nip, 0.0);
|
||||
$jumlahPublikasi = $publikasi->get($nip, 0.0);
|
||||
$total = $jumlahP1 + $jumlahP2 + $jumlahThr + $jumlahR13 + $jumlahPublikasi;
|
||||
|
||||
if ($total <= 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$bulananNip = $p1Bulanan->get($nip);
|
||||
$jumlahP1Bulanan = [];
|
||||
for ($bulan = 1; $bulan <= $bulanTerakhir; $bulan++) {
|
||||
$jumlahP1Bulanan[$bulan] = $bulananNip?->get($bulan, 0.0) ?? 0.0;
|
||||
}
|
||||
|
||||
return [
|
||||
'nip' => ltrim($info->nip ?? $nip, "'"),
|
||||
'nama' => $info->nama ?? '-',
|
||||
'jenis_pegawai' => strtolower($info->jenis_pegawai ?? ''),
|
||||
'unit_kerja_id' => $info->unit_kerja_id,
|
||||
'nama_unit' => $info->nama_unit ?? '-',
|
||||
'jumlah_p1' => $jumlahP1,
|
||||
'jumlah_p1_bulanan' => $jumlahP1Bulanan,
|
||||
'jumlah_p2' => $jumlahP2,
|
||||
'jumlah_thr' => $jumlahThr,
|
||||
'jumlah_r13' => $jumlahR13,
|
||||
'jumlah_publikasi' => $jumlahPublikasi,
|
||||
'total' => $total,
|
||||
];
|
||||
})->filter()->values()->all();
|
||||
}
|
||||
}
|
||||
@@ -685,6 +685,21 @@ class SiskaService
|
||||
return $sks;
|
||||
}
|
||||
|
||||
public function daftarPimpinan(): ?array
|
||||
{
|
||||
try {
|
||||
$response = $this->client->get('api/v2/user/pimpinan');
|
||||
} catch (Throwable $th) {
|
||||
Log::error('SISKA: '.$th->getMessage());
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
$data = json_decode($response->getBody()->getContents(), true);
|
||||
|
||||
return $data['data'] ?? null;
|
||||
}
|
||||
|
||||
public function status(string $status)
|
||||
{
|
||||
$result = [
|
||||
|
||||
@@ -553,6 +553,15 @@
|
||||
</a>
|
||||
</li>
|
||||
@endrole
|
||||
|
||||
@role('Superuser')
|
||||
<li class="li-remunerasi-keseluruhan">
|
||||
<a href="{{ route('remunerasi.keseluruhan.index') }}">
|
||||
<i class="uil-layer-group" style="margin-right: 3px; font-size:18px"></i>
|
||||
<span> Keseluruhan </span>
|
||||
</a>
|
||||
</li>
|
||||
@endrole
|
||||
</ul>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
@@ -0,0 +1,297 @@
|
||||
@extends('layouts.main')
|
||||
|
||||
@section('breadcrumb')
|
||||
<ol class="breadcrumb m-0">
|
||||
<li class="breadcrumb-item"><a href="javascript:void(0);">Perhitungan</a></li>
|
||||
<li class="breadcrumb-item"><a href="javascript:void(0);">Remunerasi</a></li>
|
||||
<li class="breadcrumb-item active" aria-current="page">{{ $title }}</li>
|
||||
</ol>
|
||||
@endsection
|
||||
|
||||
@section('content')
|
||||
<!-- Summary Card -->
|
||||
<div class="row">
|
||||
<div class="col-lg-6 col-md-6">
|
||||
<div class="card border">
|
||||
<div class="card-body">
|
||||
<div class="d-flex align-items-center">
|
||||
<div class="flex-shrink-0">
|
||||
<div class="bg-primary text-white rounded-2 p-2">
|
||||
<i class="uil-coins fs-4"></i>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex-grow-1 ms-3">
|
||||
<h6 class="text-muted mb-1">Total Keseluruhan</h6>
|
||||
<h4 class="mb-0" id="totalKeseluruhanDisplay">-</h4>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-6 col-md-6">
|
||||
<div class="card border">
|
||||
<div class="card-body">
|
||||
<div class="d-flex align-items-center">
|
||||
<div class="flex-shrink-0">
|
||||
<div class="bg-success text-white rounded-2 p-2">
|
||||
<i class="uil-users-alt fs-4"></i>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex-grow-1 ms-3">
|
||||
<h6 class="text-muted mb-1">Jumlah Pegawai</h6>
|
||||
<h4 class="mb-0" id="jumlahPegawaiDisplay">-</h4>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Table -->
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="card border">
|
||||
<div class="card-body">
|
||||
@php
|
||||
$actionButtons = '<button type="button" class="btn btn-sm btn-outline-success me-2" id="btn-export">
|
||||
<i class="uil-file-download-alt"></i> Export
|
||||
</button>
|
||||
<button type="button" class="btn btn-sm btn-outline-secondary" id="btnRefresh">
|
||||
<i class="uil-refresh"></i>
|
||||
Refresh
|
||||
</button>';
|
||||
@endphp
|
||||
|
||||
@include('components.datatable-header', [
|
||||
'title' => 'Rekap Keseluruhan Remunerasi',
|
||||
'description' => 'Rekap Jumlah P1, P2, THR, R13, dan Publikasi per pegawai',
|
||||
'actionButton' => $actionButtons,
|
||||
])
|
||||
|
||||
<!-- Filter Section -->
|
||||
<div class="row mb-3">
|
||||
<div class="col-sm-3">
|
||||
<label for="filter-jenis-pegawai" class="form-label">Jenis Pegawai</label>
|
||||
<select name="jenis_pegawai" id="filter-jenis-pegawai" class="form-select select2" data-placeholder="Semua Jenis">
|
||||
<option value=""></option>
|
||||
<option value="dosen">Dosen</option>
|
||||
<option value="tendik">Tendik</option>
|
||||
</select>
|
||||
<div class="d-flex align-items-center gap-3 mt-1">
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="checkbox" id="include_pppk_2025">
|
||||
<label class="form-check-label" for="include_pppk_2025">PPPK 2025</label>
|
||||
</div>
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="checkbox" id="include_p1_zero">
|
||||
<label class="form-check-label" for="include_p1_zero">P1 = 0</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-3">
|
||||
<label for="filter-unit" class="form-label">Unit Kerja</label>
|
||||
<select name="unit" id="filter-unit" class="form-select select2" data-placeholder="Semua Unit Kerja">
|
||||
<option value=""></option>
|
||||
<option value="99">Universitas</option>
|
||||
<option value="1">Fakultas Hukum</option>
|
||||
<option value="2">Fakultas Ekonomi dan Bisnis</option>
|
||||
<option value="3">Fakultas Pertanian</option>
|
||||
<option value="4">Fakultas Teknik</option>
|
||||
<option value="5">Fakultas Ilmu Sosial dan Ilmu Politik</option>
|
||||
<option value="6">Fakultas Keguruan dan Ilmu Pendidikan</option>
|
||||
<option value="7">Fakultas Kehutanan</option>
|
||||
<option value="8">Fakultas Matematika dan Ilmu Pengetahuan Alam</option>
|
||||
<option value="9">Fakultas Kedokteran</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-3">
|
||||
<label for="filter-tahun" class="form-label">Tahun</label>
|
||||
<select name="tahun" id="filter-tahun" class="form-select select2" data-placeholder="Pilih Tahun">
|
||||
@for ($year = date('Y'); $year >= 2025; $year--)
|
||||
<option value="{{ $year }}" {{ $year == date('Y') ? 'selected' : '' }}>{{ $year }}</option>
|
||||
@endfor
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Tabel Data -->
|
||||
<div class="table-responsive">
|
||||
<table class="table table-bordered w-100 dt-styled" id="keseluruhan-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Pegawai</th>
|
||||
<th>Unit Kerja</th>
|
||||
<th class="text-center">Jumlah P1</th>
|
||||
<th class="text-center">Jumlah P2</th>
|
||||
<th class="text-center">Jumlah THR</th>
|
||||
<th class="text-center">Jumlah R13</th>
|
||||
<th class="text-center">Jumlah Publikasi</th>
|
||||
<th class="text-center">Total</th>
|
||||
</tr>
|
||||
</thead>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@section('js')
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
function renderRupiah(data) {
|
||||
if (!data) {
|
||||
return 'Rp. 0,00';
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
function renderJenisPegawaiTag(jenis) {
|
||||
var config = {
|
||||
'Dosen': { color: 'var(--ct-primary)', rgb: 'var(--ct-primary-rgb)', icon: 'uil-user-graduate' },
|
||||
'Tendik': { color: '#fd7e14', rgb: '253, 126, 20', icon: 'uil-briefcase-alt' }
|
||||
};
|
||||
var c = config[jenis];
|
||||
if (!c) {
|
||||
return '';
|
||||
}
|
||||
return '<small class="d-inline-block fw-bold" style="padding: 1px 18px 1px 6px; color: ' +
|
||||
c.color + '; background: linear-gradient(to right, rgba(' + c.rgb + ', 0.25), rgba(' + c.rgb +
|
||||
', 0)); clip-path: polygon(0 0, 100% 0, calc(100% - 20px) 100%, 0 100%);"><i class="' + c.icon +
|
||||
'"></i> ' + jenis.toUpperCase() + '</small>';
|
||||
}
|
||||
|
||||
var table = $('#keseluruhan-table').DataTable({
|
||||
processing: true,
|
||||
serverSide: true,
|
||||
autoWidth: false,
|
||||
ajax: {
|
||||
url: "{{ route('remunerasi.keseluruhan.data') }}",
|
||||
data: function(d) {
|
||||
d.jenis_pegawai = $('#filter-jenis-pegawai').val();
|
||||
d.unit = $('#filter-unit').val();
|
||||
d.tahun = $('#filter-tahun').val();
|
||||
d.include_pppk_2025 = $('#include_pppk_2025').is(':checked') ? 1 : 0;
|
||||
d.include_p1_zero = $('#include_p1_zero').is(':checked') ? 1 : 0;
|
||||
}
|
||||
},
|
||||
columns: [
|
||||
{
|
||||
data: 'nama',
|
||||
name: 'nama',
|
||||
render: function(data, type, row) {
|
||||
if (type !== 'display') {
|
||||
return data;
|
||||
}
|
||||
var nama = data || '-';
|
||||
var nip = row.nip || '-';
|
||||
return '<div>' +
|
||||
'<div class="fw-semibold">' + nama + '</div>' +
|
||||
'<div class="text-muted small font-monospace">' + nip + '</div>' +
|
||||
'<div class="mt-1">' + renderJenisPegawaiTag(row.jenis_pegawai) + '</div>' +
|
||||
'</div>';
|
||||
}
|
||||
},
|
||||
{ data: 'nama_unit', name: 'nama_unit' },
|
||||
{ data: 'jumlah_p1', name: 'jumlah_p1', className: 'text-end font-monospace', orderable: false },
|
||||
{ data: 'jumlah_p2', name: 'jumlah_p2', className: 'text-end font-monospace', orderable: false },
|
||||
{ data: 'jumlah_thr', name: 'jumlah_thr', className: 'text-end font-monospace', orderable: false },
|
||||
{ data: 'jumlah_r13', name: 'jumlah_r13', className: 'text-end font-monospace', orderable: false },
|
||||
{ data: 'jumlah_publikasi', name: 'jumlah_publikasi', className: 'text-end font-monospace', orderable: false },
|
||||
{ data: 'total', name: 'total', className: 'text-end font-monospace fw-bold', orderable: false }
|
||||
],
|
||||
order: [],
|
||||
language: {
|
||||
processing: "<div class='spinner'></div> Sedang Memuat...",
|
||||
},
|
||||
drawCallback: function(settings) {
|
||||
var api = this.api();
|
||||
var response = api.ajax.json();
|
||||
|
||||
if (response && response.totalKeseluruhan !== undefined) {
|
||||
$('#totalKeseluruhanDisplay').text('Rp ' + response.totalKeseluruhan);
|
||||
$('#jumlahPegawaiDisplay').text(response.jumlahPegawai + ' orang');
|
||||
} else {
|
||||
$('#totalKeseluruhanDisplay').text('Rp 0');
|
||||
$('#jumlahPegawaiDisplay').text('0 orang');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$('#filter-jenis-pegawai, #filter-unit, #filter-tahun, #include_pppk_2025, #include_p1_zero').on('change', function() {
|
||||
table.draw();
|
||||
});
|
||||
|
||||
$('#btnRefresh').on('click', function() {
|
||||
var button = $(this);
|
||||
var originalText = button.html();
|
||||
|
||||
button.prop('disabled', true).html('<i class="uil-sync uil-spin"></i> Refreshing...');
|
||||
|
||||
table.ajax.reload(function() {
|
||||
button.prop('disabled', false).html(originalText);
|
||||
showSuccess('Berhasil!', 'Data berhasil direfresh');
|
||||
}, false);
|
||||
});
|
||||
|
||||
$('#btn-export').on('click', function() {
|
||||
var button = $(this);
|
||||
var originalHtml = button.html();
|
||||
|
||||
var params = [];
|
||||
var jenisPegawai = $('#filter-jenis-pegawai').val();
|
||||
var unit = $('#filter-unit').val();
|
||||
var tahun = $('#filter-tahun').val();
|
||||
var includePppk2025 = $('#include_pppk_2025').is(':checked') ? 1 : 0;
|
||||
var includeP1Zero = $('#include_p1_zero').is(':checked') ? 1 : 0;
|
||||
|
||||
if (jenisPegawai) { params.push('jenis_pegawai=' + jenisPegawai); }
|
||||
if (unit) { params.push('unit=' + unit); }
|
||||
if (tahun) { params.push('tahun=' + tahun); }
|
||||
params.push('include_pppk_2025=' + includePppk2025);
|
||||
params.push('include_p1_zero=' + includeP1Zero);
|
||||
|
||||
var url = "{{ route('remunerasi.keseluruhan.export') }}";
|
||||
if (params.length > 0) {
|
||||
url += '?' + params.join('&');
|
||||
}
|
||||
|
||||
button.prop('disabled', true).html('<i class="uil-sync uil-spin"></i> Exporting...');
|
||||
|
||||
fetch(url)
|
||||
.then(function(response) {
|
||||
if (!response.ok) { throw new Error('gagal'); }
|
||||
var filename = 'remunerasi_keseluruhan.xlsx';
|
||||
var disposition = response.headers.get('Content-Disposition');
|
||||
if (disposition) {
|
||||
var match = disposition.match(/filename[^;=\n]*=['"]?([^'"\n]+)['"]?/);
|
||||
if (match) { filename = match[1]; }
|
||||
}
|
||||
return response.blob().then(function(blob) {
|
||||
return { blob: blob, filename: filename };
|
||||
});
|
||||
})
|
||||
.then(function(data) {
|
||||
var downloadUrl = URL.createObjectURL(data.blob);
|
||||
var a = document.createElement('a');
|
||||
a.href = downloadUrl;
|
||||
a.download = data.filename;
|
||||
a.style.display = 'none';
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
document.body.removeChild(a);
|
||||
URL.revokeObjectURL(downloadUrl);
|
||||
button.prop('disabled', false).html(originalHtml);
|
||||
showSuccess('Berhasil!', 'File Excel berhasil didownload');
|
||||
})
|
||||
.catch(function() {
|
||||
button.prop('disabled', false).html(originalHtml);
|
||||
showError('Gagal', 'Terjadi kesalahan saat export Excel');
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@endsection
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
use App\Http\Controllers\Perhitungan\Remunerasi\DewasController;
|
||||
use App\Http\Controllers\Perhitungan\Remunerasi\KeseluruhanController;
|
||||
use App\Http\Controllers\Perhitungan\Remunerasi\P1Controller;
|
||||
use App\Http\Controllers\Perhitungan\Remunerasi\P2Controller;
|
||||
use App\Http\Controllers\Perhitungan\Remunerasi\PoinController;
|
||||
@@ -70,4 +71,10 @@ Route::middleware('permission:Baca Pembayaran')->prefix('/remunerasi')->name('re
|
||||
Route::prefix('/dewas')->name('dewas.')->group(function () {
|
||||
Route::get('/', [DewasController::class, 'index'])->name('index');
|
||||
});
|
||||
|
||||
Route::prefix('/keseluruhan')->name('keseluruhan.')->group(function () {
|
||||
Route::get('/', [KeseluruhanController::class, 'index'])->name('index');
|
||||
Route::get('/data', [KeseluruhanController::class, 'data'])->name('data');
|
||||
Route::get('/export', [KeseluruhanController::class, 'export'])->name('export');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user