@extends ('layouts.patient')

@section('inner-content')
    <div class="">
        <div class="d-flex align-items-center pb-2">
            <h4 class="font-weight-bold m-0">Handouts</h4>
            <span class="mx-2 text-secondary">|</span>
            <div moe>
                <a start show class="">Add</a>
                <form url="/api/handoutClient/create">
                    <input type="hidden" name="clientUid" value="{{ $patient->uid }}">
                    <div class="mb-2">
                        <select name="handoutUid" class="form-control form-control-sm">
                            <option value=""> --select--</option>
                            @foreach($handouts as $handout)
                                <option value="{{$handout->uid}}">
                                    {{$handout->display_name}}
                                </option>
                            @endforeach
                        </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 m-0">
            <thead>
            <tr>
                <th class="px-2 text-secondary">Internal Name</th>
                <th class="px-2 text-secondary">Display Name</th>
                <th class="px-2 text-secondary">View</th>
                <th class="px-2 text-secondary w-50">Shareable Link</th>
                <th class="px-2 text-secondary"></th>
            </tr>
            </thead>
            <tbody>
            @foreach($patient->handouts() as $handout)
                <?php $downloadLink = env('APP_URL') . "/guest/handout/{$handout->handout_client_uid}"; ?>
                <tr>
                    <td class="px-2">{{$handout->internal_name}}</td>
                    <td class="px-2">{{$handout->display_name}}</td>
                    <td class="px-2">
                        <a native href="{{ $downloadLink }}" target="_blank" class="pdf-viewer-trigger">
                            <i class="fa fa-eye mr-2"></i>View
                        </a>
                    </td>
                    <td class="px-2"><b>{{ $downloadLink }}</b></td>
                    <td class="px-2">
                        <div moe="" relative="">
                            <a start="" show="" href="#">SMS Link</a>
                            <form url="/api/clientSms/createOutgoing" right="" class="mcp-theme-1">
                                <input type="hidden" name="uid" value="d5de7592-14f1-4df8-aed3-988b1e50afb2">
                                <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" rows="10" class="form-control form-control-sm" name="message"
                                        >Dear {{$patient->displayName()}}, Access the handout ({{$handout->display_name}}) at the following link: {{$downloadLink}}
                                    </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>
                    </td>
                </tr>
            @endforeach
            </tbody>
        </table>
    </div>
@endsection
