Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 13f0a47af2 | |||
| f0e1d4fcaa | |||
| 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 {
|
||||||
|
|||||||
@@ -857,10 +857,19 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function hasSelectedDiterima() {
|
||||||
|
var table = $('#table-detail').DataTable();
|
||||||
|
return $('.select-item:checked').toArray().some(function(el) {
|
||||||
|
var row = table.row($(el).closest('tr')).data();
|
||||||
|
return row && row.status === 'Diterima';
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// Event handler untuk tombol hapus selected (hanya untuk Superuser)
|
// Event handler untuk tombol hapus selected (hanya untuk Superuser)
|
||||||
$('#btn-hapus-selected').on('click', function() {
|
$('#btn-hapus-selected').on('click', function() {
|
||||||
var ids = getSelectedIds();
|
var ids = getSelectedIds();
|
||||||
if (ids.length === 0) { showWarning('Peringatan', 'Pilih minimal satu item untuk dihapus'); return; }
|
if (ids.length === 0) { showWarning('Peringatan', 'Pilih minimal satu item untuk dihapus'); return; }
|
||||||
|
if (hasSelectedDiterima()) { showWarning('Peringatan', 'Pengajuan yang sudah diterima tidak dapat dihapus'); return; }
|
||||||
$('#modal-hapus-msg').text('Anda akan menghapus ' + ids.length + ' pengajuan secara permanen.');
|
$('#modal-hapus-msg').text('Anda akan menghapus ' + ids.length + ' pengajuan secara permanen.');
|
||||||
$('#modalHapusSelected').modal('show');
|
$('#modalHapusSelected').modal('show');
|
||||||
});
|
});
|
||||||
@@ -896,6 +905,7 @@
|
|||||||
$('#btn-batalkan-selected').on('click', function() {
|
$('#btn-batalkan-selected').on('click', function() {
|
||||||
var ids = getSelectedIds();
|
var ids = getSelectedIds();
|
||||||
if (ids.length === 0) { showWarning('Peringatan', 'Pilih minimal satu item'); return; }
|
if (ids.length === 0) { showWarning('Peringatan', 'Pilih minimal satu item'); return; }
|
||||||
|
if (hasSelectedDiterima()) { showWarning('Peringatan', 'Pengajuan yang sudah diterima tidak dapat dibatalkan'); return; }
|
||||||
$('#modal-batalkan-msg').text('Anda akan membatalkan verifikasi ' + ids.length + ' pengajuan yang dipilih kembali ke status Diajukan.');
|
$('#modal-batalkan-msg').text('Anda akan membatalkan verifikasi ' + ids.length + ' pengajuan yang dipilih kembali ke status Diajukan.');
|
||||||
$('#modalBatalkanSelected').modal('show');
|
$('#modalBatalkanSelected').modal('show');
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -590,10 +590,19 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function hasSelectedDiterima() {
|
||||||
|
var table = $('#table-detail').DataTable();
|
||||||
|
return $('.select-item:checked').toArray().some(function(el) {
|
||||||
|
var row = table.row($(el).closest('tr')).data();
|
||||||
|
return row && row.status === 'Diterima';
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// Event handler untuk hapus selected
|
// Event handler untuk hapus selected
|
||||||
$('#btn-hapus-selected').on('click', function() {
|
$('#btn-hapus-selected').on('click', function() {
|
||||||
var ids = getSelectedIds();
|
var ids = getSelectedIds();
|
||||||
if (ids.length === 0) { showWarning('Peringatan', 'Pilih minimal satu item'); return; }
|
if (ids.length === 0) { showWarning('Peringatan', 'Pilih minimal satu item'); return; }
|
||||||
|
if (hasSelectedDiterima()) { showWarning('Peringatan', 'Pengajuan yang sudah diterima tidak dapat dihapus'); return; }
|
||||||
$('#modal-hapus-msg').text('Anda akan menghapus ' + ids.length + ' pengajuan yang dipilih.');
|
$('#modal-hapus-msg').text('Anda akan menghapus ' + ids.length + ' pengajuan yang dipilih.');
|
||||||
$('#modalHapusSelected').modal('show');
|
$('#modalHapusSelected').modal('show');
|
||||||
});
|
});
|
||||||
@@ -623,6 +632,7 @@
|
|||||||
$('#btn-batalkan-selected').on('click', function() {
|
$('#btn-batalkan-selected').on('click', function() {
|
||||||
var ids = getSelectedIds();
|
var ids = getSelectedIds();
|
||||||
if (ids.length === 0) { showWarning('Peringatan', 'Pilih minimal satu item'); return; }
|
if (ids.length === 0) { showWarning('Peringatan', 'Pilih minimal satu item'); return; }
|
||||||
|
if (hasSelectedDiterima()) { showWarning('Peringatan', 'Pengajuan yang sudah diterima tidak dapat dibatalkan'); return; }
|
||||||
$('#modal-batalkan-msg').text('Anda akan membatalkan verifikasi ' + ids.length + ' pengajuan yang dipilih kembali ke status Diajukan.');
|
$('#modal-batalkan-msg').text('Anda akan membatalkan verifikasi ' + ids.length + ' pengajuan yang dipilih kembali ke status Diajukan.');
|
||||||
$('#modalBatalkanSelected').modal('show');
|
$('#modalBatalkanSelected').modal('show');
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user