@extends('mobile.layouts.app')

@section('content')
<div id="accountLoginLog" class="container">
    @include('mobile.account.navTabs')

    <h4>로그인 기록</h4>
    <hr/>

    <dl>
        <dd>※ 최대 3개월 이내의 내역만 확인 가능합니다.</dd>
    </dl>

    <form name="f_account_login_log" id="fAccountLoginLog" method="post" action="{{ route('account.loginLog') }}" autocomplete="off" accept-charset="UTF-8">
        @csrf
        <div class="row g-2 align-items-center mb-2">
            <div class="col col-sm-auto">
                Total : {{ $loginLog->total }}
            </div>
            <div class="col-auto col-sm">
                <div class="row g-2 align-items-center justify-content-end">
                    <div class="col col-sm-auto">
                        <input type="text" name="start_date" id="startDate" class="form-control date-picker" size="10" value="{{ $params->startDate }}"/>
                    </div>
                    <div class="col-auto">-</div>
                    <div class="col col-sm-auto">
                        <input type="text" name="end_date" id="endDate" class="form-control date-picker" size="10" value="{{ $params->endDate }}"/>
                    </div>
                    <div class="col-auto">
                        <button type="submit" class="btn btn-default">조회</button>
                    </div>
                </div>
            </div>
        </div>
    </form>

    <div class="table-responsive">
        <table class="table  table-hover">
            <colgroup>
                <col style="width: 5%;min-width: 50px;"/>
                <col style="width: 20%;"/>
                <col style="width: 13%;"/>
                <col style="width: 13%;"/>
                <col style="width: 13%;"/>
                <col style="width: auto;"/>
                <col style="width: 10%;"/>
            </colgroup>
            <thead>
                <tr>
                    <th>번호</th>
                    <th>일시</th>
                    <th>OS</th>
                    <th>IP</th>
                    <th>접속기기</th>
                    <th>사유</th>
                    <th>결과</th>
                </tr>
            </thead>
            <tbody>
            @if($loginLog->rows > 0)
                @foreach($loginLog->list as $row)
                    <tr>
                        <td>{{ $row->num }}</td>
                        <td>{{ $row->created_at }}</td>
                        <td>{{ $row->os }}</td>
                        <td>{{ $row->ip_address }}</td>
                        <td>{{ $row->device }}</td>
                        <td>{{ $row->reason }}</td>
                        <td>{{ $row->result }}</td>
                    </tr>
                @endforeach
            @else
                <tr>
                    <td colspan="7" class="p-5">
                        로그인 기록이 없습니다.
                    </td>
                </tr>
            @endif
            </tbody>
        </table>
    </div>

    @if($loginLog->total > 0)
    <div class="pagination">
        {{ $loginLog->list->withQueryString()->links('component.pagination') }}
    </div>
    @endif
</div>
@endsection

@push('styles')
    <link rel="stylesheet" href="{{ asset('css/mobile/account/loginLog.css') }}"/>
@endpush

