sim_rs/resources/views/pegawai/index.blade.php
Muhammad Thoriq 7966b1f95d Set Project
2025-04-27 20:58:13 +07:00

139 lines
4.8 KiB
PHP

@extends('template.template')
@section('title', 'Dashboard')
@section('content')
<div class="card shadow-sm">
<div class="card-header">
<h3 class="card-title">LIST PEGAWAI</h3>
<div class="card-toolbar gap-2">
<a href="{{ url('/pegawai/create') }}" class="btn btn-success">Tambah</a>
</div>
</div>
<div class="card-body">
<div class="table-responsive">
<table id="table_pegawai" class="table table-row-bordered gy-5">
<thead>
<tr class="fw-semibold fs-6 text-muted">
<th>Nama</th>
<th>Ruang Pelayanan</th>
<th>Created</th>
<th>Updated</th>
<th>Action</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
</div>
@endsection
@section('custom_js')
<script>
let DATATABLE = null;
$(document).ready(function() {
loadTable();
});
function loadTable() {
DATATABLE = $('#table_pegawai').DataTable({
processing: true,
serverSide: true,
order: [
[0, 'asc']
],
ajax: {
url: "{{ url('/pegawai/get_list_table') }}",
type: "POST",
data: function(d) {
d._token = "{{ csrf_token() }}"; // Tambahkan CSRF token
}
},
columns: [
{
data: 'pegawai_name',
name: 'pegawai_name'
},
{
data: 'ruang_pelayanan_name',
name: 'ruang_pelayanan_name'
},
{
data: 'created_at',
name: 'created_at'
},
{
data: 'updated_at',
name: 'updated_at'
},
{
data: 'action',
name: 'action',
orderable: false,
searchable: false
}
]
});
}
function deleteData(id) {
Swal.fire({
icon: "question",
title: "Apakah anda yakin?",
showCancelButton: true,
confirmButtonText: "Yes",
cancelButtonText: "No",
customClass: {
confirmButton: "btn btn-success",
cancelButton: "btn btn-danger"
}
}).then((result) => {
/* Read more about isConfirmed, isDenied below */
if (result.isConfirmed) {
const data = {
id: id,
_token: "{{ csrf_token() }}"
}
$.ajax({
url: "{{ url('/pegawai/delete') }}",
type: "POST",
data: data,
dataType: 'JSON',
success: function(response) {
if (response.status) {
Swal.fire({
icon: "success",
text: "Data Berhasil Dihapus",
buttonsStyling: false,
confirmButtonText: "close",
customClass: {
confirmButton: "btn btn-danger"
}
}).then(() => {
DATATABLE.ajax.reload(null, false);
});
}
},
error: function(xhr) {
var errorMessage = xhr.responseJSON ? xhr.responseJSON.msg :
"Terjadi kesalahan!";
Swal.fire({
icon: "error",
text: errorMessage,
buttonsStyling: false,
confirmButtonText: "Close",
customClass: {
confirmButton: "btn btn-danger"
}
});
}
});
}
});
}
</script>
@endsection