Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 8e5432c983 | |||
| 3dc0f870c9 |
@@ -6,6 +6,7 @@ use App\Http\Controllers\Controller;
|
|||||||
use App\Http\Requests\Api\AbsenRequest;
|
use App\Http\Requests\Api\AbsenRequest;
|
||||||
use App\Http\Resources\Presensi\AbsenCollection;
|
use App\Http\Resources\Presensi\AbsenCollection;
|
||||||
use App\Http\Resources\Presensi\AbsenResource;
|
use App\Http\Resources\Presensi\AbsenResource;
|
||||||
|
use App\Models\Verifikator\Dosen;
|
||||||
use App\Models\Verifikator\Honorer;
|
use App\Models\Verifikator\Honorer;
|
||||||
use App\Models\Verifikator\PengajuanPresensi;
|
use App\Models\Verifikator\PengajuanPresensi;
|
||||||
use App\Models\Verifikator\Tendik;
|
use App\Models\Verifikator\Tendik;
|
||||||
@@ -600,6 +601,27 @@ class PengajuanAbsenController extends Controller
|
|||||||
return false;
|
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.
|
* Kirim notifikasi WhatsApp ke atasan berisi link verifikasi (terima/tolak) pengajuan absen.
|
||||||
* Kegagalan di sini tidak menggagalkan pengajuan (dicatat ke log saja).
|
* Kegagalan di sini tidak menggagalkan pengajuan (dicatat ke log saja).
|
||||||
@@ -615,14 +637,19 @@ class PengajuanAbsenController extends Controller
|
|||||||
return;
|
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']);
|
$link = (new VerifikasiAbsenLinkService())->generate($pengajuan->id, $atasan['nip']);
|
||||||
|
|
||||||
$tanggalMulai = Carbon::parse($pengajuan->tanggal_mulai);
|
$tanggalMulai = Carbon::parse($pengajuan->tanggal_mulai);
|
||||||
$tanggalSelesai = Carbon::parse($pengajuan->tanggal_selesai ?? $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(
|
(new WhatsAppService())->sendPengajuanAbsenNotification(
|
||||||
$nomorTujuan,
|
$nomorTujuan,
|
||||||
$atasan['nama_lengkap'] ?? $atasan['nama'],
|
$atasan['nama_lengkap'] ?? $atasan['nama'],
|
||||||
|
|||||||
@@ -32,7 +32,11 @@ class VerifikasiAbsenController extends Controller
|
|||||||
|
|
||||||
public function show(Request $request, int $id): JsonResponse
|
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);
|
$otorisasi = $this->otorisasiAtasan($request, $pengajuan);
|
||||||
|
|
||||||
@@ -54,7 +58,11 @@ class VerifikasiAbsenController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function perbaruiSesi(Request $request, int $id): JsonResponse
|
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)) {
|
if ($this->isExpired($pengajuan)) {
|
||||||
return response()->json([
|
return response()->json([
|
||||||
@@ -87,7 +95,11 @@ class VerifikasiAbsenController extends Controller
|
|||||||
'passphrase' => 'required|string',
|
'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);
|
$otorisasi = $this->otorisasiAtasan($request, $pengajuan);
|
||||||
|
|
||||||
@@ -146,7 +158,11 @@ class VerifikasiAbsenController extends Controller
|
|||||||
'catatan' => 'required|string|max:500',
|
'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);
|
$otorisasi = $this->otorisasiAtasan($request, $pengajuan);
|
||||||
|
|
||||||
@@ -254,6 +270,15 @@ class VerifikasiAbsenController extends Controller
|
|||||||
return $hasil['nip'];
|
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
|
private function responseTidakBerwenang(string $reason): JsonResponse
|
||||||
{
|
{
|
||||||
return match ($reason) {
|
return match ($reason) {
|
||||||
|
|||||||
@@ -32,7 +32,9 @@ class VerifikasiAbsenHalamanController extends Controller
|
|||||||
|
|
||||||
abort_unless($hasil['ok'], 403, 'Tautan tidak valid atau sesi sudah berakhir.');
|
abort_unless($hasil['ok'], 403, 'Tautan tidak valid atau sesi sudah berakhir.');
|
||||||
|
|
||||||
$pengajuan = PengajuanPresensi::findOrFail($id);
|
$pengajuan = PengajuanPresensi::find($id);
|
||||||
|
|
||||||
|
abort_unless($pengajuan, 404, 'Pengajuan tidak ditemukan.');
|
||||||
|
|
||||||
$namaFile = basename($img);
|
$namaFile = basename($img);
|
||||||
$fileSah = array_filter([
|
$fileSah = array_filter([
|
||||||
@@ -46,7 +48,7 @@ class VerifikasiAbsenHalamanController extends Controller
|
|||||||
|
|
||||||
abort_unless(Storage::disk('public')->exists($path), 404, 'File tidak ditemukan.');
|
abort_unless(Storage::disk('public')->exists($path), 404, 'File tidak ditemukan.');
|
||||||
|
|
||||||
return Storage::disk('public')->response($path, $namaFile, [
|
return response()->file(Storage::disk('public')->path($path), [
|
||||||
'Content-Disposition' => 'inline; filename="'.$namaFile.'"',
|
'Content-Disposition' => 'inline; filename="'.$namaFile.'"',
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -154,10 +154,6 @@
|
|||||||
<dt>Kategori</dt>
|
<dt>Kategori</dt>
|
||||||
<dd id="dataKategori">-</dd>
|
<dd id="dataKategori">-</dd>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-12">
|
|
||||||
<dt>Keterangan</dt>
|
|
||||||
<dd id="dataKeterangan">-</dd>
|
|
||||||
</div>
|
|
||||||
<div class="col-12" id="dataAlasanWrap" style="display:none">
|
<div class="col-12" id="dataAlasanWrap" style="display:none">
|
||||||
<dt>Catatan</dt>
|
<dt>Catatan</dt>
|
||||||
<dd id="dataAlasan">-</dd>
|
<dd id="dataAlasan">-</dd>
|
||||||
@@ -263,7 +259,6 @@
|
|||||||
$('#dataNip').text(data.nip || '-');
|
$('#dataNip').text(data.nip || '-');
|
||||||
$('#dataTanggal').text(data.tanggal || '-');
|
$('#dataTanggal').text(data.tanggal || '-');
|
||||||
$('#dataKategori').text(data.kategori || '-');
|
$('#dataKategori').text(data.kategori || '-');
|
||||||
$('#dataKeterangan').text(data.keterangan || '-');
|
|
||||||
// File bukti dibuka lewat halaman ini sendiri (?token=...&img=nama-file) supaya tidak bergantung pada /storage.
|
// File bukti dibuka lewat halaman ini sendiri (?token=...&img=nama-file) supaya tidak bergantung pada /storage.
|
||||||
const linkFile = data.file_nama
|
const linkFile = data.file_nama
|
||||||
? `${window.location.pathname}?token=${encodeURIComponent(token)}&img=${encodeURIComponent(data.file_nama)}`
|
? `${window.location.pathname}?token=${encodeURIComponent(token)}&img=${encodeURIComponent(data.file_nama)}`
|
||||||
|
|||||||
Reference in New Issue
Block a user