@extends ('layouts/template')

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

        <div class="card-header px-2 py-1 d-flex align-items-center">
            <strong class="mr-4">
                <i class="fas fa-notes-medical"></i>
                Notes
            </strong>
        </div>

        <div class="card-body p-0">
            <div class="p-3">
                @include('app.rd.notes_filters')
            </div>
            <table class="table table-sm table-striped border-top p-0 m-0">
                <thead class="bg-light">
                    <tr>
                        <th class="border-0">Effective Date</th>
                        <th class="border-0">Patient</th>
                        <th class="border-0">New Patient / FU</th>

                        <th class="border-0">HCP</th>

                        <th class="border-0">HCP Signed</th>
                        <th class="border-0">&nbsp;</th>
                    </tr>
                </thead>
                <tbody>
                    @foreach ($notes as $note)
                    <tr class="{{ $note->is_cancelled ? 'cancelled-item always-clickable' : '' }}">
                        <td>
                            <a href="/patients/view/{{ $note->client->uid }}/notes/view/{{ $note->uid }}" class="font-weight-bold">
                                {{ friendly_date_time($note->effective_dateest, false) }}
                            </a>
                            @if(!!$note->visitTemplate)
                            <span class="text-info font-weight-bold">*</span>
                            @endif
                            <span class="ml-1">{{ $note->is_cancelled ? '[cancelled]' : '' }}</span>
                        </td>
                        <td>
                            {{ $note->client->displayName() }}
                        </td>

                        <td>
                            {{ $note->new_or_fu_or_na === 'NEW' ? 'New Patient' : $note->new_or_fu_or_na }}
                        </td>

                        <td>
                            {{$note->hcpPro ? $note->hcpPro->name_display: '-'}}
                        </td>

                        <td>
                            {!! $note->hcpPro && $note->is_signed_by_hcp ? '<b class="text-success">Yes</b>' : 'No' !!}
                        </td>
                        <td>
                            <div class="position-relative c-pointer text-center stag-tooltip">
                                <i class="fa fa-info-circle"></i>
                                <div class="position-absolute bg-white border rounded p-2 stag-tooltip-content">
                                    <div class="text-nowrap small text-left pb-1">Created on <b>{{ friendly_date_time($note->created_at, true) }}</b></div>
                                    <div class="text-nowrap small text-left">Created by <b>{{ $note->createdSession && $note->createdSession->pro ? $note->createdSession->pro->displayName() : '-'}}</b></div>
                                </div>
                            </div>
                        </td>
                    </tr>
                    @endforeach

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

            </table>

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

</div>
@endsection