@extends('admin.layouts.app')

@section('content')
<div class="container-fluid">
    <h2>휴면계정 관리 - 목록</h2>
    <hr/>
    @include('admin.messages')
    @include('admin.user.dormant.navTabs')

    <form name="f_admin_search" id="fAdminSearch" method="get" action="{{ route('admin.user.dormant.list.index') }}">
        <input type="hidden" name="is_dormant" value="{{ $params->isDormancy }}" />
        <table class="table table-bordered">
            <colgroup>
                <col width="15%" />
                <col width="*" />
            </colgroup>
            <tbody>
                <tr>
                    <th>검색</th>
                    <td>
                        <div class="row g-2">
                            <div class="col-auto">
                                <select name="field" id="field" class="form-select">
                                    <option value="{{ $sTable }}.id" @if($params->field == $sTable . '.id') selected @endif>회원 PK</option>
                                    <option value="{{ $sTable }}.sid" @if($params->field == $sTable . '.sid') selected @endif>회원 ID</option>
                                    <option value="{{ $sTable }}.name" @if($params->field == $sTable . '.name') selected @endif>이름</option>
                                    <option value="{{ $sTable }}.nickname" @if($params->field == $sTable . '.nickname') selected @endif>닉네임</option>
                                    <option value="{{ $sTable }}.email" @if($params->field == $sTable . '.email') selected @endif>이메일</option>
                                    <option value="{{ $sTable }}.created_at" @if($params->field == $sTable . '.created_at') selected @endif>회원가입 일시</option>
                                    <option value="{{ $sTable }}.last_login_at" @if($params->field == $sTable . '.last_login_at') selected @endif>로그인 일시</option>
                                </select>
                            </div>
                            <div class="col">
                                <input type="text" name="keyword" id="keyword" class="form-control" value="{{ $params->keyword }}" placeholder="검색어를 입력하세요." />
                            </div>
                        </div>
                    </td>
                </tr>
            </tbody>
        </table>

        <div class="text-center">
            <button type="submit" class="btn btn-dark">검색</button>
        </div>
    </form>
    <br/>

    <div class="row mb-2">
        <div class="col">
            <ul id="myTab" class="nav nav-tabs" role="tablist">
                <li class="nav-item">
                    <a class="nav-link @if(!$params->isDormancy) active @endif" href="/admin/user/dormant/list?is_dormant=0" role="tab">휴면예정 회원</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link @if($params->isDormancy == '1') active @endif" href="/admin/user/dormant/list?is_dormant=1" role="tab">휴면회원</a>
                </li>
            </ul>
        </div>
    </div>

    <div class="row mb-2">
        <div class="col align-self-center">
            <label>전체 : {{ $userDormantData->total }} / {{ $userDormantData->rows }}</label>
        </div>
        <div class="col text-end">
            <button type="button" class="btn btn-outline-primary btn-list-action btn-list-selected disabled" data-list-action-url="/admin/user/dormant/list/notify" data-desc="알림">선택알림</button>
            <button type="button" class="btn btn-outline-dark btn-list-action btn-list-selected disabled"
                    data-list-action-url="/admin/user/dormant/list/{{ !$params->isDormancy ? 'dormancy' : 'recover' }}"
                    data-desc="{{ !$params->isDormancy ? '휴면' : '해제' }}">
                    {{ !$params->isDormancy ? '선택휴면' : '선택해제' }}
            </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>PK</th>
                        <th>ID</th>
                        <th>이메일</th>
                        <th>이름</th>
                        <th>닉네임</th>
                        <th>그룹</th>
                        <th>등급</th>
                        <th>적립금(P)</th>
                        <th>로그인 일시</th>
                        <th>가입 일시</th>
                        @if($params->isDormancy)
                            <th>휴면일시</th>
                        @endif
                    </tr>
                </thead>
                <tbody>
                    @if($userDormantData->rows)
                        @foreach($userDormantData->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->id }}</td>
                            <td>{{ $row->sid }}</td>
                            <td>{{ $row->email ?? '-' }}</td>
                            <td>{{ $row->name ?? '-' }}</td>
                            <td>{{ $row->nickname ?? '-' }}</td>
                            <td>{{ $row->userGroup->kor_name ?? '-' }}</td>
                            <td>{{ $row->userGrade->kor_name ?? '-' }}</td>
                            <td>{{ $row->point }}</td>
                            <td>{!! $row->lastLoginAt !!}</td>
                            <td>{!! $row->createdAt !!}</td>
                            @if($params->isDormancy)
                                <td>{!! $row->dormantAt !!}</td>
                            @endif
                        </tr>
                        @endforeach
                    @else
                        <tr>
                            <td colspan="13">
                                No data.
                            </td>
                        </tr>
                    @endif
                </tbody>
            </table>

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