@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>
                    Cellular Device Manager
                </strong>
                <select class="ml-auto max-width-300px form-control form-control-sm"
                        onchange="fastLoad('/practice-management/cellular-device-manager/' + this.value, true, false, false)">
                    <option value="" {{ $proUid === '' ? 'selected' : '' }}>All Pros</option>
                    @foreach($allPros as $_pro)
                        <option value="{{$_pro->uid}}" {{ $proUid === $_pro->uid ? 'selected' : '' }}>{{$_pro->displayName()}}</option>
                    @endforeach
                </select>
            </div>
            <style>
                .cellular-bp {
                    background-color: #d7d9f2;
                }
                .cellular-weight {
                    background-color: #ffe8d4;
                }
            </style>
            <div class="card-body p-0">
                <table class="table table-sm table-condensed p-0 m-0">
                    <colgroup>
                        <col span="4">
                        <col span="4" class="cellular-bp">
                        <col span="4" class="cellular-weight">
                    </colgroup>
                    <thead class="bg-light">
                    <tr>
                        <th colspan="4"></th>
                        <th colspan="4">Cellular BP</th>
                        <th colspan="4">Cellular Weight</th>
                    </tr>
                    <tr>
                        <th class="px-3 border-0">Created</th>
                        <th class="border-0">Patient</th>
                        <th class="border-0">MCP</th>
                        <th class="border-0">RME</th>

                        <th class="border-0">Sent?</th>
                        <th class="border-0">First use</th>
                        <th class="border-0">Last use</th>
                        <th class="border-0">Total measurements</th>

                        <th class="border-0">Sent?</th>
                        <th class="border-0">First use</th>
                        <th class="border-0">Last use</th>
                        <th class="border-0">Total measurements</th>
                    </tr>
                    </thead>
                    <tbody>
                    @foreach ($clients as $client)
                        <tr>

                            <td>{{ $client->created_at }}</td>
                            <td>{{ $client->displayName() }}</td>
                            <td>{{ $client->mcpDisplayName() }}</td>
                            <td>{{ $client->rmeDisplayName() }}</td>

                            <td>{{ $client->firstCellularBPDevice() ? 'Yes' : 'No' }}</td>
                            <td>{{ $client->getFirstCellularBPMeasurementAt()  }}</td>
                            <td>{{ $client->getLatestCellularBPMeasurementAt() }}</td>
                            <td>{{ $client->getTotalCellularBPMeasurements() }}</td>

                            <td>{{ $client->firstCellularWeightDevice() ? 'Yes' : 'No' }}</td>
                            <td>{{ $client->getFirstCellularWeightMeasurementAt()  }}</td>
                            <td>{{ $client->getLatestCellularWeightMeasurementAt() }}</td>
                            <td>{{ $client->getTotalCellularWeightMeasurements() }}</td>

                        </tr>
                    @endforeach
                    </tbody>
                </table>
                <div>
                    {{$clients->links()}}
                </div>
            </div>
        </div>
    </div>

@endsection
