@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">
                    <div class="card-header">
                        <h3 class="card-title">{!! $variables['judul'] !!}</h3>
                        <div class="float-right">
                            <a href="{{ route('target_sisa_malam.index') }}" class="btn btn-warning btn-sm button-cek-permission" data-permission="target_sisa_malam.index">
                                <i class="fas fa-list"></i> Daftar
                            </a>
                            <a href="{{ route('target_sisa_malam.edit', $data->id) }}" class="btn btn-warning btn-sm button-cek-permission" data-permission="target_sisa_malam.edit">
                                <i class="fas fa-edit"></i> Ubah
                            </a>
                            <a href="{{ route('target_sisa_malam.destroy', $data->id) }}" data='delete' onclick="notificationBeforeDelete(event, this)" class="btn btn-warning btn-sm button-cek-permission" data-permission="target_sisa_malam.destroy">
                                <i class="fas fa-trash"></i> {{ $data->delete_flag ? 'Aktifkan' : 'Nonaktifkan' }}
                            </a>
                        </div>
                    </div>
                    <div class="card-body">
                        <!-- Target Sisa Malam Header Info -->
                        <div class="row">
                            <div class="col-md-6">
                                <table class="table table-borderless">
                                    <tr>
                                        <td width="40%"><strong>ID</strong></td>
                                        <td>: <span class="badge badge-info">{{ $data->id }}</span></td>
                                    </tr>
                                    <tr>
                                        <td><strong>Store</strong></td>
                                        <td>: {{ $data->store->name ?? 'N/A' }}</td>
                                    </tr>
                                    <tr>
                                        <td><strong>Kode Item</strong></td>
                                        <td>: <span class="badge badge-info">{{ $data->rawMaterial->code ?? 'N/A' }}</span></td>
                                    </tr>
                                    <tr>
                                        <td><strong>Nama Item</strong></td>
                                        <td>: {{ $data->rawMaterial->name ?? 'N/A' }}</td>
                                    </tr>
                                </table>
                            </div>
                            <div class="col-md-6">
                                <table class="table table-borderless">
                                    <tr>
                                        <td width="40%"><strong>Jumlah Target</strong></td>
                                        <td>: <span class="badge badge-info">{{ number_format($data->target_qty, 2) }}</span></td>
                                    </tr>
                                    <tr>
                                        <td><strong>UOM</strong></td>
                                        <td>: {{ $data->rawMaterial->uom ?? 'N/A' }}</td>
                                    </tr>
                                    <tr>
                                        <td><strong>Kategori</strong></td>
                                        <td>: {{ $data->rawMaterial->category ?? 'N/A' }}</td>
                                    </tr>
                                    <tr>
                                        <td><strong>Status</strong></td>
                                        <td>: 
                                            @if($data->delete_flag)
                                            <span class="badge badge-secondary">Nonaktif</span>
                                            @else
                                            <span class="badge badge-success">Aktif</span>
                                            @endif
                                        </td>
                                    </tr>
                                    <tr>
                                        <td><strong>Dibuat Oleh</strong></td>
                                        <td>: {{ $data->creator->fullname ?? 'System' }} ({{ $data->created_at->format('d M Y, H:i') }})</td>
                                    </tr>
                                    <tr>
                                        <td><strong>Diubah Oleh</strong></td>
                                        <td>: {{ $data->modificator->fullname ?? '-' }} ({{ $data->updated_at ? $data->updated_at->format('d M Y, H:i') : '-' }})</td>
                                    </tr>
                                </table>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</section>

<form action="" id="delete-form" method="post">
    @method('delete')
    @csrf
</form>
@endsection