Penggantian Nomor asli pmipinan
This commit is contained in:
@@ -6,6 +6,7 @@ use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\Api\AbsenRequest;
|
||||
use App\Http\Resources\Presensi\AbsenCollection;
|
||||
use App\Http\Resources\Presensi\AbsenResource;
|
||||
use App\Models\Verifikator\Dosen;
|
||||
use App\Models\Verifikator\Honorer;
|
||||
use App\Models\Verifikator\PengajuanPresensi;
|
||||
use App\Models\Verifikator\Tendik;
|
||||
@@ -600,6 +601,27 @@ class PengajuanAbsenController extends Controller
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Nomor HP pimpinan (diisi oleh command pegawai:update-no-hp-pimpinan) dalam format 62xxxxxxxxxx.
|
||||
*/
|
||||
private function nomorWhatsAppPimpinan(string $nip): ?string
|
||||
{
|
||||
$noHp = Dosen::where('nip', $nip)->value('no_hp') ?: Tendik::where('nip', $nip)->value('no_hp');
|
||||
|
||||
$digit = preg_replace('/\D+/', '', (string) $noHp);
|
||||
|
||||
if ($digit === '') {
|
||||
return null;
|
||||
}
|
||||
|
||||
return match (true) {
|
||||
str_starts_with($digit, '62') => $digit,
|
||||
str_starts_with($digit, '0') => '62'.substr($digit, 1),
|
||||
str_starts_with($digit, '8') => '62'.$digit,
|
||||
default => null,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Kirim notifikasi WhatsApp ke atasan berisi link verifikasi (terima/tolak) pengajuan absen.
|
||||
* Kegagalan di sini tidak menggagalkan pengajuan (dicatat ke log saja).
|
||||
@@ -615,14 +637,19 @@ class PengajuanAbsenController extends Controller
|
||||
return;
|
||||
}
|
||||
|
||||
$nomorTujuan = $this->nomorWhatsAppPimpinan($atasan['nip']);
|
||||
|
||||
if (! $nomorTujuan) {
|
||||
Log::error("Notifikasi WhatsApp Pengajuan Absen: nomor HP atasan (NIP {$atasan['nip']}) belum tersedia untuk pengajuan #$pengajuan->id");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$link = (new VerifikasiAbsenLinkService())->generate($pengajuan->id, $atasan['nip']);
|
||||
|
||||
$tanggalMulai = Carbon::parse($pengajuan->tanggal_mulai);
|
||||
$tanggalSelesai = Carbon::parse($pengajuan->tanggal_selesai ?? $pengajuan->tanggal_mulai);
|
||||
|
||||
// TODO: nomor WA atasan masih manual/sementara, belum ada sumber data resminya.
|
||||
$nomorTujuan = '6289698424476';
|
||||
|
||||
(new WhatsAppService())->sendPengajuanAbsenNotification(
|
||||
$nomorTujuan,
|
||||
$atasan['nama_lengkap'] ?? $atasan['nama'],
|
||||
|
||||
@@ -32,7 +32,11 @@ class VerifikasiAbsenController extends Controller
|
||||
|
||||
public function show(Request $request, int $id): JsonResponse
|
||||
{
|
||||
$pengajuan = PengajuanPresensi::with(['pegawai', 'notes'])->findOrFail($id);
|
||||
$pengajuan = PengajuanPresensi::with(['pegawai', 'notes'])->find($id);
|
||||
|
||||
if (! $pengajuan) {
|
||||
return $this->responsePengajuanTidakDitemukan();
|
||||
}
|
||||
|
||||
$otorisasi = $this->otorisasiAtasan($request, $pengajuan);
|
||||
|
||||
@@ -54,7 +58,11 @@ class VerifikasiAbsenController extends Controller
|
||||
*/
|
||||
public function perbaruiSesi(Request $request, int $id): JsonResponse
|
||||
{
|
||||
$pengajuan = PengajuanPresensi::findOrFail($id);
|
||||
$pengajuan = PengajuanPresensi::find($id);
|
||||
|
||||
if (! $pengajuan) {
|
||||
return $this->responsePengajuanTidakDitemukan();
|
||||
}
|
||||
|
||||
if ($this->isExpired($pengajuan)) {
|
||||
return response()->json([
|
||||
@@ -87,7 +95,11 @@ class VerifikasiAbsenController extends Controller
|
||||
'passphrase' => 'required|string',
|
||||
]);
|
||||
|
||||
$pengajuan = PengajuanPresensi::with(['pegawai', 'notes'])->findOrFail($id);
|
||||
$pengajuan = PengajuanPresensi::with(['pegawai', 'notes'])->find($id);
|
||||
|
||||
if (! $pengajuan) {
|
||||
return $this->responsePengajuanTidakDitemukan();
|
||||
}
|
||||
|
||||
$otorisasi = $this->otorisasiAtasan($request, $pengajuan);
|
||||
|
||||
@@ -146,7 +158,11 @@ class VerifikasiAbsenController extends Controller
|
||||
'catatan' => 'required|string|max:500',
|
||||
]);
|
||||
|
||||
$pengajuan = PengajuanPresensi::with(['pegawai', 'notes'])->findOrFail($id);
|
||||
$pengajuan = PengajuanPresensi::with(['pegawai', 'notes'])->find($id);
|
||||
|
||||
if (! $pengajuan) {
|
||||
return $this->responsePengajuanTidakDitemukan();
|
||||
}
|
||||
|
||||
$otorisasi = $this->otorisasiAtasan($request, $pengajuan);
|
||||
|
||||
@@ -254,6 +270,15 @@ class VerifikasiAbsenController extends Controller
|
||||
return $hasil['nip'];
|
||||
}
|
||||
|
||||
private function responsePengajuanTidakDitemukan(): JsonResponse
|
||||
{
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'state' => 'not_found',
|
||||
'message' => 'Pengajuan ini sudah dihapus oleh pemohon atau tidak ditemukan lagi, sehingga tidak dapat diverifikasi.',
|
||||
], 404);
|
||||
}
|
||||
|
||||
private function responseTidakBerwenang(string $reason): JsonResponse
|
||||
{
|
||||
return match ($reason) {
|
||||
|
||||
Reference in New Issue
Block a user