@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>
                Segment Templates
            </strong>
            @include('app.practice-management.segment-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">Default Display Title</th>
                        <th class="border-0">Created At</th>
                        <th class="border-0">Status</th>
                        <th class="border-0">&nbsp;</th>
                    </tr>
                </thead>
                <tbody>
                    @foreach($segmentTemplates as $template)
                    <tr>
                        <td>{{ $template->internal_name }}</td>
                        <td>{{ $template->default_display_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.segment-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.segment-templates.update-memo')
                                        </div>
                                    @endif
                                @endif
                            </div>
                        </td>
                        <td>
                            <div class="d-flex align-items-center">
                                <div class="mr-2">
                                @include('app.practice-management.segment-templates.update')
                                </div>
                                <div>
                                @include('app.practice-management.segment-templates.activate-deactivate')
                                </div>
                            </div>
                        </td>                
                    </tr>
                    @endforeach

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

            </table>

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