<div class="d-flex align-items-end mb-3">
    <b class="large">Measurements in {{friendly_month(date('Y-m-d'))}}</b>
</div>
<table class="table table-striped table-sm table-bordered mb-0">
    <thead>
        <tr>
            <th class="border-0 px-2 text-secondary">Patient</th>
            <th class="border-0 px-2 text-secondary">Category</th>
            <th class="border-0 px-2 text-secondary">Value</th>
            <th class="border-0 px-2 text-secondary">Timestamp</th>
            <th class="border-0 px-2 text-secondary">Mins this month</th>
        </tr>
    </thead>
    <tbody>
        @if(count($measurements))
            <?php foreach($measurements as $measurement): ?>
                <tr>
                    <td class="px-2">
                        <a href="/patients/view/{{$measurement->client_uid}}" class="font-weight-normal">
                            {{ $measurement->name_first }} {{ $measurement->name_last }}
                        </a>
                    </td>
                    <td class="px-2">{{ $measurement->label }}</td>
                    <td class="px-2">
                        @if($measurement->label === 'BP')
                            {{ $measurement->sbp_mm_hg }}/{{ $measurement->dbp_mm_hg }} mmHg
                        @elseif($measurement->label === 'Wt. (lbs.)')
                            {{ round(floatval($measurement->numeric_value), 2) }} lbs
                        @else
                            {{ $measurement->value }}
                        @endif
                    </td>
                    <td>
                        {{ friendly_date_time_short_with_tz_from_timestamp_divide1000($measurement->ts, 'EASTERN') }}
                        EST
                    </td>
                    <td class="px-2">
                        @if($measurement->rm_total_time_in_seconds)
                            {{ floor($measurement->rm_total_time_in_seconds/60) }}
                        @else
                            0
                        @endif
                    </td>
                </tr>
            <?php endforeach ?>
        @else
            <tr>
                <td class="text-secondary p-0 p-3" colspan="7">
                    No items to show
                </td>
            </tr>
        @endif
    </tbody>
</table>
<ul class="dashboard-measurements pagination mt-3">

    <?php $totalPages = ceil($numMeasurements / $page); ?>

    <li class="page-item {{ $page === 1 ? 'disabled' : ''}}" aria-disabled="true" aria-label="« Previous">
        @if($page == 1)
            <span class="page-link" aria-hidden="true">‹</span>
        @else
            <a native target="_top" class="page-link" href="#" data-target-page="{{$page - 1}}">‹</a>
        @endif
    </li>

    <li class="page-item"><span class="page-link text-secondary">Showing {{(($page-1) * 20) + 1}} to {{$numMeasurements < $page * 20 ? $numMeasurements : $page * 20}} of {{$numMeasurements}} measurements</span></li>

    <li class="page-item {{ $page === $totalPages ? 'disabled' : ''}}">
        @if($page === $totalPages)
            <span class="page-link" aria-hidden="true">›</span>
        @else
            <a native target="_top" class="page-link" href="#" data-target-page="{{$page + 1}}">›</a>
        @endif
    </li>
</ul>
