first commit
This commit is contained in:
@@ -0,0 +1,315 @@
|
||||
@extends('layouts.main')
|
||||
|
||||
@section('breadcrumb')
|
||||
<ol class="breadcrumb m-0">
|
||||
<li class="breadcrumb-item"><a href="javascript:void(0);">Lainnya</a></li>
|
||||
<li class="breadcrumb-item active" aria-current="page">{{ $title }}</li>
|
||||
</ol>
|
||||
@endsection
|
||||
|
||||
@section('content')
|
||||
<!-- Filter Card -->
|
||||
@if (Auth::user()->nip == 'Superuser')
|
||||
<div class="row">
|
||||
<div class="col-sm-12">
|
||||
<div class="card border">
|
||||
<div class="card-body">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="form-group">
|
||||
<label for="filter-unit-kerja">Unit Kerja</label>
|
||||
<select id="filter-unit-kerja" class="form-select select2"
|
||||
data-placeholder="Pilih Unit Kerja">
|
||||
<option value="">Semua Unit Kerja</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<!-- Summary Card -->
|
||||
<div class="row" id="summary-card">
|
||||
<div class="col-sm-12">
|
||||
<div class="card border border-success">
|
||||
<div class="card-body">
|
||||
<div class="row">
|
||||
<div class="col-md-3">
|
||||
<div class="d-flex align-items-center">
|
||||
<div class="flex-shrink-0">
|
||||
<i class="uil-database text-danger display-6"></i>
|
||||
</div>
|
||||
<div class="flex-grow-1 ms-3">
|
||||
<h5 class="mb-0">Total Selisih</h5>
|
||||
<span class="mb-0" style="font-size: 17px" id="total-selisih">...</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<div class="d-flex align-items-center">
|
||||
<div class="flex-shrink-0">
|
||||
<i class="uil-users-alt text-success display-6"></i>
|
||||
</div>
|
||||
<div class="flex-grow-1 ms-3">
|
||||
<h5 class="mb-0">Jumlah Pegawai</h5>
|
||||
<span class="mb-0" style="font-size: 17px" id="total-pegawai">...</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="d-flex align-items-center">
|
||||
<div class="flex-shrink-0">
|
||||
<i class="uil-building text-info display-6"></i>
|
||||
</div>
|
||||
<div class="flex-grow-1 ms-3">
|
||||
<h5 class="mb-0">Unit Kerja Terpilih</h5>
|
||||
<span class="mb-0" style="font-size: 17px" id="selected-unit">...</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Data Table -->
|
||||
<div class="row">
|
||||
<div class="col-sm-12">
|
||||
<div class="card border">
|
||||
<div class="card-body">
|
||||
<div class="table-responsive">
|
||||
<table id="pegawai-table" class="table table-bordered table-striped w-100">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>No</th>
|
||||
<th>NIP</th>
|
||||
<th>Nama</th>
|
||||
<th>Unit Kerja</th>
|
||||
<th>Aksi</th>
|
||||
</tr>
|
||||
</thead>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@section('js')
|
||||
<!-- DataTable -->
|
||||
<script>
|
||||
var table;
|
||||
$(document).ready(function() {
|
||||
// Initialize DataTable
|
||||
table = $('#pegawai-table').DataTable({
|
||||
processing: true,
|
||||
serverSide: true,
|
||||
ajax: {
|
||||
url: "{{ route('lainnya.cek-poin.data') }}",
|
||||
data: function(d) {
|
||||
d.unit_kerja = $('#filter-unit-kerja').val();
|
||||
}
|
||||
},
|
||||
columns: [{
|
||||
data: 'DT_RowIndex',
|
||||
name: 'DT_RowIndex',
|
||||
className: 'text-center',
|
||||
orderable: false,
|
||||
searchable: false
|
||||
},
|
||||
{
|
||||
data: 'nip',
|
||||
name: 'nip',
|
||||
className: 'text-center'
|
||||
},
|
||||
{
|
||||
data: 'nama',
|
||||
name: 'nama',
|
||||
orderable: true,
|
||||
searchable: true
|
||||
},
|
||||
{
|
||||
data: 'unit_kerja',
|
||||
name: 'unit_kerja',
|
||||
orderable: true,
|
||||
searchable: true
|
||||
},
|
||||
{
|
||||
data: 'action',
|
||||
name: 'action',
|
||||
orderable: false,
|
||||
searchable: false,
|
||||
className: 'text-center'
|
||||
}
|
||||
],
|
||||
language: {
|
||||
processing: "<div class='spinner'></div> Sedang Memuat...",
|
||||
}
|
||||
});
|
||||
|
||||
// Load unit kerja options
|
||||
loadUnitKerjaOptions();
|
||||
|
||||
// Load initial summary data
|
||||
loadSummaryData();
|
||||
|
||||
// On change filter - auto reload table
|
||||
$('#filter-unit-kerja').on('change', function() {
|
||||
table.ajax.reload();
|
||||
loadSummaryData();
|
||||
});
|
||||
});
|
||||
|
||||
// Load unit kerja options
|
||||
function loadUnitKerjaOptions() {
|
||||
$.ajax({
|
||||
url: "{{ route('lainnya.cek-poin.data') }}",
|
||||
type: 'GET',
|
||||
data: {
|
||||
get_unit_kerja: true
|
||||
},
|
||||
success: function(response) {
|
||||
if (response.unit_kerja) {
|
||||
var select = $('#filter-unit-kerja');
|
||||
select.empty().append('<option value="">Semua Unit Kerja</option>');
|
||||
|
||||
$.each(response.unit_kerja, function(index, item) {
|
||||
select.append('<option value="' + item + '">' + item + '</option>');
|
||||
});
|
||||
|
||||
// Trigger change to update Select2
|
||||
select.trigger('change');
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Load summary data
|
||||
function loadSummaryData() {
|
||||
var unitKerja = $('#filter-unit-kerja').val();
|
||||
|
||||
// Show loading state
|
||||
$('#total-selisih').html('<i class="uil-spin uil-refresh"></i> Loading...');
|
||||
$('#total-pegawai').html('<i class="uil-spin uil-refresh"></i> Loading...');
|
||||
$('#selected-unit').html('<i class="uil-spin uil-refresh"></i> Loading...');
|
||||
|
||||
$.ajax({
|
||||
url: "{{ route('lainnya.cek-poin.summary') }}",
|
||||
type: 'GET',
|
||||
data: {
|
||||
unit_kerja: unitKerja
|
||||
},
|
||||
timeout: 30000, // 30 second timeout
|
||||
success: function(response) {
|
||||
if (response.success) {
|
||||
$('#total-selisih').text('Rp ' + number_format(response.data.total_selisih, 0, ',',
|
||||
'.'));
|
||||
|
||||
$('#total-pegawai').text(response.data.total_pegawai);
|
||||
|
||||
$('#selected-unit').text(unitKerja || 'Semua Unit Kerja');
|
||||
$('#summary-card').show();
|
||||
} else {
|
||||
$('#total-selisih').text('Error');
|
||||
$('#total-pegawai').text('Error');
|
||||
$('#selected-unit').text('Error');
|
||||
}
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
if (status === 'timeout') {
|
||||
$('#total-selisih').text('Timeout');
|
||||
$('#total-pegawai').text('Timeout');
|
||||
$('#selected-unit').text('Request timeout');
|
||||
} else {
|
||||
$('#total-selisih').text('Error');
|
||||
$('#total-pegawai').text('Error');
|
||||
$('#selected-unit').text('Load failed');
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Number formatting function
|
||||
function number_format(number, decimals, dec_point, thousands_sep) {
|
||||
number = (number + '').replace(',', '').replace(' ', '');
|
||||
var n = !isFinite(+number) ? 0 : +number,
|
||||
prec = !isFinite(+decimals) ? 0 : Math.abs(decimals),
|
||||
sep = (typeof thousands_sep === 'undefined') ? ',' : thousands_sep,
|
||||
dec = (typeof dec_point === 'undefined') ? '.' : dec_point,
|
||||
s = '',
|
||||
toFixedFix = function(n, prec) {
|
||||
var k = Math.pow(10, prec);
|
||||
return '' + Math.round(n * k) / k;
|
||||
};
|
||||
s = (prec ? toFixedFix(n, prec) : '' + Math.round(n)).split('.');
|
||||
if (s[0].length > 3) {
|
||||
s[0] = s[0].replace(/\B(?=(?:\d{3})+(?!\d))/g, sep);
|
||||
}
|
||||
if ((s[1] || '').length < prec) {
|
||||
s[1] = s[1] || '';
|
||||
s[1] += new Array(prec - s[1].length + 1).join('0');
|
||||
}
|
||||
return s.join(dec);
|
||||
}
|
||||
</script>
|
||||
|
||||
<!-- Detail Button Handler -->
|
||||
<script>
|
||||
$(document).on('click', '.detail-btn', function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
var nip = $(this).data('nip');
|
||||
var nama = $(this).data('nama');
|
||||
var button = $(this);
|
||||
|
||||
if (!nip) {
|
||||
alert('NIP tidak valid');
|
||||
return;
|
||||
}
|
||||
|
||||
button.prop('disabled', true).text('Loading...');
|
||||
|
||||
// AJAX check untuk validasi
|
||||
$.ajax({
|
||||
url: "{{ route('lainnya.cek-poin.detail', ':nip') }}".replace(':nip', nip),
|
||||
type: 'GET',
|
||||
data: {
|
||||
ajax: true
|
||||
},
|
||||
headers: {
|
||||
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content'),
|
||||
'X-Requested-With': 'XMLHttpRequest'
|
||||
},
|
||||
dataType: 'json',
|
||||
success: function(response) {
|
||||
if (response.success) {
|
||||
// Redirect ke halaman detail
|
||||
window.location.href = "{{ route('lainnya.cek-poin.detail', ':nip') }}".replace(
|
||||
':nip', nip);
|
||||
} else {
|
||||
alert('Terjadi kesalahan: ' + (response.message || 'Unknown error'));
|
||||
}
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
var errorMessage = 'Terjadi kesalahan saat memuat data';
|
||||
|
||||
if (xhr.status === 404) {
|
||||
errorMessage = 'Pegawai tidak ditemukan';
|
||||
} else if (xhr.status === 500) {
|
||||
errorMessage = 'Terjadi kesalahan pada server';
|
||||
}
|
||||
|
||||
alert(errorMessage);
|
||||
},
|
||||
complete: function() {
|
||||
button.prop('disabled', false).text('Detail');
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@endsection
|
||||
Reference in New Issue
Block a user