{{-- Extends layout --}}
@extends('layout.default')
{{-- Content --}}
@section('content')

<div class="card card-custom">
    <div class="card-header flex-wrap border-0 pt-6 pb-0">
        <div class="card-title">
            <h3 class="card-label">{{ $eventdata[0]->Name }}
            </h3>
        </div>
        <div class="card-toolbar">
        </div>
        @if(session()->has('message'))
        <div class="alert alert-success">
            {{ session()->get('message') }}
        </div>
        @endif
    </div>

    <div class="card-body">
        <form method="POST" action="{{ route('participantadd') }}">
            @csrf
            @isset($batch->id)
            {{ method_field('PATCH')}}
            @endisset
            @if ($errors->any())
            <div class="alert alert-danger">
                <strong>Error!</strong>
                <ul>
                    @foreach ($errors->all() as $error)
                    <li>{{ $error }}</li>
                    @endforeach
                </ul>
            </div>
            @endif
            <input type="hidden" name="eventmodel_id" value="{{$eventdata[0]->id}}" />
            <input type="hidden" name="cFees" value="{{$eventdata[0]->cFees}}" />
            <input type="hidden" name="id" value="{{$regdata[0]->id}}" />
            <div class="form-group row">
                <label for="participant_name" class="col-md-4 col-form-label ">{{ __('Club') }}</label>

                <div class="col-md-8">
                    <label for="participant_name" class="col-md-4 col-form-label ">{{ $regdata[0]->club}}</label>
                </div>
            </div>
            <div class="form-group row">
                <label for="name" class="col-md-4 col-form-label ">{{ __('Gymnast Name') }}</label>

                <div class="col-md-8">
                    <label for="participant_name" class="col-md-4 col-form-label ">{{ $regdata[0]->name}}</label>
                </div>
            </div>
            <div class="form-group row">
                <label class="col-md-4">DOB</label>
                <div class="col-md-8">
                    <input type="hidden" name="dob" value="{{ $regdata[0]->dob}}" />
                    <label for="participant_name" class="col-md-4 col-form-label ">{{ $regdata[0]->dob}}</label>
                </div>
            </div>
            <div class="form-group row">
                <label class="col-md-4">Level</label>
                <div class="col-md-4">
                    <select name="level" id="level" class="form-control" required></select>
                </div>
            </div>
            <div class="form-group row mb-0">
                <div class="col-md-8 offset-md-4">
                    <input type="submit" class="btn btn-primary" value="Submit">
                    </a>
                </div>
            </div>
        </form>
    </div>
</div>
@endsection
{{-- Global Theme JS Bundle (used by all pages)  --}}
    @foreach(config('layout.resources.js') as $script)
    <script src="{{ asset($script) }}" type="text/javascript"></script>
    @endforeach

    {{-- Includable JS --}}
    @yield('scripts')
<script type="text/javascript">
    $(function() {
        var dt="{{ $regdata[0]->dob}}";
      
        var myDateArray = dt.split("-");
        var dob = new Date(myDateArray[0],myDateArray[1]-1,myDateArray[2]); 
        // var dob = new Date($('#dob').val());
       
        var birthyear = dob.getFullYear();
        $('#level').empty();
       
        if (birthyear > 2014) {
           
            $('#dob').val('');
        } else if (birthyear == 2014) {
            $('#level').append('<option value="L1">Level 1</option>');
        } else if (birthyear == 2013) {
            $('#level').append('<option value="L2">Level 2</option>');
            $('#level').append('<option value="L1-Aboveage">Level 1-Aboveage</option>');
        } else if (birthyear == 2012) {
            $('#level').append('<option value="L3">Level 3</option>');
            $('#level').append('<option value="L1-Aboveage">Level 1-Aboveage</option>');
            $('#level').append('<option value="L2-Aboveage">Level 2-Aboveage</option>');
        } else if (birthyear == 2011 || birthyear == 2010) {
            $('#level').append('<option value="L4">Level 4</option>');
            $('#level').append('<option value="L1-Aboveage">Level 1-Aboveage</option>');
            $('#level').append('<option value="L2-Aboveage">Level 2-Aboveage</option>');
            $('#level').append('<option value="L3-Aboveage">Level 3-Aboveage</option>');
        } else if (birthyear >= 2007 && birthyear <= 2009) {
            $('#level').append('<option value="L5">Level 5</option>');
            $('#level').append('<option value="L1-Aboveage">Level 1-Aboveage</option>');
            $('#level').append('<option value="L2-Aboveage">Level 2-Aboveage</option>');
            $('#level').append('<option value="L3-Aboveage">Level 3-Aboveage</option>');
            $('#level').append('<option value="L4-Aboveage">Level 4-Aboveage</option>');
        } else {
            $('#level').append('<option value="L1-Aboveage">Level 1-Aboveage</option>');
            $('#level').append('<option value="L2-Aboveage">Level 2-Aboveage</option>');
            $('#level').append('<option value="L3-Aboveage">Level 3-Aboveage</option>');
            $('#level').append('<option value="L4-Aboveage">Level 4-Aboveage</option>');
            $('#level').append('<option value="L5-Aboveage">Level 5-Aboveage</option>');
        }

    });
</script>
