@extends('layouts.admin')

@section('title', 'Tambah Rule Certainty Factor')

@section('content')

<div class="container">

    <div class="card shadow-sm">

        <div class="card-header bg-primary text-white">

            <b>Form Tambah Rule Certainty Factor</b>

        </div>

        <div class="card-body">

            {{-- ALERT ERROR --}}
            @if($errors->any())

                <div class="alert alert-danger">

                    <ul class="mb-0">

                        @foreach($errors->all() as $error)

                            <li>{{ $error }}</li>

                        @endforeach

                    </ul>

                </div>

            @endif

            {{-- ALERT LOGIKA CF --}}
            @if(session('error'))

                <div class="alert alert-warning">

                    {{ session('error') }}

                </div>

            @endif

            <form action="{{ route('rule.store') }}" method="POST">

                @csrf

                {{-- HIPOTESIS --}}
                <div class="mb-3">

                    <label class="form-label">

                        Hipotesis

                    </label>

                    <input
                        type="text"
                        class="form-control"
                        value="H01 - Deteksi Dini Perlunya Pemeriksaan Hipertensi"
                        readonly>

                    <small class="text-muted">

                        Seluruh rule pada sistem ini mengarah pada Hipotesis H01.

                    </small>

                </div>

                {{-- GEJALA --}}
                <div class="mb-3">

                    <label class="form-label">

                        Gejala

                    </label>

                    <select
                        name="gejala_id"
                        class="form-control"
                        required>

                        <option value="">

                            -- Pilih Gejala --

                        </option>

                        @foreach($gejalas as $g)

                            <option
                                value="{{ $g->id }}"
                                {{ old('gejala_id') == $g->id ? 'selected' : '' }}>

                                {{ $g->kode }} - {{ $g->nama }}

                            </option>

                        @endforeach

                    </select>

                </div>

                {{-- MB --}}
                <div class="mb-3">

                    <label class="form-label">

                        MB (Measure of Belief)

                    </label>

                    <input
                        type="number"
                        name="mb"
                        class="form-control"
                        step="0.01"
                        min="0"
                        max="1"
                        value="{{ old('mb') }}"
                        placeholder="Contoh : 0.80"
                        required>

                    <small class="text-muted">

                        Nilai MB berada pada rentang 0 sampai 1.

                    </small>

                </div>

                {{-- MD --}}
                <div class="mb-3">

                    <label class="form-label">

                        MD (Measure of Disbelief)

                    </label>

                    <input
                        type="number"
                        name="md"
                        class="form-control"
                        step="0.01"
                        min="0"
                        max="1"
                        value="{{ old('md') }}"
                        placeholder="Contoh : 0.20"
                        required>

                    <small class="text-muted">

                        Nilai MD berada pada rentang 0 sampai 1.

                    </small>

                </div>

                <hr>

                {{-- BUTTON --}}
                <div class="d-flex justify-content-between">

                    <a
                        href="{{ route('rule.index') }}"
                        class="btn btn-secondary">

                        ← Kembali

                    </a>

                    <button
                        type="submit"
                        class="btn btn-success">

                        Simpan Rule

                    </button>

                </div>

            </form>

        </div>

    </div>

</div>

@endsection