Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 8fa9f9b724 | |||
| 5e54639ca4 |
@@ -22,6 +22,7 @@ use Illuminate\Database\Eloquent\ModelNotFoundException;
|
|||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Illuminate\Support\Facades\Http;
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
use Illuminate\Support\Facades\Storage;
|
use Illuminate\Support\Facades\Storage;
|
||||||
use Illuminate\Support\Facades\Validator;
|
use Illuminate\Support\Facades\Validator;
|
||||||
@@ -539,8 +540,16 @@ class PengajuanAbsenController extends Controller
|
|||||||
|
|
||||||
$this->catatLog($pengajuan, 'Pengajuan Presensi Berhasil diajukan', $pegawai->nip, 'Pemohon', 'POST', $pegawai->nama);
|
$this->catatLog($pengajuan, 'Pengajuan Presensi Berhasil diajukan', $pegawai->nip, 'Pemohon', 'POST', $pegawai->nama);
|
||||||
|
|
||||||
$this->notifikasiTertunda[] = fn () => $this->notifikasiAtasanWhatsApp($pengajuan, $pegawai, $dawaiService);
|
if ((int) $request->kategori === 2) {
|
||||||
$this->notifikasiTertunda[] = fn () => (new VerifikatorWebhookService)->kirimIzin($pengajuan, VerifikatorWebhookService::STATUS_PENDING);
|
// Tugas / Dinas langsung disetujui otomatis tanpa verifikasi atasan.
|
||||||
|
$gagal = $this->setujuiOtomatis($pengajuan, $pegawai, $dawaiService);
|
||||||
|
if ($gagal) {
|
||||||
|
return $gagal;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$this->notifikasiTertunda[] = fn () => $this->notifikasiAtasanWhatsApp($pengajuan, $pegawai, $dawaiService);
|
||||||
|
$this->notifikasiTertunda[] = fn () => (new VerifikatorWebhookService)->kirimIzin($pengajuan, VerifikatorWebhookService::STATUS_PENDING);
|
||||||
|
}
|
||||||
|
|
||||||
// Ambil nama kategori dari Dawai Service
|
// Ambil nama kategori dari Dawai Service
|
||||||
$statusPresensi = collect($dawaiService->listStatusPresensi());
|
$statusPresensi = collect($dawaiService->listStatusPresensi());
|
||||||
@@ -568,6 +577,44 @@ class PengajuanAbsenController extends Controller
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function setujuiOtomatis(PengajuanPresensi $pengajuan, $pegawai, DawaiService $dawaiService): ?JsonResponse
|
||||||
|
{
|
||||||
|
$pengajuan->update(['status' => 'Diterima']);
|
||||||
|
|
||||||
|
$this->catatLog($pengajuan, 'Pengajuan Presensi Berhasil diterima (otomatis, Tugas / Dinas)', $pegawai->nip, 'Sistem', 'POST', $pegawai->nama);
|
||||||
|
|
||||||
|
$kategori = $pengajuan->getRawOriginal('kategori');
|
||||||
|
|
||||||
|
$dawai = $dawaiService->verifikasiUsulanPresensi($pengajuan->nip, [$pengajuan->tanggal_mulai], true, $kategori, $pegawai->nip, $pegawai->nama);
|
||||||
|
|
||||||
|
if (! $dawai || ! $dawaiService->kirimVerifikasiPresensi($pengajuan, 'Diterima', null, $pegawai->nip)) {
|
||||||
|
Log::error("Auto approve Tugas / Dinas gagal kirim ke DAWAI: $pengajuan->nip");
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'code' => 500,
|
||||||
|
'status' => 'failed',
|
||||||
|
'message' => 'Gagal melakukan pengajuan absen',
|
||||||
|
], 500);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->notifikasiTertunda[] = fn () => (new VerifikatorWebhookService)->kirimIzin($pengajuan, VerifikatorWebhookService::STATUS_APPROVED);
|
||||||
|
$this->notifikasiTertunda[] = function () use ($pengajuan, $pegawai, $kategori) {
|
||||||
|
try {
|
||||||
|
Http::timeout(5)->asMultipart()->post('http://172.16.50.94:8084/webhook/presensi', [
|
||||||
|
['name' => 'nip', 'contents' => $pengajuan->nip],
|
||||||
|
['name' => 'tanggal[]', 'contents' => $pengajuan->tanggal_mulai],
|
||||||
|
['name' => 'kategori', 'contents' => (string) $kategori],
|
||||||
|
['name' => 'username', 'contents' => $pegawai->nip],
|
||||||
|
['name' => 'name', 'contents' => $pegawai->nama],
|
||||||
|
]);
|
||||||
|
} catch (Throwable $e) {
|
||||||
|
Log::error("Webhook Presensi error (auto approve): $pengajuan->nip - ".$e->getMessage());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public function batalkan(Request $request, string $id)
|
public function batalkan(Request $request, string $id)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user