@extends ('layouts.patient')

@section('inner-content')

    @if($patient->has_mcp_done_onboarding_visit !== 'YES')
        <div class="pt-2 d-flex align-items-start">
            <h6 class="my-0 text-secondary d-flex align-items-start">
                <div>
                    <div>
                        <span class="text-dark font-weight-bold">Care Months</span>
                    </div>
                    <div class="text-dark d-inline-flex align-items-center mt-2">
                                    <span class="mr-2">
                                        <i class="fa fa-exclamation-triangle"></i>
                                        MCP Onboarding Visit Pending
                                    </span>
                        <div moe>
                            <a start show>Update</a>
                            <form url="/api/client/updateMcpOnboardingVisitInfo" class="mcp-theme-1">
                                <input type="hidden" name="uid" value="{{$patient->uid}}">
                                <div class="mb-2">
                                    <select name="hasMcpDoneOnboardingVisit"
                                            class="form-control form-control-sm"
                                            onchange="toggleDisabledAsNeeded(this, 'YES', 'if-visit-done')">
                                        <option value="">-- Select Status --</option>
                                        <option value="YES" {{ $patient->has_mcp_done_onboarding_visit === 'YES' ? 'selected' : '' }}>YES</option>
                                        <option value="NO" {{ $patient->has_mcp_done_onboarding_visit === 'NO' ? 'selected' : '' }}>NO</option>
                                        <option value="UNKNOWN" {{ $patient->has_mcp_done_onboarding_visit === 'UNKNOWN' ? 'selected' : '' }}>UNKNOWN</option>
                                    </select>
                                </div>
                                <div class="mb-2">
                                    <input type="date" class="if-visit-done form-control form-control-sm" disabled name="mcpOnboardingVisitDate" max="{{ date('Y-m-d') }}">
                                </div>
                                <div class="mb-2">
                                    <select name="mcpOnboardingVisitNoteUid" disabled
                                            class="form-control form-control-sm if-visit-done"
                                            onchange="toggleVisibilityAsNeeded(this, '', 'if-note-outside-system')">
                                        <option value="">-- Visit Note --</option>
                                        @foreach ($notes as $note)
                                            @if(!empty($note->title) && $note->client_id === $patient->id && !$note->is_cancelled)
                                                <option value="{{$note->uid}}">{{$note->title}}</option>
                                            @endif
                                        @endforeach
                                    </select>
                                </div>
                                <div class="mb-2 if-note-outside-system">
                                                <textarea class="form-control form-control-sm"
                                                          name="reasonOnboardingVisitNoteOutsideSystem"
                                                          placeholder="Visit note outside the system reason"></textarea>
                                </div>
                                <div>
                                    <button submit class="btn btn-sm btn-primary mr-1">Submit</button>
                                    <button cancel class="btn btn-sm btn-default border">Cancel</button>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </h6>
        </div>
    @else

    <div class="">
        <div class="d-flex align-items-center pt-2">
            <h6 class="my-0 font-weight-bold text-secondary">Care Months</h6>
            <span class="mx-2 text-secondary">|</span>
            <div moe>
                <a start show class="py-0 mb-3">Add</a>
                <form url="/api/careMonth/create" redir="patients/view/{{ $patient->uid }}/care-months/view/[data]">
                    <input type="hidden" name="clientUid" value="{{ $patient->uid }}">
                    <div class="mb-2">
                        <label class="text-secondary text-sm mb-1">Month *</label>
                        <select name="startMonth" class="form-control form-control-sm" required>
                            <option value="">-- Start Month --</option>
                            <option value="1" {{ date('n') === '1' ? 'selected' : '' }}>January</option>
                            <option value="2" {{ date('n') === '2' ? 'selected' : '' }}>February</option>
                            <option value="3" {{ date('n') === '3' ? 'selected' : '' }}>March</option>
                            <option value="4" {{ date('n') === '4' ? 'selected' : '' }}>April</option>
                            <option value="5" {{ date('n') === '5' ? 'selected' : '' }}>May</option>
                            <option value="6" {{ date('n') === '6' ? 'selected' : '' }}>June</option>
                            <option value="7" {{ date('n') === '7' ? 'selected' : '' }}>July</option>
                            <option value="8" {{ date('n') === '8' ? 'selected' : '' }}>August</option>
                            <option value="9" {{ date('n') === '9' ? 'selected' : '' }}>September</option>
                            <option value="10" {{ date('n') === '10' ? 'selected' : '' }}>October</option>
                            <option value="11" {{ date('n') === '11' ? 'selected' : '' }}>November</option>
                            <option value="12" {{ date('n') === '12' ? 'selected' : '' }}>December</option>
                        </select>
                    </div>
                    <div class="mb-2">
                        <label class="text-secondary text-sm mb-1">Year *</label>
                        <select name="startYear" class="form-control form-control-sm" required>
                            <option value="">-- Start Year --</option>
                            <option value="2020" {{ date('Y') === '2020' ? 'selected' : '' }}>2020</option>
                            @if(date('m') === '12')
                                <option value="2021" {{ date('Y') === '2021' ? 'selected' : '' }}>2021</option>
                            @endif
                        </select>
                    </div>
                    <div class="d-flex align-items-center">
                        <button class="btn btn-sm btn-primary mr-2" submit>Save</button>
                        <button class="btn btn-sm btn-default mr-2 border" cancel>Cancel</button>
                    </div>
                </form>
            </div>
        </div>
        <table class="table table-striped table-sm table-bordered mt-2 mb-0">
            <thead>
            <tr>
                <th class="px-2 text-secondary border-bottom-0">Start Date</th>
                <th class="px-2 text-secondary border-bottom-0">Total Time</th>
                <th class="px-2 text-secondary border-bottom-0">Bill</th>
                <th class="px-2 text-secondary border-bottom-0">MCP</th>
                <th class="px-2 text-secondary border-bottom-0">RMM</th>
                <th class="px-2 text-secondary border-bottom-0">RME</th>
            </tr>
            </thead>
            <tbody>
            @foreach($careMonths as $careMonth)
                <tr>
                    <td class="px-2">
                        <a href="/patients/view/{{ $patient->uid }}/care-months/view/{{ $careMonth->uid }}">
                            {{friendly_month($careMonth->start_date)}}
                        </a>
                    </td>
                    <td class="px-2">{{time_in_hrminsec($careMonth->rm_total_time_in_seconds)}}</td>
                    <td class="px-2">
                        @if($careMonth->rmBill)
                            {{ $careMonth->rmBill->code }}
                        @else
                            -
                        @endif
                    </td>
                    <td class="px-2">{{$careMonth->mcp ? $careMonth->mcp->name_display : '-'}}</td>
                    <td class="px-2">{{$careMonth->rmmPro ? $careMonth->rmmPro->name_display : '-'}}</td>
                    <td class="px-2">{{$careMonth->rmePro ? $careMonth->rmePro->name_display : '-'}}</td>
                </tr>
            @endforeach
            </tbody>
        </table>
    </div>

    @endif
@endsection
