first commit
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Perhitungan\Remunerasi;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class DewasController extends Controller
|
||||
{
|
||||
public function index(): View
|
||||
{
|
||||
$title = 'Dewas';
|
||||
|
||||
return view('perhitungan.remunerasi.dewas.index', compact('title'));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,324 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Perhitungan\Remunerasi;
|
||||
|
||||
use App\Exports\P1Export;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Verifikator\Team;
|
||||
use App\Models\Verifikator\UnitKerja;
|
||||
use App\Services\DawaiService;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\View\View;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
||||
use Yajra\DataTables\Facades\DataTables;
|
||||
|
||||
class P1Controller extends Controller
|
||||
{
|
||||
public function index(): View
|
||||
{
|
||||
$title = 'P1';
|
||||
$team = Team::find(session('team_id'));
|
||||
|
||||
if (! $team || ! isset($team->unit_kerja_id) || $team->unit_kerja_id === null || $team->unit_kerja_id === 0) {
|
||||
$units = UnitKerja::get();
|
||||
|
||||
return view('perhitungan.remunerasi.p1.index', compact('units', 'team', 'title'));
|
||||
}
|
||||
|
||||
return view('perhitungan.remunerasi.p1.index', compact('team', 'title'));
|
||||
}
|
||||
|
||||
public function data(Request $request): JsonResponse
|
||||
{
|
||||
$datenow = Carbon::now();
|
||||
$bulanNow = $datenow->format('m');
|
||||
$tahunNow = $datenow->format('Y');
|
||||
$team = Team::find(session('team_id'));
|
||||
|
||||
if (! $team) {
|
||||
return DataTables::of(collect([]))->make();
|
||||
}
|
||||
|
||||
if (! isset($team->unit_kerja_id) || $team->unit_kerja_id === null || $team->unit_kerja_id === 0) {
|
||||
$unit = $request->unit;
|
||||
} else {
|
||||
$unit = $team->unit_kerja_id;
|
||||
}
|
||||
|
||||
$jenisPegawai = $request->jenis_pegawai ?? '';
|
||||
$tahun = $request->tahun ?? $tahunNow;
|
||||
$bulan = $request->bulan ?? $bulanNow;
|
||||
|
||||
$cacheKey = "p1_data_{$jenisPegawai}_{$tahun}_{$bulan}_{$unit}";
|
||||
|
||||
$data = Cache::remember($cacheKey, now()->addDay(), function () use ($jenisPegawai, $tahun, $bulan, $unit) {
|
||||
$dawaiService = new DawaiService;
|
||||
|
||||
return $dawaiService->getDataP1($jenisPegawai, $tahun, $bulan, $unit);
|
||||
});
|
||||
|
||||
$filteredData = collect($data)
|
||||
->filter(fn ($item) => isset($item['harga_p1']) && $item['harga_p1'] > 0);
|
||||
|
||||
return DataTables::of($filteredData)
|
||||
->addIndexColumn()
|
||||
->editColumn('nip', function ($row) {
|
||||
return ltrim($row['nip'] ?? '', "'");
|
||||
})
|
||||
->editColumn('nama_jtt', function ($row) {
|
||||
return $row['nama_jtt'] ?: '-';
|
||||
})
|
||||
->editColumn('jenis_pegawai', function ($row) {
|
||||
return $row['jenis_pegawai'] == 'dosen' ? 'Dosen' : ($row['jenis_pegawai'] == 'tendik' ? 'Tendik' : '-');
|
||||
})
|
||||
->editColumn('harga_p1', function ($row) {
|
||||
return 'Rp. '.number_format($row['harga_p1'] ?: 0, 2, ',', '.');
|
||||
})
|
||||
->editColumn('pajak_p1', function ($row) {
|
||||
return 'Rp. '.number_format($row['pajak_p1'] ?: 0, 2, ',', '.');
|
||||
})
|
||||
->editColumn('harga_p1_setelah_pajak', function ($row) {
|
||||
return 'Rp. '.number_format($row['harga_p1_setelah_pajak'] ?: 0, 2, ',', '.');
|
||||
})
|
||||
->make();
|
||||
}
|
||||
|
||||
public function dataSelisih(Request $request): JsonResponse
|
||||
{
|
||||
$datenow = Carbon::now();
|
||||
$bulanNow = $datenow->format('m');
|
||||
$tahunNow = $datenow->format('Y');
|
||||
$team = Team::find(session('team_id'));
|
||||
|
||||
if (! $team) {
|
||||
return DataTables::of(collect([]))->make();
|
||||
}
|
||||
|
||||
if (! isset($team->unit_kerja_id) || $team->unit_kerja_id === null || $team->unit_kerja_id === 0) {
|
||||
$unit = $request->unit;
|
||||
} else {
|
||||
$unit = $team->unit_kerja_id;
|
||||
}
|
||||
|
||||
$jenisPegawai = $request->jenis_pegawai ?? '';
|
||||
$tahun = $request->tahun ?? $tahunNow;
|
||||
$bulan = $request->bulan ?? $bulanNow;
|
||||
|
||||
$cacheKey = "p1_selisih_data_{$jenisPegawai}_{$tahun}_{$bulan}_{$unit}";
|
||||
|
||||
$data = Cache::remember($cacheKey, now()->addDay(), function () use ($jenisPegawai, $tahun, $bulan, $unit) {
|
||||
$dawaiService = new DawaiService;
|
||||
|
||||
return $dawaiService->getDataP1Selisih($jenisPegawai, $tahun, $bulan, $unit);
|
||||
});
|
||||
|
||||
$filteredData = collect($data)->filter(function ($item) {
|
||||
return isset($item['harga_p1']) && $item['harga_p1'] > 0;
|
||||
});
|
||||
|
||||
return DataTables::of($filteredData)
|
||||
->addIndexColumn()
|
||||
->editColumn('nip', function ($row) {
|
||||
return ltrim($row['nip'] ?? '', "'");
|
||||
})
|
||||
->editColumn('jenis_pegawai', function ($row) {
|
||||
return $row['jenis_pegawai'] == 'dosen' ? 'Dosen' : ($row['jenis_pegawai'] == 'tendik' ? 'Tendik' : '-');
|
||||
})
|
||||
->addColumn('p1_lama_jafung', function ($row) {
|
||||
return $row['riwayat_pembayaran'][0]['nama_jafung'] ?? '-';
|
||||
})
|
||||
->addColumn('p1_lama_jtt', function ($row) {
|
||||
return $row['riwayat_pembayaran'][0]['nama_jtt'] ?? '-';
|
||||
})
|
||||
->addColumn('p1_lama_bruto', function ($row) {
|
||||
$value = $row['riwayat_pembayaran'][0]['harga_p1'] ?? 0;
|
||||
|
||||
return 'Rp. '.number_format($value, 2, ',', '.');
|
||||
})
|
||||
->addColumn('p1_lama_netto', function ($row) {
|
||||
$value = $row['riwayat_pembayaran'][0]['harga_p1_setelah_pajak'] ?? 0;
|
||||
|
||||
return 'Rp. '.number_format($value, 2, ',', '.');
|
||||
})
|
||||
->addColumn('p1_baru_jafung', function ($row) {
|
||||
return $row['nama_jafung'] ?? '-';
|
||||
})
|
||||
->addColumn('p1_baru_jtt', function ($row) {
|
||||
return $row['nama_jtt'] ?? '-';
|
||||
})
|
||||
->addColumn('p1_baru_bruto', function ($row) {
|
||||
$value = $row['harga_p1'] ?? 0;
|
||||
|
||||
return 'Rp. '.number_format($value, 2, ',', '.');
|
||||
})
|
||||
->addColumn('p1_baru_netto', function ($row) {
|
||||
$value = $row['harga_p1_setelah_pajak'] ?? 0;
|
||||
|
||||
return 'Rp. '.number_format($value, 2, ',', '.');
|
||||
})
|
||||
->addColumn('selisih_bruto', function ($row) {
|
||||
$value = $row['selisih_harga_p1'] ?? 0;
|
||||
|
||||
return 'Rp. '.number_format($value, 2, ',', '.');
|
||||
})
|
||||
->addColumn('selisih_netto', function ($row) {
|
||||
$value = $row['selisih_harga_p1_setelah_pajak'] ?? 0;
|
||||
|
||||
return 'Rp. '.number_format($value, 2, ',', '.');
|
||||
})
|
||||
->addColumn('detail', function ($row) {
|
||||
return json_encode([
|
||||
'p1_lama_jafung' => $row['riwayat_pembayaran'][0]['nama_jafung'] ?? '-',
|
||||
'p1_lama_jtt' => $row['riwayat_pembayaran'][0]['nama_jtt'] ?? '-',
|
||||
'p1_lama_bruto' => 'Rp. '.number_format($row['riwayat_pembayaran'][0]['harga_p1'] ?? 0, 2, ',', '.'),
|
||||
'p1_lama_netto' => 'Rp. '.number_format($row['riwayat_pembayaran'][0]['harga_p1_setelah_pajak'] ?? 0, 2, ',', '.'),
|
||||
'p1_baru_jafung' => $row['nama_jafung'] ?? '-',
|
||||
'p1_baru_jtt' => $row['nama_jtt'] ?? '-',
|
||||
'p1_baru_bruto' => 'Rp. '.number_format($row['harga_p1'] ?? 0, 2, ',', '.'),
|
||||
'p1_baru_netto' => 'Rp. '.number_format($row['harga_p1_setelah_pajak'] ?? 0, 2, ',', '.'),
|
||||
'selisih_bruto' => 'Rp. '.number_format($row['selisih_harga_p1'] ?? 0, 2, ',', '.'),
|
||||
'selisih_netto' => 'Rp. '.number_format($row['selisih_harga_p1_setelah_pajak'] ?? 0, 2, ',', '.'),
|
||||
]);
|
||||
})
|
||||
->rawColumns(['detail'])
|
||||
->make();
|
||||
}
|
||||
|
||||
public function export(Request $request): BinaryFileResponse
|
||||
{
|
||||
$datenow = Carbon::now();
|
||||
$bulanNow = $datenow->format('m');
|
||||
$tahunNow = $datenow->format('Y');
|
||||
$team = Team::find(session('team_id'));
|
||||
|
||||
if ($request->has('unit_kerja') && $request->unit_kerja !== null) {
|
||||
$unit = $request->unit_kerja;
|
||||
} elseif ($team && $team->unit_kerja_id !== null && $team->unit_kerja_id !== 0) {
|
||||
$unit = $team->unit_kerja_id;
|
||||
} else {
|
||||
$unit = $request->unit_kerja;
|
||||
}
|
||||
|
||||
$jenisPegawai = $request->jenis_pegawai ?? '';
|
||||
$tahun = $request->tahun ?? $tahunNow;
|
||||
$bulan = $request->bulan ?? null;
|
||||
|
||||
$unitIdForModel = ($unit == 99) ? 0 : $unit;
|
||||
|
||||
if (! $bulan) {
|
||||
$unitName = '';
|
||||
if ($unit) {
|
||||
$unitKerja = UnitKerja::find($unitIdForModel);
|
||||
if ($unitKerja) {
|
||||
$unitName = '_'.str_replace(['/', ' ', '.'], '_', $unitKerja->nama);
|
||||
}
|
||||
} else {
|
||||
$unitName = '_Semua_Unit_Kerja';
|
||||
}
|
||||
|
||||
$bulanNames = [
|
||||
1 => 'Januari', 2 => 'Februari', 3 => 'Maret', 4 => 'April', 5 => 'Mei', 6 => 'Juni',
|
||||
7 => 'Juli', 8 => 'Agustus', 9 => 'September', 10 => 'Oktober', 11 => 'November', 12 => 'Desember',
|
||||
];
|
||||
$namaBulanSekarang = $bulanNames[(int) $bulanNow];
|
||||
$filename = "P1_Januari_sampai_{$namaBulanSekarang}_{$tahun}{$unitName}.xlsx";
|
||||
|
||||
return Excel::download(new P1Export($jenisPegawai, $tahun, null, $unit), $filename);
|
||||
}
|
||||
|
||||
$bulanNames = [
|
||||
1 => 'Januari', 2 => 'Februari', 3 => 'Maret', 4 => 'April', 5 => 'Mei', 6 => 'Juni',
|
||||
7 => 'Juli', 8 => 'Agustus', 9 => 'September', 10 => 'Oktober', 11 => 'November', 12 => 'Desember',
|
||||
];
|
||||
$bulanName = $bulanNames[(int) $bulan];
|
||||
|
||||
$unitName = '';
|
||||
if ($unit) {
|
||||
$unitKerja = UnitKerja::find($unitIdForModel);
|
||||
if ($unitKerja) {
|
||||
$unitName = '_'.str_replace(['/', ' ', '.'], '_', $unitKerja->nama);
|
||||
}
|
||||
} else {
|
||||
$unitName = '_Semua_Unit_Kerja';
|
||||
}
|
||||
|
||||
$filename = "P1_{$bulanName}_{$tahun}{$unitName}.xlsx";
|
||||
|
||||
return Excel::download(new P1Export($jenisPegawai, $tahun, $bulan, $unit), $filename);
|
||||
}
|
||||
|
||||
public function exportSelisih(Request $request): BinaryFileResponse
|
||||
{
|
||||
$datenow = Carbon::now();
|
||||
$bulanNow = $datenow->format('m');
|
||||
$tahunNow = $datenow->format('Y');
|
||||
$team = Team::find(session('team_id'));
|
||||
|
||||
if ($request->has('unit_kerja') && $request->unit_kerja !== null) {
|
||||
$unit = $request->unit_kerja;
|
||||
} elseif ($team && $team->unit_kerja_id !== null && $team->unit_kerja_id !== 0) {
|
||||
$unit = $team->unit_kerja_id;
|
||||
} else {
|
||||
$unit = $request->unit_kerja;
|
||||
}
|
||||
|
||||
$jenisPegawai = $request->jenis_pegawai ?? '';
|
||||
$tahun = $request->tahun ?? $tahunNow;
|
||||
$bulan = $request->bulan ?? null;
|
||||
|
||||
$unitIdForModel = ($unit == 99) ? 0 : $unit;
|
||||
|
||||
if (! $bulan) {
|
||||
$unitName = '';
|
||||
if ($unit) {
|
||||
$unitKerja = UnitKerja::find($unitIdForModel);
|
||||
if ($unitKerja) {
|
||||
$unitName = '_'.str_replace(['/', ' ', '.'], '_', $unitKerja->nama);
|
||||
}
|
||||
} else {
|
||||
$unitName = '_Semua_Unit_Kerja';
|
||||
}
|
||||
|
||||
$bulanNames = [
|
||||
1 => 'Januari', 2 => 'Februari', 3 => 'Maret', 4 => 'April', 5 => 'Mei', 6 => 'Juni',
|
||||
7 => 'Juli', 8 => 'Agustus', 9 => 'September', 10 => 'Oktober', 11 => 'November', 12 => 'Desember',
|
||||
];
|
||||
$namaBulanSekarang = $bulanNames[(int) $bulanNow];
|
||||
$filename = "P1_Selisih_Januari_sampai_{$namaBulanSekarang}_{$tahun}{$unitName}.xlsx";
|
||||
|
||||
return Excel::download(new P1Export($jenisPegawai, $tahun, null, $unit, 'selisih'), $filename);
|
||||
}
|
||||
|
||||
$bulanNames = [
|
||||
1 => 'Januari', 2 => 'Februari', 3 => 'Maret', 4 => 'April', 5 => 'Mei', 6 => 'Juni',
|
||||
7 => 'Juli', 8 => 'Agustus', 9 => 'September', 10 => 'Oktober', 11 => 'November', 12 => 'Desember',
|
||||
];
|
||||
$bulanName = $bulanNames[(int) $bulan];
|
||||
|
||||
$unitName = '';
|
||||
if ($unit) {
|
||||
$unitKerja = UnitKerja::find($unitIdForModel);
|
||||
if ($unitKerja) {
|
||||
$unitName = '_'.str_replace(['/', ' ', '.'], '_', $unitKerja->nama);
|
||||
}
|
||||
} else {
|
||||
$unitName = '_Semua_Unit_Kerja';
|
||||
}
|
||||
|
||||
$filename = "P1_Selisih_{$bulanName}_{$tahun}{$unitName}.xlsx";
|
||||
|
||||
return Excel::download(new P1Export($jenisPegawai, $tahun, $bulan, $unit, 'selisih'), $filename);
|
||||
}
|
||||
|
||||
public function logs(Request $request): JsonResponse
|
||||
{
|
||||
Log::info('Export P1 Log:', $request->all());
|
||||
|
||||
return response()->json(['status' => 'success', 'message' => 'Log berhasil disimpan']);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,156 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Perhitungan\Remunerasi;
|
||||
|
||||
use App\Exports\P2Export;
|
||||
use App\Helpers\JabatanPegawaiTambahanHelper;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Controllers\Perhitungan\PlenoPenunjang\RasioP2Controller;
|
||||
use App\Models\Verifikator\Periode;
|
||||
use App\Models\Verifikator\Team;
|
||||
use App\Models\Verifikator\UnitKerja;
|
||||
use App\Models\Verifikator\View\Pegawai;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\View\View;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
||||
use Yajra\DataTables\Facades\DataTables;
|
||||
|
||||
class P2Controller extends Controller
|
||||
{
|
||||
private function authorizeAccess(): void
|
||||
{
|
||||
$team = Team::find(session('team_id'));
|
||||
$isAdmin = $team && $team->nama === 'Admin';
|
||||
|
||||
$userNip = auth()->user()->nip;
|
||||
$isWakilDekan = JabatanPegawaiTambahanHelper::isWakilDekan($userNip);
|
||||
$isDekan = JabatanPegawaiTambahanHelper::isDekan($userNip);
|
||||
|
||||
abort_unless($isAdmin || $isWakilDekan || $isDekan || $userNip == '198706242010121005', 403);
|
||||
}
|
||||
|
||||
public function index(): View
|
||||
{
|
||||
$this->authorizeAccess();
|
||||
|
||||
$title = 'P2';
|
||||
$team = Team::find(session('team_id'));
|
||||
$periodes = Periode::orderBy('id_periode', 'desc')->get();
|
||||
$periodeNow = Periode::where('status', true)->first()?->id_periode;
|
||||
|
||||
return view('perhitungan.remunerasi.p2.index', compact('title', 'team', 'periodes', 'periodeNow'));
|
||||
}
|
||||
|
||||
public function data(Request $request): JsonResponse
|
||||
{
|
||||
$this->authorizeAccess();
|
||||
|
||||
$team = Team::find(session('team_id'));
|
||||
|
||||
if (! $team) {
|
||||
return DataTables::of(collect([]))->make();
|
||||
}
|
||||
|
||||
[$unitKerjaId, $jenisPegawai, $periode] = $this->resolveFilters($request, $team);
|
||||
|
||||
$query = $this->buildQuery($periode, $unitKerjaId, $jenisPegawai);
|
||||
|
||||
return DataTables::of($query)
|
||||
->editColumn('nip', fn ($row) => ltrim($row->nip ?? '', "'"))
|
||||
->editColumn('jenis_pegawai', fn ($row) => $row->jenis_pegawai === 'dosen' ? 'Dosen' : ($row->jenis_pegawai === 'tendik' ? 'Tendik' : '-'))
|
||||
->editColumn('total_p2_bruto', fn ($row) => 'Rp. '.number_format($row->total_p2_bruto ?? 0, 2, ',', '.'))
|
||||
->editColumn('total_p2_pajak', fn ($row) => 'Rp. '.number_format($row->total_p2_pajak ?? 0, 2, ',', '.'))
|
||||
->editColumn('total_p2_netto', fn ($row) => 'Rp. '.number_format($row->total_p2_netto ?? 0, 2, ',', '.'))
|
||||
->filterColumn('nip', fn ($query, $keyword) => $query->where('verifikator.pegawais.nip', 'ILIKE', "%{$keyword}%"))
|
||||
->filterColumn('nama', fn ($query, $keyword) => $query->where('verifikator.pegawais.nama', 'ILIKE', "%{$keyword}%"))
|
||||
->filterColumn('nama_unit', fn ($query, $keyword) => $query->where('ukp.nama', 'ILIKE', "%{$keyword}%"))
|
||||
->make();
|
||||
}
|
||||
|
||||
public function export(Request $request): BinaryFileResponse
|
||||
{
|
||||
$this->authorizeAccess();
|
||||
|
||||
$team = Team::find(session('team_id'));
|
||||
|
||||
[$unitKerjaId, $jenisPegawai, $periode] = $this->resolveFilters($request, $team);
|
||||
|
||||
$periodeNama = Periode::where('id_periode', $periode)->first()?->nama ?? $periode;
|
||||
$unitNama = $unitKerjaId !== null && $unitKerjaId !== '' ? (UnitKerja::find($unitKerjaId)?->nama ?? 'Semua Unit') : 'Semua Unit';
|
||||
$jenisPegawaiNama = $jenisPegawai ? '_'.ucfirst($jenisPegawai) : '';
|
||||
|
||||
$filename = 'P2_'.str_replace(['/', ' ', '.'], '_', $periodeNama)
|
||||
.'_'.str_replace(['/', ' ', '.'], '_', $unitNama)
|
||||
.$jenisPegawaiNama.'.xlsx';
|
||||
|
||||
return Excel::download(new P2Export($periode, $unitKerjaId, $jenisPegawai), $filename);
|
||||
}
|
||||
|
||||
public function detail(Request $request, string $nip): View
|
||||
{
|
||||
$this->authorizeAccess();
|
||||
|
||||
$request->merge(['gabung' => '1']);
|
||||
|
||||
return app(RasioP2Controller::class)->detailNew($request, $nip);
|
||||
}
|
||||
|
||||
public function exportPoin(Request $request, string $nip)
|
||||
{
|
||||
$this->authorizeAccess();
|
||||
|
||||
$request->merge(['gabung' => '1']);
|
||||
|
||||
return app(RasioP2Controller::class)->exportPoin($request, $nip);
|
||||
}
|
||||
|
||||
private function resolveFilters(Request $request, ?Team $team): array
|
||||
{
|
||||
if (! $team || ! isset($team->unit_kerja_id) || $team->unit_kerja_id === null || $team->unit_kerja_id === 0) {
|
||||
$unitKerjaId = $request->unit_kerja_id ?: null;
|
||||
} else {
|
||||
$unitKerjaId = $team->unit_kerja_id;
|
||||
}
|
||||
|
||||
$periodeNow = Periode::where('status', true)->first()?->id_periode;
|
||||
$periode = $request->periode ?? $periodeNow;
|
||||
$jenisPegawai = $request->jenis_pegawai ?: null;
|
||||
|
||||
return [$unitKerjaId, $jenisPegawai, $periode];
|
||||
}
|
||||
|
||||
private function buildQuery(mixed $periode, mixed $unitKerjaId, ?string $jenisPegawai)
|
||||
{
|
||||
$fakultasIds = [1, 2, 3, 4, 5, 6, 7, 8, 9];
|
||||
|
||||
$query = 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')
|
||||
->leftJoin('verifikator.unit_kerja_pegawais as ukp', 'verifikator.pegawais.unit_kerja_id', '=', 'ukp.id')
|
||||
->select(['verifikator.pegawais.nip', 'verifikator.pegawais.nama'])
|
||||
->selectRaw('MAX(ukp.nama) as nama_unit')
|
||||
->selectRaw('MAX(jpd.jenis_pegawai) as jenis_pegawai')
|
||||
->selectRaw('SUM(rpb.p2_bruto) as total_p2_bruto')
|
||||
->selectRaw('SUM(rpb.p2_bruto) - SUM(rpb.p2_netto) as total_p2_pajak')
|
||||
->selectRaw('SUM(rpb.p2_netto) as total_p2_netto')
|
||||
->whereNull('rpb.deleted_at')
|
||||
->where('jp.periode', $periode)
|
||||
->groupBy('verifikator.pegawais.nip', 'verifikator.pegawais.nama')
|
||||
->havingRaw('SUM(rpb.p2_bruto) > 0');
|
||||
|
||||
if ($unitKerjaId == 99) {
|
||||
$query->whereNotIn('verifikator.pegawais.unit_kerja_id', $fakultasIds);
|
||||
} elseif ($unitKerjaId !== null && $unitKerjaId !== '') {
|
||||
$query->where('verifikator.pegawais.unit_kerja_id', $unitKerjaId);
|
||||
}
|
||||
|
||||
if ($jenisPegawai !== null && $jenisPegawai !== '') {
|
||||
$query->where('jpd.jenis_pegawai', $jenisPegawai);
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,309 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Perhitungan\Remunerasi;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Verifikator\JabatanPegawaiDetailPoin;
|
||||
use App\Models\Verifikator\Periode;
|
||||
use App\Models\Verifikator\UnitKerja;
|
||||
use Illuminate\Auth\Access\AuthorizationException;
|
||||
use Illuminate\Http\Request;
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
use PhpOffice\PhpSpreadsheet\Style\Alignment;
|
||||
use PhpOffice\PhpSpreadsheet\Style\Border;
|
||||
use PhpOffice\PhpSpreadsheet\Style\Fill;
|
||||
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
|
||||
use Yajra\DataTables\Facades\DataTables;
|
||||
|
||||
class PoinController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
if (! isSuperuser()) {
|
||||
throw new AuthorizationException('Anda tidak memiliki hak akses');
|
||||
}
|
||||
|
||||
$title = 'Poin';
|
||||
$unitKerjas = UnitKerja::orderBy('nama')->get();
|
||||
$periodes = Periode::orderBy('id_periode', 'desc')->get();
|
||||
$periodeNow = Periode::where('status', true)->first()->id_periode;
|
||||
|
||||
// Daftar bulan berdasarkan periode ganjil/genap
|
||||
$bulanGanjil = [
|
||||
1 => 'Januari',
|
||||
2 => 'Februari',
|
||||
3 => 'Maret',
|
||||
4 => 'April',
|
||||
5 => 'Mei',
|
||||
6 => 'Juni',
|
||||
];
|
||||
|
||||
$bulanGenap = [
|
||||
7 => 'Juli',
|
||||
8 => 'Agustus',
|
||||
9 => 'September',
|
||||
10 => 'Oktober',
|
||||
11 => 'November',
|
||||
12 => 'Desember',
|
||||
];
|
||||
|
||||
return view('perhitungan.remunerasi.poin.index', compact('title', 'unitKerjas', 'periodes', 'bulanGanjil', 'bulanGenap', 'periodeNow'));
|
||||
}
|
||||
|
||||
public function getData(Request $request)
|
||||
{
|
||||
if (! isSuperuser()) {
|
||||
throw new AuthorizationException('Anda tidak memiliki hak akses');
|
||||
}
|
||||
$periodeNow = Periode::where('status', true)->first()->id_periode;
|
||||
$periode = $request->get('periode', $periodeNow); // Default periode now
|
||||
|
||||
// Tentukan default bulan berdasarkan periode ganjil/genap
|
||||
// Periode ganjil: Januari-Juni (1-6), Periode genap: Juli-Desember (7-12)
|
||||
$defaultBulan = ($periode % 2 === 1) ? 1 : 7;
|
||||
$bulan = $request->get('bulan', $defaultBulan);
|
||||
|
||||
$unitKerjaId = $request->get('unit_kerja_id');
|
||||
$jenisPegawai = $request->get('jenis_pegawai');
|
||||
|
||||
// Menggunakan Eloquent dengan relasi sesuai models
|
||||
$query = JabatanPegawaiDetailPoin::select([
|
||||
'verifikator.jabatan_pegawais.nip',
|
||||
'verifikator.pegawais.nama as nama_pegawai',
|
||||
'verifikator.jabatan_pegawai_details.jenis_pegawai',
|
||||
'verifikator.unit_kerjas.nama as unit_pembayaran',
|
||||
'verifikator.pegawais.unit_kerja_nama as unit_kerja',
|
||||
'verifikator.poin_per_bulans.poin_kegiatan',
|
||||
'verifikator.poin_per_bulans.poin_absen',
|
||||
'verifikator.poin_per_bulans.poin_skp',
|
||||
])
|
||||
->join('verifikator.jabatan_pegawai_details', 'verifikator.poin_per_bulans.jabatan_pegawai_detail_id', '=', 'verifikator.jabatan_pegawai_details.id')
|
||||
->join('verifikator.jabatan_pegawais', 'verifikator.jabatan_pegawai_details.jabatan_pegawai_id', '=', 'verifikator.jabatan_pegawais.id')
|
||||
->join('verifikator.pegawais', 'verifikator.jabatan_pegawais.nip', '=', 'verifikator.pegawais.nip')
|
||||
->leftJoin('verifikator.unit_kerjas', 'verifikator.jabatan_pegawai_details.unit_pembayaran_id', '=', 'verifikator.unit_kerjas.id')
|
||||
->where('verifikator.jabatan_pegawai_details.bulan', $bulan)
|
||||
->where('verifikator.jabatan_pegawais.periode', $periode)
|
||||
->whereNull('verifikator.poin_per_bulans.deleted_at')
|
||||
->where(function ($query) {
|
||||
$query->where('verifikator.poin_per_bulans.poin_kegiatan', '!=', 0)
|
||||
->orWhere('verifikator.poin_per_bulans.poin_absen', '!=', 0)
|
||||
->orWhere('verifikator.poin_per_bulans.poin_skp', '!=', 0);
|
||||
})
|
||||
->orderBy('verifikator.pegawais.nama', 'asc');
|
||||
|
||||
if ($unitKerjaId !== null && $unitKerjaId !== '') {
|
||||
$query->where('verifikator.jabatan_pegawai_details.unit_pembayaran_id', $unitKerjaId);
|
||||
}
|
||||
|
||||
if ($jenisPegawai !== null && $jenisPegawai !== '') {
|
||||
$query->where('verifikator.jabatan_pegawai_details.jenis_pegawai', $jenisPegawai);
|
||||
}
|
||||
|
||||
return DataTables::of($query)
|
||||
->addIndexColumn()
|
||||
->editColumn('poin_kegiatan', function ($row) {
|
||||
return number_format($row->poin_kegiatan, 2, ',', '.');
|
||||
})
|
||||
->editColumn('poin_absen', function ($row) {
|
||||
return number_format($row->poin_absen, 2, ',', '.');
|
||||
})
|
||||
->editColumn('poin_skp', function ($row) {
|
||||
return number_format($row->poin_skp, 2, ',', '.');
|
||||
})
|
||||
->filterColumn('nip', function ($query, $keyword) {
|
||||
$query->where('verifikator.jabatan_pegawais.nip', 'ILIKE', "%{$keyword}%");
|
||||
})
|
||||
->filterColumn('nama_pegawai', function ($query, $keyword) {
|
||||
$query->where('verifikator.pegawais.nama', 'ILIKE', "%{$keyword}%");
|
||||
})
|
||||
->filterColumn('unit_pembayaran', function ($query, $keyword) {
|
||||
$query->where('verifikator.unit_kerjas.nama', 'ILIKE', "%{$keyword}%");
|
||||
})
|
||||
->filterColumn('unit_kerja', function ($query, $keyword) {
|
||||
$query->where('verifikator.pegawais.unit_kerja_nama', 'ILIKE', "%{$keyword}%");
|
||||
})
|
||||
->filterColumn('jenis_pegawai', function ($query, $keyword) {
|
||||
$query->where('verifikator.jabatan_pegawai_details.jenis_pegawai', 'ILIKE', "%{$keyword}%");
|
||||
})
|
||||
->make(true);
|
||||
}
|
||||
|
||||
public function export(Request $request)
|
||||
{
|
||||
if (! isSuperuser()) {
|
||||
throw new AuthorizationException('Anda tidak memiliki hak akses');
|
||||
}
|
||||
|
||||
$periode = $request->get('periode', 395); // Default periode 395
|
||||
|
||||
// Tentukan default bulan berdasarkan periode ganjil/genap
|
||||
// Periode ganjil: Januari-Juni (1-6), Periode genap: Juli-Desember (7-12)
|
||||
$defaultBulan = ($periode % 2 === 1) ? 1 : 7;
|
||||
$bulan = $request->get('bulan', $defaultBulan);
|
||||
|
||||
$unitKerjaId = $request->get('unit_kerja_id');
|
||||
$jenisPegawai = $request->get('jenis_pegawai');
|
||||
|
||||
// Set memory limit dan max execution time untuk export
|
||||
ini_set('memory_limit', '1024M');
|
||||
ini_set('max_execution_time', 300);
|
||||
|
||||
$spreadsheet = new Spreadsheet;
|
||||
$sheet = $spreadsheet->getActiveSheet();
|
||||
|
||||
// Set judul
|
||||
$namaBulan = [
|
||||
1 => 'Januari',
|
||||
2 => 'Februari',
|
||||
3 => 'Maret',
|
||||
4 => 'April',
|
||||
5 => 'Mei',
|
||||
6 => 'Juni',
|
||||
7 => 'Juli',
|
||||
8 => 'Agustus',
|
||||
9 => 'September',
|
||||
10 => 'Oktober',
|
||||
11 => 'November',
|
||||
12 => 'Desember',
|
||||
];
|
||||
|
||||
$judulUnit = '';
|
||||
if ($unitKerjaId) {
|
||||
$unitKerja = UnitKerja::find($unitKerjaId);
|
||||
$judulUnit = ' - ' . strtoupper($unitKerja->nama ?? '');
|
||||
}
|
||||
|
||||
$sheet->setCellValue('A1', 'DATA POIN PEGAWAI BULAN ' . strtoupper($namaBulan[$bulan]) . $judulUnit);
|
||||
$sheet->mergeCells('A1:I1');
|
||||
$sheet->getStyle('A1')->getFont()->setBold(true)->setSize(14);
|
||||
$sheet->getStyle('A1')->getAlignment()->setHorizontal(Alignment::HORIZONTAL_CENTER);
|
||||
|
||||
// Header tabel
|
||||
$headers = ['No', 'NIP', 'Nama Pegawai', 'Jenis Pegawai', 'Unit Pembayaran', 'Unit Kerja', 'Poin Kegiatan', 'Poin Absen', 'Poin SKP'];
|
||||
$column = 'A';
|
||||
foreach ($headers as $header) {
|
||||
$sheet->setCellValue($column . '3', $header);
|
||||
$column++;
|
||||
}
|
||||
|
||||
// Style header
|
||||
$headerStyle = [
|
||||
'font' => ['bold' => true, 'color' => ['rgb' => 'FFFFFF']],
|
||||
'fill' => ['fillType' => Fill::FILL_SOLID, 'startColor' => ['rgb' => '4472C4']],
|
||||
'alignment' => ['horizontal' => Alignment::HORIZONTAL_CENTER, 'vertical' => Alignment::VERTICAL_CENTER],
|
||||
'borders' => ['allBorders' => ['borderStyle' => Border::BORDER_THIN]],
|
||||
];
|
||||
$sheet->getStyle('A3:I3')->applyFromArray($headerStyle);
|
||||
|
||||
// Set width kolom
|
||||
$sheet->getColumnDimension('A')->setWidth(5);
|
||||
$sheet->getColumnDimension('B')->setWidth(20);
|
||||
$sheet->getColumnDimension('C')->setWidth(30);
|
||||
$sheet->getColumnDimension('D')->setWidth(15);
|
||||
$sheet->getColumnDimension('E')->setWidth(30);
|
||||
$sheet->getColumnDimension('F')->setWidth(30);
|
||||
$sheet->getColumnDimension('G')->setWidth(15);
|
||||
$sheet->getColumnDimension('H')->setWidth(15);
|
||||
$sheet->getColumnDimension('I')->setWidth(15);
|
||||
|
||||
// Isi data menggunakan chunk untuk menghindari memory exhausted
|
||||
$row = 4;
|
||||
$no = 1;
|
||||
|
||||
$query = JabatanPegawaiDetailPoin::select([
|
||||
'verifikator.jabatan_pegawais.nip',
|
||||
'verifikator.pegawais.nama as nama_pegawai',
|
||||
'verifikator.jabatan_pegawai_details.jenis_pegawai',
|
||||
'verifikator.unit_kerjas.nama as unit_pembayaran',
|
||||
'verifikator.pegawais.unit_kerja_nama as unit_kerja',
|
||||
'verifikator.poin_per_bulans.poin_kegiatan',
|
||||
'verifikator.poin_per_bulans.poin_absen',
|
||||
'verifikator.poin_per_bulans.poin_skp',
|
||||
])
|
||||
->join('verifikator.jabatan_pegawai_details', 'verifikator.poin_per_bulans.jabatan_pegawai_detail_id', '=', 'verifikator.jabatan_pegawai_details.id')
|
||||
->join('verifikator.jabatan_pegawais', 'verifikator.jabatan_pegawai_details.jabatan_pegawai_id', '=', 'verifikator.jabatan_pegawais.id')
|
||||
->join('verifikator.pegawais', 'verifikator.jabatan_pegawais.nip', '=', 'verifikator.pegawais.nip')
|
||||
->leftJoin('verifikator.unit_kerjas', 'verifikator.jabatan_pegawai_details.unit_pembayaran_id', '=', 'verifikator.unit_kerjas.id')
|
||||
->where('verifikator.jabatan_pegawai_details.bulan', $bulan)
|
||||
->where('verifikator.jabatan_pegawais.periode', $periode)
|
||||
->whereNull('verifikator.poin_per_bulans.deleted_at')
|
||||
->where(function ($query) {
|
||||
$query->where('verifikator.poin_per_bulans.poin_kegiatan', '!=', 0)
|
||||
->orWhere('verifikator.poin_per_bulans.poin_absen', '!=', 0)
|
||||
->orWhere('verifikator.poin_per_bulans.poin_skp', '!=', 0);
|
||||
})
|
||||
->orderBy('verifikator.pegawais.nama', 'asc');
|
||||
|
||||
if ($unitKerjaId !== null && $unitKerjaId !== '') {
|
||||
$query->where('verifikator.jabatan_pegawai_details.unit_pembayaran_id', $unitKerjaId);
|
||||
}
|
||||
|
||||
if ($jenisPegawai !== null && $jenisPegawai !== '') {
|
||||
$query->where('verifikator.jabatan_pegawai_details.jenis_pegawai', $jenisPegawai);
|
||||
}
|
||||
|
||||
$query->chunk(500, function ($items) use ($sheet, &$row, &$no) {
|
||||
foreach ($items as $item) {
|
||||
$sheet->setCellValue('A' . $row, $no++);
|
||||
$sheet->setCellValueExplicit('B' . $row, $item->nip ?? '-', \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING);
|
||||
$sheet->setCellValue('C' . $row, $item->nama_pegawai ?? '-');
|
||||
$sheet->setCellValue('D' . $row, $item->jenis_pegawai ?? '-');
|
||||
$sheet->setCellValue('E' . $row, $item->unit_pembayaran ?? '-');
|
||||
$sheet->setCellValue('F' . $row, $item->unit_kerja ?? '-');
|
||||
$sheet->setCellValue('G' . $row, $item->poin_kegiatan);
|
||||
$sheet->setCellValue('H' . $row, $item->poin_absen);
|
||||
$sheet->setCellValue('I' . $row, $item->poin_skp);
|
||||
|
||||
$row++;
|
||||
}
|
||||
});
|
||||
|
||||
// Style data
|
||||
if ($row > 4) {
|
||||
$dataStyle = [
|
||||
'borders' => ['allBorders' => ['borderStyle' => Border::BORDER_THIN]],
|
||||
'alignment' => ['vertical' => Alignment::VERTICAL_CENTER],
|
||||
];
|
||||
$sheet->getStyle('A4:I' . ($row - 1))->applyFromArray($dataStyle);
|
||||
|
||||
// Format number untuk kolom poin
|
||||
$sheet->getStyle('G4:I' . ($row - 1))->getNumberFormat()
|
||||
->setFormatCode('#,##0.00');
|
||||
|
||||
// Center align untuk kolom no
|
||||
$sheet->getStyle('A4:A' . ($row - 1))->getAlignment()
|
||||
->setHorizontal(Alignment::HORIZONTAL_CENTER);
|
||||
}
|
||||
|
||||
// Generate file
|
||||
$periodeName = '';
|
||||
if ($periode) {
|
||||
$periodeData = Periode::where('id_periode', $periode)->first();
|
||||
$periodeName = $periodeData ? '_Periode_' . str_replace(' ', '_', $periodeData->nama) : '';
|
||||
}
|
||||
|
||||
$unitName = '';
|
||||
if ($unitKerjaId) {
|
||||
$unitKerja = UnitKerja::find($unitKerjaId);
|
||||
$unitName = $unitKerja ? '_' . str_replace(' ', '_', $unitKerja->nama) : '';
|
||||
}
|
||||
|
||||
$jenisPegawaiName = '';
|
||||
if ($jenisPegawai) {
|
||||
$jenisPegawaiName = '_' . ucfirst($jenisPegawai);
|
||||
}
|
||||
|
||||
$tanggalExport = date('Ymd_His');
|
||||
|
||||
$fileName = 'Poin_Pegawai_Bulan_' . $namaBulan[$bulan] . $periodeName . $unitName . $jenisPegawaiName . '_' . $tanggalExport . '.xlsx';
|
||||
|
||||
$writer = new Xlsx($spreadsheet);
|
||||
|
||||
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
|
||||
header('Content-Disposition: attachment;filename="' . $fileName . '"');
|
||||
header('Cache-Control: max-age=0');
|
||||
|
||||
$writer->save('php://output');
|
||||
exit;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Perhitungan\Remunerasi;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Verifikator\Periode;
|
||||
use App\Models\Verifikator\Rekapitulasi;
|
||||
use Carbon\Carbon;
|
||||
use Exception;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Yajra\DataTables\DataTables;
|
||||
|
||||
class ProyeksiController extends Controller
|
||||
{
|
||||
function index()
|
||||
{
|
||||
$title = 'Proyeksi';
|
||||
$tahun = Carbon::now()->year;
|
||||
|
||||
// Tentukan range bulan berdasarkan periode
|
||||
$periode = Periode::where('status', true)->first()->id_periode;
|
||||
$namaRange = $periode % 2 === 1 ? 'Januari - Juni' : 'Juli - Desember';
|
||||
|
||||
return view('perhitungan.remunerasi.proyeksi.index', compact('title', 'namaRange', 'tahun'));
|
||||
}
|
||||
|
||||
function data()
|
||||
{
|
||||
try {
|
||||
$tahun = Carbon::now()->year;
|
||||
|
||||
// Static data untuk Total Pagu Periode Lalu
|
||||
$periodeLaluData = [
|
||||
'Fakultas Hukum' => 7691511525,
|
||||
'Fakultas Ekonomi dan Bisnis' => 13232558670,
|
||||
'Fakultas Pertanian' => 8464466392,
|
||||
'Fakultas Teknik' => 14252737454,
|
||||
'Fakultas Ilmu Sosial dan Ilmu Politik' => 10469423552,
|
||||
'Fakultas Keguruan dan Ilmu Pendidikan' => 17700926761,
|
||||
'Fakultas Kehutanan' => 4398583583,
|
||||
'Fakultas Matematika dan Ilmu Pengetahuan Alam' => 8515750179,
|
||||
'Fakultas Kedokteran' => 6843290846,
|
||||
'Universitas' => 34559127364
|
||||
];
|
||||
|
||||
// Get data from Rekapitulasi model
|
||||
$rekapitulasi = Rekapitulasi::where('tahun', $tahun)
|
||||
->orderBy('id', 'ASC')
|
||||
->get()
|
||||
->map(function ($item) use ($periodeLaluData) {
|
||||
// Hitung total_remunerasi per baris (jumlah dari semua kolom)
|
||||
$totalRemunerasi = ($item->total_p1 ?? 0) +
|
||||
($item->total_p2 ?? 0) +
|
||||
($item->total_thr ?? 0) +
|
||||
($item->total_r13 ?? 0) +
|
||||
($item->total_publikasi ?? 0);
|
||||
|
||||
// Get total periode lalu untuk unit kerja ini
|
||||
$totalPeriodeLalu = $periodeLaluData[$item->unit_kerja_nama] ?? 0;
|
||||
|
||||
// Perkiraan publikasi sama dengan total publikasi
|
||||
$perkiraanPublikasi = $item->total_publikasi ?? 0;
|
||||
|
||||
// Hitung total tersisa (Total Periode Lalu - Total Terpakai - Perkiraan Publikasi Semester Ini)
|
||||
$totalTersisa = $totalPeriodeLalu - $totalRemunerasi - $perkiraanPublikasi;
|
||||
|
||||
return [
|
||||
'unit_kerja' => $item->unit_kerja_nama,
|
||||
'total_p1' => $item->total_p1 ?? 0,
|
||||
'total_p2' => $item->total_p2 ?? 0,
|
||||
'total_thr' => $item->total_thr ?? 0,
|
||||
'total_r13' => $item->total_r13 ?? 0,
|
||||
'total_publikasi' => $item->total_publikasi ?? 0,
|
||||
'total_remunerasi' => $totalRemunerasi,
|
||||
'total_periode_lalu' => $totalPeriodeLalu,
|
||||
'perkiraan_publikasi' => $perkiraanPublikasi,
|
||||
'total_tersisa' => $totalTersisa
|
||||
];
|
||||
});
|
||||
|
||||
return DataTables::of($rekapitulasi)
|
||||
->addIndexColumn()
|
||||
->addColumn('total_p1_formatted', function ($row) {
|
||||
return number_format($row['total_p1'], 2, ',', '.');
|
||||
})
|
||||
->addColumn('total_p2_formatted', function ($row) {
|
||||
return number_format($row['total_p2'], 2, ',', '.');
|
||||
})
|
||||
->addColumn('total_thr_formatted', function ($row) {
|
||||
return number_format($row['total_thr'], 2, ',', '.');
|
||||
})
|
||||
->addColumn('total_r13_formatted', function ($row) {
|
||||
return number_format($row['total_r13'], 2, ',', '.');
|
||||
})
|
||||
->addColumn('total_publikasi_formatted', function ($row) {
|
||||
return number_format($row['total_publikasi'], 2, ',', '.');
|
||||
})
|
||||
->addColumn('total_remunerasi_formatted', function ($row) {
|
||||
return number_format($row['total_remunerasi'], 2, ',', '.');
|
||||
})
|
||||
->addColumn('total_periode_lalu_formatted', function ($row) {
|
||||
return number_format($row['total_periode_lalu'], 2, ',', '.');
|
||||
})
|
||||
->addColumn('perkiraan_publikasi_formatted', function ($row) {
|
||||
return number_format($row['perkiraan_publikasi'], 2, ',', '.');
|
||||
})
|
||||
->addColumn('total_tersisa_formatted', function ($row) {
|
||||
return number_format($row['total_tersisa'], 2, ',', '.');
|
||||
})
|
||||
->with([
|
||||
'grandTotalP1' => $rekapitulasi->sum('total_p1'),
|
||||
'grandTotalP2' => $rekapitulasi->sum('total_p2'),
|
||||
'grandTotalThr' => $rekapitulasi->sum('total_thr'),
|
||||
'grandTotalR13' => $rekapitulasi->sum('total_r13'),
|
||||
'grandTotalPublikasi' => $rekapitulasi->sum('total_publikasi'),
|
||||
'grandTotalRemunerasi' => $rekapitulasi->sum('total_remunerasi'),
|
||||
'grandTotalPeriodeLalu' => $rekapitulasi->sum('total_periode_lalu'),
|
||||
'grandTotalPerkiraanPublikasi' => $rekapitulasi->sum('perkiraan_publikasi'),
|
||||
'grandTotalTersisa' => $rekapitulasi->sum('total_tersisa')
|
||||
])
|
||||
->make(true);
|
||||
} catch (Exception $e) {
|
||||
Log::error("Proyeksi DataTables error: " . $e->getMessage());
|
||||
return response()->json(['error' => 'Terjadi kesalahan saat memuat data'], 500);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,324 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Perhitungan\Remunerasi;
|
||||
|
||||
use App\Exports\PublikasiExport;
|
||||
use App\Helpers\BeritaAcaraHelper;
|
||||
use App\Helpers\TotalTersisaRemunerasiHelper;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Verifikator\Periode;
|
||||
use App\Models\Verifikator\Publikasi;
|
||||
use App\Models\Verifikator\RasioPublikasi;
|
||||
use App\Models\Verifikator\UnitKerja;
|
||||
use Exception;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Yajra\DataTables\Facades\DataTables;
|
||||
|
||||
class PublikasiController extends Controller
|
||||
{
|
||||
public function index(): View
|
||||
{
|
||||
$title = 'Publikasi';
|
||||
|
||||
$isSuperuser = Auth::user()->hasRole('Superuser');
|
||||
|
||||
$periodes = Periode::orderBy('id_periode', 'desc')->get();
|
||||
$periodeAktif = Periode::where('status', true)->first();
|
||||
|
||||
$unitKerjas = UnitKerja::orderBy('nama')->get();
|
||||
|
||||
$beritaAcaraCheck = BeritaAcaraHelper::checkBeritaAcaraByTeam(session('team_id'));
|
||||
$beritaAcaraUploaded = $beritaAcaraCheck['uploaded'];
|
||||
$beritaAcaraMessage = $beritaAcaraCheck['message'];
|
||||
|
||||
return view('perhitungan.remunerasi.publikasi.index', compact(
|
||||
'title', 'isSuperuser', 'periodes', 'periodeAktif',
|
||||
'unitKerjas', 'beritaAcaraUploaded', 'beritaAcaraMessage'
|
||||
));
|
||||
}
|
||||
|
||||
public function data(Request $request): JsonResponse
|
||||
{
|
||||
$periode = $request->filter_periode ?? Periode::where('status', true)->first()->id_periode;
|
||||
$selectedUnit = $request->filled('filter_unit_kerja') ? $request->filter_unit_kerja : null;
|
||||
|
||||
if ($selectedUnit === null) {
|
||||
$allData = collect();
|
||||
$totalNormalAll = 0;
|
||||
|
||||
for ($unit = 0; $unit <= 9; $unit++) {
|
||||
$unitResult = $this->getDataForUnit($unit, $request, $periode);
|
||||
$allData = $allData->merge($unitResult['data']);
|
||||
$totalNormalAll += $unitResult['totalNormal'];
|
||||
}
|
||||
|
||||
return $this->buildDataTableResponse($allData, $totalNormalAll, null);
|
||||
}
|
||||
|
||||
$unitResult = $this->getDataForUnit($selectedUnit, $request, $periode);
|
||||
|
||||
return $this->buildDataTableResponse($unitResult['data'], $unitResult['totalNormal'], $unitResult['calculatedRasio']);
|
||||
}
|
||||
|
||||
private function buildDataTableResponse($data, float $totalNormal, ?float $calculatedRasio): JsonResponse
|
||||
{
|
||||
$data = $data->sortBy('nama', SORT_NATURAL | SORT_FLAG_CASE)->values();
|
||||
|
||||
$filteredCount = $data->count();
|
||||
$totalBruto = $data->sum('bruto_numeric');
|
||||
|
||||
return DataTables::of($data)
|
||||
->addColumn('rasio', function ($row) {
|
||||
return $row['rasio_display'];
|
||||
})
|
||||
->addColumn('detail', function ($row) {
|
||||
return json_encode([
|
||||
'unit_kerja' => $row['unit_kerja'],
|
||||
'jenis_pegawai' => $row['jenis_pegawai'],
|
||||
'poin_total' => $row['poin_total'],
|
||||
'bruto_sebelum' => 'Rp. '.$row['bruto_sebelum_rasio'],
|
||||
'rasio_persen' => $row['rasio_display'],
|
||||
'bruto_sesudah' => 'Rp. '.$row['bruto'],
|
||||
'pajak' => 'Rp. '.$row['pajak'],
|
||||
'netto' => 'Rp. '.$row['netto'],
|
||||
]);
|
||||
})
|
||||
->with([
|
||||
'totalBruto' => number_format($totalBruto, 2, ',', '.'),
|
||||
'totalNormal' => number_format($totalNormal, 2, ',', '.'),
|
||||
'calculatedRasio' => $calculatedRasio !== null ? number_format($calculatedRasio, 1, ',', '.').'%' : null,
|
||||
'jumlahData' => $filteredCount,
|
||||
'recordsTotal' => $filteredCount,
|
||||
'recordsFiltered' => $filteredCount,
|
||||
])
|
||||
->rawColumns(['rasio', 'detail'])
|
||||
->make(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Pegawai punya unit_kerja_id dari tabel verifikator.unit_kerja_pegawais (Fakultas 1-9
|
||||
* ditambah unit non-Fakultas seperti Rektorat/Biro/UPA/Lembaga/dll). Unit non-Fakultas
|
||||
* dibundel ke rasio "Universitas" (bucket 0) karena tidak punya rasio sendiri.
|
||||
*/
|
||||
private function scopeToUnitBucket($query, int $unit): void
|
||||
{
|
||||
if ($unit === 0) {
|
||||
$query->where(function ($q) {
|
||||
$q->whereNull('unit_kerja_id')->orWhereNotIn('unit_kerja_id', range(1, 9));
|
||||
});
|
||||
} else {
|
||||
$query->where('unit_kerja_id', $unit);
|
||||
}
|
||||
}
|
||||
|
||||
private function getDataForUnit(int|string $unit, Request $request, int|string $periode): array
|
||||
{
|
||||
$publikasisQuery = Publikasi::with([
|
||||
'pegawai' => function ($query) {
|
||||
$query->withoutGlobalScopes()->select('id', 'nip', 'nama', 'jenis_pegawai', 'unit_kerja_id');
|
||||
},
|
||||
'pegawai.unit:id,nama',
|
||||
])
|
||||
->where('periode', $periode)
|
||||
->where('poin_total', '>', 0)
|
||||
->whereHas('pegawai', function ($query) use ($unit) {
|
||||
$query->withoutGlobalScopes();
|
||||
$this->scopeToUnitBucket($query, (int) $unit);
|
||||
});
|
||||
|
||||
$data = $publikasisQuery->get()->map(function (Publikasi $row) use ($unit) {
|
||||
$bruto = (float) ($row->biaya_remunerasi ?? 0);
|
||||
$pajak = (float) ($row->pajak ?? 0);
|
||||
|
||||
return [
|
||||
'nip' => $row->nip,
|
||||
'nama' => $row->pegawai?->nama ?? '-',
|
||||
'jenis_pegawai' => $row->pegawai?->jenis_pegawai === 'dosen' ? 'Dosen' : ($row->pegawai?->jenis_pegawai === 'tendik' ? 'Tendik' : '-'),
|
||||
'unit_kerja' => $row->pegawai?->unit?->nama ?? '-',
|
||||
'unit_kerja_id' => $unit,
|
||||
'poin_total' => number_format((float) $row->poin_total, 2, ',', '.'),
|
||||
'bruto_sebelum_rasio' => number_format($bruto, 2, ',', '.'),
|
||||
'bruto_sebelum_rasio_numeric' => $bruto,
|
||||
'pajak' => number_format($pajak, 2, ',', '.'),
|
||||
'pajak_numeric' => $pajak,
|
||||
'pajak_sebelum_rasio_numeric' => $pajak,
|
||||
'bruto' => number_format($bruto, 2, ',', '.'),
|
||||
'bruto_numeric' => $bruto,
|
||||
'netto' => number_format(max($bruto - $pajak, 0), 2, ',', '.'),
|
||||
'netto_numeric' => max($bruto - $pajak, 0),
|
||||
'rasio_display' => '-',
|
||||
'rasio_numeric' => 100,
|
||||
];
|
||||
})->filter(function ($item) {
|
||||
return $item['bruto_sebelum_rasio_numeric'] > 0;
|
||||
})->values();
|
||||
|
||||
$totalNormal = $data->sum('bruto_sebelum_rasio_numeric');
|
||||
|
||||
$defaultRasio = RasioPublikasi::where('unit_kerja_id', $unit)
|
||||
->where('periode', $periode)
|
||||
->first();
|
||||
|
||||
$filterRasio = $request->get('filter_rasio');
|
||||
$filterNominal = $request->get('filter_nominal');
|
||||
|
||||
$calculatedRasio = null;
|
||||
|
||||
if ($filterNominal !== null && $filterNominal !== '') {
|
||||
$calculatedRasio = $totalNormal > 0 ? ($filterNominal / $totalNormal) * 100 : 0;
|
||||
} elseif ($filterRasio !== null && $filterRasio !== '') {
|
||||
$calculatedRasio = $filterRasio;
|
||||
} elseif ($defaultRasio) {
|
||||
$calculatedRasio = $defaultRasio->rasio * 100;
|
||||
}
|
||||
|
||||
if ($calculatedRasio !== null) {
|
||||
$data = $data->map(function ($item) use ($calculatedRasio) {
|
||||
$bruto = ($item['bruto_sebelum_rasio_numeric'] * $calculatedRasio) / 100;
|
||||
$pajak = ($item['pajak_sebelum_rasio_numeric'] * $calculatedRasio) / 100;
|
||||
$netto = max($bruto - $pajak, 0);
|
||||
|
||||
$item['bruto'] = number_format($bruto, 2, ',', '.');
|
||||
$item['bruto_numeric'] = $bruto;
|
||||
$item['pajak'] = number_format($pajak, 2, ',', '.');
|
||||
$item['pajak_numeric'] = $pajak;
|
||||
$item['netto'] = number_format($netto, 2, ',', '.');
|
||||
$item['netto_numeric'] = $netto;
|
||||
$item['rasio_display'] = number_format($calculatedRasio, 1, ',', '.').'%';
|
||||
$item['rasio_numeric'] = $calculatedRasio;
|
||||
|
||||
return $item;
|
||||
});
|
||||
}
|
||||
|
||||
return [
|
||||
'data' => $data,
|
||||
'totalNormal' => $totalNormal,
|
||||
'calculatedRasio' => $calculatedRasio,
|
||||
];
|
||||
}
|
||||
|
||||
public function apply(Request $request): JsonResponse
|
||||
{
|
||||
abort_unless(Auth::user()->hasRole('Superuser'), 403);
|
||||
|
||||
$request->validate([
|
||||
'filter_unit_kerja' => 'required',
|
||||
'filter_rasio' => 'nullable|numeric|min:0|max:100',
|
||||
'filter_nominal' => 'nullable|numeric|min:0',
|
||||
]);
|
||||
|
||||
if (empty($request->filter_rasio) && empty($request->filter_nominal)) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Harus diisi salah satu antara Rasio atau Nominal',
|
||||
], 422);
|
||||
}
|
||||
|
||||
if (! empty($request->filter_rasio) && ! empty($request->filter_nominal)) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Pilih salah satu antara Rasio atau Nominal',
|
||||
], 422);
|
||||
}
|
||||
|
||||
$unitKerjaId = $request->filter_unit_kerja;
|
||||
$periode = $request->filter_periode ?? Periode::where('status', true)->first()->id_periode;
|
||||
|
||||
if (! empty($request->filter_nominal)) {
|
||||
$totalTersisa = TotalTersisaRemunerasiHelper::getTotalTersisaByUnit($unitKerjaId);
|
||||
|
||||
if ($request->filter_nominal > $totalTersisa) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Batas Nominal yang dapat diinput itu Rp. '.number_format($totalTersisa, 2, ',', '.'),
|
||||
], 422);
|
||||
}
|
||||
|
||||
$totalNormal = $this->getDataForUnit($unitKerjaId, $request, $periode)['totalNormal'];
|
||||
|
||||
if ($totalNormal <= 0) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Total Publikasi Normal adalah 0, tidak dapat menghitung rasio dari nominal',
|
||||
], 422);
|
||||
}
|
||||
|
||||
$calculatedRasio = $request->filter_nominal / $totalNormal;
|
||||
} else {
|
||||
$calculatedRasio = $request->filter_rasio / 100;
|
||||
}
|
||||
|
||||
try {
|
||||
RasioPublikasi::updateOrCreate(
|
||||
[
|
||||
'unit_kerja_id' => $unitKerjaId,
|
||||
'periode' => $periode,
|
||||
],
|
||||
[
|
||||
'rasio' => $calculatedRasio,
|
||||
'paid_at' => now(),
|
||||
]
|
||||
);
|
||||
|
||||
$message = ! empty($request->filter_nominal)
|
||||
? 'Nominal berhasil dikonversi menjadi rasio dan disimpan ke database'
|
||||
: 'Rasio berhasil diaplikasikan dan disimpan ke database';
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => $message,
|
||||
'applied_rasio' => number_format($calculatedRasio * 100, 2).'%',
|
||||
]);
|
||||
} catch (Exception $e) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Terjadi kesalahan: '.$e->getMessage(),
|
||||
], 500);
|
||||
}
|
||||
}
|
||||
|
||||
public function getBatasMaksimal(Request $request): JsonResponse
|
||||
{
|
||||
abort_unless(Auth::user()->hasRole('Superuser'), 403);
|
||||
|
||||
$unitKerjaId = $request->get('unit_kerja_id');
|
||||
|
||||
if (! $unitKerjaId && $unitKerjaId !== '0') {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Unit kerja ID diperlukan',
|
||||
], 400);
|
||||
}
|
||||
|
||||
$totalTersisa = TotalTersisaRemunerasiHelper::getTotalTersisaByUnit($unitKerjaId);
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'batas_maksimal' => $totalTersisa,
|
||||
'batas_maksimal_formatted' => number_format($totalTersisa, 2, ',', '.'),
|
||||
]);
|
||||
}
|
||||
|
||||
public function export(Request $request)
|
||||
{
|
||||
// Increase time limit and memory for large exports
|
||||
set_time_limit(900); // 15 minutes
|
||||
ini_set('memory_limit', '1024M'); // 1GB
|
||||
ini_set('max_execution_time', '900');
|
||||
ignore_user_abort(true);
|
||||
|
||||
$unitKerja = $request->unit_kerja_id;
|
||||
$format = $request->format ?? 'multiple'; // default: multiple sheets
|
||||
$periode = $request->periode ?? Periode::where('status', true)->first()->id_periode;
|
||||
|
||||
$export = new PublikasiExport($unitKerja, $format, $periode);
|
||||
|
||||
$filename = 'remunerasi-publikasi-'.date('Y-m-d-H-i-s').'.xlsx';
|
||||
|
||||
return $export->download($filename);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,268 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Perhitungan\Remunerasi;
|
||||
|
||||
use App\Exports\R13Export;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Verifikator\Team;
|
||||
use App\Models\Verifikator\UnitKerja;
|
||||
use App\Services\DawaiService;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use Yajra\DataTables\Facades\DataTables;
|
||||
|
||||
class R13Controller extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
$title = 'R13';
|
||||
$team = Team::find(session('team_id'));
|
||||
|
||||
if ($team->unit_kerja_id === null || $team->unit_kerja_id === 0) {
|
||||
$units = UnitKerja::get();
|
||||
|
||||
return view('perhitungan.remunerasi.r13.index', compact('units', 'team', 'title'));
|
||||
}
|
||||
|
||||
return view('perhitungan.remunerasi.r13.index', compact('team', 'title'));
|
||||
}
|
||||
|
||||
public function data(Request $request)
|
||||
{
|
||||
$tahunNow = Carbon::now()->format('Y');
|
||||
$team = Team::find(session('team_id'));
|
||||
|
||||
if ($team->unit_kerja_id === null || $team->unit_kerja_id === 0) {
|
||||
$unit = $request->unit;
|
||||
} else {
|
||||
$unit = $team->unit_kerja_id;
|
||||
}
|
||||
|
||||
$jenisPegawai = $request->jenis_pegawai ?? '';
|
||||
$tahun = $request->tahun ?? $tahunNow;
|
||||
|
||||
// Create cache key based on parameters
|
||||
$cacheKey = "r13_data_{$jenisPegawai}_{$tahun}_{$unit}";
|
||||
|
||||
// Get data from cache or fetch from API
|
||||
$data = Cache::remember($cacheKey, now()->addDay(), function () use ($jenisPegawai, $tahun, $unit) {
|
||||
$dawaiService = new DawaiService;
|
||||
|
||||
return $dawaiService->getDataR13($jenisPegawai, $tahun, $unit, false);
|
||||
});
|
||||
|
||||
// Filter data yang total_r13 nya tidak nol
|
||||
$filteredData = collect($data)->filter(function ($item) {
|
||||
return ($item['total_r13'] ?? 0) > 0;
|
||||
})->sortBy('nama')->values();
|
||||
|
||||
return DataTables::of($filteredData)
|
||||
->addIndexColumn()
|
||||
->editColumn('nip', function ($row) {
|
||||
return ltrim($row['nip'] ?? '', "'");
|
||||
})
|
||||
->editColumn('jenis_pegawai', function ($row) {
|
||||
return $row['jenis_pegawai'] == 'dosen' ? 'Dosen' : ($row['jenis_pegawai'] == 'tendik' ? 'Tendik' : '-');
|
||||
})
|
||||
->addColumn('total_r13_formatted', function ($row) {
|
||||
return 'Rp. '.number_format($row['total_r13'] ?? 0, 2, ',', '.');
|
||||
})
|
||||
->addColumn('total_pajak_r13_formatted', function ($row) {
|
||||
$total = $row['total_r13'] ?? 0;
|
||||
$totalSetelahPajak = $row['total_r13_setelah_pajak'] ?? 0;
|
||||
|
||||
return 'Rp. '.number_format($total - $totalSetelahPajak, 2, ',', '.');
|
||||
})
|
||||
->addColumn('total_r13_setelah_pajak_formatted', function ($row) {
|
||||
return 'Rp. '.number_format($row['total_r13_setelah_pajak'] ?? 0, 2, ',', '.');
|
||||
})
|
||||
->addColumn('detail', function ($row) {
|
||||
return json_encode([
|
||||
'golongan' => $row['golongan'] ?? '-',
|
||||
'status_pegawai' => $row['status_pegawai'] ?? '-',
|
||||
'poin_p2' => $row['poin_p2'] ?? '-',
|
||||
'faktor' => $row['faktor'] ?? '-',
|
||||
'jabatan_fungsional' => $row['jabatan_fungsional'] ?? '-',
|
||||
'jabatan_tugas_tambahan' => $row['jabatan_tugas_tambahan'] ?? '-',
|
||||
'r13_p1' => $row['r13_p1'] ?? [],
|
||||
'r13_p2' => $row['r13_p2'] ?? [],
|
||||
'steps' => $row['steps'] ?? [],
|
||||
]);
|
||||
})
|
||||
->rawColumns(['detail'])
|
||||
->make();
|
||||
}
|
||||
|
||||
public function dataSelisih(Request $request)
|
||||
{
|
||||
$tahunNow = Carbon::now()->format('Y');
|
||||
$team = Team::find(session('team_id'));
|
||||
|
||||
if ($team->unit_kerja_id === null) {
|
||||
$unit = $request->unit;
|
||||
} else {
|
||||
$unit = $team->unit_kerja_id;
|
||||
}
|
||||
|
||||
$jenisPegawai = $request->jenis_pegawai ?? '';
|
||||
$tahun = $request->tahun ?? $tahunNow;
|
||||
|
||||
// Create cache key for selisih data
|
||||
$cacheKey = "r13_selisih_data_{$jenisPegawai}_{$tahun}_{$unit}";
|
||||
|
||||
// Get data from cache or fetch from API
|
||||
$data = Cache::remember($cacheKey, now()->addDay(), function () use ($jenisPegawai, $tahun, $unit) {
|
||||
$dawaiService = new DawaiService;
|
||||
|
||||
return $dawaiService->getDataR13($jenisPegawai, $tahun, $unit, true);
|
||||
});
|
||||
|
||||
// Filter data yang total_r13 nya tidak nol
|
||||
$filteredData = collect($data)->filter(function ($item) {
|
||||
return ($item['total_r13'] ?? 0) > 0;
|
||||
})->sortBy('nama')->values();
|
||||
|
||||
return DataTables::of($filteredData)
|
||||
->addIndexColumn()
|
||||
->addColumn('nip', function ($row) {
|
||||
return ltrim($row['nip'] ?? '', "'");
|
||||
})
|
||||
->addColumn('nama', function ($row) {
|
||||
return $row['nama'] ?? '';
|
||||
})
|
||||
->addColumn('nama_unit', function ($row) {
|
||||
return $row['nama_unit'] ?? '';
|
||||
})
|
||||
->editColumn('jenis_pegawai', function ($row) {
|
||||
return $row['jenis_pegawai'] == 'dosen' ? 'Dosen' : ($row['jenis_pegawai'] == 'tendik' ? 'Tendik' : '-');
|
||||
})
|
||||
->addColumn('selisih_r13_formatted', function ($row) {
|
||||
$value = $row['selisih_total_r13'] ?? 0;
|
||||
|
||||
return 'Rp. '.number_format($value, 2, ',', '.');
|
||||
})
|
||||
->addColumn('selisih_pajak_formatted', function ($row) {
|
||||
$total = $row['selisih_total_r13'] ?? 0;
|
||||
$totalSetelahPajak = $row['selisih_total_r13_setelah_pajak'] ?? 0;
|
||||
|
||||
return 'Rp. '.number_format($total - $totalSetelahPajak, 2, ',', '.');
|
||||
})
|
||||
->addColumn('selisih_total_formatted', function ($row) {
|
||||
$value = $row['selisih_total_r13_setelah_pajak'] ?? 0;
|
||||
|
||||
return 'Rp. '.number_format($value, 2, ',', '.');
|
||||
})
|
||||
->addColumn('detail', function ($row) {
|
||||
return json_encode([
|
||||
'golongan' => $row['golongan'] ?? '-',
|
||||
'status_pegawai' => $row['status_pegawai'] ?? '-',
|
||||
'poin_p2' => $row['poin_p2'] ?? '-',
|
||||
'faktor' => $row['faktor'] ?? '-',
|
||||
'jabatan_fungsional' => $row['jabatan_fungsional'] ?? '-',
|
||||
'jabatan_tugas_tambahan' => $row['jabatan_tugas_tambahan'] ?? '-',
|
||||
'r13_p1' => $row['r13_p1'] ?? [],
|
||||
'r13_p2' => $row['r13_p2'] ?? [],
|
||||
'steps' => $row['steps'] ?? [],
|
||||
]);
|
||||
})
|
||||
->rawColumns(['detail'])
|
||||
->make();
|
||||
}
|
||||
|
||||
public function export(Request $request)
|
||||
{
|
||||
$tahunNow = Carbon::now()->format('Y');
|
||||
$team = Team::find(session('team_id'));
|
||||
|
||||
// Prioritaskan pilihan user dari request, baru fallback ke team unit
|
||||
if ($request->has('unit_kerja') && $request->unit_kerja !== null) {
|
||||
$unit = $request->unit_kerja;
|
||||
} elseif ($team && $team->unit_kerja_id !== null && $team->unit_kerja_id !== 0) {
|
||||
$unit = $team->unit_kerja_id;
|
||||
} else {
|
||||
$unit = $request->unit_kerja;
|
||||
}
|
||||
|
||||
$jenisPegawai = $request->jenis_pegawai ?? '';
|
||||
$tahun = $request->tahun ?? $tahunNow;
|
||||
|
||||
if (! $tahun) {
|
||||
return response()->json(['error' => 'Tahun harus dipilih'], 400);
|
||||
}
|
||||
|
||||
// Get unit name for filename
|
||||
// Model UnitKerja uses 0 for Universitas, but blade and DAWAI API use 99
|
||||
$unitIdForModel = ($unit == 99) ? 0 : $unit;
|
||||
$unitName = '';
|
||||
if ($unit) {
|
||||
$unitKerja = UnitKerja::find($unitIdForModel);
|
||||
if ($unitKerja) {
|
||||
$unitName = '_'.str_replace(['/', ' ', '.'], '_', $unitKerja->nama);
|
||||
}
|
||||
} else {
|
||||
// If no unit selected, show "Semua Unit Kerja"
|
||||
$unitName = '_Semua_Unit_Kerja';
|
||||
}
|
||||
|
||||
$filename = "R13_{$tahun}{$unitName}.xlsx";
|
||||
|
||||
// Send original unit value to DAWAI API (99 for Universitas)
|
||||
return Excel::download(new R13Export($jenisPegawai, $tahun, $unit), $filename);
|
||||
}
|
||||
|
||||
public function exportSelisih(Request $request)
|
||||
{
|
||||
$tahunNow = Carbon::now()->format('Y');
|
||||
$team = Team::find(session('team_id'));
|
||||
|
||||
// Prioritaskan pilihan user dari request, baru fallback ke team unit
|
||||
if ($request->has('unit_kerja') && $request->unit_kerja !== null) {
|
||||
$unit = $request->unit_kerja;
|
||||
} elseif ($team && $team->unit_kerja_id !== null && $team->unit_kerja_id !== 0) {
|
||||
$unit = $team->unit_kerja_id;
|
||||
} else {
|
||||
$unit = $request->unit_kerja;
|
||||
}
|
||||
|
||||
$jenisPegawai = $request->jenis_pegawai ?? '';
|
||||
$tahun = $request->tahun ?? $tahunNow;
|
||||
|
||||
if (! $tahun) {
|
||||
return response()->json(['error' => 'Tahun harus dipilih'], 400);
|
||||
}
|
||||
|
||||
// Get unit name for filename
|
||||
// Model UnitKerja uses 0 for Universitas, but blade and DAWAI API use 99
|
||||
$unitIdForModel = ($unit == 99) ? 0 : $unit;
|
||||
$unitName = '';
|
||||
if ($unit) {
|
||||
$unitKerja = UnitKerja::find($unitIdForModel);
|
||||
if ($unitKerja) {
|
||||
$unitName = '_'.str_replace(['/', ' ', '.'], '_', $unitKerja->nama);
|
||||
}
|
||||
} else {
|
||||
// If no unit selected, show "Semua Unit Kerja"
|
||||
$unitName = '_Semua_Unit_Kerja';
|
||||
}
|
||||
|
||||
$filename = "R13_Selisih_{$tahun}{$unitName}.xlsx";
|
||||
|
||||
// Send original unit value to DAWAI API (99 for Universitas)
|
||||
return Excel::download(new R13Export($jenisPegawai, $tahun, $unit, 'selisih'), $filename);
|
||||
}
|
||||
|
||||
public function logs(Request $request)
|
||||
{
|
||||
// Ambil data dari request
|
||||
$data = $request->all();
|
||||
|
||||
// Log informasi ke file log Laravel
|
||||
Log::info('Export R13 Log:', $data);
|
||||
|
||||
// Berikan respons ke klien
|
||||
return response()->json(['status' => 'success', 'message' => 'Log berhasil disimpan']);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,273 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Perhitungan\Remunerasi;
|
||||
|
||||
use App\Exports\ThrExport;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Verifikator\Team;
|
||||
use App\Models\Verifikator\UnitKerja;
|
||||
use App\Services\DawaiService;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use Yajra\DataTables\Facades\DataTables;
|
||||
|
||||
class THRController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
$title = 'THR';
|
||||
$team = Team::find(session('team_id'));
|
||||
|
||||
if ($team->unit_kerja_id === null || $team->unit_kerja_id === 0) {
|
||||
$units = UnitKerja::get();
|
||||
|
||||
return view('perhitungan.remunerasi.thr.index', compact('units', 'team', 'title'));
|
||||
}
|
||||
|
||||
return view('perhitungan.remunerasi.thr.index', compact('team', 'title'));
|
||||
}
|
||||
|
||||
public function data(Request $request)
|
||||
{
|
||||
$tahunNow = Carbon::now()->format('Y');
|
||||
$team = Team::find(session('team_id'));
|
||||
|
||||
if ($team->unit_kerja_id === null || $team->unit_kerja_id === 0) {
|
||||
$unit = $request->unit;
|
||||
} else {
|
||||
$unit = $team->unit_kerja_id;
|
||||
}
|
||||
|
||||
$jenisPegawai = $request->jenis_pegawai ?? '';
|
||||
$tahun = $request->tahun ?? $tahunNow;
|
||||
|
||||
// Create cache key based on parameters
|
||||
$cacheKey = "thr_data_{$jenisPegawai}_{$tahun}_{$unit}";
|
||||
|
||||
// Get data from cache or fetch from API
|
||||
$data = Cache::remember($cacheKey, now()->addDay(), function () use ($jenisPegawai, $tahun, $unit) {
|
||||
$dawaiService = new DawaiService;
|
||||
|
||||
return $dawaiService->getDataThr($jenisPegawai, $tahun, $unit, false);
|
||||
});
|
||||
|
||||
// Filter data yang total_thr nya tidak nol
|
||||
$filteredData = collect($data)->filter(function ($item) {
|
||||
return ($item['total_thr'] ?? 0) > 0;
|
||||
})->sortBy('nama')->values();
|
||||
|
||||
return DataTables::of($filteredData)
|
||||
->addIndexColumn()
|
||||
->editColumn('nip', function ($row) {
|
||||
return ltrim($row['nip'] ?? '', "'");
|
||||
})
|
||||
->editColumn('jenis_pegawai', function ($row) {
|
||||
return $row['jenis_pegawai'] == 'dosen' ? 'Dosen' : ($row['jenis_pegawai'] == 'tendik' ? 'Tendik' : '-');
|
||||
})
|
||||
->addColumn('total_thr_formatted', function ($row) {
|
||||
return 'Rp. '.number_format($row['total_thr'] ?? 0, 2, ',', '.');
|
||||
})
|
||||
->addColumn('total_pajak_thr_formatted', function ($row) {
|
||||
return 'Rp. '.number_format($row['total_pajak_thr'] ?? 0, 2, ',', '.');
|
||||
})
|
||||
->addColumn('total_thr_setelah_pajak_formatted', function ($row) {
|
||||
return 'Rp. '.number_format($row['total_thr_setelah_pajak'] ?? 0, 2, ',', '.');
|
||||
})
|
||||
->addColumn('detail', function ($row) {
|
||||
return json_encode([
|
||||
'golongan' => $row['golongan'] ?? '-',
|
||||
'status_pegawai' => $row['status_pegawai'] ?? '-',
|
||||
'poin_p2' => $row['poin_p2'] ?? '-',
|
||||
'faktor' => $row['faktor'] ?? '-',
|
||||
'jabatan_fungsional' => $row['jabatan_fungsional'] ?? '-',
|
||||
'jabatan_tugas_tambahan' => $row['jabatan_tugas_tambahan'] ?? '-',
|
||||
'thr_p1' => $row['thr_p1'] ?? [],
|
||||
'thr_p2' => $row['thr_p2'] ?? [],
|
||||
'steps' => $row['steps'] ?? [],
|
||||
]);
|
||||
})
|
||||
->rawColumns(['detail'])
|
||||
->make();
|
||||
}
|
||||
|
||||
public function dataSelisih(Request $request)
|
||||
{
|
||||
$tahunNow = Carbon::now()->format('Y');
|
||||
$team = Team::find(session('team_id'));
|
||||
|
||||
if ($team->unit_kerja_id === null) {
|
||||
$unit = $request->unit;
|
||||
} else {
|
||||
$unit = $team->unit_kerja_id;
|
||||
}
|
||||
|
||||
$jenisPegawai = $request->jenis_pegawai ?? '';
|
||||
$tahun = $request->tahun ?? $tahunNow;
|
||||
|
||||
// Create cache key for selisih data
|
||||
$cacheKey = "thr_selisih_data_{$jenisPegawai}_{$tahun}_{$unit}";
|
||||
|
||||
// Get data from cache or fetch from API
|
||||
$data = Cache::remember($cacheKey, now()->addDay(), function () use ($jenisPegawai, $tahun, $unit) {
|
||||
$dawaiService = new DawaiService;
|
||||
|
||||
return $dawaiService->getDataThr($jenisPegawai, $tahun, $unit, true);
|
||||
});
|
||||
|
||||
// Filter data yang total_thr nya tidak nol
|
||||
$filteredData = collect($data)->filter(function ($item) {
|
||||
return ($item['total_thr'] ?? 0) > 0;
|
||||
})->sortBy('nama')->values();
|
||||
|
||||
return DataTables::of($filteredData)
|
||||
->addIndexColumn()
|
||||
->addColumn('nip', function ($row) {
|
||||
return ltrim($row['nip'] ?? '', "'");
|
||||
})
|
||||
->addColumn('nama', function ($row) {
|
||||
return $row['nama'] ?? '';
|
||||
})
|
||||
->addColumn('nama_unit', function ($row) {
|
||||
return $row['nama_unit'] ?? '';
|
||||
})
|
||||
->editColumn('jenis_pegawai', function ($row) {
|
||||
return $row['jenis_pegawai'] == 'dosen' ? 'Dosen' : ($row['jenis_pegawai'] == 'tendik' ? 'Tendik' : '-');
|
||||
})
|
||||
->addColumn('selisih_thr_formatted', function ($row) {
|
||||
$value = $row['selisih_total_thr'] ?? 0;
|
||||
|
||||
return 'Rp. '.number_format($value, 2, ',', '.');
|
||||
})
|
||||
->addColumn('selisih_pajak_formatted', function ($row) {
|
||||
$totalThr = $row['selisih_total_thr'] ?? 0;
|
||||
$totalThrSetelahPajak = $row['selisih_total_thr_setelah_pajak'] ?? 0;
|
||||
$value = $totalThr - $totalThrSetelahPajak;
|
||||
|
||||
return 'Rp. '.number_format($value, 2, ',', '.');
|
||||
})
|
||||
->addColumn('selisih_total_formatted', function ($row) {
|
||||
$value = $row['selisih_total_thr_setelah_pajak'] ?? 0;
|
||||
|
||||
return 'Rp. '.number_format($value, 2, ',', '.');
|
||||
})
|
||||
->addColumn('detail', function ($row) {
|
||||
return json_encode([
|
||||
'golongan' => $row['golongan'] ?? '-',
|
||||
'status_pegawai' => $row['status_pegawai'] ?? '-',
|
||||
'poin_p2' => $row['poin_p2'] ?? '-',
|
||||
'faktor' => $row['faktor'] ?? '-',
|
||||
'jabatan_fungsional' => $row['jabatan_fungsional'] ?? '-',
|
||||
'jabatan_tugas_tambahan' => $row['jabatan_tugas_tambahan'] ?? '-',
|
||||
'thr_p1' => $row['thr_p1'] ?? [],
|
||||
'thr_p2' => $row['thr_p2'] ?? [],
|
||||
'steps' => $row['steps'] ?? [],
|
||||
]);
|
||||
})
|
||||
->rawColumns(['detail'])
|
||||
->make();
|
||||
}
|
||||
|
||||
public function export(Request $request)
|
||||
{
|
||||
$tahunNow = Carbon::now()->format('Y');
|
||||
$team = Team::find(session('team_id'));
|
||||
|
||||
// Prioritaskan pilihan user dari request, baru fallback ke team unit
|
||||
if ($request->has('unit_kerja') && $request->unit_kerja !== null) {
|
||||
$unit = $request->unit_kerja;
|
||||
} elseif ($team && $team->unit_kerja_id !== null && $team->unit_kerja_id !== 0) {
|
||||
$unit = $team->unit_kerja_id;
|
||||
} else {
|
||||
$unit = $request->unit_kerja;
|
||||
}
|
||||
|
||||
$jenisPegawai = $request->jenis_pegawai ?? '';
|
||||
$tahun = $request->tahun ?? $tahunNow;
|
||||
|
||||
// Debug log
|
||||
Log::info('THR Export Request', [
|
||||
'jenis_pegawai' => $jenisPegawai,
|
||||
'tahun' => $tahun,
|
||||
'unit' => $unit,
|
||||
'request_all' => $request->all(),
|
||||
]);
|
||||
|
||||
if (! $tahun) {
|
||||
return response()->json(['error' => 'Tahun harus dipilih'], 400);
|
||||
}
|
||||
|
||||
// Get unit name for filename
|
||||
// Model UnitKerja uses 0 for Universitas, but blade and DAWAI API use 99
|
||||
$unitIdForModel = ($unit == 99) ? 0 : $unit;
|
||||
$unitName = '';
|
||||
if ($unit) {
|
||||
$unitKerja = UnitKerja::find($unitIdForModel);
|
||||
if ($unitKerja) {
|
||||
$unitName = '_'.str_replace(['/', ' ', '.'], '_', $unitKerja->nama);
|
||||
}
|
||||
} else {
|
||||
// If no unit selected, show "Semua Unit Kerja"
|
||||
$unitName = '_Semua_Unit_Kerja';
|
||||
}
|
||||
|
||||
$filename = "THR_{$tahun}{$unitName}.xlsx";
|
||||
|
||||
return Excel::download(new ThrExport($jenisPegawai, $tahun, $unit), $filename);
|
||||
}
|
||||
|
||||
public function exportSelisih(Request $request)
|
||||
{
|
||||
$tahunNow = Carbon::now()->format('Y');
|
||||
$team = Team::find(session('team_id'));
|
||||
|
||||
// Prioritaskan pilihan user dari request, baru fallback ke team unit
|
||||
if ($request->has('unit_kerja') && $request->unit_kerja !== null) {
|
||||
$unit = $request->unit_kerja;
|
||||
} elseif ($team && $team->unit_kerja_id !== null && $team->unit_kerja_id !== 0) {
|
||||
$unit = $team->unit_kerja_id;
|
||||
} else {
|
||||
$unit = $request->unit_kerja;
|
||||
}
|
||||
|
||||
$jenisPegawai = $request->jenis_pegawai ?? '';
|
||||
$tahun = $request->tahun ?? $tahunNow;
|
||||
|
||||
if (! $tahun) {
|
||||
return response()->json(['error' => 'Tahun harus dipilih'], 400);
|
||||
}
|
||||
|
||||
// Get unit name for filename
|
||||
// Model UnitKerja uses 0 for Universitas, but blade and DAWAI API use 99
|
||||
$unitIdForModel = ($unit == 99) ? 0 : $unit;
|
||||
$unitName = '';
|
||||
if ($unit) {
|
||||
$unitKerja = UnitKerja::find($unitIdForModel);
|
||||
if ($unitKerja) {
|
||||
$unitName = '_'.str_replace(['/', ' ', '.'], '_', $unitKerja->nama);
|
||||
}
|
||||
} else {
|
||||
// If no unit selected, show "Semua Unit Kerja"
|
||||
$unitName = '_Semua_Unit_Kerja';
|
||||
}
|
||||
|
||||
$filename = "THR_Selisih_{$tahun}{$unitName}.xlsx";
|
||||
|
||||
// Send original unit value to DAWAI API (99 for Universitas)
|
||||
return Excel::download(new ThrExport($jenisPegawai, $tahun, $unit, 'selisih'), $filename);
|
||||
}
|
||||
|
||||
public function logs(Request $request)
|
||||
{
|
||||
// Ambil data dari request
|
||||
$data = $request->all();
|
||||
|
||||
// Log informasi ke file log Laravel
|
||||
Log::info('Export THR Log:', $data);
|
||||
|
||||
// Berikan respons ke klien
|
||||
return response()->json(['status' => 'success', 'message' => 'Log berhasil disimpan']);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user