@extends ('layouts.patient')
@section('inner-content')
    <div class="">
        <div class="d-flex align-items-start pb-2">
            <h4 class="font-weight-bold m-0">Client Memos</h4>
        </div>
        <div moe class="w-50 p-2 border mb-3">
            <form url="/api/clientMemo/create" show>
                <input type="hidden" name="clientUid" value="{{ $patient->uid }}">
                <label class="text-secondary font-weight-bold">+ New Memo</label>
                <div class="mb-2">
                    <select class="form-control form-control-sm" name="category" required>
                        <option value="">-- select --</option>
                        <option value="Incoming Call">Incoming Call</option>
                        <option value="Outgoing Call">Outgoing Call</option>
                        <option value="Call Unspecified">Call Unspecified</option>
                        <option value="Other">Other</option>
                    </select>
                </div>
                <div class="mb-2">
                    <textarea class="form-control form-control-sm" rows="5" name="content" placeholder="Content"></textarea>
                </div>
                <div class="d-flex align-items-center">
                    <button class="btn btn-sm btn-primary mr-2" type="button" submit>Save</button>
                </div>
            </form>
        </div>
        <table class="table table-striped table-sm table-bordered mb-0">
            @if($patient->memos && count($patient->memos))
                <thead>
                <tr>
                    <th class="px-2 text-secondary w-25">Category</th>
                    <th class="px-2 text-secondary w-50">Summary</th>
                    <th class="px-2 text-secondary">Created</th>
                    <th class="px-2 text-secondary delete-column">&nbsp;</th>
                </tr>
                </thead>
                <tbody>
                @foreach($patient->memos as $memo)
                    <tr>
                        <td class="px-2">{{ $memo->category }}</td>
                        <td class="px-2"><pre class="m-0 break-spaces">{{ $memo->content }}</pre></td>
                        <td class="px-2">{{ friendly_date_time($memo->created_at) }}</td>
                        <td class="px-2 text-center delete-column">
                            <div moe wide relative class="mr-2">
                                <a class="on-hover-opaque" start show title="Edit">
                                    <i class="font-size-11 fa fa-edit"></i>
                                </a>
                                <form url="/api/clientMemo/update" right>
                                    <input type="hidden" name="uid" value="{{ $memo->uid }}">
                                    <div class="mb-2">
                                        <select class="form-control form-control-sm" name="category" required>
                                            <option value="">-- select --</option>
                                            <option {{ $memo->category === "Incoming Call" ? "selected" : "" }} value="Incoming Call">Incoming Call</option>
                                            <option {{ $memo->category === "Outgoing Call" ? "selected" : "" }} value="Outgoing Call">Outgoing Call</option>
                                            <option {{ $memo->category === "Call Unspecified" ? "selected" : "" }} value="Call Unspecified">Call Unspecified</option>
                                            <option {{ $memo->category === "Other" ? "selected" : "" }} value="Other">Other</option>
                                        </select>
                                    </div>
                                    <div class="mb-2">
                                        <textarea class="form-control form-control-sm" name="content" rows="5"
                                                  placeholder="Content"><?= $memo->content ?></textarea>
                                    </div>
                                    <div class="d-flex align-items-center">
                                        <button class="btn btn-sm btn-primary mr-2" type="button" submit>Save</button>
                                        <button class="btn btn-sm btn-default mr-2 border" type="button"
                                                cancel>Cancel</button>
                                    </div>
                                </form>
                            </div>
                            <div moe relative>
                                <a start show class="on-hover-opaque"><i class="fa fa-trash-alt text-danger"></i></a>
                                <form url="/api/clientMemo/cancel" right>
                                    <input type="hidden" name="uid" value="{{ $memo->uid }}">
                                    <p class="small">Are you sure you want to cancel this memo?</p>
                                    <div class="d-flex align-items-center">
                                        <button class="btn btn-sm btn-danger mr-2" submit>Delete</button>
                                        <button class="btn btn-sm btn-default mr-2 border" cancel>Cancel</button>
                                    </div>
                                </form>
                            </div>
                        </td>
                    </tr>
                @endforeach
                </tbody>
            @else
                <tbody>
                    <tr>
                        <td class="text-secondary p-3">No memos have been created for this patient</td>
                    </tr>
                </tbody>
            @endif
        </table>
    </div>
@endsection
