@extends('layouts/base_view')
@section('title')
{!! $variables['header_routes'] !!}
@endsection
@section('content')
<section class="content">
    <div class="container-fluid">
        <div class="row">
            <div class="col-12">
                <div class="card card-outline card-warning">
                    <div class="card-header">
                        <h3 class="card-title">{{ $variables['judul'] }}</h3>
                        <div class="card-tools">
                            <a href="{{ route('store_raw_materials.edit', $data->id) }}" class="btn btn-sm btn-warning">
                                <i class="fas fa-edit"></i> Ubah
                            </a>
                            <a href="{{ route('store_raw_materials.index') }}" class="btn btn-sm btn-warning">
                                <i class="fas fa-arrow-left"></i> Kembali
                            </a>
                        </div>
                    </div>
                    <div class="card-body">
                        <div class="row">
                            <div class="col-md-6">
                                <h5 class="text-warning mb-3"><i class="fas fa-info-circle"></i> Informasi Pemetaan</h5>

                                <table class="table table-sm table-borderless">
                                    <tr>
                                        <td width="40%" class="font-weight-bold">Store:</td>
                                        <td>{{ $data->store->code }} - {{ $data->store->name }}</td>
                                    </tr>
                                    <tr>
                                        <td class="font-weight-bold">Item:</td>
                                        <td>{{ $data->rawMaterial->code }} - {{ $data->rawMaterial->name }}</td>
                                    </tr>
                                    <tr>
                                        <td class="font-weight-bold">UOM:</td>
                                        <td>{{ $data->rawMaterial->uom }}</td>
                                    </tr>
                                    <tr>
                                        <td class="font-weight-bold">Tipe Dokumen:</td>
                                        <td>
                                            @if($data->tipe_dokumen === 'DO')
                                            <span class="badge badge-primary">DO - Delivery Order</span>
                                            @elseif($data->tipe_dokumen === 'PO')
                                            <span class="badge badge-secondary">PO - Purchase Order</span>
                                            @else
                                            <span class="badge badge-info">PR - Purchase Request</span>
                                            @endif
                                        </td>
                                    </tr>
                                    <tr>
                                        <td class="font-weight-bold">Tipe Barang:</td>
                                        <td>
                                            @if($data->rawMaterial->tipe_barang === 'Basah')
                                            <span class="badge badge-info">Basah</span>
                                            @else
                                            <span class="badge badge-secondary">Kering</span>
                                            @endif
                                        </td>
                                    </tr>
                                    <tr>
                                        <td class="font-weight-bold">Status:</td>
                                        <td>
                                            @if($data->is_active)
                                            <span class="badge badge-success">Aktif</span>
                                            @else
                                            <span class="badge badge-secondary">Nonaktif</span>
                                            @endif
                                        </td>
                                    </tr>
                                </table>

                                <h5 class="text-warning mb-3 mt-4"><i class="fas fa-cog"></i> Konfigurasi</h5>

                                <table class="table table-sm table-borderless">
                                    <tr>
                                        <td width="40%" class="font-weight-bold">Flag LSM:</td>
                                        <td>
                                            @if($data->lsm_flag)
                                            <span class="badge badge-success">Ya</span>
                                            @else
                                            <span class="badge badge-secondary">Tidak</span>
                                            @endif
                                        </td>
                                    </tr>
                                    <tr>
                                        <td class="font-weight-bold">Flag SPB:</td>
                                        <td>
                                            @if($data->spb_flag)
                                            <span class="badge badge-success">Ya</span>
                                            @else
                                            <span class="badge badge-secondary">Tidak</span>
                                            @endif
                                        </td>
                                    </tr>
                                    <tr>
                                        <td class="font-weight-bold">Matriks Inventori:</td>
                                        <td>
                                            @if($data->inv_matrix_flag)
                                            <span class="badge badge-info">Aktif</span>
                                            @else
                                            <span class="badge badge-secondary">Nonaktif</span>
                                            @endif
                                        </td>
                                    </tr>
                                    <tr>
                                        <td class="font-weight-bold">Periode Pemesanan:</td>
                                        <td>
                                            @if($data->period)
                                            <span class="badge badge-success">{{ $data->period->code }} - {{ $data->period->name }}</span>
                                            @else
                                            <span class="badge badge-secondary">Belum Diatur</span>
                                            @endif
                                        </td>
                                    </tr>
                                </table>

                                <div class="alert alert-info mt-3">
                                    <i class="fas fa-info-circle"></i>
                                    <strong>Pengelompokan SPB:</strong> Item ini akan masuk ke SPB dengan kombinasi
                                    <strong>{{ $data->tipe_dokumen }}-{{ $data->rawMaterial->tipe_barang }}</strong>
                                </div>
                            </div>

                            <div class="col-md-6">
                                <h5 class="text-warning mb-3"><i class="fas fa-boxes"></i> Konfigurasi Stok</h5>

                                <table class="table table-sm table-borderless">
                                    <tr>
                                        <td width="40%" class="font-weight-bold">Stok Minimum:</td>
                                        <td>{{ number_format($data->min_stock, 2) }}</td>
                                    </tr>
                                    <tr>
                                        <td class="font-weight-bold">Stok Maksimum:</td>
                                        <td>{{ number_format($data->max_stock, 2) }}</td>
                                    </tr>
                                    <tr>
                                        <td class="font-weight-bold">Reorder Point:</td>
                                        <td>{{ number_format($data->reorder_point, 2) }}</td>
                                    </tr>
                                    <tr>
                                        <td class="font-weight-bold">Catatan:</td>
                                        <td>{{ $data->notes ?? '-' }}</td>
                                    </tr>
                                </table>

                                <h5 class="text-warning mb-3 mt-4"><i class="fas fa-history"></i> Informasi Audit</h5>

                                <table class="table table-sm table-borderless">
                                    <tr>
                                        <td width="40%" class="font-weight-bold">Dibuat Oleh:</td>
                                        <td>
                                            <small class="text-muted">
                                                {{ $data->creator->fullname ?? 'System' }}<br>
                                                {{ $data->created_at->format('d M Y, H:i') }}
                                            </small>
                                        </td>
                                    </tr>
                                    @if($data->modificator)
                                    <tr>
                                        <td class="font-weight-bold">Diubah Oleh:</td>
                                        <td>
                                            <small class="text-muted">
                                                {{ $data->modificator->fullname }}<br>
                                                {{ $data->updated_at->format('d M Y, H:i') }}
                                            </small>
                                        </td>
                                    </tr>
                                    @endif
                                </table>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</section>
@endsection