@extends ('layouts.patient')

@section('inner-content')

<div id="simpleSMSReminderComponent">
    <div class="pt-2 d-flex align-items-start">
        <h6 class="my-0 d-flex align-items-center w-100">
            <span class="font-weight-bold">SMS Reminders</span>
            <span class="mx-2 text-secondary">|</span>
            @include('app.patient.sms-reminders-form', ['smsReminder' => null])
        </h6>
    </div>

    <table class="table table-sm table-striped table-bordered mb-0 mt-2 notes-list">
        <thead>
            <tr class="bg-light">
                <th class="text-secondary border-0">#</th>
                <th class="text-secondary border-0">To Number</th>
                <th class="text-secondary border-0">Message</th>
                <th class="text-secondary border-0">Schedule</th>
                <th class="text-secondary border-0">Actions</th>
            </tr>
        </thead>
        <tbody>
            <?php $index = 0; ?>
            @foreach ($patient->smsReminders as $smsReminder)
            <?php $index++; ?>
            <tr class="{{$smsReminder->is_active ? '' : 'bg-light text-secondary'}}">
                <td>{{$index}}</td>
                <td>{{$smsReminder->sms_number}}</td>
                <td>{{$smsReminder->message}}</td>
                <td>
                    <div class="my-1">
                        Time Zone: {{friendly_timezone($smsReminder->time_zone)}}
                    </div>
                                          
                        @if($smsReminder->same_time_or_different_times == 'SAME_TIME_DAILY' && $smsReminder->same_time_of_day)
                        <span class="text-secondary">Daily at: {{ friendly_time($smsReminder->same_time_of_day) }}</span>
                        @endif
                        
                        @if($smsReminder->same_time_or_different_times == 'SAME_TIME_SPECIFIC_DAYS' || $smsReminder->same_time_or_different_times == 'CUSTOM')

                            <div>                            
                                @if($smsReminder->is_same_time_on_sunday || $smsReminder->time_of_day_sunday)
                                <span class="text-secondary">Sun</span>
                                @endif
                                @if($smsReminder->same_time_or_different_times == 'SAME_TIME_SPECIFIC_DAYS' && $smsReminder->is_same_time_on_sunday)
                                    <span class="text-secondary"> : {{ friendly_time($smsReminder->same_time_of_day) }}</span>
                                @endif
                                @if($smsReminder->same_time_or_different_times == 'CUSTOM' && $smsReminder->time_of_day_sunday)
                                    <span class="text-secondary"> : {{friendly_time($smsReminder->time_of_day_sunday)}}</span>
                                @endif
                            </div>
                            <div>                            
                                @if($smsReminder->is_same_time_on_monday || $smsReminder->time_of_day_monday)
                                <span class="text-secondary">Mon</span>
                                @endif
                                @if($smsReminder->same_time_or_different_times == 'SAME_TIME_SPECIFIC_DAYS' && $smsReminder->is_same_time_on_monday)
                                    <span class="text-secondary"> : {{ friendly_time($smsReminder->same_time_of_day) }}</span>
                                @endif
                                @if($smsReminder->same_time_or_different_times == 'CUSTOM' && $smsReminder->time_of_day_monday)
                                    <span class="text-secondary"> : {{friendly_time($smsReminder->time_of_day_monday)}}</span>
                                @endif
                            </div>
                            <div>                            
                                @if($smsReminder->is_same_time_on_tuesday || $smsReminder->time_of_day_tuesday)
                                <span class="text-secondary">Tue</span>
                                @endif
                                @if($smsReminder->same_time_or_different_times == 'SAME_TIME_SPECIFIC_DAYS' && $smsReminder->is_same_time_on_tuesday)
                                    <span class="text-secondary"> : {{ friendly_time($smsReminder->same_time_of_day) }}</span>
                                @endif
                                @if($smsReminder->same_time_or_different_times == 'CUSTOM' && $smsReminder->time_of_day_tuesday)
                                    <span class="text-secondary"> : {{friendly_time($smsReminder->time_of_day_tuesday)}}</span>
                                @endif
                            </div>
                            <div>                            
                                @if($smsReminder->is_same_time_on_wednesday || $smsReminder->time_of_day_wednesday)
                                <span class="text-secondary">Wed</span>
                                @endif
                                @if($smsReminder->same_time_or_different_times == 'SAME_TIME_SPECIFIC_DAYS' && $smsReminder->is_same_time_on_wednesday)
                                    <span class="text-secondary"> : {{ friendly_time($smsReminder->same_time_of_day) }}</span>
                                @endif
                                @if($smsReminder->same_time_or_different_times == 'CUSTOM' && $smsReminder->time_of_day_wednesday)
                                    <span class="text-secondary"> : {{friendly_time($smsReminder->time_of_day_wednesday)}}</span>
                                @endif
                            </div>
                            <div>                            
                                @if($smsReminder->is_same_time_on_thursday || $smsReminder->time_of_day_thursday)
                                <span class="text-secondary">Thu</span>
                                @endif
                                @if($smsReminder->same_time_or_different_times == 'SAME_TIME_SPECIFIC_DAYS' && $smsReminder->is_same_time_on_thursday)
                                    <span class="text-secondary"> : {{ friendly_time($smsReminder->same_time_of_day) }}</span>
                                @endif
                                @if($smsReminder->same_time_or_different_times == 'CUSTOM' && $smsReminder->time_of_day_thursday)
                                    <span class="text-secondary"> : {{friendly_time($smsReminder->time_of_day_thursday)}}</span>
                                @endif
                            </div>
                            <div>                            
                                @if($smsReminder->is_same_time_on_friday || $smsReminder->time_of_day_friday)
                                <span class="text-secondary">Fri</span>
                                @endif
                                @if($smsReminder->same_time_or_different_times == 'SAME_TIME_SPECIFIC_DAYS' && $smsReminder->is_same_time_on_friday)
                                    <span class="text-secondary"> : {{ friendly_time($smsReminder->same_time_of_day) }}</span>
                                @endif
                                @if($smsReminder->same_time_or_different_times == 'CUSTOM' && $smsReminder->time_of_day_friday)
                                    <span class="text-secondary"> : {{friendly_time($smsReminder->time_of_day_friday)}}</span>
                                @endif
                            </div>
                            <div>                            
                                @if($smsReminder->is_same_time_on_saturday || $smsReminder->time_of_day_saturday)
                                <span class="text-secondary">Sat</span>
                                @endif
                                @if($smsReminder->same_time_or_different_times == 'SAME_TIME_SPECIFIC_DAYS' && $smsReminder->is_same_time_on_saturday)
                                    <span class="text-secondary"> : {{ friendly_time($smsReminder->same_time_of_day) }}</span>
                                @endif
                                @if($smsReminder->same_time_or_different_times == 'CUSTOM' && $smsReminder->time_of_day_saturday)
                                    <span class="text-secondary"> : {{friendly_time($smsReminder->time_of_day_saturday)}}</span>
                                @endif
                            </div>
                            

                        @endif
                </td>
                <td>
                    <div class="d-flex align-items-center">
                        @include('app.patient.sms-reminders-form', ['smsReminder' => $smsReminder])
                        @if($smsReminder->is_active)
                        <div moe relative="" class="ml-2">
                            <a start show class="py-0 mb-3">Deactivate</a>
                            <form url="/api/simpleSmsReminder/deactivate" class="mcp-theme-1" right="">
                                <input type="hidden" name="uid" value="{{$smsReminder->uid}}">
                                <p>Deactivate this SMS reminder?</p>
                                <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>
                        @else
                        <div moe relative="" class="ml-2">
                            <a start show class="py-0 mb-3">Reactivate</a>
                            <form url="/api/simpleSmsReminder/reactivate" class="mcp-theme-1" right="">
                                <input type="hidden" name="uid" value="{{$smsReminder->uid}}">
                                <p>Reactivate this SMS reminder?</p>
                                <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>
                        @endif
                    </div>
                </td>
            </tr>
            @endforeach
            @if(!count($patient->smsReminders))
            <tr>
                <td colspan="5">No records found.</td>
            </tr>
            @endif
        </tbody>
    </table>
</div>

<script>
    (function() {
        function init() {

        }
        addMCInitializer('simpleSMSReminderComponent', init, '#simpleSMSReminderComponent');
    }).call(window);
</script>
@endsection