@extends ('layouts/template')

@section('content')

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

        <div class="card-header px-3 py-2 d-flex align-items-center">
            <strong class="mr-4">
                <i class="fas fa-user-injured"></i>
                Notes
            </strong>
            <select class="ml-auto max-width-300px form-control form-control-sm" onchange="fastLoad('/practice-management/notes/' + this.value, true, false, false)">
                <option value="" {{ $filter === '' ? 'selected' : '' }}>All notes</option>
                <option value="not-yet-signed" {{ $filter === 'not-yet-signed' ? 'selected' : '' }}>Notes not yet signed</option>
            </select>
        </div>
        <div class="card-body p-0">

            <table class="table table-sm table-condensed 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 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 }}" class="font-weight-bold">
                                {{ 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 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>
    </div>
    </div>

@endsection
