Penambahan Fitur Export Total Simulasi Jabatan dan Perubahan Login
This commit is contained in:
@@ -14,6 +14,7 @@ use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use App\Exports\SimulasiJabatanExport;
|
||||
use App\Exports\SimulasiJabatanTotalExport;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
|
||||
class SimulasiJabatanController extends Controller
|
||||
@@ -316,6 +317,57 @@ class SimulasiJabatanController extends Controller
|
||||
return Excel::download(new SimulasiJabatanExport($periode, null, $jenis, $unitKerjaId, $grade12), 'simulasi-jabatan-'.$periode.$suffix.'.xlsx');
|
||||
}
|
||||
|
||||
/**
|
||||
* Rekap Excel "Total": ringkas — satu baris per pegawai (atau per unit
|
||||
* pembayaran bila mode pecah aktif) berisi Total P2 (2022), P2 (2023),
|
||||
* P2 (Excel), plus satu baris TOTAL keseluruhan. Sumber angka sama dengan
|
||||
* tabel & kartu ringkasan (dataset ter-cache), menghormati filter periode,
|
||||
* unit kerja, jenis pegawai, simulasi +12 poin grade, dan unit pembayaran.
|
||||
*/
|
||||
public function exportTotal(Request $request)
|
||||
{
|
||||
@set_time_limit(300);
|
||||
@ini_set('max_execution_time', '300');
|
||||
|
||||
$periode = (int) ($request->input('periode') ?: optional(Periode::where('status', true)->first())->id_periode);
|
||||
$splitUnit = $request->boolean('split_unit');
|
||||
$grade12 = $request->boolean('grade12');
|
||||
$unitKerjaId = $request->input('unit_kerja_id') ?: null;
|
||||
|
||||
$key = $grade12 ? '_g12' : '';
|
||||
$parse = fn ($value) => (float) str_replace(',', '.', str_replace('.', '', (string) $value));
|
||||
|
||||
$rows = $this->applyUnitJenisFilter($this->dataset($periode, $splitUnit), $request)
|
||||
->values()
|
||||
->map(function ($row) use ($parse, $key, $splitUnit) {
|
||||
$out = [
|
||||
'nama_pegawai' => $row['nama_pegawai'],
|
||||
'nip' => "'".$row['nip'],
|
||||
'jenis_pegawai' => strtoupper((string) $row['jenis_pegawai']),
|
||||
'unit_kerja' => $row['unit_kerja'] ?: 'Tanpa Unit Kerja',
|
||||
];
|
||||
if ($splitUnit) {
|
||||
$out['unit_pembayaran'] = $row['unit_pembayaran'] ?: '-';
|
||||
}
|
||||
$out['p2_2022'] = $parse($row['p2_total_374'.$key]);
|
||||
$out['p2_2023'] = $parse($row['p2_total_377'.$key]);
|
||||
$out['p2_excel'] = $parse($row['p2_total_excel'.$key]);
|
||||
// Poin P2 baru terbentuk bila Total Poin melewati ambang 12
|
||||
// (rumus P2 memakai ...-12). Bila di bawah itu, atau ketiga versi
|
||||
// P2 nol, tandai supaya mudah difilter di Excel.
|
||||
$out['keterangan'] = ($parse($row['total_poin']) < 12
|
||||
|| ($out['p2_2022'] == 0.0 && $out['p2_2023'] == 0.0 && $out['p2_excel'] == 0.0))
|
||||
? 'Poin P2 tidak mencukupi 12 Poin'
|
||||
: '';
|
||||
|
||||
return $out;
|
||||
});
|
||||
|
||||
$suffix = ($unitKerjaId ? '-unit'.$unitKerjaId : '').($grade12 ? '-grade12' : '').($splitUnit ? '-unit-pembayaran' : '');
|
||||
|
||||
return Excel::download(new SimulasiJabatanTotalExport($rows, $splitUnit), 'simulasi-jabatan-total-'.$periode.$suffix.'.xlsx');
|
||||
}
|
||||
|
||||
/**
|
||||
* Rincian modal mengikuti aturan menu Remunerasi > P2: seluruh Poin P2 dikali
|
||||
* SATU harga jabatan — tendik: JTT bila ada & harga 377-nya > 0 (selain itu
|
||||
|
||||
Reference in New Issue
Block a user