@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="far fa-comments"></i>
                Client Messages
            </strong>
        </div>

        <div class="card-body p-0">
            <div class="p-3">
                @include('app.mcp.client_messages_filters')
            </div>
            <table class="table table-sm table-striped border-top p-0 m-0">
                <thead class="bg-light">
                    <tr>
                        <th class="border-0">Date</th>
                        <th class="border-0">Folder</th>
                        <th class="border-0">To</th>
                        <th class="border-0">From</th>
                        <th class="border-0">Client</th>
                        <th class="border-0">Message</th>
                        <th class="border-0">Status</th>
                    </tr>
                </thead>
                <tbody>
                    @foreach($clientMessages as $clientMessage)
                    <tr>
                        <td>{{ friendlier_date_time($clientMessage->created_at) }}</td>
                        <td>{{ $clientMessage->incoming_or_outgoing }}</td>
                        <td>{{$clientMessage->to_number}}</td>
                        <td>{{$clientMessage->from_number}}</td>
                        <td>{{ $clientMessage->client->displayName() }}</td>
                        <td style="width:300px;"><?= nl2br($clientMessage->body) ?></td>
                        <td>{{ $clientMessage->sms_status }} </td>
                    </tr>
                    @endforeach

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

            </table>

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