@extends('layouts.header')

@section('content')
<main class="container">
    <div class="row justify-content-center">
        <div class="col-lg-8">
            <div class="card shadow">
                <div class="card-body">
                    <h2 class="card-title text-center mt-5 mb-4">Student Details Form</h2>
                    <form method="POST" action="{{ route('student.store')  }}" enctype="multipart/form-data">
                        @csrf
                        <div class="mb-3">
                            <label for="student_name" class="form-label">Name of the Student:</label>
                            <input type="text" id="student_name" name="student_name" class="form-control" required>
                        </div>
                        
                        <div class="row">
                            <div class="col-md-6">
                                <div class="mb-3">
                                    <label for="student_age" class="form-label">Age:</label>
                                    <input type="number" id="student_age" name="student_age" class="form-control" required>
                                </div>
                            </div>
                            <div class="col-md-6">
                                <div class="mb-3">
                                    <label for="date_of_birth" class="form-label">Date of Birth:</label>
                                    <input type="date" id="date_of_birth" name="date_of_birth" class="form-control" required>
                                </div>
                            </div>
                        </div>

                        <div class="mb-3">
                            <label class="form-label">Gender:</label><br>
                            <div class="form-check form-check-inline">
                                <input type="radio" id="male" name="gender" value="male" class="form-check-input" required>
                                <label for="male" class="form-check-label">Male</label>
                            </div>
                            <div class="form-check form-check-inline">
                                <input type="radio" id="female" name="gender" value="female" class="form-check-input" required>
                                <label for="female" class="form-check-label">Female</label>
                            </div>
                        </div>

                        <div class="mb-3">
                            <label for="guardian_name" class="form-label">Name of the Guardian:</label>
                            <input type="text" id="guardian_name" name="guardian_name" class="form-control" required>
                        </div>

                        <div class="mb-3">
                            <label for="communication_address" class="form-label">Address for Communication:</label>
                            <textarea id="communication_address" name="communication_address" rows="4" class="form-control" required></textarea>
                        </div>

                        <div class="mb-3">
                            <label for="contact_phone" class="form-label">Contact Phone Number:</label>
                            <input type="tel" id="contact_phone" name="contact_phone" class="form-control" pattern="[0-9]{10}" required>
                        </div>

                        <h3>Educational Details</h3>

                        <div class="row">
                            <div class="col-md-6">
                                <div class="mb-3">
                                    <label for="student_class" class="form-label">Class:</label>
                                    <input type="text" id="student_class" name="student_class" class="form-control" required>
                                </div>
                            </div>
                            <div class="col-md-6">
                                <?php

function convertToRoman($num)
{
    $romanNumeralMap = [
        'M' => 1000,
        'CM' => 900,
        'D' => 500,
        'CD' => 400,
        'C' => 100,
        'XC' => 90,
        'L' => 50,
        'XL' => 40,
        'X' => 10,
        'IX' => 9,
        'V' => 5,
        'IV' => 4,
        'I' => 1
    ];

    $result = '';

    foreach ($romanNumeralMap as $roman => $value) {
        $matches = intval($num / $value);
        $result .= str_repeat($roman, $matches);
        $num = $num % $value;
    }

    return $result;
}
?>

                            <div class="mb-3">
                                    <label for="student_std" class="form-label">Std:</label>
                                    <select id="student_std" name="student_std" class="form-control" required>
                                        <option value="" disabled selected>Select Standard</option>
                                        @for ($std = 1; $std <= 12; $std++)
                                            <option value="{{ $std }}">{{ convertToRoman($std) }}</option>
                                        @endfor
                                    </select>
                                </div>
                            </div>

                        </div>

                        <div class="mb-3">
                            <label for="school_fees" class="form-label">School fees:</label>
                            <input type="text" id="school_fees" name="school_fees" class="form-control" required>
                        </div>

                        <div class="mb-3">
                            <label for="school_details" class="form-label">School Details:</label>
                            <textarea id="school_details" name="school_details" rows="4" class="form-control" required></textarea>
                        </div>
                        
                        <div class="mb-3">
                            <label for="student_image" class="form-label">Image of Student:</label>
                            <input type="file" id="student_image" name="student_image" accept="image/*" class="form-control" required>
                        </div>

                        <div class="text-center">
                            <button type="submit" class="btn btn-primary btn-lg">Submit</button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</main>
@endsection
