first commit
This commit is contained in:
@@ -0,0 +1,391 @@
|
||||
@extends('layouts.main')
|
||||
|
||||
@section('breadcrumb')
|
||||
<ol class="breadcrumb m-0">
|
||||
<li class="breadcrumb-item"><a href="javascript:void(0);">Verifikasi</a></li>
|
||||
<li class="breadcrumb-item"><a href="{{ route('sk.klaim-ulang.index') }}{{ request('unit_id') ? '?unit_id=' . request('unit_id') : '' }}">SK - Klaim Ulang</a></li>
|
||||
<li class="breadcrumb-item active" aria-current="page">{{ $title }}</li>
|
||||
</ol>
|
||||
@endsection
|
||||
|
||||
@section('content')
|
||||
<input type="hidden" id="berita_acara_uploaded" value="{{ $beritaAcaraUploaded ? '1' : '0' }}">
|
||||
<input type="hidden" id="berita_acara_message" value="{{ $beritaAcaraMessage ?? '' }}">
|
||||
|
||||
<div class="card border">
|
||||
<div class="card-body">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-sm">
|
||||
<!-- ID SK -->
|
||||
<tr>
|
||||
<th width="200">ID SK</th>
|
||||
<td class="text-primary fw-bold">{{ $sk['id'] }}</td>
|
||||
</tr>
|
||||
|
||||
<!-- Nomor SK -->
|
||||
<tr>
|
||||
<th>Nomor SK</th>
|
||||
<td>{{ $sk['no_sk'] }}</td>
|
||||
</tr>
|
||||
|
||||
<!-- Tentang -->
|
||||
<tr>
|
||||
<th>Tentang</th>
|
||||
<td>
|
||||
<textarea class="form-control" name="tentang" id="tentang" cols="30" rows="3" readonly>{{ $sk['tentang'] }}</textarea>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<!-- Tanggal SK -->
|
||||
<tr>
|
||||
<th>Tanggal SK</th>
|
||||
<td>{{ \Carbon\Carbon::parse($sk['tanggal_sk'])->format('d/m/Y') }}</td>
|
||||
</tr>
|
||||
|
||||
<!-- TMT -->
|
||||
<tr>
|
||||
<th>Terhitung pada</th>
|
||||
<td>{{ \Carbon\Carbon::parse($sk['tmt'])->format('d/m/Y') }} - {{ \Carbon\Carbon::parse($sk['tst'])->format('d/m/Y') }}</td>
|
||||
</tr>
|
||||
|
||||
<!-- Status Klaim -->
|
||||
<tr>
|
||||
<th>Status</th>
|
||||
<td>
|
||||
@if (!$periodeAktif)
|
||||
<span class="badge bg-secondary rounded-pill fs-6 px-2 py-1">Periode Tidak Aktif</span>
|
||||
@elseif ($sudahDiklaim)
|
||||
<span class="badge bg-success rounded-pill fs-6 px-2 py-1">Sudah Diklaim</span>
|
||||
@else
|
||||
<span class="badge bg-warning rounded-pill fs-6 px-2 py-1">Belum Diklaim</span>
|
||||
@endif
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<!-- Periode Terakhir Klaim -->
|
||||
@if ($periodeNama)
|
||||
<tr>
|
||||
<th>Periode Terakhir Klaim</th>
|
||||
<td>{{ $periodeNama }}</td>
|
||||
</tr>
|
||||
@endif
|
||||
|
||||
<!-- File SK -->
|
||||
<tr>
|
||||
<th>File SK</th>
|
||||
<td>
|
||||
<a href="{{ $sk['sk'] }}" class="btn btn-sm btn-info" target="_blank">
|
||||
<i class="uil-file-alt"></i> Preview SK
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Opsi Edit Jangka Waktu -->
|
||||
@can('Verifikasi SK Klaim Ulang')
|
||||
@if ($periodeAktif && !$sudahDiklaim)
|
||||
<div class="card border">
|
||||
<div class="card-body">
|
||||
@include('components.datatable-header', [
|
||||
'title' => 'Opsi Edit Jangka Waktu',
|
||||
'description' => 'Pilih metode untuk mengatur jangka waktu anggota SK'
|
||||
])
|
||||
|
||||
|
||||
<div class="mb-3">
|
||||
<div class="form-check mb-2">
|
||||
<input class="form-check-input" type="radio" name="editMode" id="editModeSingle" value="single" checked>
|
||||
<label class="form-check-label" for="editModeSingle">
|
||||
<strong>Opsi 1:</strong> Terapkan jangka waktu yang sama untuk semua anggota
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="radio" name="editMode" id="editModeIndividual" value="individual">
|
||||
<label class="form-check-label" for="editModeIndividual">
|
||||
<strong>Opsi 2:</strong> Edit jangka waktu per anggota (custom)
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Form Jangka Waktu Global (Opsi 1) -->
|
||||
<div id="singleModeForm" class="mt-3">
|
||||
<div class="row align-items-end">
|
||||
<div class="col-md-3">
|
||||
<label for="globalJangkaWaktu" class="form-label">Jangka Waktu (Bulan)</label>
|
||||
<input type="number" class="form-control" id="globalJangkaWaktu" min="0" value="0" placeholder="Masukkan jumlah bulan">
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<button type="button" class="btn {{ $beritaAcaraUploaded ? 'btn-secondary' : 'btn-primary' }}" id="btnTerapkanGlobal" {{ $beritaAcaraUploaded ? 'disabled' : '' }}>
|
||||
<i class="uil-check"></i> Terapkan ke Semua
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Info Opsi 2 -->
|
||||
<div id="individualModeInfo" class="mt-3" style="display: none;">
|
||||
<div class="alert alert-info mb-0">
|
||||
<i class="uil-info-circle"></i> Mode edit individual aktif. Anda dapat mengubah jangka waktu masing-masing anggota di kolom "Jangka Waktu" pada tabel di bawah.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
@endcan
|
||||
|
||||
<!-- Tabel Anggota SK -->
|
||||
<div class="card border">
|
||||
<div class="card-body">
|
||||
@include('components.datatable-header', [
|
||||
'title' => 'Daftar Anggota SK',
|
||||
'description' => 'Berikut adalah daftar anggota yang terdaftar dalam Surat Keputusan (SK) ini'
|
||||
])
|
||||
|
||||
<div class="table-responsive">
|
||||
<table class="table table-bordered table-striped w-100" id="anggota-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>No</th>
|
||||
<th>Nama</th>
|
||||
<th>NIP</th>
|
||||
<th>Keterangan</th>
|
||||
<th>Posisi</th>
|
||||
<th>Jangka Waktu</th>
|
||||
</tr>
|
||||
</thead>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Button Klaim Ulang -->
|
||||
@can('Verifikasi SK Klaim Ulang')
|
||||
@if ($periodeAktif && !$sudahDiklaim)
|
||||
<div class="card border">
|
||||
<div class="card-body">
|
||||
<div class="d-flex justify-content-center gap-2">
|
||||
<button type="button" class="btn {{ $beritaAcaraUploaded ? 'btn-secondary' : 'btn-success' }}" id="btnKlaimUlang" {{ $beritaAcaraUploaded ? 'disabled' : '' }}>
|
||||
<i class="uil-redo"></i> Klaim Ulang SK
|
||||
</button>
|
||||
<a href="{{ route('sk.klaim-ulang.index') }}{{ request('unit_id') ? '?unit_id=' . request('unit_id') : '' }}" class="btn btn-secondary">
|
||||
<i class="uil-arrow-left"></i> Kembali
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
@endcan
|
||||
@endsection
|
||||
|
||||
@section('js')
|
||||
<!-- Berita Acara Warning -->
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
var beritaAcaraUploaded = $('#berita_acara_uploaded').val() === '1';
|
||||
var beritaAcaraMessage = $('#berita_acara_message').val();
|
||||
|
||||
if (beritaAcaraUploaded) {
|
||||
$('#btnTerapkanGlobal, #btnKlaimUlang').on('click', function(e) {
|
||||
e.preventDefault();
|
||||
e.stopImmediatePropagation();
|
||||
showWarning('Peringatan', beritaAcaraMessage);
|
||||
return false;
|
||||
});
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$('.si-sk').addClass('menuitem-active');
|
||||
$('.ni-sk').addClass('badge-primary-lighten');
|
||||
$('.li-sk').addClass('show');
|
||||
$('.li-sk-klaim-ulang').addClass('active badge-primary-lighten');
|
||||
|
||||
// Initialize DataTable for Anggota
|
||||
const columns = [
|
||||
{
|
||||
data: 'DT_RowIndex',
|
||||
name: 'DT_RowIndex',
|
||||
className: 'text-center',
|
||||
orderable: false,
|
||||
searchable: false,
|
||||
width: '50px'
|
||||
},
|
||||
{
|
||||
data: 'nama',
|
||||
name: 'nama'
|
||||
},
|
||||
{
|
||||
data: 'nip',
|
||||
name: 'nip',
|
||||
className: 'text-center',
|
||||
width: '150px'
|
||||
},
|
||||
{
|
||||
data: 'keterangan',
|
||||
name: 'keterangan',
|
||||
className: 'text-center',
|
||||
width: '120px',
|
||||
render: function(data) {
|
||||
return data ? data.charAt(0).toUpperCase() + data.slice(1) : '-';
|
||||
}
|
||||
},
|
||||
{
|
||||
data: 'posisi',
|
||||
name: 'posisi',
|
||||
width: '150px'
|
||||
},
|
||||
{
|
||||
data: 'jangka_waktu',
|
||||
name: 'jangka_waktu',
|
||||
className: 'text-center',
|
||||
width: '150px',
|
||||
@if ($periodeAktif && !$sudahDiklaim)
|
||||
render: function(data, type, row) {
|
||||
return '<input type="number" class="form-control form-control-sm jangka-waktu-input" data-id="' + row.id + '" value="' + (data || 0) + '" min="0" style="width: 100px; margin: 0 auto;">';
|
||||
}
|
||||
@else
|
||||
render: function(data) {
|
||||
return data || '-';
|
||||
}
|
||||
@endif
|
||||
}
|
||||
];
|
||||
|
||||
const anggotaTable = $('#anggota-table').DataTable({
|
||||
processing: true,
|
||||
serverSide: true,
|
||||
ajax: "{{ route('sk.klaim-ulang.data-anggota', $sk['id']) }}",
|
||||
columns: columns,
|
||||
language: {
|
||||
processing: "<div class='spinner'></div> Sedang Memuat...",
|
||||
},
|
||||
pageLength: 25
|
||||
});
|
||||
|
||||
@can('Verifikasi SK Klaim Ulang')
|
||||
@if ($periodeAktif && !$sudahDiklaim)
|
||||
// Event handler untuk radio button mode edit
|
||||
$('input[name="editMode"]').on('change', function() {
|
||||
const mode = $(this).val();
|
||||
|
||||
if (mode === 'single') {
|
||||
// Tampilkan form global, sembunyikan info individual
|
||||
$('#singleModeForm').show();
|
||||
$('#individualModeInfo').hide();
|
||||
|
||||
// Disable semua input jangka waktu di tabel
|
||||
$('.jangka-waktu-input').prop('readonly', true).addClass('bg-light');
|
||||
} else {
|
||||
// Sembunyikan form global, tampilkan info individual
|
||||
$('#singleModeForm').hide();
|
||||
$('#individualModeInfo').show();
|
||||
|
||||
// Enable semua input jangka waktu di tabel
|
||||
$('.jangka-waktu-input').prop('readonly', false).removeClass('bg-light');
|
||||
}
|
||||
});
|
||||
|
||||
// Event handler untuk button "Terapkan ke Semua"
|
||||
$('#btnTerapkanGlobal').on('click', function() {
|
||||
const globalValue = $('#globalJangkaWaktu').val();
|
||||
|
||||
if (globalValue === '' || globalValue < 0) {
|
||||
showWarning('Peringatan', 'Masukkan jangka waktu yang valid (minimal 0)');
|
||||
return;
|
||||
}
|
||||
|
||||
// Set semua input jangka waktu dengan nilai global
|
||||
$('.jangka-waktu-input').val(globalValue);
|
||||
|
||||
showSuccess('Berhasil', 'Jangka waktu ' + globalValue + ' bulan telah diterapkan ke semua anggota');
|
||||
});
|
||||
|
||||
// Initialize mode default (single) setelah DataTable loaded
|
||||
anggotaTable.on('draw', function() {
|
||||
const currentMode = $('input[name="editMode"]:checked').val();
|
||||
if (currentMode === 'single') {
|
||||
$('.jangka-waktu-input').prop('readonly', true).addClass('bg-light');
|
||||
} else {
|
||||
$('.jangka-waktu-input').prop('readonly', false).removeClass('bg-light');
|
||||
}
|
||||
});
|
||||
@endif
|
||||
@endcan
|
||||
|
||||
@can('Verifikasi SK Klaim Ulang')
|
||||
// Event handler untuk button Klaim Ulang
|
||||
$(document).on('click', '#btnKlaimUlang', function() {
|
||||
@if ($periodeAktif && !$sudahDiklaim)
|
||||
// Kumpulkan data jangka waktu yang sudah diedit
|
||||
const anggotaData = [];
|
||||
$('.jangka-waktu-input').each(function() {
|
||||
const anggotaId = $(this).data('id');
|
||||
const jangkaWaktu = $(this).val();
|
||||
anggotaData.push({
|
||||
id: anggotaId,
|
||||
jangka_waktu: jangkaWaktu
|
||||
});
|
||||
});
|
||||
|
||||
if (confirm('Apakah Anda yakin ingin mengklaim ulang SK ini?')) {
|
||||
@else
|
||||
if (confirm('Apakah Anda yakin ingin mengklaim ulang SK ini?')) {
|
||||
@endif
|
||||
// Disable button untuk mencegah double click
|
||||
const btn = $(this);
|
||||
btn.prop('disabled', true);
|
||||
btn.html('<i class="uil-spinner-alt spinner"></i> Memproses...');
|
||||
|
||||
@if ($periodeAktif && !$sudahDiklaim)
|
||||
const requestData = {
|
||||
_token: "{{ csrf_token() }}",
|
||||
anggota: anggotaData,
|
||||
unit_id: "{{ request('unit_id') }}"
|
||||
};
|
||||
@else
|
||||
const requestData = {
|
||||
_token: "{{ csrf_token() }}",
|
||||
unit_id: "{{ request('unit_id') }}"
|
||||
};
|
||||
@endif
|
||||
|
||||
// Kirim request ke server
|
||||
$.ajax({
|
||||
url: "{{ route('sk.klaim-ulang.proses-klaim', $sk['id']) }}",
|
||||
type: 'POST',
|
||||
data: requestData,
|
||||
success: function(response) {
|
||||
if (response.success) {
|
||||
showSuccess('Berhasil', response.message);
|
||||
// Redirect ke halaman detail SK dengan delay untuk menampilkan notifikasi
|
||||
setTimeout(function() {
|
||||
if (response.redirect) {
|
||||
window.location.href = response.redirect;
|
||||
} else {
|
||||
window.location.reload();
|
||||
}
|
||||
}, 1000);
|
||||
} else {
|
||||
showError('Gagal', response.message);
|
||||
btn.prop('disabled', false);
|
||||
btn.html('<i class="uil-redo"></i> Klaim Ulang SK');
|
||||
}
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
// Gunakan handleAjaxError yang sudah didefinisikan di layouts.main
|
||||
handleAjaxError(xhr, status, error);
|
||||
btn.prop('disabled', false);
|
||||
btn.html('<i class="uil-redo"></i> Klaim Ulang SK');
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
@endcan
|
||||
});
|
||||
</script>
|
||||
@endsection
|
||||
Reference in New Issue
Block a user