@extends('supervisor.layouts.master')
@section('content') 
<div class="card p-2 rounded border-0" style="background-color: #ffffff; color: #141639c4; height: 80vh;">
    <div class="col-md-12">
        <div class="table-responsive">
            <table class="table table-bordered list_table" style="margin: 0px;">
                <thead>
                    <tr>
                        <th>Sl</th>
                        <th>Name</th>
                        <th>Email</th>
                        <th>Invited on</th>
                        <th>Applied</th>
                        <th>Channel</th>
                        <th class="text-center">Total Invited</th>
                    </tr>
                </thead>
                <tbody>
                    @if(count($refer_users) > 0)
                    @foreach($refer_users as $key=>$row)
                    <tr>
                        <td style="font-size: 11px;">{{$key+1}}</td>
                        <td style="font-size: 11px;">{{$row->first_name }} {{$row->last_name }}</td>
                        <td style="font-size: 11px;">{{$row->email}}</td>
                        <td style="font-size: 11px;">@if(!empty($row->invitation_date)) {{ date('d M Y h.i A', strtotime($row->invitation_date)) }} @else -- @endif</td>
                        <td style="font-size: 11px;">
                            @php
                                $teacher_id =\Auth::guard('teacher')->user()->id;
                                $submitted =\DB::table('student_proposals')->where(
                                'student_id',$row->id
                                )->where(
                                'teacher_id',$teacher_id
                                )->where(
                                'proposal_submit_status',1
                                )->orderBy('id','DESC')->first();
                            @endphp
                            @if(!empty($submitted->submitted_date)) {{ date('d M Y h.i A', strtotime($submitted->submitted_date)) }} @else -- @endif
                        </td>
                        <td style="font-size: 11px;">
                            @if($row->register_type==3)
                                Q-Apply
                            @else
                            --
                            @endif
                        </td>
                        <td class="text-center">
                            @php
                                $user_invited_count = \DB::table('refer_users')->where('email',$row->email)->count();
                            @endphp
                            @if($user_invited_count > 1)
                            <span class="badge bg-secondary">
                                {{ $user_invited_count }}
                            </span>
                            @else
                                --
                            @endif
                        </td>
                    </tr>
                    @endforeach
                    @else
                    <tr>
                        <td colspan="5" class="text-center text-danger">No data found!</td>
                    </tr>
                    @endif
                </tbody>
            </table>
        </div>
    </div><!--end col-->
</div>

@endsection
@push('js')

@endpush