|
|
|
@ -92,7 +92,7 @@
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
|
|
<!-- Area Bar Chart --> |
|
|
|
|
<div class="col-xl-7 col-lg-7"> |
|
|
|
|
{{-- <div class="col-xl-7 col-lg-7"> |
|
|
|
|
<div class="card shadow mb-4" style="max-height: 600px;"> |
|
|
|
|
<div class="card-header py-3 d-flex flex-row align-items-center justify-content-between"> |
|
|
|
|
<h6 class="m-0 font-weight-bold text-primary">Grafik Peminjaman VS Pengembalian</h6> |
|
|
|
@ -113,6 +113,32 @@
|
|
|
|
|
<canvas id="ChartAssetStatus" style="width: 100px; height: 68px;"></canvas> |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
</div> --}} |
|
|
|
|
<!-- Area Bar Chart --> |
|
|
|
|
{{-- <div class="col-xl-7 col-lg-7"> |
|
|
|
|
<div class="card shadow mb-4" style="max-height: 600px;"> |
|
|
|
|
<div class="card-header py-3 d-flex flex-row align-items-center justify-content-between"> |
|
|
|
|
<h6 class="m-0 font-weight-bold text-primary">Grafik Peminjaman VS Pengembalian</h6> |
|
|
|
|
</div> |
|
|
|
|
@php |
|
|
|
|
$chartData = app('App\Http\Controllers\HomeController')->generateChartData(); |
|
|
|
|
@endphp |
|
|
|
|
<div class="card-body" style="height: 80%;"> |
|
|
|
|
<label for="yearFilter">Pilih Tahun:</label> |
|
|
|
|
<select id="yearFilter" class="form-control"> |
|
|
|
|
@foreach ($chartData['years'] as $year) |
|
|
|
|
@if ($chartData['exitData'][$loop->index] || $chartData['enterData'][$loop->index]) |
|
|
|
|
<option value="{{ $year }}">{{ $year }}</option> |
|
|
|
|
@endif |
|
|
|
|
@endforeach |
|
|
|
|
</select> |
|
|
|
|
|
|
|
|
|
<!-- Add a container div for the chart --> |
|
|
|
|
<div id="chartContainer" style="position: relative; height: 100%;"> |
|
|
|
|
<canvas id="ChartAssetStatus"></canvas> |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
|
|
|
|
|
<!-- Area Pie Chart --> |
|
|
|
@ -139,9 +165,114 @@
|
|
|
|
|
<canvas id="myPieChartsiopas"></canvas> |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
</div> --}} |
|
|
|
|
</div> |
|
|
|
|
{{-- <div class="row"> |
|
|
|
|
<div class="col-6"> |
|
|
|
|
<div class="card shadow mb-4" style="max-height: 600px;"> |
|
|
|
|
<div class="card-header py-3 d-flex flex-row align-items-center justify-content-between"> |
|
|
|
|
<h6 class="m-0 font-weight-bold text-primary">Grafik Peminjaman VS Pengembalian</h6> |
|
|
|
|
</div> |
|
|
|
|
@php |
|
|
|
|
$chartData = app('App\Http\Controllers\HomeController')->generateChartData(); |
|
|
|
|
@endphp |
|
|
|
|
<div class="card-body" style="height: 80%;"> |
|
|
|
|
<label for="yearFilter">Pilih Tahun:</label> |
|
|
|
|
<select id="yearFilter" class="form-control"> |
|
|
|
|
@foreach ($chartData['years'] as $year) |
|
|
|
|
@if ($chartData['exitData'][$loop->index] || $chartData['enterData'][$loop->index]) |
|
|
|
|
<option value="{{ $year }}">{{ $year }}</option> |
|
|
|
|
@endif |
|
|
|
|
@endforeach |
|
|
|
|
</select> |
|
|
|
|
|
|
|
|
|
<!-- Add a container div for the chart --> |
|
|
|
|
<div id="chartContainer" style="position: relative; height: 100%;"> |
|
|
|
|
<canvas id="ChartAssetStatus"></canvas> |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
<div class="col-6"> |
|
|
|
|
<div class="card shadow mb-4"> |
|
|
|
|
<!-- Card Header - Dropdown --> |
|
|
|
|
<div class="card-header py-3 d-flex flex-row align-items-center justify-content-between"> |
|
|
|
|
<h6 class="m-0 font-weight-bold text-primary">Grafik Pengadaan Peti</h6> |
|
|
|
|
</div> |
|
|
|
|
@php |
|
|
|
|
$chartDataPie = app('App\Http\Controllers\HomeController')->generateChartDataPie(); |
|
|
|
|
@endphp |
|
|
|
|
|
|
|
|
|
<div class="card-body"> |
|
|
|
|
<label for="yearFilterPie">Pilih Tahun:</label> |
|
|
|
|
<select id="yearFilterPie" class="form-control"> |
|
|
|
|
@foreach ($chartDataPie['years'] as $year) |
|
|
|
|
@if (count($chartDataPie['enterData']) > 0 && $chartDataPie['enterData'][$loop->index]) |
|
|
|
|
<option value="{{ $year }}">{{ $year }}</option> |
|
|
|
|
@endif |
|
|
|
|
@endforeach |
|
|
|
|
</select> |
|
|
|
|
|
|
|
|
|
<canvas id="myPieChartsiopas"></canvas> |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
</div> --}} |
|
|
|
|
<div class="row"> |
|
|
|
|
<div class="col-6"> |
|
|
|
|
<div class="card shadow mb-4" style="height: 600px;"> |
|
|
|
|
<div class="card-header py-3 d-flex flex-row align-items-center justify-content-between"> |
|
|
|
|
<h6 class="m-0 font-weight-bold text-primary">Grafik Peminjaman VS Pengembalian</h6> |
|
|
|
|
</div> |
|
|
|
|
@php |
|
|
|
|
$chartData = app('App\Http\Controllers\HomeController')->generateChartData(); |
|
|
|
|
@endphp |
|
|
|
|
<div class="card-body" style="height: 100%; display: flex; flex-direction: column;"> |
|
|
|
|
<label for="yearFilter">Pilih Tahun:</label> |
|
|
|
|
<select id="yearFilter" class="form-control"> |
|
|
|
|
@foreach ($chartData['years'] as $year) |
|
|
|
|
@if ($chartData['exitData'][$loop->index] || $chartData['enterData'][$loop->index]) |
|
|
|
|
<option value="{{ $year }}">{{ $year }}</option> |
|
|
|
|
@endif |
|
|
|
|
@endforeach |
|
|
|
|
</select> |
|
|
|
|
|
|
|
|
|
<!-- Add a container div for the chart with 100% height --> |
|
|
|
|
<div id="chartContainer" style="position: relative; flex: 1;"> |
|
|
|
|
<canvas id="ChartAssetStatus"></canvas> |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
<div class="col-6"> |
|
|
|
|
<div class="card shadow mb-4" style="height: 600px;"> |
|
|
|
|
<!-- Card Header - Dropdown --> |
|
|
|
|
<div class="card-header py-3 d-flex flex-row align-items-center justify-content-between"> |
|
|
|
|
<h6 class="m-0 font-weight-bold text-primary">Grafik Pengadaan Peti</h6> |
|
|
|
|
</div> |
|
|
|
|
@php |
|
|
|
|
$chartDataPie = app('App\Http\Controllers\HomeController')->generateChartDataPie(); |
|
|
|
|
@endphp |
|
|
|
|
|
|
|
|
|
<div class="card-body" style="height: 100%; display: flex; flex-direction: column;"> |
|
|
|
|
<label for="yearFilterPie">Pilih Tahun:</label> |
|
|
|
|
<select id="yearFilterPie" class="form-control"> |
|
|
|
|
@foreach ($chartDataPie['years'] as $year) |
|
|
|
|
@if (count($chartDataPie['enterData']) > 0 && $chartDataPie['enterData'][$loop->index]) |
|
|
|
|
<option value="{{ $year }}">{{ $year }}</option> |
|
|
|
|
@endif |
|
|
|
|
@endforeach |
|
|
|
|
</select> |
|
|
|
|
|
|
|
|
|
<div id="chartContainerPie" style="position: relative; flex: 1;"> |
|
|
|
|
<canvas id="myPieChartsiopas"></canvas> |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@push('script') |
|
|
|
|
<!-- script pie chart --> |
|
|
|
|
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script> |
|
|
|
@ -220,7 +351,7 @@
|
|
|
|
|
</script> |
|
|
|
|
|
|
|
|
|
<!-- script bar chart --> |
|
|
|
|
<script> |
|
|
|
|
{{-- <script> |
|
|
|
|
document.addEventListener('DOMContentLoaded', function() { |
|
|
|
|
var ctx = document.getElementById('ChartAssetStatus').getContext('2d'); |
|
|
|
|
var myChart; |
|
|
|
@ -291,8 +422,104 @@
|
|
|
|
|
updateChart(selectedYear); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
</script> --}} |
|
|
|
|
<script> |
|
|
|
|
document.addEventListener('DOMContentLoaded', function() { |
|
|
|
|
var ctx = document.getElementById('ChartAssetStatus').getContext('2d'); |
|
|
|
|
var myChart; |
|
|
|
|
var chartData = @json($chartData); |
|
|
|
|
|
|
|
|
|
function updateChart(selectedYear) { |
|
|
|
|
var selectedYearIndex = chartData.years.indexOf(selectedYear); |
|
|
|
|
|
|
|
|
|
// Mengambil data berdasarkan tahun yang dipilih |
|
|
|
|
var updatedExitData = chartData.exitData[selectedYearIndex]; |
|
|
|
|
var updatedEnterData = chartData.enterData[selectedYearIndex]; |
|
|
|
|
|
|
|
|
|
// Memperbarui chart hanya dengan data tahun yang dipilih |
|
|
|
|
myChart.data.labels = chartData.monthNames; |
|
|
|
|
myChart.data.datasets[0].data = updatedExitData; |
|
|
|
|
myChart.data.datasets[1].data = updatedEnterData; |
|
|
|
|
|
|
|
|
|
myChart.update(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Add a function to update chart size based on parent container size |
|
|
|
|
function updateChartSize() { |
|
|
|
|
var container = document.getElementById('chartContainer'); |
|
|
|
|
var parentWidth = container.clientWidth; |
|
|
|
|
var parentHeight = container.clientHeight; |
|
|
|
|
|
|
|
|
|
// Set canvas dimensions based on container size |
|
|
|
|
ctx.canvas.width = parentWidth; |
|
|
|
|
ctx.canvas.height = parentHeight; |
|
|
|
|
|
|
|
|
|
// Update the chart |
|
|
|
|
myChart.update(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
myChart = new Chart(ctx, { |
|
|
|
|
type: 'bar', |
|
|
|
|
data: { |
|
|
|
|
labels: chartData.monthNames, |
|
|
|
|
datasets: [{ |
|
|
|
|
label: 'Peminjaman', |
|
|
|
|
data: chartData.exitData[0], |
|
|
|
|
backgroundColor: 'rgba(75, 192, 192, 0.2)', |
|
|
|
|
borderColor: 'rgba(75, 192, 192, 1)', |
|
|
|
|
borderWidth: 1 |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
label: 'Pengembalian', |
|
|
|
|
data: chartData.enterData[0], |
|
|
|
|
backgroundColor: 'rgba(255, 159, 64, 0.2)', |
|
|
|
|
borderColor: 'rgba(255, 159, 64, 1)', |
|
|
|
|
borderWidth: 1 |
|
|
|
|
} |
|
|
|
|
] |
|
|
|
|
}, |
|
|
|
|
options: { |
|
|
|
|
scales: { |
|
|
|
|
y: { |
|
|
|
|
beginAtZero: true |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
responsive: true, |
|
|
|
|
maintainAspectRatio: false // Allow chart to adjust size freely |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
// Event listener for year filter change |
|
|
|
|
var yearFilter = document.getElementById('yearFilter'); |
|
|
|
|
yearFilter.addEventListener('change', function() { |
|
|
|
|
var selectedYear = yearFilter.value; |
|
|
|
|
updateChart(selectedYear); |
|
|
|
|
// Simpan tahun yang dipilih ke local storage |
|
|
|
|
localStorage.setItem('selectedYear', selectedYear); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
// Kondisi Pertama: Setelah halaman dimuat |
|
|
|
|
// Coba baca tahun yang disimpan di local storage |
|
|
|
|
var selectedYear = localStorage.getItem('selectedYear'); |
|
|
|
|
if (selectedYear) { |
|
|
|
|
yearFilter.value = selectedYear; |
|
|
|
|
updateChart(selectedYear); |
|
|
|
|
} else { |
|
|
|
|
// Jika tidak ada tahun yang disimpan, pilih tahun saat ini |
|
|
|
|
selectedYear = new Date().getFullYear(); |
|
|
|
|
yearFilter.value = selectedYear; |
|
|
|
|
updateChart(selectedYear); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Event listener for window resize |
|
|
|
|
window.addEventListener('resize', updateChartSize); |
|
|
|
|
|
|
|
|
|
// Set initial chart size |
|
|
|
|
updateChartSize(); |
|
|
|
|
}); |
|
|
|
|
</script> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<!-- script generate report --> |
|
|
|
|
<script> |
|
|
|
|
function downloadReport(routeName) { |
|
|
|
|