{{-- resources/views/pages/dashboard/chart.blade.php --}}
@extends('layouts.app', ['class' => 'bg-gray-100'])
@section('content')
@php
$ID_COLS = [
'Hide' => '__exclude__',
'No' => '__no__',
'Shift Date' => 'shift_date',
'Shift' => 'shift',
'Batch' => 'batch',
'Gedung' => 'gedung',
'Customer' => 'customer',
'Material' => 'material',
'Mesin' => 'mesin',
'Team Group' => 'teamgroup',
'Delivery' => 'delivery',
'Width' => 'width',
'Length' => 'length',
'Weight' => 'weight',
'Unit of Dimension' => 'unit_of_dimension',
'Base Unit Measure' => 'base_unit_measure',
'Tested By' => 'tested_by',
'Checked By' => 'checked_by',
'Supervisor By' => 'supervisor_by',
'Tested At' => 'tested_at',
'Checked At' => 'checked_at',
'Supervisor At' => 'supervisor_at',
];
@endphp
@php
// Querystring utk link Detail
$passQsStr = http_build_query(request()->except('chart'));
$passQs = $passQsStr ? '&' . $passQsStr : '';
// ID terpilih (SUMBER KEBENARAN)
$propIds = array_filter(array_map('intval', (array) request('properties', [])));
$paramIds = array_filter(array_map('intval', (array) request('param_mesin', [])));
$hasProps = !empty($propIds);
$hasParams = !empty($paramIds);
$propCol = $hasProps && $hasParams ? 'col-lg-6' : 'col-lg-12';
$paramCol = $hasProps && $hasParams ? 'col-lg-6' : 'col-lg-12';
@endphp
@if (empty($hide_topnav))
@include('layouts.navbars.auth.topnav', ['title' => ''])
@endif
{{-- HEADER --}}
Kembali
@if (session('error'))
{{ session('error') }}
@endif
@if (session('success'))
{{ session('success') }}
@endif
@if (empty($chart_keys))
Belum ada metrik terpilih. Silakan pilih Properties atau Parameter Mesin.
@else
{{-- BLOK PROPERTIES --}}
@if ($hasProps)
@foreach ($chart_keys as $ckey)
@php
if (!str_starts_with($ckey, 'prop_')) {
continue;
}
$id = (int) str_replace('prop_', '', $ckey);
$title = $mst_properties->firstWhere('id', $id)->nama ?? 'Property';
@endphp
@php $canvasId = 'c_' . preg_replace('/[^a-zA-Z0-9_]/', '_', (string) $ckey); @endphp
@endforeach
@endif
{{-- BLOK PARAMETER MESIN --}}
@if ($hasParams)
@foreach ($chart_keys as $ckey)
@php
// HANYA PARAMETER MESIN
if (!str_starts_with($ckey, 'param_')) {
continue;
}
$id = (int) str_replace('param_', '', $ckey);
$title = $mst_parameter_mesin->firstWhere('id', $id)->nama ?? 'Parameter';
@endphp
@php $canvasId = 'c_' . preg_replace('/[^a-zA-Z0-9_]/', '_', (string) $ckey); @endphp
@endforeach
@endif
{{-- =======================
TABEL 1: DATA BATCH
======================== --}}
@foreach ($ID_COLS as $label => $key)
| {{ $label }} |
@endforeach
{{-- AJAX --}}
{{-- =======================
TABEL 2: PROPERTIES
======================== --}}
@if ($hasProps)
@php
// Kelompokkan header property menjadi: {Nama Property} -> [Nilai, Min, Target, Max, Allowance]
$propGroups = [];
foreach ($HPROP as $label => $key) {
if (preg_match('/^(.*)\s—\s(Min|Target|Max|Allowance)$/u', $label, $m)) {
$base = trim($m[1]);
$sub = $m[2];
$propGroups[$base] = $propGroups[$base] ?? [
'Nilai' => null,
'Min' => null,
'Target' => null,
'Max' => null,
'Allowance' => null,
];
$propGroups[$base][$sub] = $key;
} else {
$base = trim($label);
$propGroups[$base] = $propGroups[$base] ?? [
'Nilai' => null,
'Min' => null,
'Target' => null,
'Max' => null,
'Allowance' => null,
];
$propGroups[$base]['Nilai'] = $key; // kolom nilai aktual
}
}
// urutan sub-kolom yang dipakai
$SUBS = ['Nilai', 'Min', 'Target', 'Max'];
@endphp
{{-- Header baris-1: kolom identitas (rowspan 2) + grup property (colspan 5) --}}
{{--
@foreach ($ID_COLS as $label => $key)
|
{{ $label }}
|
@endforeach
@foreach ($propGroups as $pname => $cols)
{{ $pname }}
|
@endforeach
--}}
{{-- Header baris-2: sub kolom tiap property --}}
{{--
@foreach ($propGroups as $pname => $cols)
@foreach ($SUBS as $s)
| {{ $s }} |
@endforeach
@endforeach
--}}
{{-- DIISI VIA AJAX --}}
@endif
{{-- ============================
TABEL 3: PARAMETER MESIN
============================= --}}
@if ($hasParams)
{{--
@foreach ($ID_COLS as $label => $key)
| {{ $label }} |
@endforeach
@foreach ($HPARAM as $label => $key)
{{ $label }} |
@endforeach
--}}
{{-- DIISI VIA AJAX --}}
@endif
@endif
@includeIf('pages.dashboard.partials.modal-filter')
{{-- form export --}}
@endsection
@push('js')
@endpush