@extends('server-side.layouts.server-app')
@section('pageTitle', 'Edit Data Basis Pengetahuan | KlinikSapi.Go')
@section('mainContent')
    <div class="content d-flex flex-column flex-column-fluid" id="kt_content">
        <div class="toolbar" id="kt_toolbar">
            <div id="kt_toolbar_container" class="container-fluid d-flex flex-stack">
                <div data-kt-swapper="true" data-kt-swapper-mode="prepend"
                    data-kt-swapper-parent="{default: '#kt_content_container', 'lg': '#kt_toolbar_container'}"
                    class="page-title d-flex align-items-center flex-wrap me-3 mb-5 mb-lg-0">
                    <h1 class="d-flex align-items-center text-dark fw-bolder fs-3 my-1">Manajemen Data
                        <span class="h-20px border-gray-200 border-start ms-3 mx-2"></span>
                        <small class="text-muted fs-7 fw-bold my-1 ms-1">Basis Pengetahuan / Data Pengetahuan / Edit Basis Pengetahuan</small>
                    </h1>
                </div>
            </div>
        </div>
        <div class="post d-flex flex-column-fluid" id="kt_post">
            <div id="kt_content_container" class="container-xxl">
                <div class="card mb-5 mb-xl-8 px-10 px-lg-15 py-15">
                    <div class="mb-2">
                        <h1 class="mb-3">Formulir Perubahan Data Basis Pengetahuan</h1>
                        <div class="text-primary fw-bold fs-3"><strong>> {{ $rules[0]->penyakitId }} . {{ $rules[0]->penyakit->penyakit }}</strong></div>
                    </div>
                    <form action="{{ route('rule.update', $rules[0]->penyakitId) }}" method="POST" class="form" autocomplete="off">
                    @csrf
                    @method('PUT')
                        <div class="table-responsive">
                            <table id="kt_datatable_example_5" class="table table-row-dashed table-row-gray-300 align-middle gs-0 gy-4">
                                <thead>
                                <tr class="fw-bolder text-muted">
                                    <th>#No</th>
                                    <th class="min-w-100px">Kode Gejala</th>
                                    <th class="min-w-250px">Nama Gejala</th>
                                    <th class="min-w-100px">Nilai Pakar</th>
                                </tr>
                                </thead>
                                <tbody>
                                @foreach ($rules as $data)
                                    <tr>
                                        <td>
                                            <span class="text-muted fw-bold text-muted d-block fs-7">
                                                {{ $numtab++ }}
                                            </span>
                                        </td>
                                        <td>
                                            <input type="hidden" name="id[]" value="{{ $data->id }}">
                                            <input type="hidden" name="penyakitId" value="{{ $data->penyakitId }}">
                                            <input type="text" class="form-control form-control-solid" value="{{ $data->gejalaId }}" readonly />
                                        </td>
                                        <td>
                                            <select class="form-select form-select-solid bg-white" data-control="select2" name="gejalaId[]" required>
                                                <option value="">---</option>
                                                @foreach ($gejala as $item)
                                                    <option value="{{ $item->gejalaId }}" {{ $item->gejalaId == $data->gejalaId ? 'selected' : '' }}>{{ $item->gejala }}</option>
                                                @endforeach
                                            </select>
                                        </td>
                                        <td>
                                            <select class="form-select form-select-solid bg-white" data-control="select2" name="nilaiPakar[]" required>
                                                <option value="">---</option>
                                                @foreach ($bobot as $itemb)
                                                    <option value="{{ $itemb->nilai }}" {{ $itemb->nilai == $data->nilaiPakar ? 'selected' : '' }}>{{ $itemb->nilai }}</option>
                                                @endforeach
                                            </select>
                                        </td>
                                    </tr>
                                @endforeach
                                </tbody>
                            </table>
                        </div>
                        <div class="float-start">
                            <button type="submit" class="btn btn-primary">
                                <span class="indicator-label">Simpan Pembaruan</span>
                            </button>
                            <a href="{{ route('rule.index') }}" class="btn btn-light me-3">Batal</a>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
@endsection
