Update Status kelengkapan data
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
{{--
|
||||
Kelengkapan data (terisi X dari 209) + status Draf/Lengkap/Terverifikasi di kartu Profil Petani.
|
||||
Kelengkapan data (terisi X dari total isian) + status Draf/Lengkap/Terverifikasi di kartu Profil Petani.
|
||||
Tombol "Tandai Lengkap" hanya untuk enumerator penginput, dan nonaktif selama isian wajib masih kosong.
|
||||
--}}
|
||||
@props(['petani'])
|
||||
@@ -42,11 +42,15 @@
|
||||
|
||||
@if ($bisaTandai && $status === StatusDataPetani::DRAFT)
|
||||
<form method="POST" action="{{ route('petani.status.update', $petani->id) }}" class="form-status-petani mt-2"
|
||||
data-konfirmasi="Tandai data petani ini sudah lengkap? Koordinator akan memverifikasinya.">
|
||||
data-judul="Pernyataan Kelengkapan Data"
|
||||
data-konfirmasi="Setelah ditandai lengkap, data akan diteruskan ke koordinator untuk diverifikasi."
|
||||
data-pernyataan="Saya menyatakan bahwa data petani {{ $petani->nama }} telah saya periksa, sudah lengkap, dan sesuai dengan hasil survei bersama pihak terkait di lapangan. Saya bertanggung jawab atas kebenaran data ini."
|
||||
data-tombol="Ya, Tandai Lengkap">
|
||||
@csrf
|
||||
@method('PUT')
|
||||
<input type="hidden" name="status" value="{{ StatusDataPetani::LENGKAP->value }}">
|
||||
<button type="submit" class="btn btn-sm btn-success w-100" @disabled($wajibKosong > 0)
|
||||
<input type="hidden" name="pernyataan" value="0">
|
||||
<button type="submit" class="btn btn-sm btn-primary w-100" @disabled($wajibKosong > 0)
|
||||
@if ($wajibKosong) title="Lengkapi {{ $wajibKosong }} isian wajib terlebih dahulu" @endif>
|
||||
<i class="icon-base ti tabler-checks icon-sm me-1"></i>Tandai Sudah Lengkap
|
||||
</button>
|
||||
@@ -61,6 +65,7 @@
|
||||
<i class="icon-base ti tabler-arrow-back-up icon-sm me-1"></i>Batalkan Tanda Lengkap
|
||||
</button>
|
||||
</form>
|
||||
<p class="mb-0 mt-1 text-muted fst-italic" style="font-size: 0.7rem;">Mengubah data petani akan mengembalikan status ke Draf.</p>
|
||||
@elseif ($status === StatusDataPetani::DRAFT)
|
||||
<p class="mb-0 mt-1 text-muted fst-italic" style="font-size: 0.7rem;">Hanya enumerator penginput yang dapat menandai lengkap.</p>
|
||||
@elseif ($status === StatusDataPetani::LENGKAP)
|
||||
@@ -70,31 +75,64 @@
|
||||
@once
|
||||
@push('scripts')
|
||||
<script>
|
||||
// Tombol popup mengikuti warna tombol aplikasi (bukan ungu bawaan SweetAlert).
|
||||
const gayaTombolSwal = () => ({
|
||||
buttonsStyling: false,
|
||||
customClass: { confirmButton: 'btn btn-primary me-2', cancelButton: 'btn btn-label-secondary' },
|
||||
});
|
||||
|
||||
document.addEventListener('submit', function (e) {
|
||||
const form = e.target.closest('.form-status-petani');
|
||||
if (!form || form.dataset.terkonfirmasi) return;
|
||||
|
||||
e.preventDefault();
|
||||
const kirim = () => { form.dataset.terkonfirmasi = '1'; form.submit(); };
|
||||
const pernyataan = form.dataset.pernyataan;
|
||||
const kirim = () => {
|
||||
if (pernyataan) form.querySelector('input[name="pernyataan"]').value = '1';
|
||||
form.dataset.terkonfirmasi = '1';
|
||||
form.submit();
|
||||
};
|
||||
|
||||
if (!window.Swal) {
|
||||
if (confirm(form.dataset.konfirmasi)) kirim();
|
||||
if (confirm((pernyataan ? pernyataan + '\n\n' : '') + form.dataset.konfirmasi)) kirim();
|
||||
return;
|
||||
}
|
||||
Swal.fire({
|
||||
icon: 'question',
|
||||
|
||||
const opsi = {
|
||||
icon: pernyataan ? 'warning' : 'question',
|
||||
title: form.dataset.judul || undefined,
|
||||
text: form.dataset.konfirmasi,
|
||||
showCancelButton: true,
|
||||
confirmButtonText: 'Ya',
|
||||
confirmButtonText: form.dataset.tombol || 'Ya',
|
||||
cancelButtonText: 'Batal',
|
||||
}).then((r) => { if (r.isConfirmed) kirim(); });
|
||||
...gayaTombolSwal(),
|
||||
};
|
||||
|
||||
// Tandai Lengkap: wajib mencentang pernyataan sebelum bisa lanjut.
|
||||
if (pernyataan) {
|
||||
opsi.input = 'checkbox';
|
||||
opsi.inputValue = 0;
|
||||
opsi.inputPlaceholder = pernyataan;
|
||||
opsi.inputValidator = (dicentang) => !dicentang && 'Centang pernyataan terlebih dahulu.';
|
||||
opsi.customClass.input = 'text-start small';
|
||||
}
|
||||
|
||||
Swal.fire(opsi).then((r) => { if (r.isConfirmed) kirim(); });
|
||||
});
|
||||
|
||||
@if (session('status_petani_success') || session('status_petani_error'))
|
||||
@if (session('status_petani_info'))
|
||||
// Data diubah setelah ditandai lengkap → status kembali ke Draf (KembalikanStatusPetaniKeDraf).
|
||||
window.addEventListener('load', function () {
|
||||
const pesan = @json(session('status_petani_success') ?? session('status_petani_error'));
|
||||
const pesan = @json(session('status_petani_info'));
|
||||
window.Swal ? Swal.fire({ icon: 'info', title: 'Status kembali ke Draf', text: pesan, ...gayaTombolSwal() }) : alert(pesan);
|
||||
});
|
||||
@endif
|
||||
|
||||
@if (session('status_petani_success') || session('status_petani_error') || $errors->has('pernyataan'))
|
||||
window.addEventListener('load', function () {
|
||||
const pesan = @json(session('status_petani_success') ?? session('status_petani_error') ?? $errors->first('pernyataan'));
|
||||
const ikon = @json(session('status_petani_success') ? 'success' : 'error');
|
||||
window.Swal ? Swal.fire({ icon: ikon, text: pesan }) : alert(pesan);
|
||||
window.Swal ? Swal.fire({ icon: ikon, text: pesan, ...gayaTombolSwal() }) : alert(pesan);
|
||||
});
|
||||
@endif
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user