@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.notify.index') }}">
        <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="tb_user_dormant_notify.id" @if($params->field == 'tb_user_dormant_notify.id') selected @endif>회원 PK</option>
                                <option value="tb_user_dormant_notify.sid" @if($params->field == 'tb_user_dormant_notify.sid') selected @endif>회원 ID</option>
                                <option value="tb_user_dormant_notify.name" @if($params->field == 'tb_user_dormant_notify.name') selected @endif>이름</option>
                                <option value="tb_user_dormant_notify.nickname" @if($params->field == 'tb_user_dormant_notify.nickname') selected @endif>닉네임</option>
                                <option value="tb_user_dormant_notify.email" @if($params->field == 'tb_user_dormant_notify.email') selected @endif>이메일</option>
                                <option value="tb_user_dormant_notify.register_at" @if($params->field == 'tb_user_dormant_notify.register_at') selected @endif>회원가입 일시</option>
                                <option value="tb_user_dormant_notify.last_login_at" @if($params->field == 'tb_user_dormant_notify.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>
            <tr>
                <th>알림 발송일시</th>
                <td>
                    <div class="row g-2">
                        <div class="col-auto">
                            <input type="text" name="start_date" id="startDate" class="form-control date-picker s-start-date" value="{{ $params->startDate }}" />
                        </div>
                        <div class="col-auto align-self-center">
                            ~
                        </div>
                        <div class="col-auto">
                            <input type="text" name="end_date" id="endDate" class="form-control date-picker s-end-date" value="{{ $params->endDate }}" />
                        </div>
                        <div class="col">
                            <div class="btn-group">
                                <button type="button" onclick="setDateRange();" class="btn btn-secondary">오늘</button>
                                <button type="button" onclick="setDateRange('1d');" class="btn btn-secondary">어제</button>
                                <button type="button" onclick="setDateRange('7d');" class="btn btn-secondary">1주일</button>
                                <button type="button" onclick="setDateRange('15d');" class="btn btn-secondary">15일</button>
                                <button type="button" onclick="setDateRange('1m');" class="btn btn-secondary">1개월</button>
                                <button type="button" onclick="setDateRange('2m');" class="btn btn-secondary">2개월</button>
                                <button type="button" onclick="setDateRange('3m');" class="btn btn-secondary">3개월</button>
                            </div>
                        </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 align-self-center">
            <label>전체 : {{ $userDormantNotifyData->total }} / {{ $userDormantNotifyData->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/user/dormant/notify/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>
                        <th>로그인 일시</th>
                        <th>휴면예정 일시</th>
                        <th>알림 발송일시</th>
                    </tr>
                </thead>
                <tbody>
                    @if($userDormantNotifyData->total > 0)
                        @foreach($userDormantNotifyData->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->email }}</td>
                            <td>{{ $row->name }}</td>
                            <td>{{ $row->nickname }}</td>
                            <td>{!! $row->lastLoginAt !!}</td>
                            <td>{!! $row->dormantAt !!}</td>
                            <td>{!! $row->createdAt !!}</td>
                        </tr>
                        @endforeach
                    @else
                        <tr>
                            <td colspan="9">
                                No data.
                            </td>
                        </tr>
                    @endif
                </tbody>
            </table>

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