@extends('layout.app')

@section('content')

<div class="pagetitle">
    <h1>Normalisasi Matriks Perbandingan</h1>
    <nav>
        <ol class="breadcrumb">
            <li class="breadcrumb-item"><a href="{{ route('admindash') }}">Home</a></li>
            <li class="breadcrumb-item"><a href="{{ route('perbandingan') }}">Perbandingan Kriteria</a></li>
            <li class="breadcrumb-item"><a href="{{ route('hasil.normalisasi') }}">Normalisasi Kriteria</a></li>
        </ol>
    </nav>
</div><!-- End Page Title -->

<section class="section">
    <div class="row">
        <div class="col-lg-12">

            <!-- Form Input Normalisasi -->
            <div class="card">
                <div class="card-body">
                    <h5 class="card-title mb-4">Normalisasi Matriks</h5>
                    <div class="table-responsive">
                        <table class="table table-bordered text-center">
                            <thead>
                                <tr>
                                    <th>Kriteria</th>
                                    @foreach ($kriterias as $k)
                                        <th>{{ $k->nama }}</th>
                                    @endforeach
                                </tr>
                            </thead>
                            <tbody>
                                @foreach ($kriterias as $i => $baris)
                                    <tr>
                                        <th>{{ $baris->nama }}</th>
                                        @foreach ($kriterias as $j => $kolom)
                                            <td>
                                                {{ number_format($normalisasi[$i][$j], 4) }}
                                            </td>
                                        @endforeach
                                    </tr>
                                @endforeach
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>

            <!-- Tabel Bobot Kriteria -->
            <div class="card mt-4">
                <div class="card-body">
                    <h5 class="card-title">Bobot Kriteria</h5>
                    <div class="table-responsive">
                        <table class="table table-bordered text-center">
                            <thead>
                                <tr>
                                    <th>Kriteria</th>
                                    <th>Bobot</th>
                                </tr>
                            </thead>
                            <tbody>
                                @foreach ($kriterias as $index => $kriteria)
                                    <tr>
                                        <td>{{ $kriteria->nama }}</td>
                                        <td>{{ number_format($bobot[$index], 4) }}</td>
                                    </tr>
                                @endforeach
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>

            <!-- Tindakan Selanjutnya -->
            <div class="text-end mt-3">
                <form method="GET" action="{{ route('alternatif.pilih') }}">
                    @csrf
                    <button type="submit" class="btn btn-success">Lanjut ke Perbandingan Alternatif</button>
                </form>
            </div>

        </div>
    </div>
</section>

@endsection
