@extends('admin.layouts.app')

@section('content')
<div class="container-fluid">
    <h2>SMS 주소록 관리</h2>
    <hr/>
    @include('admin.messages')

    <div class="row mb-2">
        <div class="col align-self-center">
            <label>전체 : {{ $smsBookData->total }} / {{ $smsBookData->rows }}</label>
        </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/book/list/destroy">선택삭제</button>
            <a href="{{ route('admin.sms.book.list.create') }}" class="btn btn-success">새로등록</a>
        </div>
    </div>

    <form name="f_admin_list" id="fAdminList" method="post">
        @csrf
        <div class="table-responsive">
            <table class="table table-hover table-bordered table-nowrap">
                <colgroup>
                    <col width="2%"/>
                    <col width="2%"/>
                    <col width="*"/>
                    <col width="6%"/>
                    <col width="6%"/>
                    <col width="15%"/>
                    <col width="15%"/>
                    <col width="7%"/>
                    <col width="7%"/>
                </colgroup>
                <thead>
                    <tr>
                        <th><input type="checkbox" name="chk_all" id="chkAll" class="form-check-input" value="1"/></th>
                        <th>PK</th>
                        <th>이름</th>
                        <th>회원 수</th>
                        <th>순서</th>
                        <th>수정일시</th>
                        <th>등록일시</th>
                        <th colspan="2">비고</th>
                    </tr>
                </thead>
                <tbody>
                    @if($smsBookData->rows > 0)
                        @foreach($smsBookData->list as $row)
                        <tr>
                            <td>
                                <input type="checkbox" name="chk[]" id="chk_{{ $row->id }}" class="form-check-input list-check-box" value="{{ $row->id }}" />
                            </td>
                            <td>{{ $row->id }}</td>
                            <td>{{ $row->name }}</td>
                            <td>{{ $row->userCount }}</td>
                            <td>{{ $row->order }}</td>
                            <td>{{ $row->updated_at ?? '-' }}</td>
                            <td>{{ $row->created_at }}</td>
                            <td>
                                <a href="{{ $row->bookUserListURL }}" class="btn btn-info btn-sm text-white">회원</a>
                            </td>
                            <td>
                                <a href="{{ $row->editURL }}" class="btn btn-primary btn-sm">수정</a>
                            </td>
                        </tr>
                        @endforeach
                    @else
                        <tr>
                            <td colspan="9">
                                No data.
                            </td>
                        </tr>
                    @endif
                </tbody>
            </table>

            <div class="pagination">
                {{ $smsBookData->list->withQueryString()->links() }}
            </div>
        </div>
        <br/>
    </form>
</div>
@endsection
