@extends ('layouts/template')

@section('content')
<div class="p-3 mcp-theme-1" id="patients-list">
    <div class="card">

        <div class="card-header px-2 py-1 d-flex align-items-center">
            <strong class="mr-4">
                <i class="fas fa-notes-medical"></i>
                Memos
            </strong>
        </div>

        <div class="card-body p-0">
            <div class="p-3">
                @include('app.rd.memos_filters')
            </div>
            <table class="table table-sm table-striped border-top p-0 m-0">
                <thead class="bg-light">
                    <tr>
                        <th class="border-0">Category</th>
                        <th class="border-0">Patient</th>
                        <th class="border-0 w-25">Summary</th>
                        <th class="border-0">Created</th>
                        <th class="border-0 delete-column">&nbsp;</th>
                    </tr>
                </thead>
                <tbody>
                    @foreach($memos as $memo)
                    <tr>
                        <td>{{ $memo->category }}</td>
                        <td>
                            <a target="_blank" native href="{{route('patients.view.dashboard', $memo->client)}}">
                                {{$memo->client->displayName()}}
                            </a>
                        </td>
                        <td>
                            <pre class="m-0 break-spaces">{{ $memo->content }}</pre>
                        </td>
                        <td>{{ friendly_date_time($memo->created_at) }}</td>
                        <td class="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

                    @if(count($memos) === 0)
                    <tr>
                        <td colspan="5">No records found!</td>
                    </tr>
                    @endif
                </tbody>

            </table>

        </div>
    </div>
    <div class="mt-3">
        {{ $memos->appends(request()->input())->links() }}
    </div>

</div>
@endsection