feat: add calculation rules, management features, and services for period 401
This commit is contained in:
@@ -0,0 +1,302 @@
|
||||
@extends('layouts.main')
|
||||
|
||||
@section('css')
|
||||
<style>
|
||||
#aturanTable thead th {
|
||||
background: linear-gradient(135deg, #2080f5 0%, #0166d2 100%) !important;
|
||||
color: #fff !important;
|
||||
border-color: #0166d2 !important;
|
||||
}
|
||||
|
||||
#aturanTable tbody tr {
|
||||
transition: background-color 0.15s ease-in-out;
|
||||
}
|
||||
|
||||
#aturanTable tbody tr:hover > * {
|
||||
background-color: rgba(13, 110, 253, 0.08) !important;
|
||||
box-shadow: none;
|
||||
}
|
||||
</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 active" aria-current="page">{{ $title }}</li>
|
||||
</ol>
|
||||
@endsection
|
||||
|
||||
@section('content')
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="card border">
|
||||
<div class="card-body">
|
||||
@include('components.datatable-header', [
|
||||
'title' => 'Daftar Aturan Perhitungan',
|
||||
'description' => 'Berikut adalah daftar aturan perhitungan remunerasi yang dapat diaktifkan atau dinonaktifkan seperti pada menu Periode',
|
||||
'actionButton' => ''
|
||||
])
|
||||
|
||||
<div class="table-responsive">
|
||||
<table class="table table-bordered w-100" id="aturanTable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="text-center" style="width: 5%">No</th>
|
||||
<th>Nama Aturan</th>
|
||||
<th>Deskripsi</th>
|
||||
<th class="text-center" style="width: 15%">Periode Berlaku</th>
|
||||
<th class="text-center" style="width: 12%">Status</th>
|
||||
@if($canUbah)
|
||||
<th class="text-center" style="width: 10%">Switch</th>
|
||||
<th class="text-center" style="width: 8%">Aksi</th>
|
||||
@endif
|
||||
</tr>
|
||||
</thead>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Modal Edit Form -->
|
||||
<div class="modal fade" id="aturanModal" tabindex="-1" role="dialog" aria-labelledby="aturanModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<form id="aturanForm">
|
||||
@csrf
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="aturanModalLabel">Edit Aturan Perhitungan</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<input type="hidden" id="aturan_id" name="aturan_id">
|
||||
|
||||
<div class="form-group mb-3">
|
||||
<label for="nama" class="form-label">Nama Aturan <span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="nama" name="nama" required>
|
||||
<div class="invalid-feedback"></div>
|
||||
</div>
|
||||
|
||||
<div class="form-group mb-3">
|
||||
<label for="deskripsi" class="form-label">Deskripsi</label>
|
||||
<textarea class="form-control" id="deskripsi" name="deskripsi" rows="3"></textarea>
|
||||
<div class="invalid-feedback"></div>
|
||||
</div>
|
||||
|
||||
<div class="form-group mb-3">
|
||||
<label for="status" class="form-label">Status <span class="text-danger">*</span></label>
|
||||
<select class="form-control" id="status" name="status" required>
|
||||
<option value="1">Aktif</option>
|
||||
<option value="0">Non Aktif</option>
|
||||
</select>
|
||||
<div class="invalid-feedback"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Batal</button>
|
||||
<button type="submit" class="btn btn-primary" id="submitBtn">Simpan</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@section('js')
|
||||
<script>
|
||||
let table;
|
||||
|
||||
$(document).ready(function() {
|
||||
// Initialize DataTable
|
||||
table = $('#aturanTable').DataTable({
|
||||
processing: true,
|
||||
serverSide: true,
|
||||
ajax: {
|
||||
url: "{{ route('manajemen.aturan-perhitungan.data') }}"
|
||||
},
|
||||
columns: [
|
||||
{
|
||||
data: 'DT_RowIndex',
|
||||
name: 'DT_RowIndex',
|
||||
orderable: false,
|
||||
searchable: false,
|
||||
className: 'text-center'
|
||||
},
|
||||
{
|
||||
data: 'nama',
|
||||
name: 'nama',
|
||||
className: 'fw-bold'
|
||||
},
|
||||
{
|
||||
data: 'deskripsi',
|
||||
name: 'deskripsi'
|
||||
},
|
||||
{
|
||||
data: 'periode_badge',
|
||||
name: 'periode_badge',
|
||||
orderable: false,
|
||||
searchable: false,
|
||||
className: 'text-center'
|
||||
},
|
||||
{
|
||||
data: 'status_badge',
|
||||
name: 'status_badge',
|
||||
orderable: false,
|
||||
searchable: false,
|
||||
className: 'text-center'
|
||||
},
|
||||
@if($canUbah)
|
||||
{
|
||||
data: 'switch',
|
||||
name: 'switch',
|
||||
orderable: false,
|
||||
searchable: false,
|
||||
className: 'text-center'
|
||||
},
|
||||
{
|
||||
data: 'action',
|
||||
name: 'action',
|
||||
orderable: false,
|
||||
searchable: false,
|
||||
className: 'text-center'
|
||||
}
|
||||
@endif
|
||||
],
|
||||
language: {
|
||||
processing: "<div class='spinner'></div> Sedang Memuat...",
|
||||
}
|
||||
});
|
||||
|
||||
// Handle edit button
|
||||
$(document).on('click', '.edit-btn', function() {
|
||||
let id = $(this).data('id');
|
||||
let url = "{{ route('manajemen.aturan-perhitungan.show', ':id') }}".replace(':id', id);
|
||||
|
||||
$.ajax({
|
||||
url: url,
|
||||
type: 'GET',
|
||||
success: function(response) {
|
||||
$('#aturan_id').val(response.id);
|
||||
$('#nama').val(response.nama);
|
||||
$('#deskripsi').val(response.deskripsi);
|
||||
$('#status').val(response.status ? '1' : '0');
|
||||
|
||||
$('.is-invalid').removeClass('is-invalid');
|
||||
$('.invalid-feedback').text('');
|
||||
|
||||
$('#aturanModal').modal('show');
|
||||
},
|
||||
error: function() {
|
||||
showAlert('error', 'Gagal memuat data aturan perhitungan');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Handle toggle/switch status button (direct switch)
|
||||
$(document).on('change', '.switch-status-btn', function() {
|
||||
let id = $(this).data('id');
|
||||
let isChecked = $(this).is(':checked');
|
||||
let url = "{{ route('manajemen.aturan-perhitungan.toggle', ':id') }}".replace(':id', id);
|
||||
|
||||
$.ajax({
|
||||
url: url,
|
||||
type: 'POST',
|
||||
data: {
|
||||
_token: '{{ csrf_token() }}'
|
||||
},
|
||||
success: function(response) {
|
||||
table.ajax.reload(null, false);
|
||||
showAlert('success', response.message);
|
||||
},
|
||||
error: function() {
|
||||
table.ajax.reload(null, false);
|
||||
showAlert('error', 'Gagal mengubah status aturan perhitungan');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$(document).on('click', '.toggle-btn', function() {
|
||||
let id = $(this).data('id');
|
||||
let url = "{{ route('manajemen.aturan-perhitungan.toggle', ':id') }}".replace(':id', id);
|
||||
|
||||
$.ajax({
|
||||
url: url,
|
||||
type: 'POST',
|
||||
data: {
|
||||
_token: '{{ csrf_token() }}'
|
||||
},
|
||||
success: function(response) {
|
||||
table.ajax.reload(null, false);
|
||||
showAlert('success', response.message);
|
||||
},
|
||||
error: function() {
|
||||
showAlert('error', 'Gagal mengubah status aturan perhitungan');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Handle form submission
|
||||
$('#aturanForm').on('submit', function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
let id = $('#aturan_id').val();
|
||||
let url = "{{ route('manajemen.aturan-perhitungan.update', ':id') }}".replace(':id', id);
|
||||
|
||||
let formData = {
|
||||
_token: '{{ csrf_token() }}',
|
||||
_method: 'PUT',
|
||||
nama: $('#nama').val(),
|
||||
deskripsi: $('#deskripsi').val(),
|
||||
status: $('#status').val()
|
||||
};
|
||||
|
||||
$.ajax({
|
||||
url: url,
|
||||
type: 'POST',
|
||||
data: formData,
|
||||
beforeSend: function() {
|
||||
$('#submitBtn').prop('disabled', true).text('Menyimpan...');
|
||||
$('.is-invalid').removeClass('is-invalid');
|
||||
$('.invalid-feedback').text('');
|
||||
},
|
||||
success: function(response) {
|
||||
if (response.success) {
|
||||
$('#aturanModal').modal('hide');
|
||||
table.ajax.reload(null, false);
|
||||
showAlert('success', response.message);
|
||||
}
|
||||
},
|
||||
error: function(xhr) {
|
||||
if (xhr.status === 422) {
|
||||
let errors = xhr.responseJSON.errors;
|
||||
$.each(errors, function(key, value) {
|
||||
$('#' + key).addClass('is-invalid');
|
||||
$('#' + key).siblings('.invalid-feedback').text(value[0]);
|
||||
});
|
||||
} else {
|
||||
showAlert('error', xhr.responseJSON?.message || 'Terjadi kesalahan saat menyimpan data');
|
||||
}
|
||||
},
|
||||
complete: function() {
|
||||
$('#submitBtn').prop('disabled', false).text('Simpan');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function showAlert(type, message) {
|
||||
if (typeof Swal !== 'undefined') {
|
||||
Swal.fire({
|
||||
icon: type,
|
||||
title: type === 'success' ? 'Berhasil' : 'Perhatian',
|
||||
text: message,
|
||||
timer: 2000,
|
||||
showConfirmButton: false
|
||||
});
|
||||
} else {
|
||||
alert(message);
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
@endsection
|
||||
Reference in New Issue
Block a user