first commit
This commit is contained in:
@@ -0,0 +1,523 @@
|
||||
@extends('layouts.main')
|
||||
|
||||
@section('breadcrumb')
|
||||
<ol class="breadcrumb m-0">
|
||||
<li class="breadcrumb-item"><a href="javascript:void(0);">Perhitungan</a></li>
|
||||
<li class="breadcrumb-item"><a href="javascript:void(0);">Rekapitulasi</a></li>
|
||||
<li class="breadcrumb-item"><a href="{{ route('rekapitulasi.pendapatan.index') }}">Pendapatan</a></li>
|
||||
<li class="breadcrumb-item active" aria-current="page">{{ $unitKerja->unit_kerja_nama }}</li>
|
||||
</ol>
|
||||
@endsection
|
||||
|
||||
@section('content')
|
||||
<div class="row">
|
||||
@if($idfakultasunit)
|
||||
<div class="col-12 mb-3">
|
||||
<div class="card border">
|
||||
<div class="card-body">
|
||||
<!-- Nav tabs -->
|
||||
<ul class="nav nav-pills bg-nav-pills nav-justified mb-3" role="tablist">
|
||||
<li class="nav-item">
|
||||
<a href="#grafikMahasiswa" data-bs-toggle="tab" aria-expanded="true" class="nav-link rounded-0 active">
|
||||
<i class="ri-group-line d-md-none d-block"></i>
|
||||
<span class="d-none d-md-block">Grafik Mahasiswa</span>
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a href="#grafikPendapatan" data-bs-toggle="tab" aria-expanded="false" class="nav-link rounded-0">
|
||||
<i class="ri-money-dollar-circle-line d-md-none d-block"></i>
|
||||
<span class="d-none d-md-block">Grafik Pendapatan (Rp)</span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<!-- Tab panes -->
|
||||
<div class="tab-content">
|
||||
<div class="tab-pane active" id="grafikMahasiswa" role="tabpanel">
|
||||
<div id="chartContainerMahasiswa" style="width:100%; height:500px;"></div>
|
||||
</div>
|
||||
<div class="tab-pane" id="grafikPendapatan" role="tabpanel">
|
||||
<div id="chartContainerPendapatan" style="width:100%; height:500px;"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
<div class="col-12">
|
||||
<div class="card border">
|
||||
<div class="card-header">
|
||||
<div class="d-flex justify-content-between align-items-center">
|
||||
<h5 class="card-title mb-0">{{ $title }}</h5>
|
||||
<a href="{{ route('rekapitulasi.pendapatan.index') }}" class="btn btn-secondary btn-sm">
|
||||
<i class="ri-arrow-left-line"></i> Kembali
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
@if($idfakultasunit)
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped table-bordered w-100" id="prodiTable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th rowspan="2" class="align-middle text-center">No</th>
|
||||
<th rowspan="2" class="align-middle">Program Studi</th>
|
||||
<th rowspan="2" class="align-middle text-center">Total Mahasiswa</th>
|
||||
<th colspan="8" class="text-center">Kelompok UKT</th>
|
||||
<th rowspan="2" class="align-middle text-center">Total</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="text-center">UKT 1</th>
|
||||
<th class="text-center">UKT 2</th>
|
||||
<th class="text-center">UKT 3</th>
|
||||
<th class="text-center">UKT 4</th>
|
||||
<th class="text-center">UKT 5</th>
|
||||
<th class="text-center">UKT 6</th>
|
||||
<th class="text-center">UKT 7</th>
|
||||
<th class="text-center">UKT 8</th>
|
||||
</tr>
|
||||
</thead>
|
||||
</table>
|
||||
</div>
|
||||
@else
|
||||
<div class="alert alert-warning">
|
||||
<i class="ri-alert-line"></i> Data tidak ditemukan untuk unit kerja ini.
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@section('js')
|
||||
<script src="https://cdn.jsdelivr.net/npm/chart.js@4.4.0/dist/chart.umd.min.js"></script>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
@if($idfakultasunit)
|
||||
// Load chart data
|
||||
$.ajax({
|
||||
url: "{{ route('rekapitulasi.pendapatan.detail-chart-data', $unitKerja->id) }}",
|
||||
type: 'GET',
|
||||
success: function(response) {
|
||||
console.log('Chart data received:', response);
|
||||
|
||||
if (response.labels && response.mahasiswa && response.mahasiswa.length > 0) {
|
||||
// Solid colors with shadow effect for 3D look (8 warna untuk UKT 1-8)
|
||||
var colors = [
|
||||
'rgba(102, 126, 234, 0.9)',
|
||||
'rgba(240, 147, 251, 0.9)',
|
||||
'rgba(79, 172, 254, 0.9)',
|
||||
'rgba(67, 233, 123, 0.9)',
|
||||
'rgba(250, 112, 154, 0.9)',
|
||||
'rgba(255, 159, 64, 0.9)',
|
||||
'rgba(153, 102, 255, 0.9)',
|
||||
'rgba(255, 205, 86, 0.9)'
|
||||
];
|
||||
|
||||
var borderColors = [
|
||||
'rgba(102, 126, 234, 1)',
|
||||
'rgba(240, 147, 251, 1)',
|
||||
'rgba(79, 172, 254, 1)',
|
||||
'rgba(67, 233, 123, 1)',
|
||||
'rgba(250, 112, 154, 1)',
|
||||
'rgba(255, 159, 64, 1)',
|
||||
'rgba(153, 102, 255, 1)',
|
||||
'rgba(255, 205, 86, 1)'
|
||||
];
|
||||
|
||||
// ========== GRAFIK MAHASISWA ==========
|
||||
// Create canvas element for Chart.js Mahasiswa
|
||||
$('#chartContainerMahasiswa').html('<canvas id="uktChartMahasiswa" style="max-height: 500px;"></canvas>');
|
||||
|
||||
var ctxMahasiswa = document.getElementById('uktChartMahasiswa').getContext('2d');
|
||||
|
||||
// Create 3D bar chart for Mahasiswa
|
||||
var chartMahasiswa = new Chart(ctxMahasiswa, {
|
||||
type: 'bar',
|
||||
data: {
|
||||
labels: response.labels,
|
||||
datasets: [{
|
||||
label: 'Jumlah Mahasiswa',
|
||||
data: response.mahasiswa,
|
||||
backgroundColor: colors,
|
||||
borderColor: borderColors,
|
||||
borderWidth: 3,
|
||||
borderRadius: 10,
|
||||
borderSkipped: false,
|
||||
barPercentage: 0.7,
|
||||
categoryPercentage: 0.8
|
||||
}]
|
||||
},
|
||||
options: {
|
||||
responsive: true,
|
||||
maintainAspectRatio: false,
|
||||
plugins: {
|
||||
title: {
|
||||
display: true,
|
||||
text: 'Grafik Jumlah Mahasiswa per Kelompok UKT 1-8',
|
||||
font: {
|
||||
size: 20,
|
||||
weight: 'bold',
|
||||
family: "'Helvetica Neue', 'Helvetica', 'Arial', sans-serif"
|
||||
},
|
||||
padding: {
|
||||
top: 10,
|
||||
bottom: 30
|
||||
},
|
||||
color: '#333'
|
||||
},
|
||||
legend: {
|
||||
display: true,
|
||||
position: 'top',
|
||||
labels: {
|
||||
font: {
|
||||
size: 14
|
||||
},
|
||||
padding: 15
|
||||
}
|
||||
},
|
||||
tooltip: {
|
||||
enabled: true,
|
||||
backgroundColor: 'rgba(0, 0, 0, 0.9)',
|
||||
titleFont: {
|
||||
size: 15,
|
||||
weight: 'bold'
|
||||
},
|
||||
bodyFont: {
|
||||
size: 14
|
||||
},
|
||||
padding: 15,
|
||||
cornerRadius: 10,
|
||||
displayColors: true,
|
||||
callbacks: {
|
||||
label: function(context) {
|
||||
return 'Jumlah: ' + context.parsed.y.toLocaleString('id-ID') + ' Mahasiswa';
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
scales: {
|
||||
y: {
|
||||
beginAtZero: true,
|
||||
ticks: {
|
||||
callback: function(value) {
|
||||
return value.toLocaleString('id-ID');
|
||||
},
|
||||
font: {
|
||||
size: 13
|
||||
},
|
||||
color: '#666'
|
||||
},
|
||||
title: {
|
||||
display: true,
|
||||
text: 'Jumlah Mahasiswa',
|
||||
font: {
|
||||
size: 15,
|
||||
weight: 'bold'
|
||||
},
|
||||
color: '#333'
|
||||
},
|
||||
grid: {
|
||||
color: 'rgba(0, 0, 0, 0.08)',
|
||||
drawBorder: false,
|
||||
lineWidth: 1
|
||||
}
|
||||
},
|
||||
x: {
|
||||
ticks: {
|
||||
font: {
|
||||
size: 14,
|
||||
weight: 'bold'
|
||||
},
|
||||
color: '#333'
|
||||
},
|
||||
title: {
|
||||
display: true,
|
||||
text: 'Kelompok UKT',
|
||||
font: {
|
||||
size: 15,
|
||||
weight: 'bold'
|
||||
},
|
||||
color: '#333'
|
||||
},
|
||||
grid: {
|
||||
display: false
|
||||
}
|
||||
}
|
||||
},
|
||||
animation: {
|
||||
duration: 1500,
|
||||
easing: 'easeInOutQuart'
|
||||
},
|
||||
layout: {
|
||||
padding: {
|
||||
left: 10,
|
||||
right: 10,
|
||||
top: 10,
|
||||
bottom: 10
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// ========== GRAFIK PENDAPATAN ==========
|
||||
// Create canvas element for Chart.js Pendapatan
|
||||
$('#chartContainerPendapatan').html('<canvas id="uktChartPendapatan" style="max-height: 500px;"></canvas>');
|
||||
|
||||
var ctxPendapatan = document.getElementById('uktChartPendapatan').getContext('2d');
|
||||
|
||||
// Create 3D bar chart for Pendapatan
|
||||
var chartPendapatan = new Chart(ctxPendapatan, {
|
||||
type: 'bar',
|
||||
data: {
|
||||
labels: response.labels,
|
||||
datasets: [{
|
||||
label: 'Jumlah Pendapatan (Rp)',
|
||||
data: response.rupiah,
|
||||
backgroundColor: colors,
|
||||
borderColor: borderColors,
|
||||
borderWidth: 3,
|
||||
borderRadius: 10,
|
||||
borderSkipped: false,
|
||||
barPercentage: 0.7,
|
||||
categoryPercentage: 0.8
|
||||
}]
|
||||
},
|
||||
options: {
|
||||
responsive: true,
|
||||
maintainAspectRatio: false,
|
||||
plugins: {
|
||||
title: {
|
||||
display: true,
|
||||
text: 'Grafik Jumlah Pendapatan per Kelompok UKT 1-8',
|
||||
font: {
|
||||
size: 20,
|
||||
weight: 'bold',
|
||||
family: "'Helvetica Neue', 'Helvetica', 'Arial', sans-serif"
|
||||
},
|
||||
padding: {
|
||||
top: 10,
|
||||
bottom: 30
|
||||
},
|
||||
color: '#333'
|
||||
},
|
||||
legend: {
|
||||
display: true,
|
||||
position: 'top',
|
||||
labels: {
|
||||
font: {
|
||||
size: 14
|
||||
},
|
||||
padding: 15
|
||||
}
|
||||
},
|
||||
tooltip: {
|
||||
enabled: true,
|
||||
backgroundColor: 'rgba(0, 0, 0, 0.9)',
|
||||
titleFont: {
|
||||
size: 15,
|
||||
weight: 'bold'
|
||||
},
|
||||
bodyFont: {
|
||||
size: 14
|
||||
},
|
||||
padding: 15,
|
||||
cornerRadius: 10,
|
||||
displayColors: true,
|
||||
callbacks: {
|
||||
label: function(context) {
|
||||
return 'Jumlah: Rp ' + context.parsed.y.toLocaleString('id-ID');
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
scales: {
|
||||
y: {
|
||||
beginAtZero: true,
|
||||
ticks: {
|
||||
callback: function(value) {
|
||||
return 'Rp ' + value.toLocaleString('id-ID');
|
||||
},
|
||||
font: {
|
||||
size: 13
|
||||
},
|
||||
color: '#666'
|
||||
},
|
||||
title: {
|
||||
display: true,
|
||||
text: 'Jumlah Pendapatan (Rp)',
|
||||
font: {
|
||||
size: 15,
|
||||
weight: 'bold'
|
||||
},
|
||||
color: '#333'
|
||||
},
|
||||
grid: {
|
||||
color: 'rgba(0, 0, 0, 0.08)',
|
||||
drawBorder: false,
|
||||
lineWidth: 1
|
||||
}
|
||||
},
|
||||
x: {
|
||||
ticks: {
|
||||
font: {
|
||||
size: 14,
|
||||
weight: 'bold'
|
||||
},
|
||||
color: '#333'
|
||||
},
|
||||
title: {
|
||||
display: true,
|
||||
text: 'Kelompok UKT',
|
||||
font: {
|
||||
size: 15,
|
||||
weight: 'bold'
|
||||
},
|
||||
color: '#333'
|
||||
},
|
||||
grid: {
|
||||
display: false
|
||||
}
|
||||
}
|
||||
},
|
||||
animation: {
|
||||
duration: 1500,
|
||||
easing: 'easeInOutQuart'
|
||||
},
|
||||
layout: {
|
||||
padding: {
|
||||
left: 10,
|
||||
right: 10,
|
||||
top: 10,
|
||||
bottom: 10
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
console.log('Charts created successfully');
|
||||
} else {
|
||||
console.error('Invalid data format:', response);
|
||||
$('#chartContainerMahasiswa').html('<div class="alert alert-warning">Data grafik tidak valid</div>');
|
||||
$('#chartContainerPendapatan').html('<div class="alert alert-warning">Data grafik tidak valid</div>');
|
||||
}
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
console.error('Error loading chart data:', error);
|
||||
console.error('XHR:', xhr);
|
||||
$('#chartContainerMahasiswa').html('<div class="alert alert-warning">Gagal memuat data grafik: ' + error + '</div>');
|
||||
$('#chartContainerPendapatan').html('<div class="alert alert-warning">Gagal memuat data grafik: ' + error + '</div>');
|
||||
}
|
||||
});
|
||||
|
||||
// Initialize DataTable
|
||||
var table = $('#prodiTable').DataTable({
|
||||
processing: true,
|
||||
serverSide: true,
|
||||
ajax: {
|
||||
url: "{{ route('rekapitulasi.pendapatan.detail-data', $unitKerja->id) }}",
|
||||
},
|
||||
columns: [
|
||||
{
|
||||
data: 'DT_RowIndex',
|
||||
name: 'DT_RowIndex',
|
||||
orderable: false,
|
||||
searchable: false,
|
||||
className: 'text-center',
|
||||
width: '5%'
|
||||
},
|
||||
{
|
||||
data: 'progdi',
|
||||
name: 'progdi'
|
||||
},
|
||||
{
|
||||
data: 'total_mahasiswa',
|
||||
name: 'total_mahasiswa',
|
||||
className: 'text-center',
|
||||
orderable: false,
|
||||
searchable: false
|
||||
},
|
||||
{
|
||||
data: 'ukt_1',
|
||||
name: 'ukt_1',
|
||||
className: 'text-end',
|
||||
orderable: false,
|
||||
searchable: false
|
||||
},
|
||||
{
|
||||
data: 'ukt_2',
|
||||
name: 'ukt_2',
|
||||
className: 'text-end',
|
||||
orderable: false,
|
||||
searchable: false
|
||||
},
|
||||
{
|
||||
data: 'ukt_3',
|
||||
name: 'ukt_3',
|
||||
className: 'text-end',
|
||||
orderable: false,
|
||||
searchable: false
|
||||
},
|
||||
{
|
||||
data: 'ukt_4',
|
||||
name: 'ukt_4',
|
||||
className: 'text-end',
|
||||
orderable: false,
|
||||
searchable: false
|
||||
},
|
||||
{
|
||||
data: 'ukt_5',
|
||||
name: 'ukt_5',
|
||||
className: 'text-end',
|
||||
orderable: false,
|
||||
searchable: false
|
||||
},
|
||||
{
|
||||
data: 'ukt_6',
|
||||
name: 'ukt_6',
|
||||
className: 'text-end',
|
||||
orderable: false,
|
||||
searchable: false
|
||||
},
|
||||
{
|
||||
data: 'ukt_7',
|
||||
name: 'ukt_7',
|
||||
className: 'text-end',
|
||||
orderable: false,
|
||||
searchable: false
|
||||
},
|
||||
{
|
||||
data: 'ukt_8',
|
||||
name: 'ukt_8',
|
||||
className: 'text-end',
|
||||
orderable: false,
|
||||
searchable: false
|
||||
},
|
||||
{
|
||||
data: 'total',
|
||||
name: 'total',
|
||||
className: 'text-end',
|
||||
orderable: false,
|
||||
searchable: false
|
||||
}
|
||||
],
|
||||
language: {
|
||||
processing: "<div class='spinner'></div> Sedang Memuat...",
|
||||
},
|
||||
scrollX: true,
|
||||
pageLength: 25,
|
||||
order: [[1, 'asc']]
|
||||
});
|
||||
@endif
|
||||
});
|
||||
</script>
|
||||
|
||||
<!-- Sidebar Aktif -->
|
||||
<script>
|
||||
$('.si-rekapitulasi').addClass('menuitem-active');
|
||||
$('.ni-rekapitulasi').addClass('badge-primary-lighten');
|
||||
$('.li-rekapitulasi').addClass('show');
|
||||
$('.li-rekapitulasi-pendapatan').addClass('active badge-primary-lighten');
|
||||
</script>
|
||||
@endsection
|
||||
@@ -0,0 +1,265 @@
|
||||
@extends('layouts.main')
|
||||
|
||||
@section('breadcrumb')
|
||||
<ol class="breadcrumb m-0">
|
||||
<li class="breadcrumb-item"><a href="javascript:void(0);">Perhitungan</a></li>
|
||||
<li class="breadcrumb-item"><a href="javascript:void(0);">Rekapitulasi</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">
|
||||
<!-- Form Select2 -->
|
||||
<div class="mb-4">
|
||||
<div class="row">
|
||||
<div class="col-md-7">
|
||||
<label for="jenis_pendapatan" class="form-label">Jenis Pendapatan</label>
|
||||
<select name="jenis_pendapatan" id="jenis_pendapatan" class="form-select select2"
|
||||
data-placeholder="Pilih Jenis Pendapatan">
|
||||
<option value="Layanan Pendidikan" selected>Layanan Pendidikan</option>
|
||||
<option value="Kerjasama Unit Kerja">Kerjasama Unit Kerja</option>
|
||||
<option value="Pendapatan Rumah Sakit">Pendapatan Rumah Sakit</option>
|
||||
<option value="Layanan Perbankan">Layanan Perbankan</option>
|
||||
<option value="Total Pendapatan">Total Pendapatan</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-5">
|
||||
<label for="tahun" class="form-label">Tahun</label>
|
||||
<select name="tahun" id="tahun" class="form-select select2"
|
||||
data-placeholder="Pilih Tahun">
|
||||
@for ($year = date('Y'); $year >= 2025; $year--)
|
||||
<option value="{{ $year }}" {{ $year == date('Y') ? 'selected' : '' }}>
|
||||
{{ $year }}</option>
|
||||
@endfor
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Content tanpa tabs (karena pendapatan tidak ada kekurangan) -->
|
||||
<div id="contentWithoutTabs">
|
||||
<div class="row">
|
||||
<!-- Tabel -->
|
||||
<div class="col-md-7">
|
||||
<div class="card">
|
||||
<div class="card-header d-flex justify-content-between align-items-center">
|
||||
<h5 class="card-title mb-0">Data Pendapatan</h5>
|
||||
<span id="totalPendapatan" class="text-primary fw-bold">Rp. 0</span>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped table-bordered w-100" id="pendapatanTable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>No</th>
|
||||
<th>Unit Kerja</th>
|
||||
<th>Jumlah</th>
|
||||
<th>Aksi</th>
|
||||
</tr>
|
||||
</thead>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Grafik Pie -->
|
||||
<div class="col-md-5">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h5 class="card-title mb-0">Grafik Pendapatan</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<canvas id="pendapatanChart" width="400" height="400"></canvas>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@section('js')
|
||||
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
let chart;
|
||||
|
||||
// Initialize DataTable
|
||||
var table = $('#pendapatanTable').DataTable({
|
||||
processing: true,
|
||||
serverSide: true,
|
||||
ajax: {
|
||||
url: "{{ route('rekapitulasi.pendapatan.data') }}",
|
||||
data: function(d) {
|
||||
d.jenis = $('#jenis_pendapatan').val();
|
||||
d.tahun = $('#tahun').val();
|
||||
}
|
||||
},
|
||||
columns: [{
|
||||
data: 'DT_RowIndex',
|
||||
name: 'DT_RowIndex',
|
||||
orderable: false,
|
||||
searchable: false,
|
||||
className: 'text-center',
|
||||
width: '10%'
|
||||
},
|
||||
{
|
||||
data: 'unit_kerja',
|
||||
name: 'unit_kerja'
|
||||
},
|
||||
{
|
||||
data: 'jumlah',
|
||||
name: 'jumlah',
|
||||
className: 'text-center',
|
||||
orderable: false,
|
||||
searchable: false
|
||||
},
|
||||
{
|
||||
data: 'aksi',
|
||||
name: 'aksi',
|
||||
className: 'text-center',
|
||||
orderable: false,
|
||||
searchable: false,
|
||||
width: '15%'
|
||||
}
|
||||
],
|
||||
language: {
|
||||
processing: "<div class='spinner'></div> Sedang Memuat...",
|
||||
},
|
||||
});
|
||||
|
||||
// Function to load total pendapatan
|
||||
function loadTotal() {
|
||||
const jenis = $('#jenis_pendapatan').val();
|
||||
const tahun = $('#tahun').val();
|
||||
|
||||
$.ajax({
|
||||
url: "{{ route('rekapitulasi.pendapatan.total') }}",
|
||||
method: 'GET',
|
||||
data: {
|
||||
jenis: jenis,
|
||||
tahun: tahun
|
||||
},
|
||||
success: function(response) {
|
||||
$('#totalPendapatan').text(response.total_formatted);
|
||||
},
|
||||
error: function(xhr) {
|
||||
console.error('Error loading total:', xhr.responseText);
|
||||
$('#totalPendapatan').text('Rp. 0');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Function to load chart data
|
||||
function loadChart() {
|
||||
const jenis = $('#jenis_pendapatan').val();
|
||||
const tahun = $('#tahun').val();
|
||||
|
||||
$.ajax({
|
||||
url: "{{ route('rekapitulasi.pendapatan.chart-data') }}",
|
||||
method: 'GET',
|
||||
data: {
|
||||
jenis: jenis,
|
||||
tahun: tahun
|
||||
},
|
||||
success: function(data) {
|
||||
updateChart(data);
|
||||
},
|
||||
error: function(xhr) {
|
||||
console.error('Error loading chart data:', xhr.responseText);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Function to update chart
|
||||
function updateChart(data) {
|
||||
const ctx = document.getElementById('pendapatanChart').getContext('2d');
|
||||
|
||||
if (chart) {
|
||||
chart.destroy();
|
||||
}
|
||||
|
||||
const labels = data.map(item => item.label);
|
||||
const values = data.map(item => item.value);
|
||||
|
||||
// Function to get color based on unit name
|
||||
function getColorByUnit(unitName) {
|
||||
const colorMap = {
|
||||
'Fakultas Hukum': '#FF0000', // Merah
|
||||
'Fakultas Ekonomi dan Bisnis': '#90EE90', // Hijau Muda
|
||||
'Fakultas Pertanian': '#006400', // Hijau Tua
|
||||
'Fakultas Teknik': '#87CEEB', // Biru Muda
|
||||
'Fakultas Ilmu Sosial dan Ilmu Politik': '#000080', // Biru Tua
|
||||
'Fakultas Keguruan dan Ilmu Pendidikan': '#FFA500', // Orange
|
||||
'Fakultas Kehutanan': '#800080', // Ungu
|
||||
'Fakultas Matematika dan Ilmu Pengetahuan Alam': '#FFFF00', // Kuning
|
||||
'Fakultas Kedokteran': '#FFFFFF', // Putih
|
||||
'Universitas': '#808080' // Abu-abu
|
||||
};
|
||||
|
||||
return colorMap[unitName] || '#CCCCCC'; // Default color jika tidak ditemukan
|
||||
}
|
||||
|
||||
const colors = labels.map(label => getColorByUnit(label));
|
||||
|
||||
chart = new Chart(ctx, {
|
||||
type: 'pie',
|
||||
data: {
|
||||
labels: labels,
|
||||
datasets: [{
|
||||
data: values,
|
||||
backgroundColor: colors,
|
||||
borderWidth: 2,
|
||||
borderColor: '#000000'
|
||||
}]
|
||||
},
|
||||
options: {
|
||||
responsive: true,
|
||||
maintainAspectRatio: false,
|
||||
plugins: {
|
||||
legend: {
|
||||
position: 'bottom',
|
||||
labels: {
|
||||
padding: 20,
|
||||
usePointStyle: true
|
||||
}
|
||||
},
|
||||
tooltip: {
|
||||
callbacks: {
|
||||
label: function(context) {
|
||||
const label = context.label || '';
|
||||
const value = new Intl.NumberFormat('id-ID', {
|
||||
style: 'currency',
|
||||
currency: 'IDR',
|
||||
minimumFractionDigits: 0
|
||||
}).format(context.parsed);
|
||||
return label + ': ' + value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Reload table, total, and chart when dropdown changes
|
||||
$('#jenis_pendapatan, #tahun').on('change', function() {
|
||||
table.ajax.reload();
|
||||
loadTotal();
|
||||
loadChart();
|
||||
});
|
||||
|
||||
// Initial load
|
||||
loadTotal();
|
||||
loadChart();
|
||||
});
|
||||
</script>
|
||||
@endsection
|
||||
Reference in New Issue
Block a user