{{-- Baris pohon menu Mesin. Markup tiap sel sengaja disalin dari master/auto/list.blade.php : kolom Action (View + dropdown Edit / Non Aktifkan), kolom No, lalu satu sel per field sys_table ber-list = 1 yang dirender lewat komponen td_* kerangka. Yang ditambahkan hanya dua hal : indentasi + tombol buka/tutup di kolom Nama Mesin, dan atribut data-* yang dibaca js/msmchn. data-path berisi seluruh kunci induk baris itu, jadi menutup satu induk cukup menyembunyikan baris yang data-path-nya memuat kunci induk tersebut. Baris line (equipment SAP tanpa PARENT, disimpan di mst_line) memakai sel yang sama supaya kolomnya tetap sejajar, tapi tanpa View / Edit / Non Aktifkan : aksi itu milik menu Mesin dan akan membuka baris mesin yang tidak ada. Line diurus lewat menu Line Produksi. --}} @php //td_join menjalankan query-nya sekali per sel. Di tabel datar itu hanya //10 baris per halaman; di pohon, hasil pencarian bisa ratusan baris, jadi //nilainya diingat per (field, nilai) — hasil tampilannya tetap sama. $joinCache = []; @endphp @foreach ($rows as $row) @php $detail = $row['detail']; $primary = (string) $detail->idmachine; $vcount = $loop->index . '-' . $row['key']; $inactive = (string) $detail->isactive === '0'; @endphp @if ($row['is_line']) Line @else
@endif {{ $row['no'] }} @foreach ($table_header as $field) @php $string = $field->field; @endphp @if ($string === 'machine_name') {{-- kolom pohon : indentasi per level + tombol buka/tutup --}}
@if ($row['child_count'] > 0) @else {{-- tanpa anak : ikon tetap ada supaya nama sejajar, tapi redup dan tidak bisa diklik --}} @endif {!! $row['name_html'] !!} @if ($row['child_count'] > 0) {{ $row['child_count'] }} @endif @if ($row['orphan']) Induk tidak ditemukan @endif
@elseif ($field->type == 'join') @php $joinCache[$string] ??= []; $joinValue = (string) $detail->$string; if (!array_key_exists($joinValue, $joinCache[$string])) { $joinRow = $field->query != '' ? (DB::select($field->query . "'" . $detail->$string . "'")[0] ?? null) : null; $joinCache[$string][$joinValue] = $joinRow ? (array_values((array) $joinRow)[0] ?? '') : ''; } @endphp {{ $joinCache[$string][$joinValue] }} @elseif ($field->type == 'enum') @include('components.td_enum') @elseif ($field->type == 'file') @include('components.td_file') @elseif ($field->type == 'image') @include('components.td_image') @elseif ($field->type == 'currency') @include('components.td_currency') @elseif ($field->type == 'date') @include('components.td_date') @elseif ($field->type == 'number') @include('components.td_number') @else @if ($field->link != '') {{ $detail->$string }}   @else {{ $detail->$string }} @endif @endif @endforeach @endforeach