@extends('app.practice-management.visit-templates.single')
@section('visitTemplateTab')
<div class="row">
    <div class="col-12">
        <div class="alert alert-info">
            <i class="fas fa-info-circle"></i> Note: <b>Admins</b> have access to all templates.
        </div>
    </div>
    <div class="col-md-12">
        <div class="card mb-2">
            <div class="card-header border-bottom-0 px-1 py-2 d-flex align-items-center">
                <div class="d-flex align-items-center">
                <strong class="mr-4">
                    <i class="fas fa-users"></i>
                    Visit Template Pro Accesses
                </strong>
                <div class="ml-4">
                    <div class="d-flex align-items-center">
                        @if(!$visitTemplate->is_accessible_to_all)
                            @include('app.practice-management.visit-templates.visit-template-accesses.create')
                        @endif
                        @include('app.practice-management.visit-templates.visit-template-accesses.toggle-access-for-all')
                    </div>
                </div>
                </div>
            </div>
            <div class="card-body p-0">
                @if($visitTemplate->is_accessible_to_all)
                <div class="p-2">
                    <div class="alert alert-info">
                        <i class="fas fa-info-circle"></i> Note: <b>All Pros</b> have access to all templates.
                    </div>
                </div>
                @else
                <div class="table-responsive">
                    <table class="table table-sm table-striped border-top p-0 m-0">
                        <thead class="bg-light">
                            <tr>
                                <th class="border-0">Pro</th>
                                <th class="border-0">Pro Type</th>
                                <th class="border-0">Type</th>
                                <th class="border-0">Status</th>
                                <th class="border-0">&nbsp;</th>
                            </tr>
                        </thead>
                        <tbody>
                            @foreach($visitTemplateAccesses as $access)
                            <tr>
                                <td>{{ $access->pro->displayName() }}</td>
                                <td>{{ $access->pro->pro_type }}</td>
                                <td>{{ $access->type }}</td>
                                <td>
                                    <div>
                                        @if($access->is_active)
                                        <span class="text-success">ACTIVE</span>
                                        @if($access->reactivation_memo)
                                        <div style="width:300px;">
                                            <small class="text-muted"><b>Memo: </b>{{ $access->reactivation_memo }}</small>
                                            @include('app.practice-management.visit-templates.visit-template-accesses.update-memo')
                                        </div>
                                        @endif
                                        @else
                                        <span class="text-danger">INACTIVE</span>
                                        @if($access->deactivation_memo)
                                        <div style="width:300px;">
                                            <small class="text-muted"><b>Memo: </b>{{ $access->deactivation_memo }}</small>
                                            @include('app.practice-management.visit-templates.visit-template-accesses.update-memo')
                                        </div>
                                        @endif
                                        @endif
                                    </div>
                                </td>
                                <td>
                                    <div class="d-flex align-items-center">
                                        <div>
                                            @include('app.practice-management.visit-templates.visit-template-accesses.activate-deactivate')
                                        </div>
                                    </div>
                                </td>
                            </tr>
                            @endforeach
                            @if(!count($visitTemplateAccesses))
                            <tr>
                                <td colspan="5">No records found!</td>
                            </tr>
                            @endif
                        </tbody>

                    </table>
                </div>
                @endif
            </div>
        </div>

        <div class="mt-3">
            {{ $visitTemplateAccesses->appends(request()->input())->links() }}
        </div>
    </div>
</div>
@endSection