562 lines
25 KiB
PHP
562 lines
25 KiB
PHP
@extends('layouts.main')
|
|
|
|
@section('css')
|
|
<style>
|
|
.tooltip-wide .tooltip-inner {
|
|
max-width: 420px;
|
|
text-align: left;
|
|
}
|
|
|
|
@keyframes rowMenuFadeIn {
|
|
from { opacity: 0; transform: scale(0.92) translateY(-6px); }
|
|
to { opacity: 1; transform: scale(1) translateY(0); }
|
|
}
|
|
#rowContextMenu { display: none; }
|
|
|
|
#rowContextMenu.arrow-top-left { transform-origin: top left; }
|
|
#rowContextMenu.arrow-top-left::before,
|
|
#rowContextMenu.arrow-top-left::after {
|
|
content: '';
|
|
position: absolute;
|
|
left: 16px;
|
|
border: 8px solid transparent;
|
|
}
|
|
#rowContextMenu.arrow-top-left::before { top: -16px; border-bottom-color: #dee2e6; }
|
|
#rowContextMenu.arrow-top-left::after { top: -15px; border-bottom-color: #fff; }
|
|
|
|
#rowContextMenu.arrow-top-right { transform-origin: top right; }
|
|
#rowContextMenu.arrow-top-right::before,
|
|
#rowContextMenu.arrow-top-right::after {
|
|
content: '';
|
|
position: absolute;
|
|
right: 16px;
|
|
border: 8px solid transparent;
|
|
}
|
|
#rowContextMenu.arrow-top-right::before { top: -16px; border-bottom-color: #dee2e6; }
|
|
#rowContextMenu.arrow-top-right::after { top: -15px; border-bottom-color: #fff; }
|
|
|
|
#rowContextMenu.arrow-bottom-left { transform-origin: bottom left; }
|
|
#rowContextMenu.arrow-bottom-left::before,
|
|
#rowContextMenu.arrow-bottom-left::after {
|
|
content: '';
|
|
position: absolute;
|
|
left: 16px;
|
|
border: 8px solid transparent;
|
|
}
|
|
#rowContextMenu.arrow-bottom-left::before { bottom: -16px; border-top-color: #dee2e6; }
|
|
#rowContextMenu.arrow-bottom-left::after { bottom: -15px; border-top-color: #fff; }
|
|
|
|
#rowContextMenu.arrow-bottom-right { transform-origin: bottom right; }
|
|
#rowContextMenu.arrow-bottom-right::before,
|
|
#rowContextMenu.arrow-bottom-right::after {
|
|
content: '';
|
|
position: absolute;
|
|
right: 16px;
|
|
border: 8px solid transparent;
|
|
}
|
|
#rowContextMenu.arrow-bottom-right::before { bottom: -16px; border-top-color: #dee2e6; }
|
|
#rowContextMenu.arrow-bottom-right::after { bottom: -15px; border-top-color: #fff; }
|
|
|
|
.row-context-item:hover {
|
|
background-color: #eef2ff !important;
|
|
color: #3b5bdb !important;
|
|
}
|
|
.row-context-item:hover i { color: #3b5bdb; }
|
|
</style>
|
|
@endsection
|
|
|
|
@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="javascript:void(0);">Laporan Kegiatan</a></li>
|
|
<li class="breadcrumb-item active" aria-current="page">{{ $title }}</li>
|
|
</ol>
|
|
@endsection
|
|
|
|
@section('content')
|
|
@if ($periode && !$periode->canVerifyLaporanKegiatan() && Auth::user()->id != 1)
|
|
<div class="row">
|
|
<div class="col-12">
|
|
<div class="alert alert-warning" role="alert">
|
|
<i class="fas fa-exclamation-triangle me-2"></i>
|
|
<strong>Perhatian!</strong> {{ $periode->getVerificationErrorMessage() ?? 'Periode verifikasi laporan kegiatan tidak aktif.' }}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
@endif
|
|
|
|
<div class="row">
|
|
<div class="col-sm-12">
|
|
<div class="card border">
|
|
<div class="card-body">
|
|
@include('components.datatable-header', [
|
|
'title' => 'Daftar Laporan Kegiatan MBKM',
|
|
'description' => 'Berikut adalah daftar laporan kegiatan MBKM yang telah diajukan'
|
|
])
|
|
|
|
@if (count($unitKerjas) > 0)
|
|
<div class="row mb-3">
|
|
<div class="col-sm-6">
|
|
<div class="mb-2">
|
|
<label for="unitKerjaFilter" class="form-label">Unit Kerja</label>
|
|
<select class="form-select select2" id="unitKerjaFilter" name="unitKerjaFilter"
|
|
data-placeholder="Pilih Unit Kerja...">
|
|
<option value=""></option>
|
|
@foreach ($unitKerjas as $unit)
|
|
<option value="{{ $unit->id }}" {{ request('unit_id') == $unit->id ? 'selected' : '' }}>{{ $unit->nama }}</option>
|
|
@endforeach
|
|
</select>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
@endif
|
|
|
|
<ul class="nav nav-pills bg-nav-pills nav-justified mb-3" id="category-tabs">
|
|
<li class="nav-item">
|
|
<a href="#belum-diverifikasi" data-bs-toggle="tab" aria-expanded="true"
|
|
class="nav-link rounded-0 active">
|
|
<i class="uil-clipboard-alt d-md-none d-block"></i>
|
|
<span class="d-none d-md-block">Belum Diverifikasi</span>
|
|
</a>
|
|
</li>
|
|
<li class="nav-item">
|
|
<a href="#diterima" data-bs-toggle="tab" aria-expanded="false" class="nav-link rounded-0">
|
|
<i class="uil-clipboard-alt d-md-none d-block"></i>
|
|
<span class="d-none d-md-block">Diterima</span>
|
|
</a>
|
|
</li>
|
|
<li class="nav-item">
|
|
<a href="#ditolak" data-bs-toggle="tab" aria-expanded="false" class="nav-link rounded-0">
|
|
<i class="uil-clipboard-alt d-md-none d-block"></i>
|
|
<span class="d-none d-md-block">Ditolak</span>
|
|
</a>
|
|
</li>
|
|
{{-- <li class="nav-item">
|
|
<a href="#kegiatan-duplikat" data-bs-toggle="tab" aria-expanded="false"
|
|
class="nav-link rounded-0">
|
|
<i class="uil-clipboard-alt d-md-none d-block"></i>
|
|
<span class="d-none d-md-block">Kegiatan Duplikat</span>
|
|
</a>
|
|
</li> --}}
|
|
</ul>
|
|
|
|
<div class="tab-content">
|
|
<div class="tab-pane show active" id="belum-diverifikasi">
|
|
<div class="table-responsive">
|
|
<table class="table table-bordered w-100 dt-styled" id="belum-diverifikasi-content">
|
|
<thead>
|
|
<tr>
|
|
<th>Nama Kegiatan</th>
|
|
<th>Tanggal</th>
|
|
<th>Duplikat</th>
|
|
<th style="width:180px;min-width:180px;max-width:180px">Status</th>
|
|
</tr>
|
|
</thead>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="tab-pane" id="diterima">
|
|
<div class="d-flex justify-content-end mb-2">
|
|
<button type="button" class="btn btn-success btn-sm" id="btn-export-diterima">
|
|
<i class="bx bx-download"></i> Export Excel
|
|
</button>
|
|
</div>
|
|
<div class="table-responsive">
|
|
<table class="table table-bordered w-100 dt-styled" id="diterima-content">
|
|
<thead>
|
|
<tr>
|
|
<th>Nama Kegiatan</th>
|
|
<th>Tanggal</th>
|
|
<th>Duplikat</th>
|
|
<th style="width:180px;min-width:180px;max-width:180px">Status</th>
|
|
</tr>
|
|
</thead>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="tab-pane" id="ditolak">
|
|
<div class="table-responsive">
|
|
<table class="table table-bordered w-100 dt-styled" id="ditolak-content">
|
|
<thead>
|
|
<tr>
|
|
<th>Nama Kegiatan</th>
|
|
<th>Tanggal</th>
|
|
<th>Duplikat</th>
|
|
<th style="width:180px;min-width:180px;max-width:180px">Status</th>
|
|
</tr>
|
|
</thead>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="tab-pane" id="kegiatan-duplikat">
|
|
<div class="table-responsive">
|
|
<table class="table table-bordered w-100 dt-styled" id="kegiatan-duplikat-content">
|
|
<thead>
|
|
<tr>
|
|
<th>Nama Kegiatan</th>
|
|
<th>Jumlah Kegiatan</th>
|
|
<th>Aksi</th>
|
|
</tr>
|
|
</thead>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Context Menu Row -->
|
|
<ul id="rowContextMenu" style="position:absolute;z-index:999;background:#fff;border:1px solid #dee2e6;border-radius:8px;box-shadow:0 4px 20px rgba(0,0,0,.12);padding:4px 0;min-width:160px;list-style:none;margin:0">
|
|
<li>
|
|
<a href="javascript:void(0);" class="row-context-item row-detail-btn d-flex align-items-center gap-2 px-3 py-2 text-decoration-none" style="font-size:14px;color:#212529;border-radius:6px;margin:2px 4px;transition:background .15s ease,color .15s ease">
|
|
<i class="uil-info-circle" style="font-size:16px"></i> Detail
|
|
</a>
|
|
</li>
|
|
<li>
|
|
<a href="javascript:void(0);" class="row-context-item row-biaya-btn d-flex align-items-center gap-2 px-3 py-2 text-decoration-none" style="font-size:14px;color:#212529;border-radius:6px;margin:2px 4px;transition:background .15s ease,color .15s ease">
|
|
<i class="uil-bill" style="font-size:16px"></i> Biaya
|
|
</a>
|
|
</li>
|
|
</ul>
|
|
@endsection
|
|
|
|
@section('js')
|
|
<!-- Sidebar Aktif -->
|
|
<script>
|
|
$('.si-laporan-kegiatan').addClass('menuitem-active');
|
|
$('.ni-laporan-kegiatan').addClass('badge-primary-lighten');
|
|
$('.li-laporan-kegiatan').addClass('show');
|
|
$('.li-laporan-kegiatan-mbkm').addClass('active badge-primary-lighten');
|
|
</script>
|
|
|
|
<!-- Datatable & Row Click -->
|
|
<script>
|
|
var detailBaseUrl = "{{ url('/laporan-kegiatan/mbkm/detail') }}";
|
|
var biayaBaseUrl = "{{ url('/laporan-kegiatan/mbkm/biaya') }}";
|
|
var currentRowId = null;
|
|
|
|
function navigateToDetail(id, url) {
|
|
@if (Auth::user()->id == 1)
|
|
var unitId = $('#unitKerjaFilter').val();
|
|
if (!unitId) {
|
|
showWarning('Peringatan!', 'Pilih Unit Kerja terlebih dahulu sebelum melihat detail.');
|
|
return;
|
|
}
|
|
window.location.href = url + '?unit_id=' + unitId;
|
|
@else
|
|
$.ajax({
|
|
url: url,
|
|
type: 'GET',
|
|
headers: { 'X-Requested-With': 'XMLHttpRequest' },
|
|
success: function(response) {
|
|
if (response.success) {
|
|
window.location.href = url;
|
|
} else {
|
|
showWarning('Peringatan', response.message || 'Periode verifikasi tidak aktif');
|
|
}
|
|
},
|
|
error: function(xhr) {
|
|
var message = 'Periode verifikasi tidak aktif';
|
|
if (xhr.responseJSON && xhr.responseJSON.message) {
|
|
message = xhr.responseJSON.message;
|
|
}
|
|
showError('Error', message);
|
|
}
|
|
});
|
|
@endif
|
|
}
|
|
|
|
function navigateToBiaya(id, url) {
|
|
window.location.href = url;
|
|
}
|
|
|
|
$(document).ready(function() {
|
|
var actionSuccess = sessionStorage.getItem('mbkm_terima_success');
|
|
if (actionSuccess) {
|
|
sessionStorage.removeItem('mbkm_terima_success');
|
|
showSuccess('Berhasil!', actionSuccess);
|
|
}
|
|
|
|
var dataTable = null;
|
|
var duplicateDataTable = null;
|
|
|
|
function initDataTable(category) {
|
|
var status = null;
|
|
|
|
if (dataTable) {
|
|
$('[data-bs-toggle="tooltip"]', dataTable.table().node()).each(function() {
|
|
var tip = bootstrap.Tooltip.getInstance(this);
|
|
if (tip) { tip.dispose(); }
|
|
});
|
|
dataTable.destroy();
|
|
}
|
|
|
|
if (category === 'belum-diverifikasi') {
|
|
status = 'belum_verifikasi';
|
|
} else if (category === 'diterima') {
|
|
status = 'diterima';
|
|
} else if (category === 'ditolak') {
|
|
status = 'ditolak';
|
|
} else {
|
|
status = category;
|
|
}
|
|
|
|
dataTable = $(`#${category}-content`).DataTable({
|
|
processing: true,
|
|
serverSide: true,
|
|
ajax: {
|
|
url: "{{ route('laporan-kegiatan.mbkm.data') }}/?status=" + status,
|
|
data: function(d) {
|
|
d.status = status;
|
|
d.unit_kerja_filter = $('#unitKerjaFilter').val();
|
|
},
|
|
},
|
|
columns: [{
|
|
data: 'nama_kegiatan',
|
|
name: 'nama_kegiatan',
|
|
searchable: true,
|
|
orderable: true,
|
|
render: function(data) {
|
|
var escaped = $('<div>').text(data).html();
|
|
return '<div data-bs-toggle="tooltip" data-bs-placement="top" data-bs-title="' + escaped + '" data-bs-custom-class="tooltip-wide" style="display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;text-overflow:ellipsis;white-space:normal;max-height:3em">' + escaped + '</div>';
|
|
}
|
|
},
|
|
{
|
|
data: 'tanggal_kegiatan',
|
|
name: 'tanggal_kegiatan',
|
|
orderable: false,
|
|
searchable: false,
|
|
className: 'text-center',
|
|
},
|
|
{
|
|
data: 'duplikat',
|
|
name: 'duplikat',
|
|
searchable: false,
|
|
orderable: true,
|
|
className: 'text-center'
|
|
},
|
|
{
|
|
data: 'status',
|
|
name: 'status',
|
|
searchable: false,
|
|
orderable: false,
|
|
className: 'text-center',
|
|
width: '180px'
|
|
}
|
|
],
|
|
order: [
|
|
[0, 'asc']
|
|
],
|
|
autoWidth: false,
|
|
createdRow: function(row, data) {
|
|
$(row).css('cursor', 'pointer').attr('data-id', data.id);
|
|
},
|
|
drawCallback: function() {
|
|
document.querySelectorAll('body > .tooltip').forEach(function(el) { el.remove(); });
|
|
$('[data-bs-toggle="tooltip"]', this.api().table().node()).each(function() {
|
|
var tip = bootstrap.Tooltip.getInstance(this);
|
|
if (tip) { tip.dispose(); }
|
|
bootstrap.Tooltip.getOrCreateInstance(this, {
|
|
trigger: 'hover',
|
|
container: 'body'
|
|
});
|
|
});
|
|
},
|
|
language: {
|
|
processing: "<div class='spinner'></div> Sedang Memuat...",
|
|
}
|
|
});
|
|
}
|
|
|
|
function initDuplicateDataTable() {
|
|
if (duplicateDataTable) {
|
|
duplicateDataTable.destroy();
|
|
}
|
|
|
|
duplicateDataTable = $('#kegiatan-duplikat-content').DataTable({
|
|
processing: true,
|
|
serverSide: true,
|
|
ajax: {
|
|
url: "{{ route('laporan-kegiatan.mbkm.data-duplikat') }}",
|
|
data: function(d) {
|
|
d.unit_kerja_filter = $('#unitKerjaFilter').val();
|
|
}
|
|
},
|
|
columns: [{
|
|
data: "nama_kegiatan",
|
|
searchable: true,
|
|
orderable: true,
|
|
},
|
|
{
|
|
data: 'jumlah',
|
|
searchable: false,
|
|
orderable: true,
|
|
className: 'text-center'
|
|
},
|
|
{
|
|
data: 'action',
|
|
name: 'action',
|
|
searchable: false,
|
|
orderable: false,
|
|
className: 'text-center',
|
|
visible: false
|
|
}
|
|
],
|
|
language: {
|
|
processing: "<div class='spinner'></div> Sedang Memuat...",
|
|
}
|
|
});
|
|
}
|
|
|
|
$('#category-tabs a[data-bs-toggle="tab"]').on('shown.bs.tab', function(e) {
|
|
var target = $(e.target).attr('href');
|
|
var category = target.replace('#', '');
|
|
|
|
if (category === 'kegiatan-duplikat') {
|
|
// Clear other datatable if exists
|
|
if (dataTable) {
|
|
dataTable.clear();
|
|
}
|
|
|
|
if (duplicateDataTable) {
|
|
duplicateDataTable.clear();
|
|
}
|
|
// Initialize duplicate datatable
|
|
initDuplicateDataTable();
|
|
} else {
|
|
// Clear duplicate datatable if exists
|
|
if (dataTable) {
|
|
dataTable.clear();
|
|
}
|
|
|
|
if (duplicateDataTable) {
|
|
duplicateDataTable.clear();
|
|
}
|
|
// Initialize regular datatable
|
|
initDataTable(category);
|
|
}
|
|
});
|
|
|
|
// Initialize default tab
|
|
initDataTable('belum-diverifikasi');
|
|
|
|
$('#unitKerjaFilter').on('select2:select select2:clear change', function() {
|
|
var activeTab = $('#category-tabs .nav-link.active').attr('href').replace('#', '');
|
|
if (activeTab === 'kegiatan-duplikat') {
|
|
if (duplicateDataTable) { duplicateDataTable.ajax.reload(); }
|
|
} else {
|
|
if (dataTable) { dataTable.ajax.reload(); }
|
|
}
|
|
});
|
|
|
|
$('#btn-export-diterima').on('click', function() {
|
|
var button = $(this);
|
|
var originalHtml = button.html();
|
|
|
|
var url = "{{ route('laporan-kegiatan.mbkm.export-excel') }}";
|
|
var unitKerjaFilter = $('#unitKerjaFilter').val();
|
|
if (unitKerjaFilter) {
|
|
url += "?unit_kerja_filter=" + encodeURIComponent(unitKerjaFilter);
|
|
}
|
|
|
|
button.prop('disabled', true).html('<span class="spinner-border spinner-border-sm me-1"></span> Exporting...');
|
|
|
|
fetch(url)
|
|
.then(function(response) {
|
|
if (!response.ok) { throw new Error('gagal'); }
|
|
var filename = 'laporan-kegiatan-mbkm-diterima.xlsx';
|
|
var disposition = response.headers.get('Content-Disposition');
|
|
if (disposition) {
|
|
var match = disposition.match(/filename[^;=\n]*=['"]?([^'"\n]+)['"]?/);
|
|
if (match) { filename = match[1]; }
|
|
}
|
|
return response.blob().then(function(blob) {
|
|
return { blob: blob, filename: filename };
|
|
});
|
|
})
|
|
.then(function(data) {
|
|
var downloadUrl = URL.createObjectURL(data.blob);
|
|
var a = document.createElement('a');
|
|
a.href = downloadUrl;
|
|
a.download = data.filename;
|
|
a.style.display = 'none';
|
|
document.body.appendChild(a);
|
|
a.click();
|
|
document.body.removeChild(a);
|
|
URL.revokeObjectURL(downloadUrl);
|
|
button.prop('disabled', false).html(originalHtml);
|
|
showSuccess('Berhasil!', 'File Excel berhasil didownload');
|
|
})
|
|
.catch(function() {
|
|
button.prop('disabled', false).html(originalHtml);
|
|
showError('Gagal', 'Terjadi kesalahan saat export Excel');
|
|
});
|
|
});
|
|
|
|
var $contextMenu = $('#rowContextMenu').appendTo('body');
|
|
var MENU_W = 168;
|
|
var MENU_H = 90;
|
|
|
|
function showContextMenu(e, id) {
|
|
currentRowId = id;
|
|
var flipH = (e.clientX + MENU_W + 8 > window.innerWidth);
|
|
var flipV = (e.clientY + MENU_H + 8 > window.innerHeight);
|
|
var x = flipH ? e.pageX - MENU_W : e.pageX;
|
|
var y = flipV ? e.pageY - MENU_H : e.pageY;
|
|
var arrowClass = 'arrow-' + (flipV ? 'bottom' : 'top') + '-' + (flipH ? 'right' : 'left');
|
|
|
|
$contextMenu
|
|
.removeClass('arrow-top-left arrow-top-right arrow-bottom-left arrow-bottom-right')
|
|
.addClass(arrowClass)
|
|
.css({ top: y, left: x, display: 'block', animation: 'none' });
|
|
|
|
$contextMenu[0].offsetWidth;
|
|
$contextMenu.css('animation', 'rowMenuFadeIn 0.2s ease forwards');
|
|
}
|
|
|
|
function hideContextMenu() {
|
|
$contextMenu.css('display', 'none');
|
|
currentRowId = null;
|
|
}
|
|
|
|
$(document).on('click', '#belum-diverifikasi-content tbody tr, #diterima-content tbody tr, #ditolak-content tbody tr', function(e) {
|
|
e.stopPropagation();
|
|
var id = $(this).data('id');
|
|
if (!id) { return; }
|
|
showContextMenu(e, id);
|
|
});
|
|
|
|
$(document).on('click', '#kegiatan-duplikat-content tbody tr', function(e) {
|
|
var id = $(this).data('id');
|
|
if (!id) { return; }
|
|
navigateToDetail(id, detailBaseUrl + '/' + id);
|
|
});
|
|
|
|
$(document).on('click', '.row-detail-btn', function() {
|
|
var id = currentRowId;
|
|
hideContextMenu();
|
|
if (!id) { return; }
|
|
navigateToDetail(id, detailBaseUrl + '/' + id);
|
|
});
|
|
|
|
$(document).on('click', '.row-biaya-btn', function() {
|
|
var id = currentRowId;
|
|
hideContextMenu();
|
|
if (!id) { return; }
|
|
navigateToBiaya(id, biayaBaseUrl + '/' + id);
|
|
});
|
|
|
|
$(document).on('click', function(e) {
|
|
if (!$(e.target).closest('#rowContextMenu').length) {
|
|
hideContextMenu();
|
|
}
|
|
});
|
|
});
|
|
</script>
|
|
@endsection
|