Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 70c796d230 | |||
| 1d58c66a7a | |||
| a1462095a7 | |||
| dcf57bcfdc | |||
| 05ab6fee35 | |||
| 16571fdffc | |||
| f2aeb9c695 | |||
| 261fa7ff8f |
@@ -85,7 +85,7 @@ PERIODE_VERIFIKATOR=395
|
|||||||
VERIFIKATOR_WEBHOOK_URL=http://172.16.50.94:8087/webhook/verifikator
|
VERIFIKATOR_WEBHOOK_URL=http://172.16.50.94:8087/webhook/verifikator
|
||||||
VERIFIKATOR_WEBHOOK_KEY=
|
VERIFIKATOR_WEBHOOK_KEY=
|
||||||
|
|
||||||
VERIFIKASI_ABSEN_WA_URL=http://verifikasi-presensi-whatsapp.test
|
VERIFIKASI_ABSEN_WA_URL=http://verifikator-untan.test/verifikasi-absen
|
||||||
|
|
||||||
GOOGLE_DRIVE_FOLDER_ID=0AJQK-NMrB4b_Uk9PVA
|
GOOGLE_DRIVE_FOLDER_ID=0AJQK-NMrB4b_Uk9PVA
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -85,7 +85,7 @@ PERIODE_VERIFIKATOR=395
|
|||||||
VERIFIKATOR_WEBHOOK_URL=http://172.16.50.94:8087/webhook/verifikator
|
VERIFIKATOR_WEBHOOK_URL=http://172.16.50.94:8087/webhook/verifikator
|
||||||
VERIFIKATOR_WEBHOOK_KEY=
|
VERIFIKATOR_WEBHOOK_KEY=
|
||||||
|
|
||||||
VERIFIKASI_ABSEN_WA_URL=http://verifikasi-presensi-whatsapp.test
|
VERIFIKASI_ABSEN_WA_URL=http://verifikator-untan.test/verifikasi-absen
|
||||||
|
|
||||||
GOOGLE_DRIVE_FOLDER_ID=
|
GOOGLE_DRIVE_FOLDER_ID=
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ class VerifikasiAbsenController extends Controller
|
|||||||
|
|
||||||
$otorisasi = $this->otorisasiAtasan($request, $pengajuan);
|
$otorisasi = $this->otorisasiAtasan($request, $pengajuan);
|
||||||
|
|
||||||
if (is_array($otorisasi)) {
|
if (! $otorisasi['ok']) {
|
||||||
return $this->responseTidakBerwenang($otorisasi['reason']);
|
return $this->responseTidakBerwenang($otorisasi['reason']);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -47,6 +47,37 @@ class VerifikasiAbsenController extends Controller
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Terbitkan token baru untuk tautan yang sesinya sudah habis (dipicu tombol "Minta Token Baru").
|
||||||
|
*/
|
||||||
|
public function perbaruiToken(Request $request, int $id): JsonResponse
|
||||||
|
{
|
||||||
|
$pengajuan = PengajuanPresensi::findOrFail($id);
|
||||||
|
|
||||||
|
if ($pengajuan->status !== 'Diajukan') {
|
||||||
|
return response()->json([
|
||||||
|
'success' => false,
|
||||||
|
'state' => 'already_processed',
|
||||||
|
'message' => 'Pengajuan ini sudah diproses sebelumnya.',
|
||||||
|
], 422);
|
||||||
|
}
|
||||||
|
|
||||||
|
$tokenBaru = $this->linkService->regenerate($id, $request->input('token'));
|
||||||
|
|
||||||
|
if (! $tokenBaru) {
|
||||||
|
return response()->json([
|
||||||
|
'success' => false,
|
||||||
|
'state' => 'link_expired',
|
||||||
|
'message' => 'Tautan verifikasi ini sudah tidak valid. Silakan minta tautan verifikasi baru.',
|
||||||
|
], 403);
|
||||||
|
}
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'success' => true,
|
||||||
|
'new_token' => $tokenBaru,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
public function setujui(Request $request, int $id): JsonResponse
|
public function setujui(Request $request, int $id): JsonResponse
|
||||||
{
|
{
|
||||||
$request->validate([
|
$request->validate([
|
||||||
@@ -58,11 +89,11 @@ class VerifikasiAbsenController extends Controller
|
|||||||
|
|
||||||
$otorisasi = $this->otorisasiAtasan($request, $pengajuan);
|
$otorisasi = $this->otorisasiAtasan($request, $pengajuan);
|
||||||
|
|
||||||
if (is_array($otorisasi)) {
|
if (! $otorisasi['ok']) {
|
||||||
return $this->responseTidakBerwenang($otorisasi['reason']);
|
return $this->responseTidakBerwenang($otorisasi['reason']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$nipAtasan = $otorisasi;
|
$nipAtasan = $otorisasi['nip'];
|
||||||
|
|
||||||
if ($gagal = $this->cekBisaDiproses($pengajuan)) {
|
if ($gagal = $this->cekBisaDiproses($pengajuan)) {
|
||||||
return $gagal;
|
return $gagal;
|
||||||
@@ -117,11 +148,11 @@ class VerifikasiAbsenController extends Controller
|
|||||||
|
|
||||||
$otorisasi = $this->otorisasiAtasan($request, $pengajuan);
|
$otorisasi = $this->otorisasiAtasan($request, $pengajuan);
|
||||||
|
|
||||||
if (is_array($otorisasi)) {
|
if (! $otorisasi['ok']) {
|
||||||
return $this->responseTidakBerwenang($otorisasi['reason']);
|
return $this->responseTidakBerwenang($otorisasi['reason']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$nipAtasan = $otorisasi;
|
$nipAtasan = $otorisasi['nip'];
|
||||||
|
|
||||||
if ($gagal = $this->cekBisaDiproses($pengajuan)) {
|
if ($gagal = $this->cekBisaDiproses($pengajuan)) {
|
||||||
return $gagal;
|
return $gagal;
|
||||||
@@ -201,23 +232,23 @@ class VerifikasiAbsenController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string|array{reason: string} Nip atasan kalau berhasil, atau array alasan gagal.
|
* @return array{ok: bool, nip: ?string, reason: ?string, new_token: ?string}
|
||||||
*/
|
*/
|
||||||
private function otorisasiAtasan(Request $request, PengajuanPresensi $pengajuan): string|array
|
private function otorisasiAtasan(Request $request, PengajuanPresensi $pengajuan, bool $renewSesi = false): array
|
||||||
{
|
{
|
||||||
$token = $request->input('token');
|
$token = $request->input('token');
|
||||||
|
|
||||||
$hasil = $this->linkService->verify($pengajuan->id, $token);
|
$hasil = $this->linkService->verify($pengajuan->id, $token, $renewSesi);
|
||||||
|
|
||||||
if (! $hasil['ok']) {
|
if (! $hasil['ok']) {
|
||||||
return ['reason' => $hasil['reason']];
|
return ['ok' => false, 'nip' => null, 'reason' => $hasil['reason'], 'new_token' => null];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! $this->dawaiService->isAtasanDari($hasil['nip'], $pengajuan->nip)) {
|
if (! $this->dawaiService->isAtasanDari($hasil['nip'], $pengajuan->nip)) {
|
||||||
return ['reason' => 'invalid'];
|
return ['ok' => false, 'nip' => null, 'reason' => 'invalid', 'new_token' => null];
|
||||||
}
|
}
|
||||||
|
|
||||||
return $hasil['nip'];
|
return ['ok' => true, 'nip' => $hasil['nip'], 'reason' => null, 'new_token' => $hasil['new_token']];
|
||||||
}
|
}
|
||||||
|
|
||||||
private function responseTidakBerwenang(string $reason): JsonResponse
|
private function responseTidakBerwenang(string $reason): JsonResponse
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
class VerifikasiAbsenHalamanController extends Controller
|
||||||
|
{
|
||||||
|
public function show(int $id)
|
||||||
|
{
|
||||||
|
return view('verifikasi-absen.halaman', ['id' => $id]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -76,6 +76,36 @@ class VerifikasiAbsenLinkService
|
|||||||
return ['ok' => true, 'nip' => $row->nip, 'reason' => null];
|
return ['ok' => true, 'nip' => $row->nip, 'reason' => null];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Terbitkan token baru untuk pengajuan yang sesinya sudah habis, dipicu lewat aksi eksplisit
|
||||||
|
* (tombol "Minta Token Baru" di halaman error), bukan otomatis saat tautan dibuka ulang.
|
||||||
|
* Token lama tetap harus dikenali (belum invalid) dan link belum lewat masa berlaku (5 hari).
|
||||||
|
*/
|
||||||
|
public function regenerate(int $pengajuanId, ?string $token): ?string
|
||||||
|
{
|
||||||
|
if (! $token) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$row = VerifikasiAbsenToken::where('pengajuan_id', $pengajuanId)
|
||||||
|
->where('token', $this->hash($token))
|
||||||
|
->where('purpose', self::PURPOSE)
|
||||||
|
->first();
|
||||||
|
|
||||||
|
if (! $row || now()->greaterThan($row->expires_at)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$tokenBaru = Str::random(40);
|
||||||
|
|
||||||
|
$row->update([
|
||||||
|
'token' => $this->hash($tokenBaru),
|
||||||
|
'first_accessed_at' => null,
|
||||||
|
]);
|
||||||
|
|
||||||
|
return $tokenBaru;
|
||||||
|
}
|
||||||
|
|
||||||
public function markUsed(int $pengajuanId, string $token): void
|
public function markUsed(int $pengajuanId, string $token): void
|
||||||
{
|
{
|
||||||
VerifikasiAbsenToken::where('pengajuan_id', $pengajuanId)
|
VerifikasiAbsenToken::where('pengajuan_id', $pengajuanId)
|
||||||
|
|||||||
+1
-1
@@ -47,7 +47,7 @@ return [
|
|||||||
],
|
],
|
||||||
|
|
||||||
'verifikasi_absen_wa' => [
|
'verifikasi_absen_wa' => [
|
||||||
'url' => env('VERIFIKASI_ABSEN_WA_URL', 'http://verifikasi-presensi-whatsapp.test'),
|
'url' => env('VERIFIKASI_ABSEN_WA_URL', env('APP_URL', 'http://localhost').'/verifikasi-absen'),
|
||||||
],
|
],
|
||||||
|
|
||||||
'google_drive' => [
|
'google_drive' => [
|
||||||
|
|||||||
@@ -0,0 +1,418 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="id">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Verifikasi Presensi | {{ config('app.name') }}</title>
|
||||||
|
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.0/css/bootstrap.min.css" rel="stylesheet">
|
||||||
|
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet">
|
||||||
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/simple-notify/dist/simple-notify.css" />
|
||||||
|
|
||||||
|
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||||
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||||
|
<link href="https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap"
|
||||||
|
rel="stylesheet">
|
||||||
|
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
background: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 50%, #1d4ed8 100%);
|
||||||
|
min-height: 100vh;
|
||||||
|
font-family: "Inter", sans-serif;
|
||||||
|
padding: 30px 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wrapper {
|
||||||
|
max-width: 640px;
|
||||||
|
margin: 0 auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card {
|
||||||
|
border: none;
|
||||||
|
border-radius: 16px;
|
||||||
|
box-shadow: 0 20px 40px rgba(30, 58, 138, 0.3);
|
||||||
|
}
|
||||||
|
|
||||||
|
.card-header {
|
||||||
|
background: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 50%, #1d4ed8 100%);
|
||||||
|
color: #fff;
|
||||||
|
border-radius: 16px 16px 0 0 !important;
|
||||||
|
padding: 24px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card-header img {
|
||||||
|
height: 48px;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card-body {
|
||||||
|
padding: 28px;
|
||||||
|
}
|
||||||
|
|
||||||
|
dt {
|
||||||
|
color: #6b7280;
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: 600;
|
||||||
|
text-transform: uppercase;
|
||||||
|
}
|
||||||
|
|
||||||
|
dd {
|
||||||
|
margin-bottom: 14px;
|
||||||
|
font-size: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.status-badge {
|
||||||
|
font-size: 13px;
|
||||||
|
padding: 6px 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-setujui {
|
||||||
|
background: #16a34a;
|
||||||
|
border-color: #16a34a;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-setujui:hover {
|
||||||
|
background: #15803d;
|
||||||
|
border-color: #15803d;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-tolak {
|
||||||
|
background: #dc2626;
|
||||||
|
border-color: #dc2626;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-tolak:hover {
|
||||||
|
background: #b91c1c;
|
||||||
|
border-color: #b91c1c;
|
||||||
|
}
|
||||||
|
|
||||||
|
.aksi-form {
|
||||||
|
display: none;
|
||||||
|
border-top: 1px solid #e5e7eb;
|
||||||
|
margin-top: 20px;
|
||||||
|
padding-top: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#loadingState {
|
||||||
|
text-align: center;
|
||||||
|
padding: 60px 20px;
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
#loadingState .fa-spinner {
|
||||||
|
font-size: 2.5rem;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<div class="wrapper">
|
||||||
|
<div id="loadingState">
|
||||||
|
<i class="fas fa-spinner fa-spin"></i>
|
||||||
|
<p class="mt-3">Memuat data pengajuan...</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="card d-none" id="mainCard">
|
||||||
|
<div class="card-header">
|
||||||
|
<img src="{{ asset('assets/images/logo-untan.png') }}" alt="untan">
|
||||||
|
<h5 class="mb-0">Verifikasi Presensi</h5>
|
||||||
|
<small>Universitas Tanjungpura</small>
|
||||||
|
</div>
|
||||||
|
<div class="card-body">
|
||||||
|
<div id="pesanState" class="d-none">
|
||||||
|
<div class="text-center py-4">
|
||||||
|
<i id="pesanIcon" class="fas fa-info-circle fa-3x text-secondary mb-3"></i>
|
||||||
|
<p id="pesanText" class="mb-0"></p>
|
||||||
|
<button type="button" class="btn btn-primary mt-3 d-none" id="btnMintaTokenBaru">
|
||||||
|
<i class="fas fa-rotate-right"></i> Minta Token Baru
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="detailState" class="d-none">
|
||||||
|
<div class="d-flex justify-content-between align-items-start mb-3">
|
||||||
|
<h6 class="mb-0">Detail Pengajuan</h6>
|
||||||
|
<span id="statusBadge" class="badge status-badge"></span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<dl class="row mb-0">
|
||||||
|
<div class="col-6">
|
||||||
|
<dt>Nama Pemohon</dt>
|
||||||
|
<dd id="dataNama">-</dd>
|
||||||
|
</div>
|
||||||
|
<div class="col-6">
|
||||||
|
<dt>NIP</dt>
|
||||||
|
<dd id="dataNip">-</dd>
|
||||||
|
</div>
|
||||||
|
<div class="col-6">
|
||||||
|
<dt>Tanggal</dt>
|
||||||
|
<dd id="dataTanggal">-</dd>
|
||||||
|
</div>
|
||||||
|
<div class="col-6">
|
||||||
|
<dt>Kategori</dt>
|
||||||
|
<dd id="dataKategori">-</dd>
|
||||||
|
</div>
|
||||||
|
<div class="col-12">
|
||||||
|
<dt>Keterangan</dt>
|
||||||
|
<dd id="dataKeterangan">-</dd>
|
||||||
|
</div>
|
||||||
|
<div class="col-12" id="dataAlasanWrap" style="display:none">
|
||||||
|
<dt>Catatan</dt>
|
||||||
|
<dd id="dataAlasan">-</dd>
|
||||||
|
</div>
|
||||||
|
<div class="col-12">
|
||||||
|
<dt>Bukti</dt>
|
||||||
|
<dd><a id="dataFile" href="#" target="_blank">Lihat file bukti <i class="fas fa-external-link-alt"></i></a></dd>
|
||||||
|
</div>
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
<div id="aksiButtons" class="d-flex gap-2 mt-3">
|
||||||
|
<button type="button" class="btn btn-setujui text-white flex-fill" id="btnBukaSetujui">
|
||||||
|
<i class="fas fa-check"></i> Setujui
|
||||||
|
</button>
|
||||||
|
<button type="button" class="btn btn-tolak text-white flex-fill" id="btnBukaTolak">
|
||||||
|
<i class="fas fa-times"></i> Tolak
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<form id="formSetujui" class="aksi-form">
|
||||||
|
<h6>Setujui & Tanda Tangani Dokumen</h6>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label class="form-label">NIK</label>
|
||||||
|
<input type="text" class="form-control" name="nik" required>
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label class="form-label">Passphrase</label>
|
||||||
|
<input type="password" class="form-control" name="passphrase" required>
|
||||||
|
</div>
|
||||||
|
<div class="d-flex gap-2">
|
||||||
|
<button type="submit" class="btn btn-setujui text-white flex-fill">Kirim Persetujuan</button>
|
||||||
|
<button type="button" class="btn btn-outline-secondary batal-aksi">Batal</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<form id="formTolak" class="aksi-form">
|
||||||
|
<h6>Tolak Pengajuan</h6>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label class="form-label">Catatan Penolakan</label>
|
||||||
|
<textarea class="form-control" name="catatan" rows="3" maxlength="500" required></textarea>
|
||||||
|
</div>
|
||||||
|
<div class="d-flex gap-2">
|
||||||
|
<button type="submit" class="btn btn-tolak text-white flex-fill">Kirim Penolakan</button>
|
||||||
|
<button type="button" class="btn btn-outline-secondary batal-aksi">Batal</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/simple-notify/dist/simple-notify.min.js"></script>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
const pengajuanId = {{ (int) $id }};
|
||||||
|
let token = new URLSearchParams(window.location.search).get('token');
|
||||||
|
const apiBase = "{{ url('/api/v1/verifikasi-absen') }}/" + pengajuanId;
|
||||||
|
|
||||||
|
function showNotification(status, title, text) {
|
||||||
|
new Notify({
|
||||||
|
status,
|
||||||
|
title,
|
||||||
|
text,
|
||||||
|
effect: 'fade',
|
||||||
|
speed: 300,
|
||||||
|
showIcon: true,
|
||||||
|
showCloseButton: true,
|
||||||
|
autoclose: true,
|
||||||
|
autotimeout: status === 'error' ? 5000 : 3000,
|
||||||
|
type: 'outline',
|
||||||
|
position: 'right top',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function ambilDataError(xhr) {
|
||||||
|
try {
|
||||||
|
return JSON.parse(xhr.responseText);
|
||||||
|
} catch (e) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function ambilPesanError(xhr) {
|
||||||
|
return ambilDataError(xhr).message || 'Terjadi kesalahan. Silakan coba lagi.';
|
||||||
|
}
|
||||||
|
|
||||||
|
const statusBadgeMap = {
|
||||||
|
'Diajukan': ['bg-warning text-dark', 'Menunggu Verifikasi'],
|
||||||
|
'Diterima': ['bg-success', 'Diterima'],
|
||||||
|
'Ditolak': ['bg-danger', 'Ditolak'],
|
||||||
|
};
|
||||||
|
|
||||||
|
function tampilkanPesan(icon, text, colorClass, bisaMintaTokenBaru = false) {
|
||||||
|
$('#pesanState').removeClass('d-none');
|
||||||
|
$('#detailState').addClass('d-none');
|
||||||
|
$('#pesanIcon').attr('class', `fas ${icon} fa-3x mb-3 ${colorClass}`);
|
||||||
|
$('#pesanText').text(text);
|
||||||
|
$('#btnMintaTokenBaru').toggleClass('d-none', !bisaMintaTokenBaru);
|
||||||
|
}
|
||||||
|
|
||||||
|
function tampilkanDetail(data, state) {
|
||||||
|
$('#pesanState').addClass('d-none');
|
||||||
|
$('#detailState').removeClass('d-none');
|
||||||
|
|
||||||
|
$('#dataNama').text(data.nama || '-');
|
||||||
|
$('#dataNip').text(data.nip || '-');
|
||||||
|
$('#dataTanggal').text(data.tanggal || '-');
|
||||||
|
$('#dataKategori').text(data.kategori || '-');
|
||||||
|
$('#dataKeterangan').text(data.keterangan || '-');
|
||||||
|
$('#dataFile').attr('href', data.file || '#');
|
||||||
|
|
||||||
|
const badge = statusBadgeMap[data.status] || ['bg-secondary', data.status];
|
||||||
|
$('#statusBadge').attr('class', `badge status-badge ${badge[0]}`).text(badge[1]);
|
||||||
|
|
||||||
|
if (data.alasan) {
|
||||||
|
$('#dataAlasanWrap').show();
|
||||||
|
$('#dataAlasan').text(data.alasan);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (state === 'pending') {
|
||||||
|
$('#aksiButtons').removeClass('d-none');
|
||||||
|
} else {
|
||||||
|
$('#aksiButtons').addClass('d-none');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function muatData() {
|
||||||
|
if (!token) {
|
||||||
|
tampilkanPesan('fa-ban', 'Tautan tidak valid: token tidak ditemukan.', 'text-danger');
|
||||||
|
selesaiLoading();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: `${apiBase}?token=${encodeURIComponent(token)}`,
|
||||||
|
method: 'GET',
|
||||||
|
success: function (res) {
|
||||||
|
tampilkanDetail(res.data, res.state);
|
||||||
|
selesaiLoading();
|
||||||
|
},
|
||||||
|
error: function (xhr) {
|
||||||
|
const data = ambilDataError(xhr);
|
||||||
|
tampilkanPesan('fa-exclamation-triangle', data.message || 'Terjadi kesalahan. Silakan coba lagi.', 'text-danger', data.state === 'session_expired');
|
||||||
|
selesaiLoading();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
$('#btnMintaTokenBaru').on('click', function () {
|
||||||
|
const $btn = $(this);
|
||||||
|
const originalText = $btn.html();
|
||||||
|
$btn.prop('disabled', true).text('Memproses...');
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: `${apiBase}/perbarui-token?token=${encodeURIComponent(token)}`,
|
||||||
|
method: 'POST',
|
||||||
|
data: { token },
|
||||||
|
success: function (res) {
|
||||||
|
token = res.new_token;
|
||||||
|
const url = new URL(window.location.href);
|
||||||
|
url.searchParams.set('token', token);
|
||||||
|
window.history.replaceState({}, '', url);
|
||||||
|
|
||||||
|
$('#loadingState').removeClass('d-none');
|
||||||
|
$('#mainCard').addClass('d-none');
|
||||||
|
muatData();
|
||||||
|
},
|
||||||
|
error: function (xhr) {
|
||||||
|
showNotification('error', 'Gagal', ambilPesanError(xhr));
|
||||||
|
},
|
||||||
|
complete: function () {
|
||||||
|
$btn.prop('disabled', false).html(originalText);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
function selesaiLoading() {
|
||||||
|
$('#loadingState').addClass('d-none');
|
||||||
|
$('#mainCard').removeClass('d-none');
|
||||||
|
}
|
||||||
|
|
||||||
|
function tutupForm() {
|
||||||
|
$('.aksi-form').slideUp(150, function () {
|
||||||
|
$(this).hide();
|
||||||
|
});
|
||||||
|
$('#aksiButtons').removeClass('d-none');
|
||||||
|
}
|
||||||
|
|
||||||
|
$('#btnBukaSetujui').on('click', function () {
|
||||||
|
$('#aksiButtons').addClass('d-none');
|
||||||
|
$('#formTolak').hide();
|
||||||
|
$('#formSetujui').show();
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#btnBukaTolak').on('click', function () {
|
||||||
|
$('#aksiButtons').addClass('d-none');
|
||||||
|
$('#formSetujui').hide();
|
||||||
|
$('#formTolak').show();
|
||||||
|
});
|
||||||
|
|
||||||
|
$('.batal-aksi').on('click', tutupForm);
|
||||||
|
|
||||||
|
$('#formSetujui').on('submit', function (e) {
|
||||||
|
e.preventDefault();
|
||||||
|
const $btn = $(this).find('button[type=submit]');
|
||||||
|
const originalText = $btn.text();
|
||||||
|
$btn.prop('disabled', true).text('Memproses...');
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: `${apiBase}/setujui?token=${encodeURIComponent(token)}`,
|
||||||
|
method: 'POST',
|
||||||
|
data: {
|
||||||
|
nik: $(this).find('[name=nik]').val(),
|
||||||
|
passphrase: $(this).find('[name=passphrase]').val(),
|
||||||
|
},
|
||||||
|
success: function (res) {
|
||||||
|
showNotification('success', 'Berhasil', res.message);
|
||||||
|
tampilkanDetail(res.data, res.state);
|
||||||
|
},
|
||||||
|
error: function (xhr) {
|
||||||
|
showNotification('error', 'Gagal', ambilPesanError(xhr));
|
||||||
|
},
|
||||||
|
complete: function () {
|
||||||
|
$btn.prop('disabled', false).text(originalText);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#formTolak').on('submit', function (e) {
|
||||||
|
e.preventDefault();
|
||||||
|
const $btn = $(this).find('button[type=submit]');
|
||||||
|
const originalText = $btn.text();
|
||||||
|
$btn.prop('disabled', true).text('Memproses...');
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: `${apiBase}/tolak?token=${encodeURIComponent(token)}`,
|
||||||
|
method: 'POST',
|
||||||
|
data: {
|
||||||
|
catatan: $(this).find('[name=catatan]').val(),
|
||||||
|
},
|
||||||
|
success: function (res) {
|
||||||
|
showNotification('success', 'Berhasil', res.message);
|
||||||
|
tampilkanDetail(res.data, res.state);
|
||||||
|
},
|
||||||
|
error: function (xhr) {
|
||||||
|
showNotification('error', 'Gagal', ambilPesanError(xhr));
|
||||||
|
},
|
||||||
|
complete: function () {
|
||||||
|
$btn.prop('disabled', false).text(originalText);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
muatData();
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
@@ -116,6 +116,7 @@ Route::prefix('v1')->group(function () {
|
|||||||
Route::prefix('/verifikasi-absen')->name('verifikasi-absen.')->group(function () {
|
Route::prefix('/verifikasi-absen')->name('verifikasi-absen.')->group(function () {
|
||||||
Route::post('/link', [VerifikasiAbsenLinkController::class, 'generate'])->name('link');
|
Route::post('/link', [VerifikasiAbsenLinkController::class, 'generate'])->name('link');
|
||||||
Route::get('/{id}', [VerifikasiAbsenController::class, 'show'])->name('show');
|
Route::get('/{id}', [VerifikasiAbsenController::class, 'show'])->name('show');
|
||||||
|
Route::post('/{id}/perbarui-token', [VerifikasiAbsenController::class, 'perbaruiToken'])->name('perbarui-token');
|
||||||
Route::post('/{id}/setujui', [VerifikasiAbsenController::class, 'setujui'])->name('setujui');
|
Route::post('/{id}/setujui', [VerifikasiAbsenController::class, 'setujui'])->name('setujui');
|
||||||
Route::post('/{id}/tolak', [VerifikasiAbsenController::class, 'tolak'])->name('tolak');
|
Route::post('/{id}/tolak', [VerifikasiAbsenController::class, 'tolak'])->name('tolak');
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ use App\Http\Controllers\Auth\LoginController;
|
|||||||
use App\Http\Controllers\Auth\OauthController;
|
use App\Http\Controllers\Auth\OauthController;
|
||||||
use App\Http\Controllers\CaptchaController;
|
use App\Http\Controllers\CaptchaController;
|
||||||
use App\Http\Controllers\JurnalController;
|
use App\Http\Controllers\JurnalController;
|
||||||
|
use App\Http\Controllers\VerifikasiAbsenHalamanController;
|
||||||
use Illuminate\Support\Facades\Route;
|
use Illuminate\Support\Facades\Route;
|
||||||
|
|
||||||
Route::get('/', function () {
|
Route::get('/', function () {
|
||||||
@@ -26,6 +27,11 @@ Route::get('/auth/google/callback', [OauthController::class, 'callback'])->name(
|
|||||||
// Jurnal Routes
|
// Jurnal Routes
|
||||||
Route::get('/jurnal', [JurnalController::class, 'index']);
|
Route::get('/jurnal', [JurnalController::class, 'index']);
|
||||||
|
|
||||||
|
// Halaman Verifikasi Presensi via WhatsApp (publik, otorisasi lewat token di query string)
|
||||||
|
Route::get('/verifikasi-absen/{id}', [VerifikasiAbsenHalamanController::class, 'show'])
|
||||||
|
->where('id', '[0-9]+')
|
||||||
|
->name('verifikasi-absen.halaman');
|
||||||
|
|
||||||
Route::middleware('auth')->group(function () {
|
Route::middleware('auth')->group(function () {
|
||||||
include __DIR__.'/prefix/profil.php';
|
include __DIR__.'/prefix/profil.php';
|
||||||
include __DIR__.'/prefix/dashboard.php';
|
include __DIR__.'/prefix/dashboard.php';
|
||||||
|
|||||||
Reference in New Issue
Block a user