@extends ('layouts.patient')
@section('inner-content')
<div class="">
    <div class="d-flex align-items-center pb-2">
        <h4 class="font-weight-bold mb-0 mr-3">Review Requests</h4>
        @if($performer->pro->pro_type === 'ADMIN')
            @include('app.patient.review-requests.partials.create')
        @endif
    </div>
    <table class="table table-striped table-sm table-bordered">
        <thead class="bg-light">
            <tr>
                <th class="border-0 text-secondary text-nowrap">Created At</th>
                <th class="border-0 text-secondary">Scoped Month Start Date</th>
                <th class="border-0 text-secondary">Access Start Date</th>
                <th class="border-0 text-secondary">Access End Date</th>
                <th class="border-0 text-secondary">Pro</th>
                <th class="border-0 text-secondary">Created By</th>
                <th  class="border-0 text-secondary">Is Active</th>
                <th  class="border-0 text-secondary">Status</th>
                <th  class="border-0 text-secondary"></th>
            </tr>
        </thead>
        <tbody>
            @foreach($reviewRequests as $rr)
            <tr>
                <td class="text-nowrap">{{ friendly_date_time($rr->created_at) }}</td>
                <td>{{ friendly_date($rr->scoped_month_start_date) }}</td>
                <td>{{ friendly_date($rr->access_start_date) }}</td>
                <td>{{ friendly_date($rr->access_end_date) }}</td>
                <td>{{ $rr->pro->displayName() }}</td>
                <td>{{ $rr->createdBySession->pro->displayName() }}</td>
                <td>
                    @if($rr->is_active)
                        <span class="text-success mr-2">YES 
                            @if($rr->reactivation_memo)
                                <i class="fas fa-info-circle text-muted" title="{{ $rr->reactivation_memo }}"></i>
                            @endif
                        </span>
                        @if($performer->pro->pro_type === 'ADMIN')
                            @include('app.patient.review-requests.partials.deactivate')
                        @endif
                    @else
                        <span class="text-secondary mr-2">NO
                        @if($rr->deactivation_memo)
                                <i class="fas fa-info-circle text-muted" title="{{ $rr->deactivation_memo }}"></i>
                            @endif
                        </span>
                        @if($performer->pro->pro_type === 'ADMIN')
                            @include('app.patient.review-requests.partials.activate')
                        @endif
                    @endif
                </td>
                <td>
                    <span class="mr-2">{{ $rr->status ?? '--' }} 
                        @if($rr->status_memo )
                            <i class="fas fa-info-circle text-muted" title="{{ $rr->status_memo }}"></i>
                        @endif
                    </span>
                    @if($performer->pro->pro_type === 'ADMIN')
                        @include('app.patient.review-requests.partials.update-status')
                    @endif
                </td>
                <td>
                    @if($performer->pro->pro_type === 'ADMIN')
                        @include('app.patient.review-requests.partials.edit')
                    @endif
                </td>
            </tr>
            @endforeach
        </tbody>
    </table>
    <div class="p-3">
        {{$reviewRequests->withQueryString()->links()}}
    </div>
</div>

@endsection