@extends ('layouts/template')

<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.23/css/jquery.dataTables.css">
<script type="text/javascript" charset="utf8" src="https://cdn.datatables.net/1.10.23/js/jquery.dataTables.js"></script>


@section('content')
<div id="rm-launch-and-clean" class="p-3 mcp-theme-1">
    <div class="d-flex align-items-end mb-3">
        <div class="font-weight-bold font-size-14 text-secondary">
            RM - Launch &amp; Clean
        </div>
    </div>
    <div class="border p-2 mb-2 rounded">
        <table class="table table-striped table-condensed table-bordered table-sm width-300px">
            <tbody>
                <tr>
                    <td class="text-nowrap">Care Months Eligible For <b>RM30 HCP + 40 EXTRA</b></td>
                    <td class="text-success font-weight-bold text-right">{{$keyNumbers['careMonthsEligibleForBillGeneration_RM30_HCP_PLUS_40']}}</td>
                </tr>

                <tr>
                    <td class="text-nowrap">Care Months Eligible For <b>RM30 HCP + 20 EXTRA</b></td>
                    <td class="text-success font-weight-bold text-right">{{$keyNumbers['careMonthsEligibleForBillGeneration_RM30_HCP_PLUS_20']}}</td>
                </tr>

                <tr>
                    <td class="text-nowrap">Care Months Eligible For <b>RM30 HCP Only</b></td>
                    <td class="text-success font-weight-bold text-right">{{$keyNumbers['careMonthsEligibleForBillGeneration_RM30_HCP']}}</td>
                </tr>

                <tr>
                    <td class="text-nowrap">Care Months Eligible For <b>RMB</b></td>
                    <td class="text-success font-weight-bold text-right">{{$keyNumbers['careMonthsEligibleForBillGeneration_RMB']}}</td>
                </tr>

                <tr>
                    <td class="text-nowrap">Care Months Eligible For <b>RM30 HCP + 40 EXTRA IF HAD INTERACTION</b></td>
                    <td class="text-success font-weight-bold text-right">{{$keyNumbers['careMonthsEligibleForBillGeneration_RM30_HCP_PLUS_40_ifHadInteraction']}}</td>
                </tr>
                <tr>
                    <td class="text-nowrap">Care Months Eligible For <b>RM30 HCP + 20 EXTRA IF HAD INTERACTION</b></td>
                    <td class="text-success font-weight-bold text-right">{{$keyNumbers['careMonthsEligibleForBillGeneration_RM30_HCP_PLUS_20_ifHadInteraction']}}</td>
                </tr>

                <tr>
                    <td class="text-nowrap">Care Months With <b>16+ Measurement Days</b></td>
                    <td class="text-success font-weight-bold text-right">{{$keyNumbers['careMonthsWith16OrMoreMeasurementDays']}}</td>
                </tr>



            </tbody>
        </table>
    </div>
    <div class="d-flex align-items-center">
        <button class="btn btn-sm btn-primary btn-launch px-3 font-weight-bold mr-3" {{@$keyNumbers['careMonthsEligibleForBillGeneration_RM30_HCP_PLUS_40'] ? '' : 'disabled'}} {{@$keyNumbers['careMonthsEligibleForBillGeneration_RM30_HCP_PLUS_40'] ? '' : 'perm-disabled'}} data-ep="rm-admin-launcher-rm30-hcp-plus-40">Generate RM-30 HCP PLUS 40 ({{@$keyNumbers['careMonthsEligibleForBillGeneration_RM30_HCP_PLUS_40']}})
        </button>
        <button class="btn btn-sm btn-primary btn-launch px-3 font-weight-bold mr-3" {{@$keyNumbers['careMonthsEligibleForBillGeneration_RM30_HCP_PLUS_20'] ? '' : 'disabled'}} {{@$keyNumbers['careMonthsEligibleForBillGeneration_RM30_HCP_PLUS_20'] ? '' : 'perm-disabled'}} data-ep="rm-admin-launcher-rm30-hcp-plus-20">Generate RM-30 HCP PLUS 20 ({{@$keyNumbers['careMonthsEligibleForBillGeneration_RM30_HCP_PLUS_20']}})
        </button>
        <button class="btn btn-sm btn-primary btn-launch px-3 font-weight-bold mr-3" {{@$keyNumbers['careMonthsEligibleForBillGeneration_RM30_HCP'] ? '' : 'disabled'}} {{@$keyNumbers['careMonthsEligibleForBillGeneration_RM30_HCP'] ? '' : 'perm-disabled'}} data-ep="rm-admin-launch-rm30-hcp">Generate RM-30 HCP ({{@$keyNumbers['careMonthsEligibleForBillGeneration_RM30_HCP']}})
        </button>
        <button class="btn btn-sm btn-primary btn-launch px-3 font-weight-bold mr-3" {{@$keyNumbers['careMonthsEligibleForBillGeneration_RMB'] ? '' : 'disabled'}} {{@$keyNumbers['careMonthsEligibleForBillGeneration_RMB'] ? '' : 'perm-disabled'}} data-ep="rm-admin-launch-rmb">Generate RMB ({{@$keyNumbers['careMonthsEligibleForBillGeneration_RMB']}})
        </button>

        <button class="btn btn-sm btn-primary btn-launch px-3 font-weight-bold mr-3" data-ep="rm-admin-launch-counts">Get counts
        </button>


    </div>
    <div class="my-3 text-secondary text-sm text-monospace launch-result" style="white-space: pre;">
    </div>
