You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
485 lines
24 KiB
485 lines
24 KiB
@extends('layouts.main') |
|
@section('content') |
|
@if (auth()->user()->role_id == 1) |
|
<div class="d-sm-flex align-items-center justify-content-between mb-4"> |
|
<h1 class="h3 mb-0 text-gray-800">Dashboard</h1> |
|
<a href="#" id="generateReportBtn" class="d-none d-sm-inline-block btn btn-sm btn-primary shadow-sm"><i |
|
class="fas fa-download fa-sm text-white-50"></i> Generate Report</a> |
|
</div> |
|
<div class="row"> |
|
<div class="col-xl-3 col-md-6 mb-4"> |
|
<div class="card border-left-primary shadow h-100 py-2"> |
|
<div class="card-body"> |
|
<div class="row no-gutters align-items-center"> |
|
<div class="col mr-2"> |
|
<div class="text-xs font-weight-bold text-primary text-uppercase mb-1" |
|
style="font-size: 14px;"> |
|
<strong>Pengadaan</strong> |
|
</div> |
|
<div class="h5 mb-0 font-weight-bold text-gray-800" style="font-size: 25px;"> |
|
{{ $jumlahPeti }} |
|
</div> |
|
</div> |
|
<div class="col-auto"> |
|
<i class="fas fa-clipboard-list fa-2x text-gray-300"></i> |
|
</div> |
|
</div> |
|
</div> |
|
</div> |
|
</div> |
|
|
|
<!-- Earnings (Monthly) Card Example --> |
|
<div class="col-xl-3 col-md-6 mb-4"> |
|
<div class="card border-left-success shadow h-100 py-2"> |
|
<div class="card-body"> |
|
<div class="row no-gutters align-items-center"> |
|
<div class="col mr-2"> |
|
<div class="text-xs font-weight-bold text-success text-uppercase mb-1" |
|
style="font-size: 14px;"> |
|
<strong>Peminjaman</strong> |
|
</div> |
|
<div class="h5 mb-0 font-weight-bold text-gray-800" style="font-size: 25px;"> |
|
{{ $jumlahPeminjaman }}</div> |
|
</div> |
|
<div class="col-auto"> |
|
<i class="fas fa-dollar-sign fa-2x text-gray-300"></i> |
|
</div> |
|
</div> |
|
</div> |
|
</div> |
|
</div> |
|
|
|
<!-- Earnings (Monthly) Card Example --> |
|
<div class="col-xl-3 col-md-6 mb-4"> |
|
<div class="card border-left-info shadow h-100 py-2"> |
|
<div class="card-body"> |
|
<div class="row no-gutters align-items-center"> |
|
<div class="col mr-2"> |
|
<div class="text-xs font-weight-bold text-info text-uppercase mb-1" |
|
style="font-size: 14px;"> |
|
<strong>Pengembalian</strong> |
|
</div> |
|
<div class="h5 mb-0 font-weight-bold text-gray-800" style="font-size: 25px;"> |
|
{{ $jumlahPengembalian }}</div> |
|
</div> |
|
<div class="col-auto"> |
|
<i class="fas fa-calendar fa-2x text-gray-300"></i> |
|
</div> |
|
</div> |
|
</div> |
|
</div> |
|
</div> |
|
|
|
<!-- Pending Requests Card Example --> |
|
<div class="col-xl-3 col-md-6 mb-4"> |
|
<div class="card border-left-warning shadow h-100 py-2"> |
|
<div class="card-body"> |
|
<div class="row no-gutters align-items-center"> |
|
<div class="col mr-2"> |
|
<div class="text-xs font-weight-bold text-warning text-uppercase mb-1" |
|
style="font-size: 13px;"> |
|
<strong>Reminder Pengembalian</strong> |
|
</div> |
|
<div class="h5 mb-0 font-weight-bold text-gray-800" style="font-size: 25px;"> |
|
{{ $reminder }}</div> |
|
</div> |
|
<div class="col-auto"> |
|
<i class="fas fa-calendar fa-2x text-gray-300"></i> |
|
</div> |
|
</div> |
|
</div> |
|
</div> |
|
</div> |
|
</div> |
|
{{-- <div class="row" style="height: 100%;"> |
|
<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> --}} |
|
{{-- <div class="row" style="height: 100%;"> |
|
<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> |
|
|
|
<!-- Add a container div for the pie chart with 100% height and resize both --> |
|
<div id="chartContainerPie" style="position: relative; flex: 1; resize: both; overflow: auto;"> |
|
<canvas id="myPieChartsiopas" style="height: 100%; width: 100%;"></canvas> |
|
</div> |
|
</div> |
|
</div> |
|
</div> |
|
</div> --}} |
|
<div class="row" style="height: 100%;"> |
|
<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; overflow: hidden; text-align: center; margin: 0 5%;"> |
|
<canvas id="myPieChartsiopas" |
|
style="max-width: 100%; max-height: 100%; width: auto; height: auto;"></canvas> |
|
</div> --}} |
|
<div id="chartContainerPie" |
|
style="position: relative; flex: 1; overflow: hidden; text-align: center; margin: 0 5%;"> |
|
<canvas id="myPieChartsiopas" |
|
style="max-width: 100%; max-height: 100%; width: auto; height: auto; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);"></canvas> |
|
</div> |
|
|
|
|
|
|
|
</div> |
|
</div> |
|
</div> |
|
</div> |
|
|
|
|
|
|
|
|
|
|
|
@push('script') |
|
<!-- script pie chart --> |
|
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script> |
|
<script> |
|
// Function to update the pie chart based on selected year |
|
function updatePieChart(selectedYear) { |
|
// Call the controller function to get data for the selected year |
|
var chartDataPie = {!! json_encode(app('App\Http\Controllers\HomeController')->generateChartDataPie()) !!}; |
|
var yearIndex = chartDataPie.years.indexOf(selectedYear); |
|
|
|
// Update the pie chart data |
|
myPieChart.data.datasets[0].data = chartDataPie.enterData[yearIndex]; |
|
myPieChart.update(); |
|
|
|
// Save selected year to local storage |
|
localStorage.setItem('selectedYearPie', selectedYear); |
|
} |
|
|
|
// Initial chart data |
|
var initialChartDataPie = {!! json_encode(app('App\Http\Controllers\HomeController')->generateChartDataPie()) !!}; |
|
|
|
// Get the canvas element for the pie chart |
|
var ctxPie = document.getElementById("myPieChartsiopas").getContext('2d'); |
|
|
|
// Create the initial pie chart instance |
|
var myPieChart = new Chart(ctxPie, { |
|
type: 'pie', |
|
data: { |
|
labels: initialChartDataPie.monthNames, |
|
datasets: [{ |
|
data: initialChartDataPie.enterData[0], |
|
backgroundColor: ["#4e73df", "#1cc88a", "#36b9cc", "#ff6384", "#ff9f40", "#9966ff", |
|
"#cc65fe", |
|
"#ffcc29", "#a4e56d", "#ff3d00", "#9c9c9c", "#0d47a1" |
|
], |
|
}] |
|
}, |
|
options: { |
|
responsive: true, |
|
plugins: { |
|
legend: { |
|
position: 'right', |
|
maxHeight: 200, |
|
}, |
|
tooltip: { |
|
callbacks: { |
|
label: function(context) { |
|
var label = context.label || ''; |
|
if (label) { |
|
label += ' : '; |
|
} |
|
label += Math.round(context.parsed * 1) + ' Peti'; |
|
return label; |
|
} |
|
} |
|
} |
|
} |
|
}, |
|
}); |
|
|
|
// Event listener for year filter change |
|
document.getElementById('yearFilterPie').addEventListener('change', function() { |
|
var selectedYear = this.value; |
|
updatePieChart(selectedYear); |
|
}); |
|
|
|
// On page load, try to retrieve the selected year from local storage |
|
document.addEventListener('DOMContentLoaded', function() { |
|
var selectedYear = localStorage.getItem('selectedYearPie'); |
|
if (selectedYear) { |
|
// If a year is found, set the dropdown value and update the chart |
|
document.getElementById('yearFilterPie').value = selectedYear; |
|
updatePieChart(selectedYear); |
|
} |
|
}); |
|
</script> |
|
|
|
<!-- script bar chart --> |
|
<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) { |
|
var exportUrl = '{{ url('dashboard') }}/' + routeName; |
|
|
|
var link = document.createElement('a'); |
|
link.href = exportUrl; |
|
link.download = 'nama_file_report.xlsx'; // Ganti dengan nama file yang diinginkan |
|
link.target = '_blank'; |
|
|
|
link.click(); |
|
} |
|
|
|
document.getElementById('generateReportBtn').addEventListener('click', function() { |
|
downloadReport('Pettern_Lot_Peti/export'); |
|
downloadReport('StokOpname/export'); |
|
}); |
|
</script> |
|
|
|
{{-- <script> |
|
var chartContainerPie = document.getElementById('chartContainerPie'); |
|
var pieChartCanvas = document.getElementById('myPieChartsiopas'); |
|
|
|
function updatePieChartSize() { |
|
var containerWidth = chartContainerPie.clientWidth * 0.9; // 90% of container width |
|
var containerHeight = chartContainerPie.clientHeight; |
|
|
|
// Set canvas dimensions based on container size |
|
pieChartCanvas.width = containerWidth; |
|
pieChartCanvas.height = containerHeight; |
|
} |
|
|
|
// Add event listener for window resize |
|
window.addEventListener('resize', updatePieChartSize); |
|
|
|
// Initial setup |
|
updatePieChartSize(); |
|
</script> --}} |
|
@endpush |
|
@elseif(auth()->user()->role_id == 2) |
|
@include('pages.user.dashboard.index') |
|
@endif |
|
@endsection
|
|
|