@if(count($teacher) >0)
@foreach($teacher as $row)
<div class="alert mt-3 mb-3" style="border: 2px solid #e9f0f3 !important; width: 100%; display: -webkit-inline-box;  font-size: 12px !important; font-weight:bold !important; color: black; border-radius: 6px;">
    <div class="col-md-12">
        <div class="row">
            <div class="col-md-10">
                <span style="margin: 0px;">{{$row->first_name}} {{$row->last_name}}</span></br>
                <span class="text-muted" style="font-weight: 500;">{{$row->designation}}</span></br>
                <span class="text-muted" style="font-weight: 500;">{{$row->department}}</span>
                <span>.</span>
                <span class="text-muted" style="font-weight: 500;">{{$row->university_name}}</span>
            </div>

            <div class="col-md-2 mt-3">
                <span class="btn btn3 apply_student" data-id="{{ $row->id }}" style="margin-left: 1.1rem;" onclick="document.getElementById('id01').style.display='block'">Apply</span>  
                <div id="id01" class="apply-modal mt-2">
                    <div class="apply-modal-content apply-animate-top apply-card-4 mb-4">
                        <header class="container apply-teal mb-3 mt-4"> 
                            <span onclick="document.getElementById('id01').style.display='none'" 
                            class="w3-button w3-display-topright">&times;</span>
                            <h5 class="mt-3 p-3" style="font-weight: bold;">Submit your Proposal</h5>
                        </header>

                        <div class="container mt-3">
                            <div class="col-md-12">
                                <div class="alert p-3" style="background-color:white;">
                                    <span style="margin: 0px;">{{$row->first_name}} {{$row->last_name}}</span></br>
                                    <span class="text-muted" style="font-weight: 500;">{{$row->designation}}</span></br>
                                    <span class="text-muted" style="font-weight: 500;">{{$row->department}}</span>
                                    <span>.</span>
                                    <span class="text-muted" style="font-weight: 500;">{{$row->university_name}}</span>
                                </div>
                            </div>

                            <div class="middle p-3" style="background-color:white; border-radius:6px;">
                                <p class="mb-3" style="font-size:14px;">Please select which proposal you want to send</p>
                                <div class="alert mt-1 mb-3 propose" style="padding: 0px;">
                                    <div style="width:100%;">
                                        <div class="mt-2 p-2" style="border-bottom:2px solid #eee;">
                                            <div class="custom-control custom-radio custom-control-inline">
                                                <div class="form-check mb-0">
                                                    <input class="form-check-input" checked type="radio" name="flexRadioDefault" id="flexRadioDefault1">
                                                    <label class="form-check-label" for="flexRadioDefault1">Proposal 1</label>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="mt-2 p-2" style="border-bottom:2px solid #eee;">
                                            <div class="custom-control custom-radio custom-control-inline">
                                                <div class="form-check mb-0">
                                                    <input class="form-check-input" checked type="radio" name="flexRadioDefault" id="flexRadioDefault1">
                                                    <label class="form-check-label" for="flexRadioDefault1">Proposal 2</label>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="mt-2 p-2">
                                            <div class="custom-control custom-radio custom-control-inline">
                                                <div class="form-check mb-0">
                                                    <input class="form-check-input" checked type="radio" name="flexRadioDefault" id="flexRadioDefault1">
                                                    <label class="form-check-label" for="flexRadioDefault1">Proposal 2</label>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div> 
                            </div>
                        </div>
                        <div class="container mt-4">
                            <div class="col-md-12 p-3" style="background-color:white; border-radius:6px;">
                                <p style="margin:0px; font-size:14px;">Select propose start date</p>
                                <div class="row">
                                    <div class="col-md-6">
                                        <div class="mb-1">
                                                <label class="form-label"></label>
                                            <div class="form-icon position-relative">
                                                <select name="startdate" id="start date" class="form-control frm" required="">
                                                    <option disabled="" selected="" value="">Year</option>
                                                    @php
                                                        $firstYear = (int)date('Y') - 20;
                                                        $lastYear = $firstYear + 20;
                                                        for($i=$firstYear;$i<=$lastYear;$i++){
                                                    @endphp
                                                    <option value="{{$i}}">{{$i}}</option>
                                                    @php
                                                        }
                                                    @endphp

                                                </select>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="col-md-6">
                                        <div class="mb-1">
                                                <label class="form-label"></label>
                                            <div class="form-icon position-relative">
                                                <select name="startmonth" id="month" class="form-control frm" required="">
                                                    <option disabled="" selected="" value="">Month</option>
                                                    <option value="01">January</option>
                                                    <option value="02">February</option>
                                                    <option value="03">March</option>
                                                    <option value="04">April</option>
                                                    <option value="05">May</option>
                                                    <option value="06">June</option>
                                                    <option value="07">July</option>
                                                    <option value="08">August</option>
                                                    <option value="09">September</option>
                                                    <option value="10">October</option>
                                                    <option value="11">November</option>
                                                    <option value="12">December</option>
                                                </select>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-12 text-end">
                                <button type="submit" class="btn btn1 mt-3 mb-3" style="padding: 3px 18px;">Submit</button>
                            </div> 
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
@endforeach
@else
<div class="alert mt-3 mb-3" style="border: 2px solid #e9f0f3 !important; width: 100%; display: -webkit-inline-box;  font-size: 12px !important; font-weight:bold !important; color: black; border-radius: 6px;">
    <div class="col-md-12">
        <div class="row">
            <div class="col-md-12 text-center">
                <span class="text-danger">No data found!</span>
            </div> 
        </div>
    </div>
</div>

@endif

<script>
    $(function(){
        $('.apply_student').on('click', function(e){
            e.preventDefault();
            var id = $(this).data('id');
            var form_data={
                _token: "{{ csrf_token() }}",
                id: id
            }
            swal(
            //     {
            //     title: "Are you sure?",
            //     text: "Do you want to send email!",
            //     type: "warning",
            //     showCancelButton: true,
            //     confirmButtonClass: "btn-success",
            //     cancelButtonClass: "btn-danger",
            //     confirmButtonText: "Yes",
            //     cancelButtonText: "No"
            // },
            function(isConfirm){
                if(isConfirm){
                    $.post("{{ route('ajax-post', ['name'=>'send_apply_student_teacher_email']) }}", form_data, function(res){

                    if(res.msg) pop_up_msg(res.msg); 

                    }).fail(function(err){

                    }); 
                }
            });
        });
    });
</script>