<form method="POST" action="{{route('ajax-post', ['name'=>'edit_register_teacher_save'])}}" class="edit_register_pending_teacher_form">   
    <input type="hidden" name="_token" value="{{ csrf_token() }}" />
    <input type="hidden" name="edit_id" value="{{$edit_data->id}}">
    <input type="hidden" name="action" value="edit"> 
    <div class="panel-body" style="padding:10px; background-color: #4b4c6824; border: 1px solid #e9e5e5; border-radius: 5px;">
    
        <div class="row">
            <div class="col-md-4">
                <div class="mb-2">
                    <label class="form-label config">First Name</label>
                    <div class="form-icon position-relative">
                        <input type="text" class="form-control" placeholder="First Name" id="first_name" name="first_name" value="{{$edit_data->first_name}}" required="" style="font-size: 13px;">
                    </div>
                </div>
            </div>
            <div class="col-md-4">
                <div class="mb-2">
                    <label class="form-label config">Last Name</label>
                    <div class="form-icon position-relative">
                        <input type="text" class="form-control" placeholder="Last Name" id="last_name" name="last_name" value="{{$edit_data->last_name}}" required="" style="font-size: 13px;">
                    </div>
                </div>
            </div>
            <div class="col-md-4">
                <div class="mb-2">
                    <label class="form-label config">Designation</label>
                    <div class="form-icon position-relative">
                        <input type="text" class="form-control" placeholder="Designation" id="designation" name="designation" value="{{$edit_data->designation}}" required="" style="font-size: 13px;">
                    </div>
                </div>
            </div>
            
            <div class="col-md-4">
                <div class="mb-2">
                    <label class="form-label config">University</label>
                    <div class="form-icon position-relative"> 
                        <select name="university" id="university" class="form-control" required="" style="font-size: 13px;">
                            <option selected disabled>Select University</option>
                            @foreach($universities as $row)
                                <option value="{{$row->id}}" @if($row->id==$edit_data->university_name) selected @endif>{{$row->name}}</option>
                            @endforeach 
                        </select>
                    </div>
                </div>
            </div>
            <div class="col-md-4">
                <div class="mb-2">
                    <label class="form-label config">Department</label>
                    <div class="form-icon position-relative"> 
                        <select name="department" class="form-control department_id" required="" style="font-size: 13px;">
                            <option selected disabled>Select Department</option>
                            @foreach($departments as $row)
                              <option value="{{$row->id}}" @if($row->id==$edit_data->department) selected @endif>{{$row->name}}</option>
                            @endforeach
                            <option value="">Others</option>
                        </select>
                    </div>
                </div>
            </div>
            {{-- <div class="col-md-4 others_department" style="display: none;">
                <div class="mb-2">
                    <label class="form-label config" >Others Department</label>
                    <div class="form-icon position-relative">
                        <input type="text" class="form-control" placeholder="Others Department" id="others_department" name="others_department" value="{{$edit_data->others_department}}" style="font-size: 13px;">
                    </div>
                </div>
            </div>  --}}
            <div class="col-md-4">
                <div class="mb-2">
                    <label class="form-label config">Website</label>
                    <div class="form-icon position-relative">
                        <input type="text" class="form-control" placeholder="www.xyz.com" id="uni_website" name="uni_website" value="{{$edit_data->uni_website}}"  style="font-size: 13px;">
                    </div>
                </div>
            </div>
        </div>  
        <div class="row">
            <div class="col-md-12">
                <div class="text-end">
                    <button type="button" class="btn cancel_button mr-1 btn-cancel close_form" style="background-color: #ffbd59 !important; border: 2px solid #ffbd59; color: white;border-radius: 18px; padding: 2px 6px;">
                        <i aria-hidden="true" class="fa fa-refresh"></i>
                    </button>
                    <button class="btn btn2">Update</button>                                                                                                                
                </div>
            </div> 
        </div>  
    </div>
      
</form>

<script>
    $(function(){
        // $('.department_id').change(function() { 
        //     var value = $(this).attr('selected','selected').val();
        //     if (value == "" ) {
        //         $('.others_department').show();
        //     } else {
        //         $('.others_department').removeClass('display:none');
        //         $('.others_department').hide();
        //     }
        // });

        $('.edit_register_pending_teacher_form').on('submit', function(event){
            event.preventDefault();
            var self = $(this); 
            ajax_form(self, function(self){ 
                fetch_sub_content(
                    '#pending_teacher_load',
                    "{{ route('sub-content', ['name'=>'register_pending_teacher_load']) }}"
                ); 
            });
        });
    });

    $('.btn-cancel').on('click', function(){ 
        $('.edit_data').addClass('d-none')
    });
</script>