Penambahan Detail Periode
This commit is contained in:
@@ -17,15 +17,59 @@ class PeriodeController extends Controller
|
|||||||
|
|
||||||
$title = 'Periode';
|
$title = 'Periode';
|
||||||
$canTambah = auth()->user()->can('Tambah Periode');
|
$canTambah = auth()->user()->can('Tambah Periode');
|
||||||
$canAksi = auth()->user()->canAny(['Ubah Periode', 'Hapus Periode']);
|
$canAksi = auth()->user()->canAny(['Baca Periode', 'Ubah Periode', 'Hapus Periode']);
|
||||||
|
|
||||||
return view('manajemen.periode.index', compact('title', 'canTambah', 'canAksi'));
|
return view('manajemen.periode.index', compact('title', 'canTambah', 'canAksi'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function detail($id): View
|
||||||
|
{
|
||||||
|
abort_if(! auth()->user()->can('Baca Periode'), 403);
|
||||||
|
|
||||||
|
$periode = Periode::findOrFail($id);
|
||||||
|
$title = 'Detail Periode';
|
||||||
|
$canUbah = auth()->user()->can('Ubah Periode');
|
||||||
|
|
||||||
|
return view('manajemen.periode.detail', compact('title', 'periode', 'canUbah'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function updateJadwal(Request $request, $id, string $menu): JsonResponse
|
||||||
|
{
|
||||||
|
abort_if(! auth()->user()->can('Ubah Periode'), 403);
|
||||||
|
abort_if(! array_key_exists($menu, Periode::MENU_VERIFIKASI), 404);
|
||||||
|
|
||||||
|
$periode = Periode::findOrFail($id);
|
||||||
|
|
||||||
|
$validated = $request->validate([
|
||||||
|
'status' => 'required|boolean',
|
||||||
|
'tmt' => 'nullable|required_with:tst|date',
|
||||||
|
'tst' => 'nullable|required_with:tmt|date|after:tmt',
|
||||||
|
], [
|
||||||
|
'tmt.required_with' => 'Tanggal mulai harus diisi jika tanggal selesai diisi.',
|
||||||
|
'tmt.date' => 'Tanggal mulai tidak valid.',
|
||||||
|
'tst.required_with' => 'Tanggal selesai harus diisi jika tanggal mulai diisi.',
|
||||||
|
'tst.date' => 'Tanggal selesai tidak valid.',
|
||||||
|
'tst.after' => 'Tanggal selesai harus setelah tanggal mulai.',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$periode->update([
|
||||||
|
"tmt_verifikasi_{$menu}" => $validated['tmt'] ?? null,
|
||||||
|
"tst_verifikasi_{$menu}" => $validated['tst'] ?? null,
|
||||||
|
"status_verifikasi_{$menu}" => (bool) $validated['status'],
|
||||||
|
]);
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'success' => true,
|
||||||
|
'message' => 'Jadwal '.Periode::MENU_VERIFIKASI[$menu].' berhasil disimpan',
|
||||||
|
'kondisi' => $periode->kondisiVerifikasi($menu),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
public function data(): JsonResponse
|
public function data(): JsonResponse
|
||||||
{
|
{
|
||||||
abort_if(! auth()->user()->can('Baca Periode'), 403);
|
abort_if(! auth()->user()->can('Baca Periode'), 403);
|
||||||
|
|
||||||
|
// Method ini sudah dibatasi "Baca Periode", jadi menu Detail selalu tersedia
|
||||||
$canEdit = auth()->user()->can('Ubah Periode');
|
$canEdit = auth()->user()->can('Ubah Periode');
|
||||||
$canDelete = auth()->user()->can('Hapus Periode');
|
$canDelete = auth()->user()->can('Hapus Periode');
|
||||||
|
|
||||||
@@ -40,7 +84,11 @@ class PeriodeController extends Controller
|
|||||||
return '<span class="'.$badgeClass.'">'.$statusText.'</span>';
|
return '<span class="'.$badgeClass.'">'.$statusText.'</span>';
|
||||||
})
|
})
|
||||||
->addColumn('action', function ($row) use ($canEdit, $canDelete) {
|
->addColumn('action', function ($row) use ($canEdit, $canDelete) {
|
||||||
$actions = '';
|
$actions = '<li>
|
||||||
|
<a href="'.route('manajemen.periode.detail', $row->id).'" class="dropdown-item">
|
||||||
|
<i class="uil-eye" style="margin-right: 5px"></i> Detail
|
||||||
|
</a>
|
||||||
|
</li>';
|
||||||
|
|
||||||
if ($canEdit) {
|
if ($canEdit) {
|
||||||
$actions .= '<li>
|
$actions .= '<li>
|
||||||
@@ -58,10 +106,6 @@ class PeriodeController extends Controller
|
|||||||
</li>';
|
</li>';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! $actions) {
|
|
||||||
return '-';
|
|
||||||
}
|
|
||||||
|
|
||||||
return '
|
return '
|
||||||
<div class="dropdown">
|
<div class="dropdown">
|
||||||
<span id="dropdownMenuButton" data-bs-toggle="dropdown">
|
<span id="dropdownMenuButton" data-bs-toggle="dropdown">
|
||||||
|
|||||||
@@ -6,6 +6,18 @@ use Illuminate\Database\Eloquent\Model;
|
|||||||
|
|
||||||
class Periode extends Model
|
class Periode extends Model
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Menu verifikasi yang jadwalnya diatur per periode.
|
||||||
|
* Key adalah akhiran kolom tmt_verifikasi_*, tst_verifikasi_*, dan status_verifikasi_*.
|
||||||
|
*/
|
||||||
|
public const MENU_VERIFIKASI = [
|
||||||
|
'sk' => 'Verifikasi SK',
|
||||||
|
'tri_dharma' => 'Verifikasi Tri Dharma',
|
||||||
|
'laporan_kegiatan' => 'Verifikasi Laporan Kegiatan',
|
||||||
|
'pengajuan_presensi' => 'Verifikasi Pengajuan Presensi',
|
||||||
|
'skp' => 'Verifikasi SKP',
|
||||||
|
];
|
||||||
|
|
||||||
protected $table = 'verifikator.periodes';
|
protected $table = 'verifikator.periodes';
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'id_periode',
|
'id_periode',
|
||||||
@@ -47,6 +59,33 @@ class Periode extends Model
|
|||||||
'status_verifikasi_skp' => 'boolean'
|
'status_verifikasi_skp' => 'boolean'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Kondisi jadwal sebuah menu saat ini, mengikuti aturan method canVerify*.
|
||||||
|
*
|
||||||
|
* @return string ditutup|belum_dimulai|selesai|dibuka
|
||||||
|
*/
|
||||||
|
public function kondisiVerifikasi(string $menu): string
|
||||||
|
{
|
||||||
|
if (! $this->{"status_verifikasi_{$menu}"}) {
|
||||||
|
return 'ditutup';
|
||||||
|
}
|
||||||
|
|
||||||
|
$mulai = $this->{"tmt_verifikasi_{$menu}"};
|
||||||
|
$selesai = $this->{"tst_verifikasi_{$menu}"};
|
||||||
|
|
||||||
|
if ($mulai && $selesai) {
|
||||||
|
if (now()->isBefore($mulai)) {
|
||||||
|
return 'belum_dimulai';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (now()->isAfter($selesai)) {
|
||||||
|
return 'selesai';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 'dibuka';
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mengecek apakah verifikasi laporan kegiatan dapat dilakukan
|
* Mengecek apakah verifikasi laporan kegiatan dapat dilakukan
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -0,0 +1,195 @@
|
|||||||
|
@extends('layouts.main')
|
||||||
|
|
||||||
|
@section('css')
|
||||||
|
<style>
|
||||||
|
#jadwalTable th,
|
||||||
|
#jadwalTable td {
|
||||||
|
vertical-align: middle !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
#jadwalTable thead th {
|
||||||
|
background: #2563eb !important; background-color: #2563eb !important;
|
||||||
|
color: #fff !important;
|
||||||
|
border-color: #2563eb !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
#jadwalTable input[type="datetime-local"] {
|
||||||
|
min-width: 220px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#jadwalTable .form-switch .form-check-input {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
@endsection
|
||||||
|
|
||||||
|
@section('breadcrumb')
|
||||||
|
<ol class="breadcrumb m-0">
|
||||||
|
<li class="breadcrumb-item"><a href="javascript:void(0);">Manajemen</a></li>
|
||||||
|
<li class="breadcrumb-item"><a href="{{ route('manajemen.periode.index') }}">Periode</a></li>
|
||||||
|
<li class="breadcrumb-item active" aria-current="page">{{ $periode->nama }}</li>
|
||||||
|
</ol>
|
||||||
|
@endsection
|
||||||
|
|
||||||
|
@section('content')
|
||||||
|
@php
|
||||||
|
$daftarKondisi = [
|
||||||
|
'dibuka' => ['label' => 'Sedang Dibuka', 'class' => 'bg-success'],
|
||||||
|
'belum_dimulai' => ['label' => 'Belum Dimulai', 'class' => 'bg-warning'],
|
||||||
|
'selesai' => ['label' => 'Sudah Berakhir', 'class' => 'bg-danger'],
|
||||||
|
'ditutup' => ['label' => 'Ditutup', 'class' => 'bg-secondary'],
|
||||||
|
];
|
||||||
|
@endphp
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-12">
|
||||||
|
<div class="card border">
|
||||||
|
<div class="card-body">
|
||||||
|
@include('components.datatable-header', [
|
||||||
|
'title' => 'Detail Periode - ' . $periode->nama,
|
||||||
|
'description' => 'Atur rentang tanggal dan status aktif verifikasi setiap menu pada periode ini',
|
||||||
|
'actionButton' => '<a href="' . route('manajemen.periode.index') . '" class="btn btn-secondary">
|
||||||
|
<i class="uil-arrow-left"></i> Kembali
|
||||||
|
</a>',
|
||||||
|
])
|
||||||
|
|
||||||
|
<div class="mb-3">
|
||||||
|
<span class="me-3">ID Periode: <strong>{{ $periode->id_periode }}</strong></span>
|
||||||
|
<span>Status Periode:
|
||||||
|
<span class="badge {{ $periode->status ? 'bg-success' : 'bg-secondary' }}">
|
||||||
|
{{ $periode->status ? 'Aktif' : 'Non Aktif' }}
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@unless ($periode->status)
|
||||||
|
<div class="alert alert-warning">
|
||||||
|
Periode ini tidak aktif. Jadwal di bawah baru berlaku setelah periode ini diaktifkan.
|
||||||
|
</div>
|
||||||
|
@endunless
|
||||||
|
|
||||||
|
<div class="table-responsive">
|
||||||
|
<table class="table table-bordered w-100" id="jadwalTable">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Menu</th>
|
||||||
|
<th>Tanggal Mulai</th>
|
||||||
|
<th>Tanggal Selesai</th>
|
||||||
|
<th class="text-center">Status Aktif</th>
|
||||||
|
<th class="text-center">Kondisi Saat Ini</th>
|
||||||
|
@if ($canUbah)
|
||||||
|
<th class="text-center">Aksi</th>
|
||||||
|
@endif
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
@foreach (\App\Models\Verifikator\Periode::MENU_VERIFIKASI as $menu => $label)
|
||||||
|
@php
|
||||||
|
$mulai = $periode->{"tmt_verifikasi_{$menu}"};
|
||||||
|
$selesai = $periode->{"tst_verifikasi_{$menu}"};
|
||||||
|
$aktif = $periode->{"status_verifikasi_{$menu}"};
|
||||||
|
$kondisi = $daftarKondisi[$periode->kondisiVerifikasi($menu)];
|
||||||
|
@endphp
|
||||||
|
<tr data-url="{{ route('manajemen.periode.jadwal.update', [$periode->id, $menu]) }}">
|
||||||
|
<td class="fw-semibold">{{ $label }}</td>
|
||||||
|
<td>
|
||||||
|
<input type="datetime-local" step="1" class="form-control" data-field="tmt"
|
||||||
|
aria-label="Tanggal mulai {{ $label }}"
|
||||||
|
value="{{ $mulai?->format('Y-m-d\TH:i:s') }}" @disabled(! $canUbah)>
|
||||||
|
<div class="invalid-feedback"></div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<input type="datetime-local" step="1" class="form-control" data-field="tst"
|
||||||
|
aria-label="Tanggal selesai {{ $label }}"
|
||||||
|
value="{{ $selesai?->format('Y-m-d\TH:i:s') }}" @disabled(! $canUbah)>
|
||||||
|
<div class="invalid-feedback"></div>
|
||||||
|
</td>
|
||||||
|
<td class="text-center">
|
||||||
|
<div class="form-check form-switch d-inline-block">
|
||||||
|
<input type="checkbox" class="form-check-input" role="switch" data-field="status"
|
||||||
|
id="status_{{ $menu }}" @checked($aktif) @disabled(! $canUbah)>
|
||||||
|
<label class="form-check-label" for="status_{{ $menu }}">
|
||||||
|
{{ $aktif ? 'Aktif' : 'Non Aktif' }}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
<td class="text-center">
|
||||||
|
<span class="badge kondisi-badge {{ $kondisi['class'] }}">{{ $kondisi['label'] }}</span>
|
||||||
|
</td>
|
||||||
|
@if ($canUbah)
|
||||||
|
<td class="text-center">
|
||||||
|
<button type="button" class="btn btn-primary btn-sm simpan-jadwal-btn">Simpan</button>
|
||||||
|
</td>
|
||||||
|
@endif
|
||||||
|
</tr>
|
||||||
|
@endforeach
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<p class="text-muted mb-0">
|
||||||
|
Menu dengan status aktif tanpa rentang tanggal akan terbuka tanpa batas waktu.
|
||||||
|
Waktu mengikuti zona WIB.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@endsection
|
||||||
|
|
||||||
|
@section('js')
|
||||||
|
@if ($canUbah)
|
||||||
|
<script>
|
||||||
|
$(document).ready(function() {
|
||||||
|
const daftarKondisi = @json($daftarKondisi);
|
||||||
|
|
||||||
|
$('#jadwalTable').on('change', '[data-field="status"]', function() {
|
||||||
|
$(this).siblings('label').text(this.checked ? 'Aktif' : 'Non Aktif');
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#jadwalTable').on('click', '.simpan-jadwal-btn', function() {
|
||||||
|
const $tombol = $(this);
|
||||||
|
const $baris = $tombol.closest('tr');
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: $baris.data('url'),
|
||||||
|
type: 'POST',
|
||||||
|
data: {
|
||||||
|
_token: '{{ csrf_token() }}',
|
||||||
|
_method: 'PUT',
|
||||||
|
tmt: $baris.find('[data-field="tmt"]').val(),
|
||||||
|
tst: $baris.find('[data-field="tst"]').val(),
|
||||||
|
status: $baris.find('[data-field="status"]').is(':checked') ? 1 : 0
|
||||||
|
},
|
||||||
|
beforeSend: function() {
|
||||||
|
$tombol.prop('disabled', true).text('Menyimpan...');
|
||||||
|
$baris.find('.is-invalid').removeClass('is-invalid');
|
||||||
|
$baris.find('.invalid-feedback').text('');
|
||||||
|
},
|
||||||
|
success: function(response) {
|
||||||
|
const kondisi = daftarKondisi[response.kondisi];
|
||||||
|
|
||||||
|
$baris.find('.kondisi-badge')
|
||||||
|
.attr('class', 'badge kondisi-badge ' + kondisi.class)
|
||||||
|
.text(kondisi.label);
|
||||||
|
showSuccess('Berhasil', response.message);
|
||||||
|
},
|
||||||
|
error: function(xhr, status, error) {
|
||||||
|
if (xhr.status === 422 && xhr.responseJSON.errors) {
|
||||||
|
$.each(xhr.responseJSON.errors, function(field, pesan) {
|
||||||
|
const $input = $baris.find('[data-field="' + field + '"]');
|
||||||
|
$input.addClass('is-invalid');
|
||||||
|
$input.siblings('.invalid-feedback').text(pesan[0]);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
handleAjaxError(xhr, status, error);
|
||||||
|
},
|
||||||
|
complete: function() {
|
||||||
|
$tombol.prop('disabled', false).text('Simpan');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
@endif
|
||||||
|
@endsection
|
||||||
@@ -112,6 +112,8 @@ Route::middleware('permission:Baca Periode,Tambah Periode,Ubah Periode,Hapus Per
|
|||||||
Route::get('/{id}', [PeriodeController::class, 'show'])->name('show');
|
Route::get('/{id}', [PeriodeController::class, 'show'])->name('show');
|
||||||
Route::put('/{id}', [PeriodeController::class, 'update'])->name('update');
|
Route::put('/{id}', [PeriodeController::class, 'update'])->name('update');
|
||||||
Route::delete('/{id}', [PeriodeController::class, 'destroy'])->name('destroy');
|
Route::delete('/{id}', [PeriodeController::class, 'destroy'])->name('destroy');
|
||||||
|
Route::get('/{id}/detail', [PeriodeController::class, 'detail'])->name('detail');
|
||||||
|
Route::put('/{id}/jadwal/{menu}', [PeriodeController::class, 'updateJadwal'])->name('jadwal.update');
|
||||||
});
|
});
|
||||||
|
|
||||||
Route::prefix('/aturan-perhitungan')->name('aturan-perhitungan.')->group(function () {
|
Route::prefix('/aturan-perhitungan')->name('aturan-perhitungan.')->group(function () {
|
||||||
|
|||||||
Reference in New Issue
Block a user