<div class="border rounded p-2">
    <div class="table-responsive">
        <table class="table table-sm table-striped text-nowrap" id="careMonthsTable">
            <thead>
                <tr>
                    <th>Created At</th>
                    <th>Uid</th>
                    <th>Cm Total Time In Seconds</th>
                    <th>Cm Total Time In Seconds By Cm Pro</th>
                    <th>Cm Total Time In Seconds By Mcp</th>
                    <th>Has Mcp Done Em Visit</th>
                    <th>Is Client Enrolled In Cm</th>
                    <th>Is Client Enrolled In Rm</th>
                    <th>Is Cm Canceled This Month</th>
                    <th>Is Rm Canceled This Month</th>
                    <th>Is Tm This Month</th>
                    <th>Rm Total Time In Seconds</th>
                    <th>Rm Total Time In Seconds By Mcp</th>
                    <th>Rm Total Time In Seconds By Rme Pro</th>
                    <th>Rm Total Time In Seconds By Rmm Pro</th>
                    <th>Start Date</th>
                    <th>Why Is Cm Canceled This Month</th>
                    <th>Why Is Rm Canceled This Month</th>
                    <th>Why Not Enrolled In Cm Category</th>
                    <th>Why Not Enrolled In Cm Memo</th>
                    <th>Why Not Enrolled In Rm Category</th>
                    <th>Why Not Enrolled In Rm Memo</th>
                    <th>Created By Session Id</th>
                    <th>Client Id</th>
                    <th>Cm Bill Id</th>
                    <th>Cm Pro Id</th>
                    <th>Mcp Pro Id</th>
                    <th>Rm Bill Id</th>
                    <th>Rme Pro Id</th>
                    <th>Rmm Pro Id</th>
                    <th>Rms Pro Id</th>
                    <th>Rmg Pro Id</th>
                    <th>Rm Total Time In Seconds By Rms Pro</th>
                    <th>Rm Total Time In Seconds By Rmg Pro</th>
                    <th>Number Of Days With Remote Measurements</th>
                    <th>Is Bill Closed</th>
                    <th>Bill Closed At</th>
                    <th>Bill Closed By Session Id</th>
                    <th>Bill Closed By Pro Id</th>
                    <th>Is Billing Marked Done</th>
                    <th>Billing Marked Done By Session Id</th>
                    <th>Billing Marked Done By Pro Id</th>
                    <th>Billing Marked Done At</th>
                    <th>Claim Total Expected</th>
                    <th>Is Claim Closed</th>
                    <th>Claim Closed At</th>
                    <th>Claim Closed By Session Id</th>
                    <th>Claim Closed By Pro Id</th>
                    <th>Claim Summary</th>
                    <th>Claim Total Paid</th>
                    <th>Company Pro Payer Id</th>
                    <th>Company Pro Id</th>
                    <th>Company Id</th>
                    <th>Company Location Id</th>
                    <th>Has Anyone Interacted With Client About Rm Outside Note</th>
                    <th>Rm Num Measurements Not Stamped By Mcp</th>
                    <th>Rm Num Measurements Not Stamped By Non HCP</th>
                    <th>Rm Num Measurements Not Stamped By Rmm</th>
                    <th>Rm Num Measurements Not Stamped By Rme</th>
                    <th>Has Mcp Rm Interacted By Note</th>
                    <th>Mcp Rm Interaction Note Id</th>
                    <th>Is Rm Interaction Waived</th>
                </tr>
            </thead>

            <tbody>
                @foreach($careMonthsWith16PlusMeasurements as $careMonth)
                <tr>
                    <td>{{$careMonth->created_at}}</td>
                    <td>{{$careMonth->uid}}</td>
                    <td>{{$careMonth->cm_total_time_in_seconds}}</td>
                    <td>{{$careMonth->cm_total_time_in_seconds_by_cm_pro}}</td>
                    <td>{{$careMonth->cm_total_time_in_seconds_by_mcp}}</td>
                    <td>{{$careMonth->has_mcp_done_em_visit}}</td>
                    <td>{{$careMonth->is_client_enrolled_in_cm}}</td>
                    <td>{{$careMonth->is_client_enrolled_in_rm}}</td>
                    <td>{{$careMonth->is_cm_canceled_this_month}}</td>
                    <td>{{$careMonth->is_rm_canceled_this_month}}</td>
                    <td>{{$careMonth->is_tm_this_month}}</td>
                    <td>{{$careMonth->rm_total_time_in_seconds}}</td>
                    <td>{{$careMonth->rm_total_time_in_seconds_by_mcp}}</td>
                    <td>{{$careMonth->rm_total_time_in_seconds_by_rme_pro}}</td>
                    <td>{{$careMonth->rm_total_time_in_seconds_by_rmm_pro}}</td>
                    <td>{{$careMonth->start_date}}</td>
                    <td>{{$careMonth->why_is_cm_canceled_this_month}}</td>
                    <td>{{$careMonth->why_is_rm_canceled_this_month}}</td>
                    <td>{{$careMonth->why_not_enrolled_in_cm_category}}</td>
                    <td>{{$careMonth->why_not_enrolled_in_cm_memo}}</td>
                    <td>{{$careMonth->why_not_enrolled_in_rm_category}}</td>
                    <td>{{$careMonth->why_not_enrolled_in_rm_memo}}</td>
                    <td>{{$careMonth->created_by_session_id}}</td>
                    <td>{{$careMonth->client_id}}</td>
                    <td>{{$careMonth->cm_bill_id}}</td>
                    <td>{{$careMonth->cm_pro_id}}</td>
                    <td>{{$careMonth->mcp_pro_id}}</td>
                    <td>{{$careMonth->rm_bill_id}}</td>
                    <td>{{$careMonth->rme_pro_id}}</td>
                    <td>{{$careMonth->rmm_pro_id}}</td>
                    <td>{{$careMonth->rms_pro_id}}</td>
                    <td>{{$careMonth->rmg_pro_id}}</td>
                    <td>{{$careMonth->rm_total_time_in_seconds_by_rms_pro}}</td>
                    <td>{{$careMonth->rm_total_time_in_seconds_by_rmg_pro}}</td>
                    <td>{{$careMonth->number_of_days_with_remote_measurements}}</td>
                    <td>{{$careMonth->is_bill_closed}}</td>
                    <td>{{$careMonth->bill_closed_at}}</td>
                    <td>{{$careMonth->bill_closed_by_session_id}}</td>
                    <td>{{$careMonth->bill_closed_by_pro_id}}</td>
                    <td>{{$careMonth->is_billing_marked_done}}</td>
                    <td>{{$careMonth->billing_marked_done_by_session_id}}</td>
                    <td>{{$careMonth->billing_marked_done_by_pro_id}}</td>
                    <td>{{$careMonth->billing_marked_done_at}}</td>
                    <td>{{$careMonth->claim_total_expected}}</td>
                    <td>{{$careMonth->is_claim_closed}}</td>
                    <td>{{$careMonth->claim_closed_at}}</td>
                    <td>{{$careMonth->claim_closed_by_session_id}}</td>
                    <td>{{$careMonth->claim_closed_by_pro_id}}</td>
                    <td>{{$careMonth->claim_summary}}</td>
                    <td>{{$careMonth->claim_total_paid}}</td>
                    <td>{{$careMonth->company_pro_payer_id}}</td>
                    <td>{{$careMonth->company_pro_id}}</td>
                    <td>{{$careMonth->company_id}}</td>
                    <td>{{$careMonth->company_location_id}}</td>
                    <td>{{$careMonth->has_anyone_interacted_with_client_about_rm_outside_note}}</td>
                    <td>{{$careMonth->rm_num_measurements_not_stamped_by_mcp}}</td>
                    <td>{{$careMonth->rm_num_measurements_not_stamped_by_non_hcp}}</td>
                    <td>{{$careMonth->rm_num_measurements_not_stamped_by_rmm}}</td>
                    <td>{{$careMonth->rm_num_measurements_not_stamped_by_rme}}</td>
                    <td>{{$careMonth->has_mcp_rm_interacted_by_note}}</td>
                    <td>{{$careMonth->mcp_rm_interaction_note_id}}</td>
                    <td>{{$careMonth->is_rm_interaction_waived}}</td>
                </tr>
                @endforeach
            </tbody>
        </table>
    </div>
    </div>
</div>
<script>
    $(document).ready(function() {
        $('#careMonthsTable').DataTable();
    });
</script>
<script>
    (function() {
        function init() {
            $('.btn-launch')
                .off('click')
                .on('click', function() {
                    $('.launch-result').text('Please wait...');
                    $('.btn-launch').prop('disabled', true);
                    $.get('/api/careMonth/' + $(this).attr('data-ep'), _data => {
                            if (!hasResponseError(_data)) {
                                if (_data.data && _data.data.length) {
                                    $('.launch-result').text(_data.data.join("\n"));
                                }
                            }
                        }, 'json')
                        .then(() => {
                            $('.btn-launch:not([perm-disabled])').prop('disabled', false);
                        });
                });
        }
        addMCInitializer('rm-launch-and-clean', init, '#rm-launch-and-clean');
    }).call(window);
</script>
@endsection