@extends('layouts.admin') @section('content')
<div class="row mb-3">
    <div class="col-10">
        <div class="card mb-3">
            <div class="card-header">
                <div class="row flex-between-end">
                    <div class="col-auto align-self-center">
                        <h5 class="mb-0" data-anchor="data-anchor">Register Member</h5>
                    </div>
                </div>
            </div>
            <div class="card-body bg-light">
                <form class="form-material" method="POST" action="{{ url ('/member')}}">
                    @csrf
                    @if(count($errors->all()))
                    @foreach ($errors->all() as $error)
                    <div class="alert alert-danger alert-dismissable"> <a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a> <strong>Alert!</strong> {{ $error }} </div> @endforeach @endif
                    <div class="row">
                        <div class="col-sm-6">
                            <input type="text" required class="form-control" id="name" name="name" value="" placeholder="Name">
                        </div>
                        <div class="col-sm-6">
                            <input type="text" required class="form-control" id="surname" name="surname" value="" placeholder="Surname">
                            <br>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-sm-6">
                            Male <input type="radio" required class="form-check-input" id="gender" name="gender" value="Male">
                            Female <input type="radio" required class="form-check-input" id="gender" name="gender" value="Female">
                        </div>
                        <div class="col-sm-6">
                            <input type="number" required class="form-control" id="national_id" name="national_id" value="" placeholder="National ID">
                        </div>
                    </div><br>
                    <div class="row">
                        <div class="col-sm-6">
                            Date of birth:
                        </div>
                        <div class="col-sm-6">
                            <input type="date" onmouseover="myFunctions()" required class="form-control" id="date_of_birth" name="date_of_birth" value=""><br>


                            <p id="demo"></p>

                            <script>
                                function myFunctions() {
                                    var options = {
                                        weekday: 'long',
                                        year: 'numeric',
                                        month: 'long',
                                        day: 'numeric'
                                    };
                                    var date = document.getElementById("national_id").value;
                                    var year = +date.substring(0, 2);
                                    var month = +date.substring(2, 4);
                                    var day = +date.substring(4, 6);

                                    //var yyyy = (+year == 00) ? '20' + year : '19' + year;                                    
                                    document.getElementById("date_of_birth").value = ("19" + year + "-" + month + "-" + day);
                                }
                            </script>
                        </div>
                    </div>

                    <div class="row">
                        <div class="col-sm-4">
                            <select name="nationality" class="form-control">
                                <option>Liswati</option>
                            </select>
                        </div>

                        <div class="col-sm-4">
                            <input type="email" class="form-control" id="email" name="email" placeholder="Email">
                            <br>
                        </div>

                        <div class="col-sm-4">
                            <select name="group_id" class="form-control">
                                <option selected disabled value="">Select group</option>
                                @foreach($groups as $group)
                                <option value="{{ $group->id }}">{{ $group->name }}</option>
                                @endforeach
                            </select>
                        </div>
                    </div>


                    <div class="row">
                        <div class="col-sm-6">
                            <input type="number" class="form-control" id="work_number" name="work_number" value="" placeholder="Work Number">

                        </div>
                        <div class="col-sm-6">
                            <input type="text" required class="form-control" id="cell_number" name="cell_number" value="" placeholder="Cell Number" minlength="8" maxlength="8">
                            <br>
                        </div>
                    </div>

                    <div class="row">
                        <div class="col-sm-6">
                            <input type="text" class="form-control" id="passport_number" name="passport_number" value="" placeholder="Passport Number">

                        </div>
                        <div class="col-sm-6">
                            <input type="text" required class="form-control" id="postal_address" name="postal_address" value="" placeholder="Postal Address">
                            <br>
                        </div>
                    </div>

                    <div class="row">
                        <div class="col-sm-6">
                            <textarea class="form-control" id="residential_address" name="residential_address" rows="3">Residential Address
                        </textarea>
                        </div>
                        <div class="col-sm-6">
                            Registration date:
                            <input 
    type="date"
    required
    class="form-control"
    id="registration_date"
    name="registration_date"
    value="{{ now()->toDateString() }}"
    max="{{ now()->toDateString() }}"
>

                        </div>
                    </div>

                    <div class="text-center">
                        <br><button type="submit" class="btn btn-primary btn-sm"><i class="far fa-save"></i> Save</button>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>


@endsection