@extends('admin.layouts.app')

@section('content')
<div class="container-fluid">
    <h2>이메일 변경 기록</h2>
    <hr/>
    @include('admin.messages')

    <form name="f_admin_search" id="fAdminSearch" method="get" action="{{ route('admin.user.log.name.index') }}">
        <div class="row g-2">
            <div class="col-auto">
                <select name="field" id="field" class="form-select">
                    <option value="users.id" @if( $params->field == 'users.id') selected @endif>회원 PK</option>
                    <option value="users.sid" @if( $params->field == 'users.sid') selected @endif>회원 ID</option>
                    <option value="users.name" @if( $params->field == 'users.name') selected @endif>회원명</option>
                    <option value="users.email" @if( $params->field == 'users.email') selected @endif>회원 이메일</option>
                    <option value="tb_user_email_log.before" @if( $params->field == 'tb_user_email_log.before') selected @endif>이전 이름</option>
                    <option value="tb_user_email_log.after" @if( $params->field == 'tb_user_email_log.after') 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>
    </form>
    <br/>

    <div class="row mb-2">
        <div class="col align-self-center">
            전체 : {{ $userEmailLog->total }} / {{ $userEmailLog->rows }}
        </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/user/log/name/destroy">선택삭제</button>
        </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">
                <thead>
                    <tr>
                        <th><input type="checkbox" name="chk_all" id="chkAll" class="form-check-input" value="1" /></th>
                        <th>번호</th>
                        <th>ID</th>
                        <th>이전 이름</th>
                        <th>현재 이름</th>
                        <th>등록일시</th>
                    </tr>
                </thead>
                <tbody>
                @if($userEmailLog->rows > 0)
                    @foreach($userEmailLog->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->num }}</td>
                        <td>{{ $row->sid }}</td>
                        <td>{{ $row->before ?? '-' }}</td>
                        <td>{{ $row->after ?? '-' }}</td>
                        <td>{{ $row->created_at }}</td>
                    </tr>
                    @endforeach
                @else
                    <tr>
                        <td colspan="7">
                            No data.
                        </td>
                    </tr>
                @endif
                </tbody>
            </table>

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