Penambahan Filter P1 Perbandingan

This commit is contained in:
Ariyutta
2026-09-19 19:31:35 +07:00
parent 2ed50051a5
commit 64bbd3ef16
4 changed files with 464 additions and 1 deletions
@@ -3,6 +3,7 @@
namespace App\Http\Controllers\Perhitungan\Remunerasi;
use App\Exports\P1Export;
use App\Exports\P1PerbandinganExport;
use App\Exports\P1SelisihExport;
use App\Http\Controllers\Controller;
use App\Models\Rekapitulasi\P1;
@@ -536,6 +537,58 @@ class P1Controller extends Controller
return Excel::download(new P1SelisihExport($jenisPegawai, $tahun, $bulan, $unit, $includePppk2025), $filename);
}
public function exportPerbandingan(Request $request): BinaryFileResponse
{
set_time_limit(300);
$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 = (int) ($request->tahun ?? $tahunNow);
$bulan = $request->bulan ?? null;
$arah = $request->arah ?? '';
$unitIdForModel = ($unit == 99) ? 0 : $unit;
$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',
];
$unitName = '';
if ($unit) {
$unitKerja = UnitKerja::find($unitIdForModel);
if ($unitKerja) {
$unitName = '_'.str_replace(['/', ' ', '.'], '_', $unitKerja->nama);
}
} else {
$unitName = '_Semua_Unit_Kerja';
}
if (! $bulan) {
$namaBulanSekarang = $bulanNames[(int) $bulanNow];
$filename = "P1_Perbandingan_Januari_sampai_{$namaBulanSekarang}_{$tahun}{$unitName}.xlsx";
return Excel::download(new P1PerbandinganExport($jenisPegawai, $tahun, null, $unitIdForModel, $arah), $filename);
}
$bulanName = $bulanNames[(int) $bulan];
$filename = "P1_Perbandingan_{$bulanName}_{$tahun}{$unitName}.xlsx";
return Excel::download(new P1PerbandinganExport($jenisPegawai, $tahun, (int) $bulan, $unitIdForModel, $arah), $filename);
}
public function logs(Request $request): JsonResponse
{
Log::info('Export P1 Log:', $request->all());