@extends ('layouts/template')

@section('content')
<div class="p-3 mcp-theme-1" id="patients-list">
    <div class="card">

        <div class="card-header border-bottom-0 px-1 py-2 d-flex align-items-center">
            <strong class="mr-4">
                <i class="fas fa-notes-medical"></i>
                Visit Templates
            </strong>
            @include('app.practice-management.visit-templates.create')
        </div>

        <div class="card-body p-0">
            <table class="table table-sm table-striped border-top p-0 m-0">
                <thead class="bg-light">
                    <tr>
                        <th class="border-0">Internal Name</th>
                        <th class="border-0">Title</th>
                        <th class="border-0">Created At</th>
                        <th class="border-0">Status</th>
                        <th class="border-0">Accessiblity</th>
                        <th class="border-0">&nbsp;</th>
                    </tr>
                </thead>
                <tbody>
                    @foreach($visitTemplates as $template)
                    <tr>
                        <td><a href="{{ route('practice-management.visitTemplate', $template) }}">{{ $template->internal_name }}</a></td>
                        <td>{{ $template->title }}</td>
                        <td>{{ friendly_date_time($template->created_at) }}</td>
                        <td>
                            <div>
                                @if($template->is_active)
                                    <span class="text-success">ACTIVE</span>
                                    @if($template->reactivation_memo)
                                        <div style="width:300px;">
                                            <small class="text-muted"><b>Memo: </b>{{ $template->reactivation_memo }}</small>
                                            @include('app.practice-management.visit-templates.update-memo')
                                        </div>
                                    @endif
                                @else
                                    <span class="text-danger">INACTIVE</span>
                                    @if($template->deactivation_memo)
                                        <div style="width:300px;">
                                            <small class="text-muted"><b>Memo: </b>{{ $template->deactivation_memo }}</small>
                                            @include('app.practice-management.visit-templates.update-memo')
                                        </div>
                                    @endif
                                @endif
                            </div>
                        </td>
                        <td>
                            @if($template->is_accessible_to_all)
                                <small class="text-muted"><i class="fas fa-check text-success"></i> Accessible to All</small>
                            @else
                                <small class="text-muted"><i class="fas fa-ban"></i> Limited Access</small>
                            @endif
                        </td>
                        <td>
                            <div class="d-flex align-items-center">
                                <div class="mr-2">
                                @include('app.practice-management.visit-templates.update')
                                </div>
                                <div>
                                @include('app.practice-management.visit-templates.activate-deactivate')
                                </div>
                            </div>
                        </td>                
                    </tr>
                    @endforeach

                    @if(count($visitTemplates) === 0)
                    <tr>
                        <td colspan="5">No records found!</td>
                    </tr>
                    @endif
                </tbody>

            </table>

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