
<div class="row">
    <strong>Consultations Found:</strong>
    {{ consultationsFound }}
</div>
<div class="row">
    <table class="manage-items">
        <tr>
            <th>ID</th>
            <th>Type</th>
            <th>Date &amp; Time</th>
            <th>Status</th>
            <th>Patient</th>
            <th>Assigned To</th>
            <th>Duration</th>
            <th>Cost</th>
            <th>Medium</th>
            <th>Documents</th>
            <th class="center">Transcript</th>
            <th class="center">View</th>
            <th class="center">Video</th>
        </tr>
        <tbody class="tabular">
        {% for consultation in consultations %}
            <tr>
                <td>
                    <a href="{{ consultation.viewURL }}"
                       target="_blank"
                    >
                        {{ consultation.wisebee_id }}
                    </a>
                </td>
                <td>
                    {{ consultation.rate }}
                </td>
                <td>
                    {{ consultation.dateTime }}
                </td>
                <td>
                    {{ consultation.status }}
                </td>
                <td>
                    {% if consultation.member_id is not empty %}
                        <a href="{{ route('admin-patients-profile', {
                            id: consultation.member_id
                        }) }}">
                            {{ consultation.patient.firstname }} {{ consultation.patient.lastname }}
                        </a>
                    {% else %}
                        {{ consultation.patient.firstname }} {{ consultation.patient.lastname }}
                    {% endif %}
                </td>
                <td>
                    {{ consultation.specialist ?
                    consultation.specialist.firstname ~ ' ' ~ consultation.specialist.lastname :
                    '-'
                    }}
                </td>
                <td>
                    {{ consultation.length }} min
                </td>
                <td>
                    {{ (consultation.cost > 0 ? '&pound;' ~ consultation.cost : '-')|raw }}
                </td>
                <td>
                    {{ mediums[consultation.medium] }}
                </td>
                <td>
                    {% include 'wisebee/admin/documents.twig' with {
                        documents: consultation.documents
                    } %}
                </td>
                <td class="center">
                    {% if consultation.transcript_data %}
                        <i class="fa fa-file-text-o mtcOverlay transcriptIcon viewTranscriptButton {% if not consultation.transcript_data.is_approved %}is-pending{% endif %}"
                           title="{% if consultation.transcript_data.is_approved %}Transcript — Approved {{ consultation.transcript_data.approved_at|date('d/m/Y H:i') }}{% else %}Transcript — Not yet approved{% endif %}"
                           href="#transcriptModal-{{ consultation.transcript_data.id }}"
                           data-no-ajax="1"
                        ></i>
                        <div id="transcriptModal-{{ consultation.transcript_data.id }}" class="transcriptModal" hidden>
                            <div class="transcriptModal__header">
                                <h4>Consultation Transcript</h4>
                                <a href="{{ route('admin-patient-transcripts-pdf', { id: consultation.transcript_data.id }) }}"
                                   target="_blank"
                                   title="Download PDF"
                                   class="transcriptModal__download"
                                >
                                    <i class="fa fa-download"></i>
                                </a>
                            </div>
                            {{ consultation.transcript_data.formatted_content|raw }}
                        </div>
                    {% else %}
                        <span class="textMuted">&mdash;</span>
                    {% endif %}
                </td>
                <td class="center">
                    <a href="{{ consultation.viewURL }}"
                       target="_blank"
                    >
                        <i class="fa fa-eye"></i>
                    </a>
                </td>
                <td class="center">
                    {% if consultation.videoURL is not empty %}
                        <a href="{{ consultation.videoURL }}"
                           target="_blank"
                        >
                            <i class="fa fa-video-camera"></i>
                        </a>
                    {% endif %}
                </td>
            </tr>
        {% endfor %}
        </tbody>
    </table>
</div>
<script>
    (function () {
        var bind = function () {
            try {
                $('.viewTranscriptButton').mtcOverlay({});
            } catch (e) {}
        };
        if (typeof $ === 'function') {
            $(bind);
        } else {
            document.addEventListener('DOMContentLoaded', bind);
        }
    })();
</script>