@extends('web.layouts.master')
@section('content')
        <section class="bg-half-170 d-table w-100" style="background-color: #efefef; height:100vh; padding:121px 0px 5px;">
            <div class="container mb-2">
                <div class="row align-items-center p-3">
                    <div class="col-md-12">
                        <div class="row">
                            <div class="col-md-10" style="width:83%;">
                                <div class="content_header ml-0">
                                    <div class="right">
                                        <h6 style="font-weight:bold !important; margin: 0px; color: #141639c4;">MY APPLICATION</h6>
                                    </div>
                                </div>
                            </div>
                            <!-- <div class="col-md-2 text-right">
                                <button class="submit_button" style="margin-left:2.6rem;">Add New</button>
                            </div> -->
                        </div>
                    </div>
                    <div class="col-md-12">
                        @if(count($student_proposal) > 0 )
                        <div class="scrolled_content_part">
                            @foreach($student_proposal as $key=>$row)
                            <div class="single_ad_pref_item mb-4">
                                <div class="p-2" style="display:flex;">
                                    <div class="left" style="width:50%;">
                                        <div class="uni_details" style="display:flex;"> 
                                            @if(cn($row,'teacher_details.university'))
                                            <img class="img-responsive listFlag" style="border-radius: 20px; padding: 0px;height: 37px;width: 37px;" src="{{ asset('/assets/img/flags/4x3').'/'.strtolower(cn($row,'teacher_details.university.country.iso_3166_2','')).'.svg' }}" alt="Flag" data-toggle="tooltip" title="" data-placement="top">
                                            @else
                                            <div class="inner_left mt-1" style="border: 1px solid black; border-radius: 20px; padding: 6px; height: 37px; width: 37px;">
                                                <i class="fa fa fa-university ms-1"></i>
                                            </div>
                                            @endif
                                            <div class="alert" style="background-color:white; padding: 3px 7px; margin-bottom: 0px;">
                                                <strong style="font-size:13px;">{{ cn($row,'teacher_details.first_name','')}} {{ cn($row,'teacher_details.last_name','')}}</strong></br>
                                                    <span style="font-size:12px; font-weight:400;"> {{cn($row,'teacher_details.designation','')}} </span>
                                                    <span> • </span>
                                                    @if(isset($row->teacher_details->department_name))
                                                        <span style="font-size:12px; font-weight:400;">{{cn($row,'teacher_details.others_department','')}}</span>
                                                    @else
                                                        <span style="font-size:12px; font-weight:400;"> {{cn($row,'teacher_details.department_name.name','')}}</span>
                                                    @endif
                                                    <span> • </span>
                                                    @if($row->teacher_details->university_name)
                                                        <span style="font-size:12px; font-weight:400;"> {{cn($row,'teacher_details.university_name','')}} </span>
                                                    @else
                                                        <span style="font-size:12px; font-weight:400;"> {{cn($row,'teacher_details.university.name','')}} </span>
                                                    @endif
                                            </div>
                                        </div>
                                    </div>
                                    <div class="text-end" style="width:50%;">
                                        <span style="font-size:12px;">Apply Reference</span><br>
                                        <span class="label_badge_radius" style="background-color: #463993; color: white; border-radius: 4px; font-size:11px !important; font-weight:800;">{{$row->student_apply_ref ?? 'N/A'}}</span>
                                    </div>
                                </div>
                                <div class="p-2" style="display:flex; border-top: 1px solid #eee;">
                                    <div class="left" style="width:50%;">
                                        <div class="uni_details" style="display:flex;">
                                            <div class="inner_right ms-5">
                                                <span @if(isset($row->proposal->document_file)) class="open_modal_page" style="cursor: pointer;"  data-url="{{route('modal-get',['name'=>'view_student_proposal','id'=>$row->proposal->id])}}" @endif>
                                                     <strong style="font-size: 13px; font-weight: 600;">{{cn($row,'proposal.title','N/A')}}</strong>
                                                </span>
                                               <br>
                                                    <div style="margin-top: -2px;">
                                                        <span style="font-size:12px;">{{cn($row,'proposal.proposal_ref','N/A')}}</span>
                                                        <span> • </span>
                                                        <span style="font-size:12px;">{{cn($row,'proposal.methology','N/A')}}</span>
                                                        @php
                                                            $proposal =\DB::table('proposal')->where('id',$row->proposal_id)->first();
                                                            if(isset($proposal->department)){
                                                                $department =model('Department')::find($proposal->department);
                                                            }

                                                            @endphp
                                                        @if(isset($department))
                                                        <span> • </span>
                                                            <span style="font-size:12px;">{{$department->name ?? ''}}</span>
                                                        @endif
                                                        <span> • </span>
                                                        <span style="font-size:12px;">{{cn($row,'proposal.status','N/A')}}</span>
                                                    </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="p-2" style="display:flex; border-top: 1px solid #eee;">
                                    <div class="left" style="width:50%;">
                                        <div class="uni_details" style="display:flex;">
                                            <div class="inner_right ms-5">
                                                <span style="font-size:12px;">Preferred Start Date : <br><strong style="font-size:13px;">@if(!empty($row->submitted_date)){{ date('M Y', strtotime($row->submitted_date))}} @else {{'N/A'}} @endif</strong></span><br>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="text-end" style="width:50%;">
                                        <span style="font-size:12px;">Application Status </span><br>
                                        @if($row->proposal_submit_status==1 && $row->proposal_status ==1)
                                            <span class="label_badge_radius" style="background-color: #d8fdd8; color: green; border-radius: 5px; font-weight: bold;">Applied</span>
                                        @elseif($row->proposal_submit_status==1 && $row->proposal_status ==2 || $row->proposal_submit_status==1 && $row->proposal_status ==3)
                                            <span class="label_badge_radius" style="background-color: #d8fdd8; color: green; border-radius: 5px; font-weight: bold;">In Review</span>
                                        @elseif($row->proposal_submit_status==1 && $row->proposal_status ==4)
                                            <span class="label_badge_radius" style="background-color: #d8fdd8; color: green; border-radius: 5px; font-weight: bold;">Hold</span>
                                        @elseif($row->proposal_submit_status==1 && $row->proposal_status ==5)
                                            <span class="label_badge_radius" style="background-color: #d8fdd8; color: green; border-radius: 5px; font-weight: bold;">Interested</span>
                                        @elseif($row->proposal_submit_status==1 && $row->proposal_status ==6)
                                            <span class="label_badge_radius" style="background-color: #d8fdd8; color: green; border-radius: 5px; font-weight: bold;">Rejected</span>
                                        @elseif($proposal =='true' || $publication =='true' || $worK_exp =='true'|| $institution =='true'|| $score =='true')   
                                          <span class="label_badge_radius" style="background-color: #d8fdd8; color: green; border-radius: 5px; font-weight: bold; cursor: pointer;">Draft</span>
                                        @else
                                            <span class="label_badge_radius open_modal_page" data-url="{{ route('modal-get',['name'=>'update_student_proposal','id'=>$row->id,'student_id'=>$row->student_id,'teacher_id'=>$row->teacher_id]) }}" data-title="Submit your Proposal" style="background-color: #f2d0a4; color: #dc3545; border-radius: 5px; font-weight: bold; cursor: pointer;">Submit</span>
                                        @endif
                                    </div>
                                </div> 
                                   
                                <div class="p-2" style="display:flex; border-top: 1px solid #eee;"> 
                                    @if($row->proposal_submit_status==1 && $row->proposal_status ==6 && $row->feedback_msg)    
                                    <span class="alert mt-3" role="alert" style="font-size: 12px !important; border-radius: .55rem; padding: 8px 12px; margin-top: 6px; background: #fff0d6; color: rgb(237, 14, 14); border-color: #ffebca; border-width: 3px; border-style: double;"> 
                                        <i class="fa fa-warning" style="font-size: 11px; margin-right: 5px; color: rgb(237, 14, 14) !important; top: 0px; position: relative;"></i>  
                                        Rejected, {{ $row->feedback_msg }} 
                                    </span>
                                    @elseif($row->proposal_submit_status==1 && $row->proposal_status ==4)
                                    <span class="alert mt-3" role="alert" style="font-size: 12px !important; border-radius: .55rem; padding: 8px 12px; margin-top: 6px; background: #fff0d6; color: rgb(237, 14, 14); border-color: #ffebca; border-width: 3px; border-style: double;"> 
                                        <i class="fa fa-warning" style="font-size: 11px; margin-right: 5px; color: rgb(237, 14, 14) !important; top: 0px; position: relative;"></i>  
                                            
                                        {{'Hold, Further document/information needed'}}
                                    </span>
                                    @elseif($row->proposal_submit_status==1 && $row->proposal_status ==5)
                                    <span class="alert mt-3" role="alert" style="font-size: 12px !important; border-radius: .55rem; padding: 8px 12px; margin-top: 6px; background: #fff0d6; color: rgb(237, 14, 14); border-color: #ffebca; border-width: 3px; border-style: double;"> 
                                        <i class="fa fa-warning" style="font-size: 11px; margin-right: 5px; color: rgb(237, 14, 14) !important; top: 0px; position: relative;"></i>  
                                            
                                        {{'Interested, please submit application'}}
                                    </span>
                                    @endif 
                                
                               </div>
                            </div>
                            @endforeach
                        </div>
                        @else
                        <div class="alert  mt-2 mb-3" style="background-color: #ffff; border-color: #e9f0f3; font-size: 12px !important; color: #dc3545; border-radius: 30px; padding: 8px 15px;">
                            <span>No Application available.</span>
                        </div>
                        @endif
                    </div>
                </div>
            </div><!--end container-->
        </section>
@endsection