Files
verifikator/resources/views/verifikasi/laporan-kegiatan/mbkm/detail.blade.php
T

1810 lines
85 KiB
PHP

@extends('layouts.main')
@section('css')
<style>
.penunjang-table tbody tr { cursor: pointer; }
.penunjang-table tbody tr:hover > * { background-color: rgba(13,110,253,0.08) !important; }
.penunjang-table tbody tr.row-selected > * { background-color: rgba(13,110,253,0.15) !important; }
.penunjang-table td, .penunjang-table th { border-color: #ced4da !important; }
.penunjang-table tbody .badge,
.penunjang-table tbody a.badge,
.penunjang-table tbody button { transition: filter 0.1s ease, transform 0.1s ease; cursor: pointer; }
.penunjang-table tbody .badge:hover,
.penunjang-table tbody a.badge:hover,
.penunjang-table tbody button:hover { filter: brightness(0.85); transform: scale(0.97); }
.penunjang-table thead th {
background: #2563eb !important; background-color: #2563eb !important;
color: #fff !important;
border-color: #2563eb !important;
}
.penunjang-table thead th,
.penunjang-table thead th.nominal-cell,
.penunjang-table thead th.nip-col {
color: #fff !important;
font-family: inherit !important;
}
.penunjang-table thead th .form-check-input { border-color: #fff !important; }
.select-item-shared { pointer-events: none; }
</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"><a href="javascript:void(0);">MBKM</a></li>
<li class="breadcrumb-item active" aria-current="page">{{ $title }}</li>
</ol>
@endsection
@section('content')
<input type="hidden" id="berita_acara_uploaded" value="{{ $beritaAcaraUploaded ? '1' : '0' }}">
<input type="hidden" id="berita_acara_message" value="{{ $beritaAcaraMessage ?? '' }}">
<div class="row">
<div class="col-sm-12">
<ul class="nav nav-pills bg-nav-pills nav-justified mb-2">
@foreach ($kegiatans as $index => $nav_kat)
<li class="nav-item">
<a href="#nav-{{ $loop->iteration }}" data-bs-toggle="tab"
aria-expanded="{{ $loop->iteration === 1 ? 'true' : 'false' }}"
class="nav-link rounded-0 {{ $loop->iteration === 1 ? 'active' : '' }}">
<i class="mdi mdi-home-variant d-md-none d-block"></i>
<span class="d-none d-md-block">{{ $nav_kat['nama'] }}</span>
</a>
</li>
@endforeach
</ul>
</div>
</div>
<div class="tab-content">
@foreach ($kegiatans as $key => $kegiatan)
<div class="tab-pane {{ $loop->iteration === 1 ? 'active' : '' }}" id="nav-{{ $loop->iteration }}">
<div class="card border">
<div class="card-body">
<div class="table-responsive">
<table class="table table-sm">
<!-- Nama Kegiatan -->
<tr>
<th>Nama Kegiatan</th>
<td>
<textarea class="form-control" name="nama_kegiatan" id="nama_kegiatan_{{ $key }}" cols="30" rows="3"
readonly>{{ $data->nama_kegiatan ?? ($kegiatan['nama_kegiatan'] ?? '') }}</textarea>
</td>
</tr>
<!-- Tanggal -->
<tr>
<th>Tanggal</th>
<td>{{ isset($data->tanggal_kegiatan) ? \Carbon\Carbon::parse($data->tanggal_kegiatan)->format('d/m/Y') : ($kegiatan['tanggal_kegiatan'] ? \Carbon\Carbon::parse($kegiatan['tanggal_kegiatan'])->format('d/m/Y') : '-') }}
</td>
</tr>
<!-- Kategori -->
<tr>
<th>Kategori</th>
<td>{{ $kegiatan['nama'] }}</td>
</tr>
<!-- Aksi Button -->
<tr>
<th></th>
<td>
<button class="btn btn-sm {{ $beritaAcaraUploaded ? 'btn-outline-secondary' : 'btn-outline-danger' }} jangka-waktu-multiple-btn"
data-kegiatan="{{ $key }}">
<i class="uil-edit"></i>
<span>Ubah Jangka Waktu <span class="count">0</span> Anggota</span>
</button>
</td>
</tr>
<!-- File Data -->
<tr>
<th>File</th>
<td>
@php $hasFile = false; @endphp
@if (isset($unit) && isset($data->nama_sk) && $data->nama_sk)
@php $hasFile = true; @endphp
<button type="button" class="btn btn-sm btn-outline-secondary"
data-bs-toggle="modal" data-bs-target="#previewSk"
data-links="{{ $data->nama_sk }}">
<i class="uil-eye"></i> SK
</button>
@endif
@if (isset($kegiatan['anggota']) && $kegiatan['anggota']->isNotEmpty())
@php
$laporanKegiatan = $kegiatan['anggota']
->first()
->dokumens->where('kategori_dokumen', 'Laporan Kegiatan')
->first();
@endphp
@if ($laporanKegiatan)
@php $hasFile = true; @endphp
<button type="button" class="btn btn-sm btn-outline-secondary"
data-bs-toggle="modal" data-bs-target="#previewLaporan"
data-links="https://dokumen.siremun.untan.ac.id/storage/dokumen/periode{{ \App\Models\Verifikator\Periode::where('status', true)->first()->id_periode }}/Laporan%20Kegiatan/{{ $laporanKegiatan->nama_file }}">
<i class="uil-eye"></i> Laporan Kegiatan
</button>
@endif
@endif
@if (!$hasFile)
<span class="text-danger">Tidak Ada</span>
@endif
</td>
</tr>
</table>
</div>
</div>
</div>
<div class="card border">
<div class="card-body">
@php
$tblIdx = $loop->iteration;
$tblId = 'table-' . $loop->iteration;
$mbkmBtns = '<span class="text-muted me-1">(<span id="mbkm-selected-count-'.$tblIdx.'" class="mbkm-selected-count">0</span> dipilih)</span>';
$mbkmBtns .= '<button type="button" class="btn btn-success btn-sm mbkm-btn-terima" data-table-id="'.$tblId.'" disabled><i class="uil-check"></i> Terima</button> ';
$mbkmBtns .= '<button type="button" class="btn btn-danger btn-sm mbkm-btn-tolak" data-table-id="'.$tblId.'" disabled><i class="uil-times"></i> Tolak</button> ';
if (\Illuminate\Support\Facades\Auth::user()->can('Batalkan Pengajuan Penunjang')) {
$mbkmBtns .= '<button type="button" class="btn btn-warning btn-sm text-dark mbkm-btn-batalkan" data-table-id="'.$tblId.'" disabled><i class="uil-redo"></i> Batalkan</button>';
}
@endphp
@include('components.datatable-header', [
'title' => 'Daftar Anggota',
'description' => $kegiatan['nama'],
'actionButton' => $mbkmBtns,
])
<!-- Filter Status Verifikasi -->
<div class="row mb-3">
<div class="col-md-4">
<label for="statusFilter-{{ $loop->iteration }}" class="form-label">Status Verifikasi</label>
<select class="form-select status-filter-select" id="statusFilter-{{ $loop->iteration }}" data-table-id="table-{{ $loop->iteration }}">
<option value=""></option>
<option value="1">Belum Diajukan</option>
<option value="3">Diajukan</option>
<option value="6">Diterima</option>
<option value="2,5,8">Ditolak</option>
</select>
</div>
</div>
<div class="table-responsive">
<table class="table table-bordered penunjang-table w-100" id="table-{{ $loop->iteration }}">
<thead>
<tr>
<th>
<div class="d-flex justify-content-center">
<div class="form-check">
<input type="checkbox" class="form-check-input" id="checkAll">
</div>
</div>
</th>
<th>NIP</th>
<th>Nama</th>
<th>Posisi</th>
<th>Syarat</th>
<th>Jangka Waktu</th>
<th>Jumlah</th>
<th>Poin</th>
<th>Status</th>
</tr>
</thead>
</table>
</div>
</div>
</div>
</div>
@endforeach
</div>
@endsection
@section('modal')
<!-- Edit Jangka Waktu -->
<div class="modal fade" id="modalEditJangkaWaktu" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1"
aria-labelledby="modalEditJangkaWaktuLabel" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<div class="modal-header bg-primary text-white">
<h5 class="modal-title" id="modalEditJangkaWaktuLabel">Edit Jangka Waktu Anggota</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<form id="formEditJangkaWaktu">
<div class="mb-2">
<label for="jumlahBulan" class="form-label">Jumlah Bulan <span class="text-danger">*</span></label>
<input type="number" class="form-control" id="jumlahBulan" name="jumlah_bulan"
min="1" max="6" placeholder="Masukkan Jangka Waktu" required>
<div class="form-text"><i>Maksimal 6 bulan</i></div>
</div>
<div class="mb-2">
<label for="keterangan" class="form-label">Keterangan <span class="text-danger">*</span></label>
<textarea class="form-control" id="keterangan" name="keterangan" rows="3" placeholder="Masukkan Keterangan"></textarea>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" id="simpanJangkaWaktu">
<span class="btn-text">Simpan</span>
</button>
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Batal</button>
</div>
</div>
</div>
</div>
<!-- Ubah Jumlah Mahasiswa -->
<div class="modal fade" id="modalEditJumlahSatuan" tabindex="-1" data-bs-backdrop="static" data-bs-keyboard="false"
aria-labelledby="jmlSatuanModalLabel" aria-hidden="true" role="dialog">
<div class="modal-dialog modal-dialog-centered modal-dialog-scrollable modal-sm" role="document">
<div class="modal-content">
<div class="modal-header bg-primary text-white">
<h5 class="modal-title" id="jmlSatuanModalLabel">Edit Jumlah Mahasiswa</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<form id="formEditJmlSatuan">
<input type="hidden" id="syarat_id" name="syarat_id">
<div class="row">
<div class="col-sm-12">
<label id="jumlah_satuan_label" for="jumlah_satuan" class="form-label">Jumlah Mahasiswa</label>
<input type="number" id="jumlah_satuan" name="jumlah" class="form-control"
min="1" required>
<div class="invalid-feedback" id="jumlah_satuan_error"></div>
</div>
</div>
</form>
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-primary" id="simpanJumlahSatuan" form="formEditJmlSatuan">
Simpan
</button>
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Tutup</button>
</div>
</div>
</div>
</div>
<!-- Preview Dokumen Syarat -->
<div class="modal fade" id="modalPreviewDokumenSyarat" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1">
<div class="modal-dialog modal-lg modal-dialog-centered">
<div class="modal-content">
<div class="modal-header bg-primary text-white">
<h5 class="modal-title" id="modalPreviewDokumenSyaratLabel">Dokumen Syarat</h5>
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body p-0">
<iframe id="dokumenSyaratViewer" src="" style="width: 100%; height: 580px; border: none;"></iframe>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Tutup</button>
</div>
</div>
</div>
</div>
<!-- Modal Konfirmasi Terima -->
<div class="modal fade" id="modalKonfirmasiTerima" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<div class="modal-header bg-success text-white">
<h5 class="modal-title">Konfirmasi Penerimaan</h5>
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<p>Apakah Anda yakin ingin menerima pengajuan yang dipilih?</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-success" id="konfirmasiTerimaLaporan">
<i class="uil-check-circle"></i> Ya, Terima
</button>
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Batal</button>
</div>
</div>
</div>
</div>
<!-- Modal Konfirmasi Batalkan -->
<div class="modal fade" id="modalKonfirmasiBatalkan" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<div class="modal-header bg-warning">
<h5 class="modal-title">Konfirmasi Pembatalan</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<p>Apakah Anda yakin ingin membatalkan pengajuan yang dipilih?</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-warning text-dark" id="konfirmasiBatalkanLaporan">
<i class="uil-redo"></i> Ya, Batalkan
</button>
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Batal</button>
</div>
</div>
</div>
</div>
<!-- Modal Tolak Laporan -->
<div class="modal fade" id="modalTolakLaporan" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<div class="modal-header bg-danger text-white">
<h5 class="modal-title">Keterangan Penolakan</h5>
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<form id="formTolakLaporan">
<div class="mb-3">
<label class="form-label">Alasan Penolakan <span class="text-danger">*</span></label>
<textarea class="form-control" id="keteranganTolak" rows="4" placeholder="Masukkan alasan penolakan..." required></textarea>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-danger" id="konfirmasiTolakLaporan">
<i class="uil-times-circle"></i> Tolak Pengajuan
</button>
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Batal</button>
</div>
</div>
</div>
</div>
<!-- Preview SK -->
<div class="modal fade" id="previewSk" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1">
<div class="modal-dialog modal-lg modal-dialog-centered">
<div class="modal-content">
<div class="modal-body p-0">
<iframe id="skViewer" src="" style="width: 100%; height: 580px; border: none;"></iframe>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Tutup</button>
</div>
</div>
</div>
</div>
<!-- Preview Laporan Kegiatan -->
<div class="modal fade" id="previewLaporan" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1">
<div class="modal-dialog modal-lg modal-dialog-centered">
<div class="modal-content">
<div class="modal-body p-0">
<iframe id="laporanViewer" style="width: 100%; height: 580px; border: none;"></iframe>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Tutup</button>
</div>
</div>
</div>
</div>
<!-- Detail Laporan -->
<div class="modal fade" id="detailLaporan" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1"
aria-labelledby="detailLaporanLabel" aria-hidden="true" role="dialog">
<div class="modal-dialog modal-fullscreen" role="document">
<div class="modal-content">
<div class="modal-header bg-primary text-white">
<h5 class="modal-title" id="detailLaporanLabel">Detail Laporan</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<form id="formDetailLaporan">
<input type="hidden" id="id_syarats" name="id_syarats">
<input type="hidden" id="id_kegiatans" name="id_kegiatans">
<ul class="nav nav-pills bg-nav-pills nav-justified mb-3">
<li class="nav-item">
<a href="#umum" data-bs-toggle="tab" aria-expanded="true"
class="nav-link rounded-0 active">
<i class="mdi mdi-home-variant d-md-none d-block"></i>
<span class="d-none d-md-block">Umum</span>
</a>
</li>
<li class="nav-item">
<a href="#fileSyarat" data-bs-toggle="tab" aria-expanded="false"
class="nav-link rounded-0">
<i class="mdi mdi-account-circle d-md-none d-block"></i>
<span class="d-none d-md-block">File Syarat</span>
</a>
</li>
<li class="nav-item">
<a href="#catatanRiwayat" data-bs-toggle="tab" aria-expanded="false"
class="nav-link rounded-0">
<i class="mdi mdi-settings-outline d-md-none d-block"></i>
<span class="d-none d-md-block">Catatan Riwayat</span>
</a>
</li>
</ul>
<div class="tab-content">
<!-- Umum -->
<div class="tab-pane show active" id="umum">
<div>
<div class="media mb-4">
<div class="media-body d-flex">
<div class="d-flex flex-column">
<img src="{{ asset('assets/images/book.png') }} " width="80px"
alt="">
</div>
<div class="d-flex flex-column ms-2">
<div class="d-flex flex-row align-items-center">
<div id="displayStatusContainer"></div>
<i class="uil-stopwatch text-secondary mx-1"></i> <span
class="pull-right text-secondary" id="displayTanggal">...</span>
</div>
<span class="f-w-600" id="displayNamaKegiatan">...</span>
<span id="displayNamaDosen" class="fw-bold"
style="font-size:16px">...</span>
</div>
</div>
</div>
<div class="table-responsive">
<table class="table table-sm">
<tr>
<th>Uraian</th>
<th style="text-align: right"><span class="text-primary"
id="displayUraian">...</span></th>
</tr>
<tr>
<th>Kategori</th>
<th style="text-align: right"><span class="text-primary"
id="displayKategori">...</span></th>
</tr>
<tr>
<th>Poin</th>
<th style="text-align: right"><span class="text-primary"
id="displayPoin">...</span></th>
</tr>
<tr id="rowAlasanPenolakan" style="display:none;">
<th class="text-danger">Alasan Penolakan</th>
<th style="text-align: right"><span class="text-danger" id="displayAlasanPenolakan"></span></th>
</tr>
</table>
</div>
</div>
</div>
<!-- File Syarat -->
<div class="tab-pane" id="fileSyarat">
<div id="dokumenContainer"></div>
</div>
<!-- Catatan Riwayat -->
<div class="tab-pane" id="catatanRiwayat">
<div class="row">
<div class="col-sm-12">
<div class="card border">
<div class="card-body">
<div class="table-responsive">
<table class="table table-bordered table-sm table-striped w-100"
id="catatan-verifikasi">
<thead>
<tr>
<th>No.</th>
<th>Verifikator</th>
<th>Catatan</th>
<th>Waktu</th>
</tr>
</thead>
</table>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-12">
<div class="card border">
<div class="card-body">
<div class="table-responsive">
<table class="table table-bordered table-sm table-striped w-100"
id="riwayat-verifikasi">
<thead>
<tr>
<th>No.</th>
<th>Nama</th>
<th>Aktivitas Log</th>
<th>Waktu</th>
</tr>
</thead>
</table>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-12">
<label class="mb-1" for="sanggahanVerifikasi">Sanggahan dari Pegawai</label>
<textarea class="form-control" name="sanggahanVerifikasi" id="sanggahanVerifikasi" rows="5" disabled></textarea>
</div>
</div>
</div>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-success" id="konfirmasiTerimaDetailLaporan" style="display: none;">
<i class="uil-check-circle"></i> Terima
</button>
<button type="button" class="btn btn-danger" id="btnTolakDetailLaporan" style="display: none;">
<i class="uil-times-circle"></i> Tolak
</button>
<button type="button" class="btn btn-warning text-dark" id="konfirmasiBatalDetailLaporan" style="display: none;">
<i class="fa fa-times-circle"></i> Batalkan
</button>
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">
<i class="uil-times"></i> Tutup
</button>
</div>
</div>
</div>
</div>
<!-- Modal Tolak Detail Laporan -->
<div class="modal fade" id="modalTolakDetailLaporan" data-bs-backdrop="static" data-bs-keyboard="false"
tabindex="-1" aria-labelledby="modalTolakDetailLaporanLabel" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<div class="modal-header bg-danger text-white">
<h5 class="modal-title" id="modalTolakDetailLaporanLabel">Keterangan Penolakan Detail</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<form id="formTolakDetailLaporan">
<div class="mb-3">
<label for="keteranganTolakDetail" class="form-label">Alasan Penolakan <span
class="text-danger">*</span></label>
<textarea class="form-control" id="keteranganTolakDetail" name="keterangan_tolak_detail" rows="4"
placeholder="Masukkan alasan penolakan..." required></textarea>
<div class="form-text">Jelaskan alasan mengapa pengajuan ini ditolak</div>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-danger" id="konfirmasiTolakDetailLaporan">
<i class="uil-times-circle"></i> Tolak Pengajuan
</button>
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Batal</button>
</div>
</div>
</div>
</div>
@endsection
@section('js')
<!-- Berita Acara Warning -->
<script>
var beritaAcaraUploaded = $('#berita_acara_uploaded').val() === '1';
var beritaAcaraMessage = $('#berita_acara_message').val();
if (beritaAcaraUploaded) {
document.addEventListener('click', function(e) {
var $matched = $(e.target).closest(
'.jangka-waktu-multiple-btn, .mbkm-btn-terima, .mbkm-btn-tolak, ' +
'.mbkm-btn-batalkan, .badge-edit-disabled-ba, ' +
'#konfirmasiTerimaDetailLaporan, #btnTolakDetailLaporan, #konfirmasiBatalDetailLaporan, ' +
'input[type="checkbox"].form-check-input'
);
if ($matched.length) {
e.preventDefault();
e.stopPropagation();
e.stopImmediatePropagation();
showWarning('Peringatan', beritaAcaraMessage);
}
}, true);
}
</script>
@php
$anyHasLaporanSyarat = collect($kegiatans)->some(function ($kegiatan) {
$anggota = $kegiatan['anggota'] ?? collect();
if ($anggota->isEmpty()) { return false; }
$first = $anggota->first();
return isset($first->rubrik->syarats) &&
$first->rubrik->syarats->whereIn('nama', ['laporan kegiatan'])->count() > 0;
});
@endphp
<!-- 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');
var hasLaporanKegiatanSyarat = {{ $anyHasLaporanSyarat ? 'true' : 'false' }};
var mbkmIndexUrl = "{{ route('laporan-kegiatan.mbkm.index') }}";
var currentUnitId = {{ request()->has('unit_id') ? (int) request('unit_id') : 'null' }};
</script>
<!-- Alert Handler untuk Belum Diajukan -->
<script>
$(document).on('click', '.detail-laporan-disabled', function(e) {
e.preventDefault();
showError('Gagal',
'Tidak Dapat Melakukan Verifikasi, Silahkan Upload Laporan Kegiatan Terlebih Dahulu');
});
</script>
<!-- Tabel Anggota -->
<script>
$(document).ready(function() {
var kegiatanId = {{ $data['id'] }};
var kegiatanConfig = @json($kegiatans);
var tables = {};
// Inisialisasi Select2 untuk semua filter status
$('.status-filter-select').select2({
placeholder: 'Pilih Status',
allowClear: true,
width: '100%'
});
kegiatanConfig.forEach(function(kegiatan, index) {
var tableId = 'table-' + (index + 1);
var filterId = 'statusFilter-' + (index + 1);
// Cek apakah kegiatan ini memiliki status "Belum Diajukan"
var avgStatus = 0;
if (kegiatan.anggota && kegiatan.anggota.length > 0) {
var totalStatus = 0;
kegiatan.anggota.forEach(function(anggota) {
totalStatus += anggota.status_verifikasi_id || 0;
});
avgStatus = totalStatus / kegiatan.anggota.length;
}
var isBelumDiajukan = avgStatus === 1;
var table = $('#' + tableId).DataTable({
processing: true,
serverSide: true,
ajax: {
url: "{{ route('laporan-kegiatan.mbkm.data-detail', ':id') }}"
.replace(':id', kegiatanId),
data: function(d) {
d.kategori = kegiatan.nama;
d.status_filter = $('#' + filterId).val();
}
},
columns: [{
data: 'checkbox',
name: 'checkbox',
className: 'text-center',
orderable: false,
searchable: false,
},
{
data: 'id_pelaksana',
name: 'id_pelaksana',
orderable: true,
searchable: true,
className: 'text-center'
},
{
data: 'nama_pelaksana',
name: 'nama_pelaksana',
orderable: true,
searchable: true,
},
{
data: 'posisi',
name: 'posisi',
className: 'text-center',
orderable: false,
searchable: false,
},
{
data: 'syarat',
name: 'syarat',
className: 'text-center',
orderable: false,
searchable: false,
width: '150px',
},
{
data: 'jangka_waktu_per_semester',
name: 'jangka_waktu_per_semester',
className: 'text-center',
orderable: false,
searchable: false,
},
{
data: 'jumlah_mahasiswa',
name: 'jumlah_mahasiswa',
className: 'text-center',
orderable: false,
searchable: false,
},
{
data: 'poin_total',
name: 'poin_total',
className: 'text-center',
orderable: false,
searchable: false,
render: $.fn.dataTable.render.number('.', ',', 2),
},
{
data: 'status_verifikasi_id',
name: 'status_verifikasi_id',
className: 'text-center',
orderable: false,
searchable: false,
createdCell: function(td, cellData, rowData, row, col) {
$(td).attr('data-status-id', rowData.status_verifikasi_id_raw ?? '');
}
},
{
data: 'aksi',
name: 'aksi',
className: 'text-center',
orderable: false,
searchable: false,
visible: false,
}
],
order: [],
language: {
processing: "<div class='spinner'></div>&nbsp; Sedang Memuat...",
},
drawCallback: function() {
$('[data-bs-toggle="tooltip"]').each(function() {
var el = bootstrap.Tooltip.getInstance(this);
if (el) { el.dispose(); }
new bootstrap.Tooltip(this);
});
var firstData = kegiatan.anggota && kegiatan.anggota.length > 0 ? kegiatan.anggota[0] : null;
if (firstData && !firstData.posisi) {
table.column(3).visible(false);
}
var laporanSyaratCount = 0;
if (firstData && firstData.rubrik && firstData.rubrik.syarats) {
laporanSyaratCount = firstData.rubrik.syarats.filter(function(s) { return s.nama === 'laporan kegiatan'; }).length;
}
$('#' + tableId).data('is-shared', laporanSyaratCount > 0);
updateMbkmSelection(tableId);
if (laporanSyaratCount > 0) {
var totalAnggota = table.page.info().recordsTotal;
var idx = tableId.replace('table-', '');
$('#mbkm-selected-count-' + idx).text(totalAnggota);
}
}
});
tables[tableId] = table;
// Event handler untuk filter status - reload tabel saat filter berubah
$('#' + filterId).on('change', function() {
table.ajax.reload();
});
});
});
</script>
<!-- Bulk Selection Helpers -->
<script>
function getMbkmSelectedIds(tableId) {
var ids = [];
$('#' + tableId + ' tbody .select-item:checked').each(function() {
var id = $(this).val();
if (id && id !== 'on') { ids.push(id); }
});
return ids;
}
function updateMbkmSelection(tableId) {
if (beritaAcaraUploaded) { return; }
var ids = getMbkmSelectedIds(tableId);
var count = ids.length;
var idx = tableId.replace('table-', '');
$('#mbkm-selected-count-' + idx).text(count);
var hasDiajukan = false;
var hasBatalable = false;
$('#' + tableId + ' tbody .select-item:checked').each(function() {
var status = parseInt($(this).data('status') || 0);
if ([3, 4].includes(status)) { hasDiajukan = true; }
if ([2, 5, 6, 7, 8].includes(status)) { hasBatalable = true; }
});
$('.mbkm-btn-terima[data-table-id="' + tableId + '"]').prop('disabled', count === 0 || !hasDiajukan);
$('.mbkm-btn-tolak[data-table-id="' + tableId + '"]').prop('disabled', count === 0 || !hasDiajukan);
$('.mbkm-btn-batalkan[data-table-id="' + tableId + '"]').prop('disabled', count === 0 || !hasBatalable);
var kegiatanKey = parseInt(idx) - 1;
$('.jangka-waktu-multiple-btn[data-kegiatan="' + kegiatanKey + '"] .count').text(count);
if (count > 0) {
$('.jangka-waktu-multiple-btn[data-kegiatan="' + kegiatanKey + '"]').removeClass('btn-outline-danger').addClass('btn-outline-primary');
} else {
$('.jangka-waktu-multiple-btn[data-kegiatan="' + kegiatanKey + '"]').removeClass('btn-outline-primary').addClass('btn-outline-danger');
}
var $table = $('#' + tableId);
var total = $table.find('tbody .select-item').length;
var $checkAll = $table.find('thead #checkAll');
if (count === 0) { $checkAll.prop('checked', false).prop('indeterminate', false); }
else if (count === total) { $checkAll.prop('checked', true).prop('indeterminate', false); }
else { $checkAll.prop('checked', false).prop('indeterminate', true); }
}
function mbkmAjaxAction(url, ids, button, onSuccess) {
var originalText = button.html();
button.prop('disabled', true).html('<span class="spinner-border spinner-border-sm"></span> Memproses...');
var promises = ids.map(function(id) {
return $.ajax({ url: url, type: 'POST', data: { _token: '{{ csrf_token() }}', id: id } });
});
$.when.apply($, promises).then(function() {
var firstResponse = arguments[0];
var data = (ids.length > 1 && Array.isArray(firstResponse)) ? firstResponse[0] : firstResponse;
if (data && data.success === false) {
showWarning('Peringatan', data.message || 'Aksi tidak dapat dilakukan');
button.prop('disabled', false).html(originalText);
return;
}
onSuccess();
}).fail(function(xhr) {
var msg = (xhr.responseJSON && xhr.responseJSON.message) ? xhr.responseJSON.message : 'Terjadi kesalahan';
showError('Error', msg);
button.prop('disabled', false).html(originalText);
});
}
function mbkmHasBelumDiajukan(tableId) {
var found = false;
$('#' + tableId + ' tbody .select-item:checked').each(function() {
if (parseInt($(this).data('status')) === 1) { found = true; return false; }
});
return found;
}
// Row click → toggle checkbox
$(document).on('click', 'table[id^="table-"] tbody tr', function(e) {
if ($(e.target).is('input[type="checkbox"]') || $(e.target).closest('.form-check').length) { return; }
if ($(e.target).is('a, button, .badge') || $(e.target).closest('a, button, .badge').length) { return; }
var $cb = $(this).find('.select-item');
if ($cb.length) { $cb.prop('checked', !$cb.prop('checked')).trigger('change'); }
});
// Checkbox change
$(document).on('change', 'table[id^="table-"] tbody .select-item', function() {
var tableId = $(this).closest('table').attr('id');
$(this).closest('tr').toggleClass('row-selected', this.checked);
updateMbkmSelection(tableId);
});
// Check-all change
$(document).on('change', 'table[id^="table-"] thead #checkAll', function() {
var $table = $(this).closest('table');
var tableId = $table.attr('id');
$table.find('tbody .select-item').prop('checked', this.checked).each(function() {
$(this).closest('tr').toggleClass('row-selected', this.checked);
});
updateMbkmSelection(tableId);
});
</script>
<!-- Preview SK -->
<script>
$(document).ready(function() {
$('#previewSk').on('show.bs.modal', function(event) {
var button = $(event.relatedTarget);
var documentUrl = button.data('links');
var googleViewerUrl = documentUrl;
$('#skViewer').attr('src', googleViewerUrl);
});
$('#previewSk').on('hidden.bs.modal', function() {
$('#skViewer').attr('src', '');
});
});
</script>
<!-- Preview Laporan Kegiatan -->
<script>
$(document).ready(function() {
$('#previewLaporan').on('show.bs.modal', function(event) {
var button = $(event.relatedTarget);
var documentUrl = button.data('links');
var googleViewerUrl = documentUrl;
$('#laporanViewer').attr('src', googleViewerUrl);
});
$('#previewLaporan').on('hidden.bs.modal', function() {
$('#laporanViewer').attr('src', '');
});
});
</script>
<!-- Detail Laporan -->
<script>
$(document).on('click', '.detail-laporan', function(e) {
e.preventDefault();
var id_syarats = $(this).data('id-syarat');
var id_kegiatan = $(this).data('id-kegiatan');
var displayStatus = $(this).data('d-status');
var displayTanggal = $(this).data('d-tanggal');
var displayNamaKegiatan = $(this).data('d-nama-kegiatan');
var displayNamaDosen = $(this).data('d-nama-dosen');
var displayUraian = $(this).data('d-uraian');
var displayKategori = $(this).data('d-kategori');
var displayPoin = $(this).data('d-poin');
if (!id_syarats) {
showError('ID syarat tidak ditemukan!');
return;
}
if ($('#formDetailLaporan').length) {
$('#formDetailLaporan')[0].reset();
}
// Navtab Umum
var splitDisplayStatus = displayStatus.split(";");
var statusCode = splitDisplayStatus[0];
var statusMessage = splitDisplayStatus[1];
$('#displayStatusContainer').html(`<span class="badge ${statusCode}">${statusMessage}</span>`);
$('#displayTanggal').html(displayTanggal);
$('#displayNamaKegiatan').text(displayNamaKegiatan);
$('#displayNamaDosen').text(displayNamaDosen);
$('#displayUraian').text(displayUraian);
$('#displayKategori').text(displayKategori);
$('#displayPoin').text(displayPoin);
$('#id_syarats').val(id_syarats);
$('#id_kegiatans').val(id_kegiatan);
// Navtab File Syarat
$('#dokumenContainer').html('<p>Memuat dokumen syarat...</p>');
$.ajax({
url: "{{ route('laporan-kegiatan.mbkm.data-detail-laporan', ['id' => ':id']) }}"
.replace(':id', id_kegiatan),
type: 'GET',
data: {
id: id_syarats
},
success: function(res) {
let pengajuan_syarat = "";
if (res.dokumens && res.dokumens.length > 0) {
// File Syarat
pengajuan_syarat +=
`<div class="accordion custom-accordion" id="custom-accordion-one">`;
$.each(res.dokumens, function(i, v) {
let ext = v.url.split('.').pop().toLowerCase();
let headingId = `heading${i}`;
let collapseId = `collapse${i}`;
let showClass = i === 0 ? 'show' : '';
let collapsedClass = i === 0 ? '' : 'collapsed';
let ariaExpanded = i === 0 ? 'true' : 'false';
// Card start
pengajuan_syarat += `
<div class="card mb-0">
<div class="card-header bg-primary" id="${headingId}">
<h5 class="m-0">
<a class="custom-accordion-title text-white d-block py-1 ${collapsedClass}"
data-bs-toggle="collapse" href="#${collapseId}"
aria-expanded="${ariaExpanded}" aria-controls="${collapseId}">
<i class="uil-file-alt mx-1"></i>
${v.kategori_dokumen}
<i class="mdi mdi-chevron-down accordion-arrow"></i>
</a>
</h5>
</div>
<div id="${collapseId}" class="collapse ${showClass}"
aria-labelledby="${headingId}"
data-bs-parent="#custom-accordion-one">
<div class="card-body">`;
// Isi dokumen
if (ext === "pdf") {
pengajuan_syarat += `
<object data="${v.url}" type="application/pdf" width="100%" height="800px">
<p>Plugin PDF tidak tersedia. Unduh:
<a href="${v.url}" target="_blank">${v.kategori_dokumen}</a>
</p>
</object>`;
} else if (["jpg", "jpeg", "png"].includes(ext)) {
pengajuan_syarat +=
`<img src="${v.url}" alt="${v.kategori_dokumen}" style="width:100%; max-height:800px; object-fit:contain;">`;
} else {
pengajuan_syarat +=
`<a href="${v.url}" class="btn btn-sm btn-success" target="_blank">Unduh ${v.kategori_dokumen}</a>`;
}
// Card close
pengajuan_syarat += `
</div>
</div>
</div>`;
});
pengajuan_syarat += `</div>`;
} else {
pengajuan_syarat =
'<p class="text-muted text-center">Tidak ada dokumen ditemukan.</p>';
}
// Catatan Riwayat - Sanggahan
$('#sanggahanVerifikasi').text('');
res.notes?.reverse()?.some(element => {
if (element.type === 'Sanggahan') {
$('#sanggahanVerifikasi').text(element.message);
return true;
}
});
// Alasan Penolakan
$('#rowAlasanPenolakan').hide();
$('#displayAlasanPenolakan').text('');
if (res.notes && res.notes.length > 0) {
var notesDesc = [...res.notes].reverse();
var catatanVerif = notesDesc.find(function(n) {
return n.type === 'Catatan' && n.employee_role === 'Verifikator';
});
if (catatanVerif) {
$('#displayAlasanPenolakan').text(catatanVerif.message);
$('#rowAlasanPenolakan').show();
}
}
$('#dokumenContainer').html(pengajuan_syarat);
},
error: function(xhr) {
console.error(xhr);
$('#dokumenContainer').html(
'<p class="text-danger text-center">Gagal memuat dokumen.</p>');
}
});
// Load DataTable
if ($.fn.DataTable.isDataTable('#riwayat-verifikasi')) {
$('#riwayat-verifikasi').DataTable().ajax.url(
"{{ route('laporan-kegiatan.mbkm.data-detail-riwayat', ':id') }}".replace(':id',
id_syarats)).load();
$('#catatan-verifikasi').DataTable().ajax.url(
"{{ route('laporan-kegiatan.mbkm.data-detail-catatan', ':id') }}".replace(':id',
id_syarats)).load();
} else {
initRiwayatTable(id_syarats);
initCatatanTable(id_syarats);
}
// Simpan id_syarat ke button verifikasi
$('#konfirmasiTerimaDetailLaporan').data('id-syarat', id_syarats);
$('#btnTolakDetailLaporan').data('id-syarat', id_syarats);
$('#konfirmasiBatalDetailLaporan').data('id-syarat', id_syarats);
// Tampilkan/sembunyikan button berdasarkan status
let statusId = 0;
if (statusMessage.includes('Diajukan Ulang')) {
statusId = 4;
} else if (statusMessage.includes('Diajukan')) {
statusId = 3;
} else if (statusMessage.includes('Diterima') && statusMessage.includes('Dipleno')) {
statusId = 7;
} else if (statusMessage.includes('Diterima')) {
statusId = 6;
} else if (statusMessage.includes('Ditolak') && statusMessage.includes('Dipleno')) {
statusId = 8;
} else if (statusMessage.includes('Ditolak Ulang')) {
statusId = 5;
} else if (statusMessage.includes('Ditolak')) {
statusId = 2;
} else if (statusMessage.includes('Belum Diajukan')) {
statusId = 1;
}
// Sembunyikan semua button dulu
$('#konfirmasiTerimaDetailLaporan').hide();
$('#btnTolakDetailLaporan').hide();
$('#konfirmasiBatalDetailLaporan').hide();
// Tampilkan button sesuai status
if (statusId === 3 || statusId === 4) {
// Status Diajukan atau Diajukan Ulang - tampilkan Terima dan Tolak
@can('Verifikasi MBKM')
$('#konfirmasiTerimaDetailLaporan').show();
$('#btnTolakDetailLaporan').show();
@endcan
} else if ([2, 5, 6, 8].includes(statusId)) {
// Status Ditolak atau Diterima - tampilkan Batalkan (jika punya permission)
@can('Verifikasi MBKM')
$('#konfirmasiBatalDetailLaporan').show();
@endcan
}
$('#detailLaporan').modal('show');
});
function initRiwayatTable(id_syarats) {
if (!id_syarats) return;
var tableRiwayat = $('#riwayat-verifikasi').DataTable({
processing: true,
serverSide: true,
destroy: true,
responsive: true,
ajax: {
url: "{{ route('laporan-kegiatan.mbkm.data-detail-riwayat', ':id') }}".replace(':id',
id_syarats),
type: 'GET',
data: function(d) {
d.id_syarat = id_syarats;
},
error: function(xhr, error, code) {
console.error('Error loading data:', error);
$('#riwayat-verifikasi tbody').html(
'<tr><td colspan="4" class="text-center text-danger">Gagal memuat data. Silakan coba lagi.</td></tr>'
);
}
},
columns: [{
data: 'DT_RowIndex',
name: 'DT_RowIndex',
orderable: false,
searchable: false,
className: 'text-center',
width: '5%'
},
{
data: 'employee_name',
name: 'employee_name',
orderable: true,
searchable: true,
width: '25%',
render: function(data, type, row) {
return data ? data : '-';
}
},
{
data: 'message',
name: 'message',
orderable: false,
searchable: true,
className: 'text-left',
width: '45%',
render: function(data, type, row) {
return data ? data : '-';
}
},
{
data: 'waktu',
name: 'waktu',
orderable: true,
searchable: false,
className: 'text-center',
width: '25%',
render: function(data, type, row) {
return data ? data : '-';
}
}
],
order: [
[3, 'desc']
],
pageLength: 10,
lengthMenu: [
[10, 25, 50, -1],
[10, 25, 50, "Semua"]
],
language: {
processing: "<div class='spinner-border spinner-border-sm' role='status'></div>&nbsp; Sedang Memuat...",
emptyTable: "Tidak ada data"
},
});
return tableRiwayat;
}
function initCatatanTable(id_syarats) {
if (!id_syarats) return;
var tableRiwayat = $('#catatan-verifikasi').DataTable({
processing: true,
serverSide: true,
destroy: true,
responsive: true,
ajax: {
url: "{{ route('laporan-kegiatan.mbkm.data-detail-catatan', ':id') }}".replace(':id',
id_syarats),
type: 'GET',
data: function(d) {
d.id_syarat = id_syarats;
},
error: function(xhr, error, code) {
console.error('Error loading data:', error);
$('#catatan-verifikasi tbody').html(
'<tr><td colspan="4" class="text-center text-danger">Gagal memuat data. Silakan coba lagi.</td></tr>'
);
}
},
columns: [{
data: 'DT_RowIndex',
name: 'DT_RowIndex',
orderable: false,
searchable: false,
className: 'text-center',
width: '5%'
},
{
data: 'employee_name',
name: 'employee_name',
orderable: true,
searchable: true,
width: '25%',
render: function(data, type, row) {
return data ? data : '-';
}
},
{
data: 'message',
name: 'message',
orderable: false,
searchable: true,
className: 'text-left',
width: '45%',
render: function(data, type, row) {
return data ? data : '-';
}
},
{
data: 'waktu',
name: 'waktu',
orderable: true,
searchable: false,
className: 'text-center',
width: '25%',
render: function(data, type, row) {
return data ? data : '-';
}
}
],
order: [
[3, 'desc']
],
pageLength: 10,
lengthMenu: [
[10, 25, 50, -1],
[10, 25, 50, "Semua"]
],
language: {
processing: "<div class='spinner-border spinner-border-sm' role='status'></div>&nbsp; Sedang Memuat...",
emptyTable: "Tidak ada data"
},
});
return tableRiwayat;
}
$('#detailLaporan').on('hidden.bs.modal', function() {
if ($.fn.DataTable.isDataTable('#riwayat-verifikasi')) {
$('#riwayat-verifikasi').DataTable().destroy();
$('#riwayat-verifikasi tbody').empty();
}
if ($.fn.DataTable.isDataTable('#catatan-verifikasi')) {
$('#catatan-verifikasi').DataTable().destroy();
$('#catatan-verifikasi tbody').empty();
}
});
</script>
<!-- Terima Detail Laporan (Inside Modal) -->
<script>
$('#konfirmasiTerimaDetailLaporan').on('click', function() {
const button = $(this);
const originalText = button.html();
const id_syarat = button.data('id-syarat');
const id_kegiatan = {{ $data->id }};
if (!id_syarat) {
showError('Error', 'ID syarat tidak ditemukan!');
return;
}
button.prop('disabled', true).html(
'<span class="spinner-border spinner-border-sm"></span> Memproses...');
$.ajax({
url: "{{ route('laporan-kegiatan.mbkm.detail-terima', ':id') }}".replace(':id',
id_kegiatan),
type: 'POST',
data: {
_token: '{{ csrf_token() }}',
id: id_syarat
},
success: function(response) {
if (response.success) {
$('#detailLaporan').modal('hide');
if (hasLaporanKegiatanSyarat) {
sessionStorage.setItem('mbkm_terima_success', response.message);
var redirectUrl = mbkmIndexUrl + (currentUnitId ? '?unit_id=' + currentUnitId : '');
window.location.href = redirectUrl;
} else {
showSuccess('Success', response.message);
setTimeout(function() {
location.reload();
}, 2000);
}
} else {
showError('Error', response.message);
}
},
error: function(xhr, status, error) {
let errorMessage = 'Terjadi kesalahan saat verifikasi';
if (xhr.responseJSON && xhr.responseJSON.message) {
errorMessage = xhr.responseJSON.message;
} else if (xhr.responseJSON && xhr.responseJSON.errors) {
const errors = xhr.responseJSON.errors;
errorMessage = Object.values(errors).flat().join('<br>');
} else if (xhr.status === 404) {
errorMessage = 'Data pengajuan tidak ditemukan';
} else if (xhr.status === 422) {
errorMessage = 'Data yang dikirim tidak valid';
} else if (xhr.status === 500) {
errorMessage = 'Terjadi kesalahan pada server';
}
showError('Error', errorMessage);
},
complete: function() {
button.prop('disabled', false).html(originalText);
}
});
});
</script>
<!-- Batal Detail Laporan (Inside Modal) -->
<script>
$('#konfirmasiBatalDetailLaporan').on('click', function() {
const button = $(this);
const originalText = button.html();
const id_syarat = button.data('id-syarat');
const id_kegiatan = {{ $data->id }};
if (!id_syarat) {
showError('Error', 'ID syarat tidak ditemukan!');
return;
}
button.prop('disabled', true).html(
'<span class="spinner-border spinner-border-sm"></span> Memproses...');
$.ajax({
url: "{{ route('laporan-kegiatan.mbkm.detail-batal', ':id') }}".replace(':id',
id_kegiatan),
type: 'POST',
data: {
_token: '{{ csrf_token() }}',
id: id_syarat
},
success: function(response) {
if (response.success) {
$('#detailLaporan').modal('hide');
showSuccess('Success', response.message);
setTimeout(function() {
location.reload();
}, 2000);
} else {
showError('Error', response.message);
}
},
error: function(xhr, status, error) {
let errorMessage = 'Terjadi kesalahan saat verifikasi';
if (xhr.responseJSON && xhr.responseJSON.message) {
errorMessage = xhr.responseJSON.message;
} else if (xhr.responseJSON && xhr.responseJSON.errors) {
const errors = xhr.responseJSON.errors;
errorMessage = Object.values(errors).flat().join('<br>');
} else if (xhr.status === 404) {
errorMessage = 'Data pengajuan tidak ditemukan';
} else if (xhr.status === 422) {
errorMessage = 'Data yang dikirim tidak valid';
} else if (xhr.status === 500) {
errorMessage = 'Terjadi kesalahan pada server';
}
showError('Error', errorMessage);
},
complete: function() {
button.prop('disabled', false).html(originalText);
}
});
});
</script>
<!-- Tolak Detail Laporan (Inside Modal) -->
<script>
// Handle tombol Tolak di dalam modal detail
$(document).on('click', '#btnTolakDetailLaporan', function() {
const id_syarat = $(this).data('id-syarat');
if (!id_syarat) {
showError('Error', 'ID syarat tidak ditemukan!');
return;
}
// Simpan ID untuk digunakan nanti
$('#modalTolakDetailLaporan').data('id-syarat', id_syarat);
// Reset form keterangan tolak detail
$('#formTolakDetailLaporan')[0].reset();
// Tampilkan modal keterangan tolak detail
$('#modalTolakDetailLaporan').modal('show');
});
// Handle konfirmasi tolak detail laporan
$('#konfirmasiTolakDetailLaporan').on('click', function() {
const button = $(this);
const originalText = button.html();
const keteranganTolak = $('#keteranganTolakDetail').val().trim();
const id_syarat = $('#modalTolakDetailLaporan').data('id-syarat');
const id_kegiatan = {{ $data->id }};
// Validasi input
if (!keteranganTolak) {
showError('Error', 'Alasan penolakan wajib diisi!');
return;
}
if (!id_syarat) {
showError('Error', 'Data pengajuan tidak ditemukan!');
return;
}
button.prop('disabled', true).html(
'<span class="spinner-border spinner-border-sm"></span> Memproses...'
);
$.ajax({
url: "{{ route('laporan-kegiatan.mbkm.detail-tolak', ':id') }}".replace(':id',
id_kegiatan),
type: 'POST',
data: {
_token: '{{ csrf_token() }}',
id: id_syarat,
keterangan: keteranganTolak
},
success: function(response) {
$('#modalTolakDetailLaporan').modal('hide');
$('#detailLaporan').modal('hide');
if (response.success) {
showSuccess('Success', response.message);
setTimeout(function() {
location.reload();
}, 2000);
} else {
showError('Error', response.message);
}
},
error: function(xhr, status, error) {
let errorMessage = 'Terjadi kesalahan saat menolak pengajuan';
if (xhr.responseJSON && xhr.responseJSON.message) {
errorMessage = xhr.responseJSON.message;
} else if (xhr.responseJSON && xhr.responseJSON.errors) {
const errors = xhr.responseJSON.errors;
errorMessage = Object.values(errors).flat().join('<br>');
} else if (xhr.status === 404) {
errorMessage = 'Data pengajuan tidak ditemukan';
} else if (xhr.status === 422) {
errorMessage = 'Data yang dikirim tidak valid';
} else if (xhr.status === 500) {
errorMessage = 'Terjadi kesalahan pada server';
}
showError('Error', errorMessage);
},
complete: function() {
button.prop('disabled', false).html(originalText);
}
});
});
// Reset data ketika modal tolak detail laporan ditutup
$('#modalTolakDetailLaporan').on('hidden.bs.modal', function() {
$(this).removeData('id-syarat');
$('#formTolakDetailLaporan')[0].reset();
});
</script>
<!-- Preview Dokumen Syarat -->
<script>
$(document).ready(function() {
$('#modalPreviewDokumenSyarat').on('show.bs.modal', function(event) {
var btn = $(event.relatedTarget);
var url = btn.data('links');
var label = btn.attr('title') || 'Dokumen Syarat';
$(this).find('.modal-title').text(label);
$('#dokumenSyaratViewer').attr('src', url);
});
$('#modalPreviewDokumenSyarat').on('hidden.bs.modal', function() {
$('#dokumenSyaratViewer').attr('src', '');
});
});
</script>
<!-- Edit Jangka Waktu -->
<script>
$(document).on('click', '.jangka-waktu-multiple-btn', function() {
var kegiatanKey = $(this).data('kegiatan');
var tableId = 'table-' + (parseInt(kegiatanKey) + 1);
var selectedIds = getMbkmSelectedIds(tableId);
if (selectedIds.length === 0) {
showWarning('Peringatan', 'Pilih minimal satu anggota untuk mengubah jangka waktu');
return;
}
$('#modalEditJangkaWaktu').data('selectedIds', selectedIds);
$('#formEditJangkaWaktu')[0].reset();
$('#modalEditJangkaWaktu').modal('show');
});
$('#simpanJangkaWaktu').on('click', function() {
const button = $(this);
const originalText = button.html();
const modal = $('#modalEditJangkaWaktu');
const selectedIds = modal.data('selectedIds');
const jumlahBulan = $('#jumlahBulan').val();
const keterangan = $('#keterangan').val() || '';
const id = {{ $data->id }};
if (!selectedIds || selectedIds.length === 0) {
showInfo('Info!', 'Tidak ada anggota yang dipilih');
return;
}
if (!jumlahBulan || jumlahBulan < 1 || jumlahBulan > 6) {
showInfo('Info!', 'Jumlah bulan harus diisi antara 1-6');
return;
}
if (!keterangan) {
showInfo('Info!', 'Keterangan wajib diisi!');
return;
}
button.prop('disabled', true).html('<span class="spinner-border spinner-border-sm"></span> Memproses...');
$.ajax({
url: "{{ route('laporan-kegiatan.mbkm.edit-jangka-waktu', ':id') }}".replace(':id', id),
type: 'POST',
data: {
_token: '{{ csrf_token() }}',
ids: selectedIds,
jangka_waktu: jumlahBulan,
alasan: keterangan
},
success: function(response) {
modal.modal('hide');
if (response.success) {
showSuccess('Success', response.message);
setTimeout(function() { location.reload(); }, 1500);
} else {
showError('Error', response.message);
}
},
error: function(xhr) {
let msg = (xhr.responseJSON && xhr.responseJSON.message) ? xhr.responseJSON.message : 'Terjadi kesalahan';
showError('Error', msg);
},
complete: function() {
button.prop('disabled', false).html(originalText);
}
});
});
$('#modalEditJangkaWaktu').on('hidden.bs.modal', function() {
$(this).removeData('selectedIds');
$('#formEditJangkaWaktu')[0].reset();
});
</script>
<!-- Edit Jumlah Mahasiswa -->
<script>
$(document).on('click', '.badge-edit-disabled', function(e) {
e.preventDefault();
e.stopImmediatePropagation();
showWarning('Peringatan', 'Tidak dapat mengubah jumlah karena pengajuan sudah diproses.');
return false;
});
$(document).on('click', '.jml-satuan', function() {
const syaratId = $(this).data('syarat-id');
const jumlahSatuan = $(this).data('jml-satuan');
const satuan = $(this).data('satuan');
if (!syaratId) {
showError('Error', 'ID syarat tidak ditemukan');
return;
}
$('#syarat_id').val(syaratId);
$('#jumlah_satuan').val(jumlahSatuan);
$('#jmlSatuanModalLabel').text('Edit Jumlah ' + (satuan || 'Mahasiswa'));
$('#jumlah_satuan_label').text('Jumlah ' + (satuan || 'Mahasiswa'));
$('#jumlah_satuan').removeClass('is-invalid');
$('#jumlah_satuan_error').text('');
$('#modalEditJumlahSatuan').modal('show');
});
$(document).on('click', '#simpanJumlahSatuan', function(e) {
e.preventDefault();
const button = $(this);
const originalText = button.html();
const syaratId = $('#syarat_id').val();
const jumlahSatuan = $('#jumlah_satuan').val();
if (!syaratId) {
showError('Error', 'ID syarat tidak ditemukan');
return;
}
if (!jumlahSatuan || jumlahSatuan < 1) {
$('#jumlah_satuan').addClass('is-invalid');
$('#jumlah_satuan_error').text('Jumlah harus diisi dan minimal 1');
return;
}
$('#jumlah_satuan').removeClass('is-invalid');
$('#jumlah_satuan_error').text('');
button.prop('disabled', true).html('<span class="spinner-border spinner-border-sm me-2"></span>Memproses...');
$.ajax({
url: "{{ route('laporan-kegiatan.mbkm.edit-jumlah-satuan', ':id') }}".replace(':id', syaratId),
type: 'POST',
data: {
_token: $('meta[name="csrf-token"]').attr('content'),
jumlah: jumlahSatuan
},
success: function(response) {
if (response.success) {
$('#modalEditJumlahSatuan').modal('hide');
showSuccess('Berhasil', response.message || 'Jumlah mahasiswa berhasil diubah');
setTimeout(function() { location.reload(); }, 1500);
} else {
showError('Error', response.message || 'Terjadi kesalahan');
}
},
error: function(xhr) {
let errorMessage = 'Terjadi kesalahan saat memperbarui jumlah mahasiswa';
if (xhr.responseJSON && xhr.responseJSON.message) {
errorMessage = xhr.responseJSON.message;
}
showError('Error', errorMessage);
},
complete: function() {
button.prop('disabled', false).html(originalText);
}
});
});
$('#formEditJmlSatuan').on('submit', function(e) {
e.preventDefault();
$('#simpanJumlahSatuan').click();
});
$('#modalEditJumlahSatuan').on('hidden.bs.modal', function() {
$('#formEditJmlSatuan')[0].reset();
$('#jumlah_satuan').removeClass('is-invalid');
$('#jumlah_satuan_error').text('');
});
</script>
<!-- Bulk Action Handlers -->
<script>
var kegiatanId = {{ $data->id }};
$(document).on('click', '.mbkm-btn-terima', function() {
var tableId = $(this).data('table-id');
var ids = getMbkmSelectedIds(tableId);
if (!ids.length) { return; }
if (mbkmHasBelumDiajukan(tableId)) { showWarning('Peringatan', 'Harap untuk mengunggah Laporan terlebih dahulu'); return; }
if ($('#' + tableId).data('is-shared')) { ids = [ids[0]]; }
$('#modalKonfirmasiTerima').data('pending', { ids: ids, button: $(this) });
$('#modalKonfirmasiTerima').modal('show');
});
$('#konfirmasiTerimaLaporan').on('click', function() {
var pending = $('#modalKonfirmasiTerima').data('pending');
if (!pending) { return; }
$('#modalKonfirmasiTerima').modal('hide');
mbkmAjaxAction(
"{{ route('laporan-kegiatan.mbkm.detail-terima', ':id') }}".replace(':id', kegiatanId),
pending.ids, pending.button,
function() {
if (hasLaporanKegiatanSyarat) {
var msg = pending.ids.length + ' pengajuan berhasil diterima';
sessionStorage.setItem('mbkm_terima_success', msg);
var redirectUrl = mbkmIndexUrl + (currentUnitId ? '?unit_id=' + currentUnitId : '');
window.location.href = redirectUrl;
} else {
showSuccess('Berhasil', pending.ids.length + ' pengajuan berhasil diterima');
setTimeout(function() { location.reload(); }, 1500);
}
}
);
});
$(document).on('click', '.mbkm-btn-batalkan', function() {
var tableId = $(this).data('table-id');
var ids = [];
$('#' + tableId + ' tbody .select-item:checked').each(function() {
if (parseInt($(this).data('status')) !== 1) { ids.push($(this).val()); }
});
if (!ids.length) { showWarning('Peringatan', 'Aksi Batal tidak dapat dilakukan jika status belum diajukan'); return; }
if ($('#' + tableId).data('is-shared')) { ids = [ids[0]]; }
$('#modalKonfirmasiBatalkan').data('pending', { ids: ids, button: $(this) });
$('#modalKonfirmasiBatalkan').modal('show');
});
$('#konfirmasiBatalkanLaporan').on('click', function() {
var pending = $('#modalKonfirmasiBatalkan').data('pending');
if (!pending) { return; }
$('#modalKonfirmasiBatalkan').modal('hide');
mbkmAjaxAction(
"{{ route('laporan-kegiatan.mbkm.detail-batal', ':id') }}".replace(':id', kegiatanId),
pending.ids, pending.button,
function() { showSuccess('Berhasil', pending.ids.length + ' pengajuan berhasil dibatalkan'); setTimeout(function() { location.reload(); }, 1500); }
);
});
$(document).on('click', '.mbkm-btn-tolak', function() {
var tableId = $(this).data('table-id');
var ids = getMbkmSelectedIds(tableId);
if (!ids.length) { return; }
if ($('#' + tableId).data('is-shared')) { ids = [ids[0]]; }
$('#modalTolakLaporan').data('selected-ids', ids);
$('#formTolakLaporan')[0].reset();
$('#modalTolakLaporan').modal('show');
});
$('#konfirmasiTolakLaporan').on('click', function() {
var button = $(this);
var ids = $('#modalTolakLaporan').data('selected-ids');
var keterangan = $('#keteranganTolak').val().trim();
if (!keterangan) { showError('Error', 'Alasan penolakan wajib diisi!'); return; }
if (!ids || !ids.length) { return; }
var originalText = button.html();
button.prop('disabled', true).html('<span class="spinner-border spinner-border-sm"></span> Memproses...');
var promises = ids.map(function(id) {
return $.ajax({ url: "{{ route('laporan-kegiatan.mbkm.detail-tolak', ':id') }}".replace(':id', kegiatanId), type: 'POST', data: { _token: '{{ csrf_token() }}', id: id, keterangan: keterangan } });
});
$.when.apply($, promises).then(function() {
$('#modalTolakLaporan').modal('hide');
showSuccess('Berhasil', ids.length + ' pengajuan berhasil ditolak');
setTimeout(function() { location.reload(); }, 1500);
}).fail(function(xhr) {
var msg = (xhr.responseJSON && xhr.responseJSON.message) ? xhr.responseJSON.message : 'Terjadi kesalahan';
showError('Error', msg);
button.prop('disabled', false).html(originalText);
});
});
</script>
@endsection