@extends ('layouts.patient')
@section('inner-content')
    <div class="">
        <div class="d-flex align-items-center pb-2">
            <h4 class="font-weight-bold m-0">SMS Messages</h4>
            <span class="mx-2 text-secondary">|</span>
            <div moe>
                <a start show class="">Send SMS</a>
                <form url="/api/clientSms/createOutgoing" class="mcp-theme-1">
                    <input type="hidden" name="uid" value="{{ $patient->uid }}">
                    <div class="mb-2">
                        <label for="" class="text-sm text-secondary mb-1">Cell Number</label>
                        <input type="text" class="form-control form-control-sm" name="cellNumber" value="{{$patient->cell_number}}">
                    </div>
                    <div class="mb-2">
                        <label for="" class="text-sm text-secondary mb-1">Message</label>
                        <textarea type="text" class="form-control form-control-sm" name="message"></textarea>
                    </div>
                    <div class="d-flex align-items-center">
                        <button class="btn btn-sm btn-primary mr-2" submit>Send</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">
            <thead class="bg-light">
            <tr>
                <th class="border-0 text-secondary text-nowrap">Date &amp; Time</th>
                <th class="border-0 text-secondary w-25">Type</th>
                <th class="border-0 text-secondary w-25">From</th>
                <th class="border-0 text-secondary w-25">To</th>
                <th class="border-0 text-secondary w-50">Content</th>
                <th></th>
                @if($performer->pro->pro_type == 'ADMIN')
                    <th></th>
                @endif
            </tr>
            </thead>
            <tbody>
            @foreach($patient->smses as $sms)
                <tr class="{{$sms->created_at > $patient->last_sms_sent_to_client_at && $sms->is_reply_needed == 'YES' ? 'bg-warning': ''}}">
                    <td class="text-nowrap">{{ friendly_date_time($sms->created_at) }}</td>
                    <td>{{ ucwords($sms->incoming_or_outgoing) }}</td>
                    <td>{{ $sms->from_number }}</td>
                    <td>{{ $sms->to_number }}</td>
                    <td>{{ $sms->body }}</td>
                    <td>
                        @if($sms->is_reply_needed == 'YES')
                            <div moe relative>
                                <a start show class="">clear</a>
                                <form url="/api/clientSms/updateIsReplyNeeded" class="mcp-theme-1" right>
                                    <input type="hidden" name="uid" value="{{ $sms->uid }}">
                                    <input type="hidden" name="isReplyNeeded" value="NO">
                                    <div class="mb-2">
                                        <label for="" class="text-sm text-secondary mb-1">Are you sure?</label>

                                    </div>

                                    <div class="d-flex align-items-center">
                                        <button class="btn btn-sm btn-primary mr-2" submit>Send</button>
                                        <button class="btn btn-sm btn-default mr-2 border" cancel>Cancel</button>
                                    </div>
                                </form>
                            </div>
                        @endif
                    </td>
                    @if($performer->pro->pro_type == 'ADMIN')
                        <td class="text-nowrap">
                            <div moe relative>
                                <a start show class="">Update Is Reply Needed</a>
                                <form url="/api/clientSms/updateIsReplyNeeded" class="mcp-theme-1" right>
                                    <input type="hidden" name="uid" value="{{ $sms->uid }}">
                                    <div class="mb-2">
                                        <label for="" class="text-sm text-secondary mb-1">Is reply needed?</label>
                                        <select class="form-control form-control-sm" name="isReplyNeeded" value="{{$patient->cell_number}}">
                                            <option value="UNKNOWN">--</option>
                                            <option value="YES">Yes</option>
                                            <option value="NO">No</option>
                                        </select>
                                    </div>

                                    <div class="d-flex align-items-center">
                                        <button class="btn btn-sm btn-primary mr-2" submit>Send</button>
                                        <button class="btn btn-sm btn-default mr-2 border" cancel>Cancel</button>
                                    </div>
                                </form>
                            </div>
                        </td>
                    @endif
                </tr>
            @endforeach
            </tbody>
        </table>
    </div>
    
@endsection
