@extends ('layouts/template')

@section('content')
    <div class="p-3 mcp-theme-1" id="daily-treatment-services">
        <div class="card">
            <div class="card-header px-2 py-2 d-flex align-items-center">
                <strong class="">
                    <i class="fas fa-user"></i>
                    Daily Treatment Services
                </strong>
                <form class="ml-3" id="dts-form">
                    <select name="t" class="form-control form-control-sm width-200px">
                        <option {{!request()->input('t') ? 'selected' : ''}} value="">Overall</option>
                        <option {{request()->input('t') === 'pro' ? 'selected' : ''}} value="pro">By Pro</option>
                    </select>
                </form>
            </div>
            <?php
            // dump($rows);
            ?>
            <div class="card-body p-0">
                <table class="table table-sm table-striped p-0 m-0">
                    <thead class="bg-light">
                        <tr>
                            <th class="px-3 border-0 width-150px">Date</th>
                            @if(request()->input('t') === 'pro')
                                <th class="border-0 width-300px">HCP</th>
                            @endif
                            <th class="border-0 width-100px">#Bills</th>
                            <th class="border-0">$Hours Total</th>
                        </tr>
                    </thead>
                    <tbody>
                        @foreach($rows as $row)
                            <tr>
                                <td class="px-3">
                                    {{ friendly_date($row->effective_date) }}
                                </td>
                                @if(request()->input('t') === 'pro')
                                <td>
                                    {{ $row->name_first }}
                                    {{ $row->name_last }}
                                </td>
                                @endif
                                <td>
                                    {{ $row->count }}
                                </td>
                                <td>
                                    {{ $row->units }}
                                </td>
                            </tr>
                        @endforeach
                    </tbody>
                </table>
            </div>
        </div>
    </div>
    <script>
        (function() {
            function init() {
                $('#dts-form [name="t"]')
                    .off('change')
                    .on('change', function() {
                        fastLoad('{{route('practice-management.daily-treatment-services')}}?' + $('#dts-form').serialize());
                        return false;
                    });
            }
            addMCInitializer('daily-treatment-services', init, '#daily-treatment-services');
        }).call(window);
    </script>
@endsection
