@extends('admin.layouts.app')

@section('content')
<div class="container-fluid">
    <h2>SMS 자주 보내는 문자</h2>
    <hr/>
    @include('admin.messages')

    <form name="f_admin_search" id="fAdminSearch" method="get" action="{{ route('admin.sms.favorite.index') }}">
        <div class="row g-2">
            <div class="col-auto">
                <select name="field" id="field" class="form-select">
                    <option value="tb_sms_favorite.id" @if($params->field == 'tb_sms_favorite.id') selected @endif>PK</option>
                    <option value="tb_sms_favorite.subject" @if($params->field == 'tb_sms_favorite.subject') selected @endif>제목</option>
                    <option value="tb_sms_favorite.content" @if($params->field == 'tb_sms_favorite.content') selected @endif>내용</option>
                </select>
            </div>
            <div class="col-auto">
                <div class="input-group">
                    <input type="text" name="keyword" id="keyword" class="form-control" value="{{ $params->keyword }}" placeholder="검색어를 입력하세요." />
                    <button type="submit" class="btn btn-dark">검색</button>
                </div>
            </div>
            <div class="col text-end">
                <button type="button" class="btn btn-outline-dark btn-list-delete btn-list-selected disabled" data-list-delete-url="/admin/sms/favorite/destroy">선택삭제</button>
                <a href="{{ route('admin.sms.favorite.create') }}" class="btn btn-success">새로등록</a>
            </div>
        </div>
    </form>
    <br/>

    <div class="row mb-2">
        <div class="col align-self-center">
            <label>전체 : {{ $smsFavoriteData->total }}</label>
        </div>
    </div>

    <form name="f_admin_list" id="fAdminList" method="post">
        @csrf
        @if($smsFavoriteData->total > 0)
            <div class="row row-cols-1 row-cols-md-5">
                @foreach($smsFavoriteData->list as $row)
                    <div class="col mb-4">
                        <div class="card h-100 mt-2">
                            <div class="card-body">
                                <div class="form-check mb-2">
                                    <input type="checkbox" name="chk[]" id="chk_{{ $row->id }}" class="form-check-input list-check-box" value="{{ $row->id }}"/>
                                    <label for="chk_{{ $row->id }}" class="form-check-label">[선택]</label>
                                </div>
                                <h5 class="card-title">
                                    <p class="card-text">
                                        @if($row->type == 1) [SMS] @else [LMS] @endif - {{ $row->id }}
                                    </p>
                                    {{ $row->subject }}
                                    <input type="hidden" class="form-control" value="{{ $row->subject }}" readonly disabled/>
                                </h5>
                                <p class="card-text">
                                    <hr/>
                                    {{ $row->content }}
                                    <input type="hidden" class="form-control" value="{{ $row->content }}" readonly disabled/>
                                </p>
                                <a href="{{ $row->editURL }}" class="btn btn-primary btn-sm">수정</a>
                            </div>
                        </div>
                    </div>
                @endforeach
                <div class="pagination">
                    {{ $smsFavoriteData->list->withQueryString()->links() }}
                </div>
            @else
                <div class="row">
                    <div class="col text-center">
                        No data.
                    </div>
                </div>
            @endif
        </div>
    </form>
</div>
@endsection
