MIF_E31231060/resources/views/detail-rencana-pengadaan.bl...

1453 lines
44 KiB
PHP

<!DOCTYPE html>
<html lang="id">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>DETAIL RENCANA PENGADAAN - UDD PMI KABUPATEN JEMBER</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="icon" type="image/png" href="{{ asset('images/logo-pmi.png') }}">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.2/css/all.min.css">
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700&display=swap" rel="stylesheet">
<style>
body {
font-family: 'Poppins', sans-serif;
background: #f7faff;
margin: 0;
padding: 28px;
box-sizing: border-box;
overflow-x: hidden;
color: #1f2937;
}
.page-card {
width: 100%;
background: rgba(255, 255, 255, 0.92);
backdrop-filter: blur(14px);
border-radius: 8px;
border: 1px solid rgba(255, 95, 95, 0.6);
box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
display: flex;
flex-direction: column;
min-height: 100vh;
overflow: hidden;
}
.header {
position: relative;
display: flex;
align-items: center;
gap: 14px;
background: linear-gradient(135deg, #d32f2f 0%, #b71c1c 45%, #7f0000 100%);
color: white;
padding: 20px 30px;
overflow: hidden;
border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.header::before {
content: "";
position: absolute;
top: -60px;
right: -50px;
width: 180px;
height: 180px;
background: radial-gradient(circle, rgba(255, 255, 255, .18) 0%, transparent 70%);
border-radius: 50%;
}
.header h1 {
font-size: 18px;
font-weight: 700;
letter-spacing: .3px;
}
.header-back {
margin-left: auto;
width: 42px;
height: 42px;
border-radius: 5px;
display: flex;
align-items: center;
justify-content: center;
color: white;
text-decoration: none;
background: linear-gradient(135deg, #22c55e, #15803d);
border: 1px solid rgba(255, 255, 255, .18);
transition: .2s;
position: relative;
z-index: 1000;
cursor: pointer;
}
.header-back:hover {
background: rgba(255, 255, 255, 0.41);
transform: translateX(-2px);
}
.header-icon {
position: relative;
font-size: 22px;
width: 50px;
height: 50px;
border-radius: 5px;
display: flex;
align-items: center;
justify-content: center;
color: rgba(255, 255, 255, .96);
background: linear-gradient(135deg, #22c55e, #15803d);
border: 1px solid rgba(255, 255, 255, .18);
backdrop-filter: blur(10px);
box-shadow:
inset 0 1px 1px rgba(255, 255, 255, .24),
inset 0 -1px 1px rgba(255, 255, 255, .05),
0 10px 18px rgba(0, 0, 0, .16),
0 4px 8px rgba(0, 0, 0, .10);
}
.header-icon i {
font-size: 20px;
}
.content {
padding: 16px;
flex: 1;
display: flex;
flex-direction: column;
gap: 14px;
min-height: 0;
}
.card {
background: rgba(255, 255, 255, 0.92);
border-radius: 8px;
border: 1px solid rgba(239, 68, 68, 0.15);
box-shadow: 0 10px 25px rgba(15, 23, 42, 0.06);
padding: 16px;
}
.card h2 {
margin: 0 0 18px;
font-size: 18px;
font-weight: 700;
color: #9a0007;
}
.info-section {
padding: 8px 4px 30px;
border-bottom: 1px solid #d5d7da;
}
.info-section h2 {
margin-bottom: 14px;
padding-left: 10px;
color: #9a0007;
font-weight: 600;
border-left: 4px solid #d32f2f;
}
.ringkasan-section {
padding: 8px 4px;
display: flex;
flex-direction: column;
min-height: 0;
height: 100%;
}
.ringkasan-section,
.chart-section {
height: 100%;
min-height: 0;
display: flex;
flex-direction: column;
}
.ringkasan-section h2 {
margin-bottom: 14px;
padding-left: 10px;
color: #9a0007;
font-weight: 600;
border-left: 4px solid #d32f2f;
}
.ringkasan-section .table-wrap {
border-radius: 10px;
border: 1px solid #b4272743;
box-shadow: 0 6px 18px rgba(72, 0, 0, 0.08);
}
.ringkasan-section .table-wrap th {
text-align: left;
}
.section-head {
display: flex;
justify-content: space-between;
align-items: center;
}
.section-head h2 {
margin: 0;
}
.toggle-btn {
background: linear-gradient(135deg, #d32f2f, #9a0007);
color: white;
border: none;
padding: 8px 14px;
border-radius: 8px;
font-weight: 600;
cursor: pointer;
transition: .25s;
}
.toggle-btn:hover {
transform: translateY(-2px);
box-shadow: 0 10px 20px rgba(211, 47, 47, .25);
}
.hidden-box {
display: none !important;
}
.chart-section {
overflow: visible;
padding: 8px 4px;
display: flex;
flex-direction: column;
min-height: 0;
}
.chart-section h2 {
margin-bottom: 14px;
padding-left: 10px;
color: #9a0007;
font-weight: 600;
border-left: 4px solid #d32f2f;
}
.chart-box {
background: white;
border-radius: 12px;
padding: 16px 12px 30px;
border: 1px solid #f1caca;
flex: 1;
height: 100%;
display: flex;
align-items: stretch;
gap: 10px;
position: relative;
overflow: visible;
min-height: 0;
}
.chart-box::before {
content: "";
position: absolute;
left: 40px;
right: 10px;
top: 16px;
bottom: 30px;
background-image: linear-gradient(to top, rgba(0, 0, 0, 0.14) 1px, transparent 1px);
background-size: 100% 25%;
pointer-events: none;
}
.y-axis {
display: flex;
flex-direction: column;
justify-content: space-between;
font-size: 11px;
color: #9ca3af;
padding-bottom: 20px;
}
.legend-box {
display: flex;
gap: 16px;
align-items: center;
margin-bottom: 10px;
padding-left: 6px;
}
.legend-item {
display: flex;
align-items: center;
gap: 6px;
font-size: 12px;
color: #6b7280;
font-weight: 500;
}
.legend-color {
width: 14px;
height: 14px;
border-radius: 2px;
}
.legend-actual {
background: #E31E27;
}
.legend-predict {
background: #8E1733;
}
.bar {
overflow: visible;
width: 42px;
position: relative;
z-index: 1;
display: flex;
flex-direction: column-reverse;
border-radius: 6px 6px 0 0;
transition: .25s ease;
animation: growBar .6s ease forwards;
transform-origin: bottom;
}
.bar-actual {
width: 100%;
background: #E31E27;
position: relative;
border-radius: 0;
}
.bar.single .bar-actual {
border-radius: 6px 6px 0 0;
}
.bar-predict {
width: 100%;
background: #8E1733;
border-radius: 6px 6px 0 0;
position: relative;
}
.bar.actual-only {
background: #dc2626;
border-radius: 6px 6px 0 0;
}
.bar::before {
content: "";
position: absolute;
inset: 0;
border-radius: 6px 6px 0 0;
background: linear-gradient(to bottom,
rgba(255, 255, 255, 0.45),
transparent 35%);
}
.bar:hover {
transform: scale(1.04);
z-index: 50;
box-shadow:
0 14px 26px rgba(124, 58, 237, 0.25),
0 10px 20px rgba(220, 38, 38, 0.22);
}
.bar span {
position: absolute;
bottom: -28px;
width: 100%;
text-align: center;
font-size: 12px;
color: #9a0007;
}
.bar .tooltip {
position: absolute;
bottom: calc(100% + 12px);
left: 50%;
transform: translateX(-50%);
background: #C52026;
color: white;
font-size: 11px;
font-weight: 600;
padding: 8px 10px;
border-radius: 8px;
white-space: nowrap;
opacity: 0;
visibility: hidden;
transition: all .2s ease;
pointer-events: none;
z-index: 999;
box-shadow: 0 10px 25px rgba(0, 0, 0, 0.18);
}
.bar .tooltip::after {
content: "";
position: absolute;
top: 100%;
left: 50%;
transform: translateX(-50%);
border: 5px solid transparent;
border-top-color: #C52026;
}
.bar:hover .tooltip {
opacity: 1;
visibility: visible;
}
.bars {
overflow: visible;
flex: 1;
display: flex;
align-items: flex-end;
gap: 14px;
}
.bar-group {
overflow: visible;
flex: 1;
display: flex;
align-items: flex-end;
justify-content: center;
position: relative;
height: 100%;
}
.bar-group-label {
position: absolute;
bottom: -28px;
width: 100%;
text-align: center;
font-size: 12px;
color: #9a0007;
}
.bar-year-label {
position: absolute;
bottom: -52px;
width: 100%;
text-align: center;
font-size: 11px;
color: #950606;
font-weight: 600;
}
.grid-top {
display: grid;
grid-template-columns: 1fr;
gap: 12px;
margin-bottom: 10px;
}
.grid-middle {
display: grid;
grid-template-columns: 1fr 1.2fr;
gap: 12px;
height: 450px;
align-items: stretch;
}
#tableView::before {
display: none;
}
#tableView thead th {
background: #dc2626;
color: white;
position: sticky !important;
top: 0;
z-index: 3;
}
#tableView thead th::after {
content: "";
position: absolute;
top: 0;
left: 0;
right: 0;
height: 40%;
background: linear-gradient(to bottom, rgba(180, 0, 0, 0.5), transparent);
pointer-events: none;
}
#tableView {
border-radius: 12px;
overflow: visible;
display: flex;
flex-direction: column;
flex: 1;
min-height: 0;
}
#tableView thead th:first-child {
border-top-left-radius: 5px;
}
#tableView thead th:last-child {
border-top-right-radius: 5px;
}
#tableView thead th {
position: relative;
overflow: hidden;
}
.table-scroll {
flex: 1;
min-height: 0;
overflow-y: auto;
overflow-x: auto;
max-height: 100%;
}
.table-scroll thead th {
position: sticky;
top: 0;
z-index: 2;
}
.table-scroll::-webkit-scrollbar {
width: 6px;
}
.table-scroll::-webkit-scrollbar-thumb {
background: #d32f2f;
border-radius: 10px;
}
.riwayat-table {
border-collapse: collapse;
}
.riwayat-table th,
.riwayat-table td {
width: auto !important;
border: 1px solid #e5e7eb;
width: 20%;
}
.riwayat-table td {
font-weight: 500 !important;
}
.riwayat-table thead th {
border-color: #b91c1c;
}
.riwayat-table tbody tr:last-child td {
border-bottom: none;
}
.riwayat-table tbody tr:nth-child(odd) {
background: #fcfcfc;
}
.riwayat-table tbody tr:nth-child(even) {
background: #f7f7f7;
}
.riwayat-table tbody tr:hover {
background: #efefef;
transition: 0.2s ease;
}
.info-grid {
display: grid;
grid-template-columns: repeat(2, 1fr);
gap: 14px;
}
.info-box {
position: relative;
display: flex;
align-items: center;
gap: 18px;
background: rgba(255, 255, 255, 0.96);
border-radius: 8px;
padding: 22px 20px;
overflow: hidden;
transition: all .28s ease;
backdrop-filter: blur(12px);
box-shadow:
0 10px 30px rgba(15, 23, 42, 0.06),
0 2px 6px rgba(15, 23, 42, 0.04);
}
.info-box::before {
content: "";
position: absolute;
inset: 0;
background:
linear-gradient(135deg,
rgba(255, 255, 255, 0.55),
rgba(255, 255, 255, 0.05));
pointer-events: none;
}
.info-box:hover {
transform: translateY(-5px);
box-shadow:
0 18px 40px rgba(15, 23, 42, 0.10),
0 4px 10px rgba(15, 23, 42, 0.05);
}
.icon-box {
width: 56px;
height: 56px;
min-width: 56px;
border-radius: 8px;
display: flex;
align-items: center;
justify-content: center;
font-size: 22px;
position: relative;
z-index: 2;
box-shadow:
inset 0 1px 0 rgba(255, 255, 255, 0.5),
0 8px 18px rgba(0, 0, 0, 0.08);
}
.info-box>div:last-child {
position: relative;
z-index: 2;
}
.info-label {
font-size: 11px;
font-weight: 600;
text-transform: uppercase;
letter-spacing: 1px;
color: #9ca3af;
margin-bottom: 4px;
}
.info-value {
font-size: 18px;
font-weight: 700;
color: #111827;
line-height: 1.3;
}
.info-value.status-danger {
color: #dc2626;
}
.info-value.status-success {
color: #16a34a;
}
.icon-dark {
background: linear-gradient(135deg, #e5e7eb, #d1d5db);
color: #374151;
}
.icon-blue {
background: linear-gradient(135deg, #e0edff, #c7dbff);
color: #1d4ed8;
/* background: linear-gradient(135deg, #e0f2fe, #bae6fd);
color: #0369a1; */
}
.icon-purple {
background: linear-gradient(135deg, #f3e8ff, #e9d5ff);
color: #7c3aed;
}
.icon-orange {
background: linear-gradient(135deg, #fff4e6, #ffe4c7);
color: #c2410c;
}
.icon-red {
background: linear-gradient(135deg, #ffe4e6, #fecdd3);
color: #b91c1c;
}
.icon-green {
background: linear-gradient(135deg, #dcfce7, #bbf7d0);
color: #166534;
}
.info-label {
font-size: 11px;
color: #9ca3af;
letter-spacing: .3px;
}
.info-value {
font-size: 16px;
font-weight: 700;
margin-top: 2px;
color: #111827;
}
.custom-info {
grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
gap: 18px;
}
.danger {
color: #dc2626;
}
.success {
color: #16a34a;
}
.warning {
color: #ca8a04;
}
.table-wrap {
background: #fff;
border-radius: 8px;
border: 1px solid rgba(211, 47, 47, 0.2);
box-shadow: 0 8px 25px rgba(72, 0, 0, 0.08);
overflow: hidden;
display: flex;
flex-direction: column;
height: 100%;
}
.table-wrap table {
height: 100%;
}
.table-wrap tbody {
height: 100%;
}
table {
width: 100%;
border-collapse: collapse;
}
th {
background: linear-gradient(180deg, #fff5f5, #ffeaea);
color: #991b1b;
font-weight: 700;
padding: 14px;
font-size: 13px;
}
td {
padding: 14px;
font-size: 13px;
border-bottom: 1px solid #eee;
}
tbody tr:nth-child(even) {
background: #fafafa;
}
tbody tr:hover {
background: linear-gradient(90deg, rgba(255, 245, 245, .9), #fff);
}
.ringkasan-card th {
background: #ffd5d53e;
color: #9a0007;
}
.ringkasan-card tbody tr:hover {
background: #f9fafb;
}
.badge {
padding: 6px 14px;
border-radius: 8px;
font-size: 12px;
font-weight: 600;
display: inline-flex;
align-items: center;
}
.badge-red {
background: linear-gradient(135deg, #fee2e2, #fecaca);
color: #991b1b;
}
.badge-green {
background: linear-gradient(135deg, #dcfce7, #bbf7d0);
color: #14532d;
}
.ringkasan-card {
background: white;
border-radius: 10px;
padding: 16px;
border: 1px solid rgba(0, 0, 0, 0.09);
box-shadow: 0 8px 25px rgba(0, 0, 0, 0.08);
}
.badge-body {
padding: auto;
border-radius: 10px;
font-weight: 700;
font-size: 13px;
display: inline-flex;
align-items: center;
justify-content: center;
min-width: 90px;
text-align: center;
border: 1px solid transparent;
}
.note-advanced {
display: flex;
align-items: center;
gap: 14px;
padding: 16px;
border-radius: 10px;
background: linear-gradient(135deg, #fff9db, #fef3c7);
border: 1px solid #fcd34d;
box-shadow: 0 6px 16px rgba(245, 158, 11, 0.08);
}
.note-icon {
width: 55px;
height: 42px;
border-radius: 10px;
display: flex;
align-items: center;
justify-content: center;
background: linear-gradient(135deg, #f59e0b, #fbbf24);
color: white;
font-size: 18px;
box-shadow: 0 6px 14px rgba(245, 158, 11, 0.25);
}
.note-title {
font-weight: 700;
font-size: 14px;
color: #92400e;
margin-bottom: 4px;
}
.note-text {
font-size: 13px;
color: #78350f;
line-height: 1.5;
}
/* =========================
RESPONSIVE BREAKPOINTS
========================= */
@media (max-width: 767px) {
.riwayat-table {
min-width: 700px;
}
}
@media (min-width: 1600px) {
.content {
padding: 24px;
}
.grid-middle {
grid-template-columns: 1fr 1.4fr;
height: 520px;
}
.bar {
width: 52px;
}
.info-value {
font-size: 18px;
}
}
@media (max-width: 1599px) {
.grid-middle {
height: 480px;
}
}
@media (max-width: 1399px) {
.grid-middle {
grid-template-columns: 1fr 1.1fr;
height: 450px;
}
.bar {
width: 38px;
}
}
@media (max-width: 1199px) {
body {
padding: 18px;
}
.custom-info {
grid-template-columns: repeat(2, 1fr);
}
.grid-middle {
grid-template-columns: 1fr;
height: auto;
}
.ringkasan-section,
.chart-section {
height: auto;
}
.chart-box {
min-height: 420px;
}
}
@media (max-width: 991px) {
.header {
padding: 18px;
}
.header h1 {
font-size: 16px;
}
.custom-info {
grid-template-columns: repeat(2, 1fr);
}
.chart-box {
min-height: 380px;
}
.bars {
gap: 10px;
}
.bar {
width: 30px;
}
}
@media (max-width: 767px) {
body {
padding: 12px;
}
.content {
padding: 12px;
}
.custom-info,
.info-grid {
grid-template-columns: 1fr;
}
.info-box {
padding: 16px;
}
.icon-box {
width: 48px;
height: 48px;
min-width: 48px;
font-size: 18px;
}
.info-value {
font-size: 15px;
}
.chart-box {
overflow-x: auto;
min-height: 350px;
}
.bars {
min-width: 700px;
}
.section-head {
flex-wrap: wrap;
gap: 10px;
}
.toggle-btn {
width: 100%;
}
}
@media (max-width: 575px) {
.header {
flex-direction: column;
text-align: center;
padding: 16px;
}
.header-icon {
width: 50px;
height: 50px;
}
.header h1 {
font-size: 15px;
}
.card,
.table-wrap,
.ringkasan-card {
border-radius: 8px;
}
.chart-box {
min-height: 320px;
}
.bars {
min-width: 650px;
}
.note-advanced {
flex-direction: column;
align-items: flex-start;
}
}
@media (max-width: 480px) {
body {
padding: 8px;
}
.content {
padding: 10px;
}
.header h1 {
font-size: 14px;
}
h2 {
font-size: 15px !important;
}
.info-label {
font-size: 10px;
}
.info-value {
font-size: 14px;
}
.chart-box {
min-height: 300px;
}
.bars {
min-width: 600px;
}
.bar {
width: 24px;
}
.bar-group-label,
.bar-year-label {
font-size: 10px;
}
.legend-box {
flex-wrap: wrap;
}
}
@media (max-width: 375px) {
.header {
padding: 14px;
}
.header h1 {
font-size: 13px;
}
.header-icon {
width: 44px;
height: 44px;
}
.icon-box {
width: 42px;
height: 42px;
min-width: 42px;
font-size: 16px;
}
.info-box {
gap: 12px;
padding: 14px;
}
.info-value {
font-size: 13px;
}
.chart-box {
min-height: 280px;
}
.bars {
min-width: 550px;
}
.bar {
width: 22px;
}
.toggle-btn {
padding: 10px;
}
.note-title {
font-size: 13px;
}
.note-text {
font-size: 12px;
}
}
/* =========================
ANIMATIONS
========================= */
@keyframes growBar {
from {
transform: scaleY(0);
}
to {
transform: scaleY(1);
}
}
@keyframes fadeSlideIn {
from {
opacity: 0;
transform: translateY(20px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
.show-anim {
animation: fadeSlideIn 0.4s ease;
}
</style>
</head>
<body class="p-8">
<div class="w-full mx-auto">
<div class="page-card">
<div class="header">
<div class="header-icon">
<i class="fa-solid fa-box-open"></i>
</div>
<div>
<h1>DETAIL RENCANA PENGADAAN BARANG</h1>
</div>
<a href="/rencana-pengadaan" class="header-back">
<i class="fa-solid fa-chevron-left"></i>
</a>
</div>
<div class="content">
<div class="grid-top">
<div class="info-section">
<h2>INFORMASI BARANG</h2>
<div class="info-grid custom-info">
<div class="info-box">
<div class="icon-box icon-dark">
<i class="bi bi-upc-scan"></i>
</div>
<div>
<div class="info-label">Kode Barang</div>
<div class="info-value">{{ $barang->kode }}</div>
</div>
</div>
<div class="info-box">
<div class="icon-box icon-blue">
<i class="bi bi-box-seam"></i>
</div>
<div>
<div class="info-label">Nama Barang</div>
<div class="info-value">{{ $barang->nama_barang }}</div>
</div>
</div>
<div class="info-box">
<div class="icon-box icon-purple">
<i class="bi bi-tags"></i>
</div>
<div>
<div class="info-label">Jenis</div>
<div class="info-value">{{ $barang->jenis }}</div>
</div>
</div>
<div class="info-box">
<div class="icon-box icon-orange">
<i class="bi bi-calendar-event"></i>
</div>
<div>
<div class="info-label">Periode</div>
<div class="info-value">
{{ \Carbon\Carbon::createFromFormat('Y-m', $periode)->locale('id')->translatedFormat('F Y') }}
</div>
</div>
</div>
<div class="info-box">
<div class="icon-box {{ $usulan > 0 ? 'icon-red' : 'icon-green' }}">
<i class="bi {{ $usulan > 0 ? 'bi-exclamation-circle' : 'bi-check-circle' }}"></i>
</div>
<div>
<div class="info-label">Status</div>
<div class="info-value {{ $usulan > 0 ? 'status-danger' : 'status-success' }}">
{{ $usulan > 0 ? 'Perlu Restock' : 'Aman' }}
</div>
</div>
</div>
</div>
</div>
</div>
<div class="grid-middle">
<div class="ringkasan-section">
<h2>RINGKASAN PENGADAAN</h2>
<div class="table-wrap">
<table>
<tbody>
<tr>
<th>Prediksi Kebutuhan</th>
<td><span class="badge-body">{{ $prediksi->jumlah_prediksi }}
{{ $barang->satuan }}</span></td>
</tr>
<tr>
<th>Stok</th>
<td><span class="badge-body">{{ $stok }} {{ $barang->satuan }}</span>
</td>
</tr>
<tr>
<th>Selisih</th>
<td>
<span
class="badge-body {{ $selisih > 0 ? 'success' : ($selisih < 0 ? 'danger' : '') }}">
{{ $selisih > 0 ? '+' : '' }}{{ $selisih }}
{{ $barang->satuan }}
</span>
</td>
</tr>
<tr>
<th>Usulan Pembelian</th>
<td><span class="badge-body">{{ $usulan }} {{ $barang->satuan }}</span>
</td>
</tr>
</tbody>
</table>
</div>
<div class="note-advanced mt-4">
<div class="note-icon">
<i class="bi bi-journal-bookmark-fill"></i>
</div>
<div>
<div class="note-title">Catatan</div>
<div class="note-text">
Sistem merekomendasikan pengadaan berdasarkan selisih antara prediksi kebutuhan
periode
terpilih dengan stok barang.
</div>
</div>
</div>
</div>
@php
$modeActualOnly = !$hasHistoricalPrediction;
@endphp
<div class="chart-section">
<div class="section-head">
<h2>
RIWAYAT PEMAKAIAN SEBELUMNYA
{{-- <div style="font-size:13px; color:#6b7280; margin-bottom:10px; font-weight: 400">
Data yang ditampilkan merupakan data pemakaian barang yang tersedia pada sistem.
</div> --}}
</h2>
<button onclick="toggleView()" id="toggleBtn" class="toggle-btn">
<i class="bi bi-table"></i>
</button>
</div>
@if (!$modeActualOnly)
<div class="legend-box" id="legendBox">
<div class="legend-item">
<div class="legend-color legend-actual"></div>
<span>Aktual</span>
</div>
<div class="legend-item">
<div class="legend-color legend-predict"></div>
<span>Prediksi</span>
</div>
</div>
@endif
@if (!$modeActualOnly && $riwayat->whereNotNull('hasil_prediksi')->isEmpty())
<div class="note-advanced mb-3">
<div>
<div class="note-text">
Data prediksi belum tersedia untuk periode historis ini, sehingga sistem hanya
menampilkan data pemakaian aktual.
</div>
</div>
</div>
@endif
<div class="chart-box" id="chartView">
@php
$maxActual = $riwayat->max('total_pemakaian') ?? 0;
$maxPred = $riwayat->max('hasil_prediksi') ?? 0;
$maxData = max($maxActual, $maxPred, 1);
$step = $maxData < 50 ? 5 : 50;
$maxY = ceil($maxData / $step) * $step;
$labels = [];
for ($i = 0; $i <= 4; $i++) {
$nilai = $maxY - $i * $step;
if ($nilai >= 0) {
$labels[] = $nilai;
}
}
@endphp
<div class="y-axis">
@foreach ($labels as $label)
<span>{{ $label }}</span>
@endforeach
</div>
<div class="bars">
@php
$prevYear = null;
@endphp
@foreach ($riwayat as $r)
<div class="bar-group">
@php
$currentYear = $r->tahun;
@endphp
@if ($prevYear !== $currentYear)
<div class="bar-year-label">
{{ $currentYear }}
</div>
@php $prevYear = $currentYear; @endphp
@endif
@php
$nilaiBar = max($r->total_pemakaian, $r->hasil_prediksi);
@endphp
@if ($modeActualOnly)
<div class="bar actual-only"
style="height:{{ ($r->total_pemakaian / $maxY) * 100 }}%;">
<div class="tooltip">
Barang Keluar : {{ $r->total_pemakaian }} {{ $barang->satuan }}
</div>
</div>
@else
@php
$actual = $r->total_pemakaian;
$predict = $r->hasil_prediksi;
$maxValue = max($actual, $predict);
$barHeight = ($maxValue / $maxY) * 100;
if ($actual == $predict) {
$actualHeight = 100;
$predictHeight = 0;
} elseif ($actual > $predict) {
$actualHeight = ($predict / $maxValue) * 100;
$predictHeight = (($actual - $predict) / $maxValue) * 100;
} else {
$actualHeight = ($actual / $maxValue) * 100;
$predictHeight = (($predict - $actual) / $maxValue) * 100;
}
@endphp
<div class="bar {{ $predictHeight == 0 ? 'single' : '' }}"
style="height:{{ $barHeight }}%;">
@if ($actualHeight > 0)
<div class="bar-actual" style="height:{{ $actualHeight }}%;"></div>
@endif
@if ($predictHeight > 0)
<div class="bar-predict" style="height:{{ $predictHeight }}%;">
</div>
@endif
<div class="tooltip">
Aktual : {{ $actual }} {{ $barang->satuan }}
<br>
Prediksi : {{ $predict }} {{ $barang->satuan }}
</div>
</div>
@endif
<span class="bar-group-label">
{{ \Carbon\Carbon::createFromDate($r->tahun, $r->bulan, 1)->locale('id')->translatedFormat('M') }}
</span>
</div>
@endforeach
</div>
</div>
<div class="chart-box hidden-box" id="tableView">
<div class="table-scroll">
<table class="riwayat-table">
<thead>
<tr>
<th>Bulan</th>
<th>Tahun</th>
@if (!$modeActualOnly)
<th>Aktual</th>
<th>Prediksi</th>
<th>Selisih</th>
@else
<th>Barang Keluar</th>
@endif
</tr>
</thead>
<tbody>
@foreach ($riwayat as $r)
<tr>
<td>
{{ \Carbon\Carbon::createFromDate($r->tahun, $r->bulan, 1)->locale('id')->translatedFormat('F') }}
</td>
<td>{{ $r->tahun }}</td>
@if (!$modeActualOnly)
<td>{{ $r->total_pemakaian }} {{ $barang->satuan }}</td>
<td>{{ $r->hasil_prediksi }} {{ $barang->satuan }}</td>
<td>
<span
class="{{ $r->selisih_prediksi == 0 ? '' : ($r->selisih_prediksi > 0 ? 'success' : 'danger') }}">
{{ $r->selisih_prediksi > 0 ? '+' : '' }}{{ $r->selisih_prediksi }}
</span>
</td>
@else
<td>{{ $r->total_pemakaian }} {{ $barang->satuan }}</td>
@endif
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<script>
function toggleView() {
const chart = document.getElementById('chartView');
const table = document.getElementById('tableView');
const btn = document.getElementById('toggleBtn');
const isChartHidden = chart.classList.toggle('hidden-box');
table.classList.toggle('hidden-box');
if (isChartHidden) {
btn.innerHTML = '<i class="bi bi-bar-chart"></i>';
table.classList.remove('show-anim');
void table.offsetWidth;
table.classList.add('show-anim');
} else {
btn.innerHTML = '<i class="bi bi-table"></i>';
}
}
</script>
</body>
</html>