@extends('layout.app')

@section('content')

<div class="pagetitle">
    <h1>Perbandingan Alternatif</h1>
    <nav>
        <ol class="breadcrumb">
            <li class="breadcrumb-item"><a href="{{ route('admindash') }}">Home</a></li>
            <li class="breadcrumb-item active"><a href="{{ route('alternatif.pilih') }}">Pemilihan Alternatif</a></li>
            <li class="breadcrumb-item active"><a href="{{ route('alternatif.perbandingan') }}">Perbandingan Alternatif</a></li>
        </ol>
    </nav>
</div><!-- End Page Title -->

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

            @if(session('success'))
                <div class="alert alert-success">{{ session('success') }}</div>
            @endif

            <div class="card">
                <div class="card-body">
                    <h5 class="card-title">Matriks Perbandingan Alternatif</h5>

                    <form action="{{ route('alternatif.simpan') }}" method="POST">
                        @csrf

                        @foreach ($kriterias as $kriteria)
                            <h6 class="mt-4">{{ $kriteria->nama }}</h6>
                            <div class="table-responsive">
                                <table class="table table-bordered text-center">
                                    <thead>
                                        <tr>
                                            <th>Alternatif</th>
                                            @foreach ($alternatifs as $alt)
                                                <th>{{ $alt->nama }}</th>
                                            @endforeach
                                        </tr>
                                    </thead>
                                    <tbody>
                                        @foreach ($alternatifs as $alt1)
                                            <tr>
                                                <th>{{ $alt1->nama }}</th>
                                                @foreach ($alternatifs as $alt2)
                                                    <td>
                                                        @if ($alt1->id == $alt2->id)
                                                            1
                                                        @elseif ($alt1->id < $alt2->id)
                                                            <input type="number" step="0.01" min="0.01"
                                                                name="nilai[{{ $kriteria->id }}][{{ $alt1->id }}][{{ $alt2->id }}]"
                                                                class="form-control" required>
                                                        @else
                                                            -
                                                        @endif
                                                    </td>
                                                @endforeach
                                            </tr>
                                        @endforeach
                                    </tbody>
                                </table>
                            </div>
                        @endforeach

                        <div class="text-end mt-4">
                            <button type="submit" name="action" value="simpan" class="btn btn-success">Simpan Saja</button>
                            <button type="submit" name="action" value="lanjut" class="btn btn-primary">Simpan & Lanjut</button>
                        </div>
                    </form>

                </div>
            </div>

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

@endsection
