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'],
|
||||
|
||||
Reference in New Issue
Block a user