first commit
This commit is contained in:
@@ -0,0 +1,224 @@
|
||||
@extends('layouts.action')
|
||||
|
||||
@section('content')
|
||||
<!-- Tampilan PDF Bukti -->
|
||||
<div class="card border shadow-sm mb-3">
|
||||
<div class="card-header bg-light">
|
||||
<h6 class="mb-0"><i class="uil-file-alt me-1"></i> Bukti Pengajuan</h6>
|
||||
</div>
|
||||
<div class="card-body p-0">
|
||||
<iframe
|
||||
src="{{ $pengajuan->file }}"
|
||||
style="width: 100%; height: 420px; border: none; display: block;"
|
||||
title="Bukti Pengajuan">
|
||||
</iframe>
|
||||
</div>
|
||||
<div class="card-footer bg-light text-end py-2">
|
||||
<a href="{{ $pengajuan->file }}" target="_blank" class="btn btn-sm btn-outline-primary">
|
||||
<i class="uil-external-link-alt me-1"></i> Buka di Tab Baru
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Detail Pengajuan -->
|
||||
<div class="card border shadow-sm mb-3">
|
||||
<div class="card-header bg-light">
|
||||
<h6 class="mb-0"><i class="uil-info-circle me-1"></i> Detail Pengajuan</h6>
|
||||
</div>
|
||||
<div class="card-body p-3">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-sm table-bordered mb-0">
|
||||
<tr>
|
||||
<th width="140" class="bg-light">NIP</th>
|
||||
<td>{{ $pengajuan->nip }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="bg-light">Nama</th>
|
||||
<td>{{ $pengajuan->pegawai?->nama ?? '-' }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="bg-light">Tanggal</th>
|
||||
<td>{{ \Carbon\Carbon::parse($pengajuan->tanggal_mulai)->translatedFormat('d F Y') }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="bg-light">Kategori</th>
|
||||
<td>{{ $pengajuan->kategori }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="bg-light">Keterangan</th>
|
||||
<td>{{ $pengajuan->keterangan ?: '-' }}</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Form Penolakan -->
|
||||
<div class="card border shadow-sm">
|
||||
<div class="card-header bg-light">
|
||||
<h6 class="mb-0 text-danger"><i class="uil-times-circle me-1"></i> Form Penolakan</h6>
|
||||
</div>
|
||||
<div class="card-body p-4">
|
||||
<div class="mb-3">
|
||||
<label for="catatan" class="form-label fw-semibold">
|
||||
Alasan Penolakan <span class="text-danger">*</span>
|
||||
</label>
|
||||
<textarea
|
||||
id="catatan"
|
||||
class="form-control"
|
||||
rows="4"
|
||||
maxlength="500"
|
||||
placeholder="Tuliskan alasan penolakan pengajuan absen ini..."
|
||||
></textarea>
|
||||
<div class="d-flex justify-content-between mt-1">
|
||||
<div id="catatan-error" class="text-danger small" style="display: none !important;">
|
||||
Alasan penolakan wajib diisi.
|
||||
</div>
|
||||
<small class="text-muted ms-auto"><span id="char-count">0</span>/500</small>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="d-flex gap-2">
|
||||
<button type="button" class="btn btn-danger flex-fill" id="btn-tolak">
|
||||
<i class="uil-times me-1"></i> Tolak
|
||||
</button>
|
||||
<button type="button" class="btn btn-secondary" id="btn-batal" onclick="window.close()">
|
||||
Batal
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Modal Konfirmasi Tolak -->
|
||||
<div class="modal fade" id="modal-konfirmasi" tabindex="-1" aria-hidden="true">
|
||||
<div class="modal-dialog modal-dialog-centered">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title text-danger">
|
||||
<i class="uil-exclamation-triangle me-1"></i> Konfirmasi Penolakan
|
||||
</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p class="mb-1">Apakah Anda yakin ingin <strong>menolak</strong> pengajuan absen ini?</p>
|
||||
<p class="text-muted small mb-0">Alasan: <span id="preview-catatan" class="fst-italic"></span></p>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Tidak</button>
|
||||
<button type="button" class="btn btn-danger" id="btn-konfirmasi-tolak">
|
||||
<i class="uil-check me-1"></i> Ya, Tolak
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@section('js')
|
||||
<script>
|
||||
const pengajuanId = {{ $pengajuan->id }};
|
||||
const catatanInput = document.getElementById('catatan');
|
||||
const charCount = document.getElementById('char-count');
|
||||
const catatanError = document.getElementById('catatan-error');
|
||||
const modalKonfirmasi = new bootstrap.Modal(document.getElementById('modal-konfirmasi'));
|
||||
|
||||
catatanInput.addEventListener('input', function() {
|
||||
charCount.textContent = this.value.length;
|
||||
if (this.value.trim()) {
|
||||
catatanError.style.setProperty('display', 'none', 'important');
|
||||
}
|
||||
});
|
||||
|
||||
document.getElementById('btn-tolak').addEventListener('click', function() {
|
||||
const catatan = catatanInput.value.trim();
|
||||
|
||||
if (!catatan) {
|
||||
catatanError.style.removeProperty('display');
|
||||
catatanInput.focus();
|
||||
return;
|
||||
}
|
||||
|
||||
document.getElementById('preview-catatan').textContent = catatan;
|
||||
modalKonfirmasi.show();
|
||||
});
|
||||
|
||||
document.getElementById('btn-konfirmasi-tolak').addEventListener('click', function() {
|
||||
const catatan = catatanInput.value.trim();
|
||||
const btn = this;
|
||||
|
||||
btn.disabled = true;
|
||||
btn.innerHTML = '<span class="spinner-border spinner-border-sm me-1"></span> Memproses...';
|
||||
|
||||
fetch('{{ route('verifikasi-absen.tolak', $pengajuan->id) }}', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').getAttribute('content'),
|
||||
'Accept': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({
|
||||
catatan: catatan
|
||||
}),
|
||||
})
|
||||
.then(res => res.json())
|
||||
.then(data => {
|
||||
modalKonfirmasi.hide();
|
||||
|
||||
if (data.success) {
|
||||
btn.disabled = false;
|
||||
btn.innerHTML = '<i class="uil-check me-1"></i> Ya, Tolak';
|
||||
|
||||
showSuccessAlert();
|
||||
} else {
|
||||
alert(data.message || 'Terjadi kesalahan. Silakan coba lagi.');
|
||||
btn.disabled = false;
|
||||
btn.innerHTML = '<i class="uil-check me-1"></i> Ya, Tolak';
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
modalKonfirmasi.hide();
|
||||
alert('Terjadi kesalahan koneksi. Silakan coba lagi.');
|
||||
btn.disabled = false;
|
||||
btn.innerHTML = '<i class="uil-check me-1"></i> Ya, Tolak';
|
||||
});
|
||||
});
|
||||
|
||||
function showSuccessAlert() {
|
||||
const overlay = document.createElement('div');
|
||||
overlay.style.cssText = `
|
||||
position: fixed; inset: 0; background: rgba(0,0,0,0.5);
|
||||
display: flex; align-items: center; justify-content: center;
|
||||
z-index: 9999;
|
||||
`;
|
||||
overlay.innerHTML = `
|
||||
<div style="background: #fff; border-radius: 12px; padding: 32px 40px; text-align: center; max-width: 360px; width: 90%;">
|
||||
<div style="width: 64px; height: 64px; background: #dcfce7; border-radius: 50%; display: flex; align-items: center; justify-content: center; margin: 0 auto 16px;">
|
||||
<svg width="32" height="32" fill="none" viewBox="0 0 24 24">
|
||||
<path stroke="#16a34a" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" d="M5 13l4 4L19 7"/>
|
||||
</svg>
|
||||
</div>
|
||||
<h5 style="color: #16a34a; margin-bottom: 8px;">Berhasil Ditolak!</h5>
|
||||
<p style="color: #6b7280; margin-bottom: 16px; font-size: 0.9rem;">Pengajuan absen telah berhasil ditolak.</p>
|
||||
<p style="color: #9ca3af; font-size: 0.8rem;" id="countdown-text">Halaman akan ditutup dalam <strong id="countdown">3</strong> detik...</p>
|
||||
</div>
|
||||
`;
|
||||
document.body.appendChild(overlay);
|
||||
|
||||
let seconds = 3;
|
||||
const timer = setInterval(() => {
|
||||
seconds--;
|
||||
const el = document.getElementById('countdown');
|
||||
if (el) { el.textContent = seconds; }
|
||||
|
||||
if (seconds <= 0) {
|
||||
clearInterval(timer);
|
||||
window.close();
|
||||
// Fallback jika window.close() diblokir browser
|
||||
setTimeout(() => {
|
||||
overlay.querySelector('p[id="countdown-text"]').textContent = 'Silakan tutup tab ini secara manual.';
|
||||
}, 500);
|
||||
}
|
||||
}, 1000);
|
||||
}
|
||||
</script>
|
||||
@endsection
|
||||
Reference in New Issue
Block a user