@extends ('layouts/template')

@section('content')

<div class="p-3 mcp-theme-1">
    <div class="card">

        <div class="card-header p-0">
            <div class="d-flex align-items-center border-bottom px-2 py-1">
                <strong class="mr-4">
                    <i class="fas fa-notes-medical"></i>
                    All Notes
                </strong>
            </div>
            <div class="px-2 py-1">
                @include('app.practice-management.notes_filters')
            </div>
        </div>
        <div class="card-body p-0">

            <table class="table table-sm table-striped p-0 m-0">
                <thead class="bg-light">
                    <tr>
                        <th class="px-3 border-0">Created</th>
                        <th class="border-0">Effective Date</th>
                        <th class="border-0">Patient</th>
                        <th class="border-0">MCP</th>
                        <th class="border-0">Ally Pro</th>
                        <th class="border-0 w-50">Content</th>
                    </tr>
                </thead>
                <tbody>
                    @foreach ($notes as $note)
                    <tr class="{{ $note->is_cancelled ? 'cancelled-item always-clickable' : '' }}">
                        <td class="px-3">
                            {{ friendly_date_time($note->created_at, true) }}
                        </td>
                        <td class="">
                            <a href="/patients/view/{{ $note->client->uid }}/notes/view/{{ $note->uid }}">
                                {{ friendly_date_time($note->effective_dateest, false) }}
                            </a>
                            <span class="ml-1">{{ $note->is_cancelled ? '[cancelled]' : '' }}</span>
                        </td>
                        <td class="">
                            <a href="/patients/view/{{ $note->client->uid }}">{{ $note->client->displayName() }}</a>
                        </td>
                        <td>{{ $note->hcpPro ? $note->hcpPro->displayName() : '-' }}</td>
                        <td>{{ $note->allyPro ? $note->allyPro->displayName() : '-' }}</td>
                        <td class="">
                            <?php
                            $textContent = strip_tags($note->free_text_html);
                            if (strlen($textContent) > 200) {
                                $textContent = substr($textContent, 0, 200) . '…';
                            }
                            ?>
                            {!! empty($textContent) ? '-' : $textContent !!}
                        </td>
                    </tr>
                    @endforeach
                </tbody>
            </table>
            <div class="mt-3">
                {{ $notes->appends(request()->input())->links() }}
            </div>
        </div>
    </div>
</div>

@endsection