@extends('backend.layouts.app')

@section('title', __('User Management'))

@section('content')
    <div class="card user-screen">
        <div class="card-body">
            <div class="text-center">
                <h3 class="card-title font-weight-bold">{{ __('string.capture.history.title') }}</h3>
                <p>{{ __('string.capture.history.description') }}</p>
            </div>
            {!! Form::open(['route' => 'admin.capture.history', 'method' => 'get', 'id' => 'form-search-user',
                'class' => 'mb-3'])
            !!}
            <div>
                <div>
                    <div class="faceBox head" style="float:left;">
                        <div style="display:flex">
                            <div data-name="No">No</div>
                            <div>
                                <div style="display:flex">
                                    <div>
                                        <div data-name="連番">連番</div>
                                        <div data-name="場所">場所</div>
                                    </div>
                                    <div>
                                        <div data-name="日時">日時</div>
                                        <div data-name="入退室">入退室</div>
                                    </div>
                                </div>
                                <div data-name="勤務者">勤務者</div>
                            </div>
                            <div data-name="画像">画像</div>
                        </div>
                    </div>
                </div>
                <div class="input-group mb-3 col-md-2">
                    {!! Form::text('date', $params['date'], [
                        'class' => 'form-control date',
                        'placeholder' => 'yyyy/mm/dd',
                        'autocomplete' => 'off',
                        'id' => 'capture-date']
                    ) !!}
                    <div class="input-group-append">
                        <label for="capture-date" class="fas fa-calendar btn-outline-secondary btn"></label>
                    </div>
                </div>
                <div>
                    @foreach([$user[0] => $unknown,'known' => $known,'総計' => $total] as $key1 => $value2)
                        <table class="inputTbl2"  style="float:left;">
                            <thead>
                                <tr>
                                    <th>{{ $key1 }}</th>
                                    @foreach($value2 as $key => $value)
                                        <th>{{ $key }}</th>
                                    @endforeach
                                </tr>
                            </thead>
                            <tbody>
                                <tr>
                                    <th>in</th>
                                    @foreach($value2 as $key => $value)
                                        <td>{{ $value['in'] }}</td>
                                    @endforeach
                                </tr>
                                <tr>
                                    <th>out</th>
                                    @foreach($value2 as $key => $value)
                                        <td>{{ $value['out'] }}</td>
                                    @endforeach
                                </tr>
                            </tbody>
                        </table>
                    @endforeach
                </div>
            </div>
            <div style="clear:left;"></div>
            <div>
                @foreach($lists as $key => $list)
                    <div class="faceBox" style="float:left;">
                        <div style="display:flex">
                            <div data-name="No">
                                {{ $lists->firstItem() + $key }}
                            </div>
                            <div>
                                <div style="display:flex">
                                    <div>
                                        <div data-name="連番">{{ $list->id }}</div>
                                        <div data-name="場所">{{ $location($list->flag, $list->device) }}</div>
                                    </div>
                                    <div>
                                        <div data-name="日時">{{ $list->checkin_at_time->format('H:i:s') }}</div>
                                        <div data-name="入退室">{{ $list->in_or_out ? 'in' : 'out' }}</div>
                                    </div>
                                </div>
                                <div data-name="勤務者" data-user_id="{{ $list->user_id }}">
                                    @if (array_key_exists($list->user_id, $user))
                                        {{ $user[$list->user_id] }}
                                    @else
                                        {{ $list->user_id }}
                                    @endif
                                </div>
                            </div>
                            <div data-name="画像">
                                <img
                                    style="max-width:150px;"
                                    class="img-fluid"
                                    src="{{ route('admin.capture.history.image',['checkinHistoryId' => $list->id]) }}" />
                            </div>
                        </div>
                    </div>
                @endforeach
            </div>
            <div style="clear:left;"></div>
            <div>
                {{ $lists->links() }}
            </div>
            {!! Form::close() !!}
        </div>
        <!--card-body-->
    </div>
    <!--card-->
@endsection

@push('after-styles')
    <style>
        .faceBox {
            border: 1px gray solid;
            margin: 2px;
        }
        .faceBox.select {
            background-color: #00BFFF;
        }
        .faceBox:hover {
            background-color: #00BFFF;
        }
        .faceBox.head {
            color: white;
            background-color: rgb(0, 123, 187);
        }
        .faceBox [data-name] {
            justify-content: center;
            align-items: center;
            display: flex;
            padding:5px;
        }
        .faceBox [data-name="No"] {
            width:30px;
            border-right: 1px gray dotted;
        }
        .faceBox [data-name="連番"] {
            width:75px;
            border-right: 1px gray dotted;
            border-bottom: 1px gray dotted;
        }
        .faceBox [data-name="日時"] {
            width:100px;
            border-right: 1px gray dotted;
            border-bottom: 1px gray dotted;
        }
        .faceBox [data-name="画像"] {
            height:105px;
            width:80px;
            border-right: 1px gray dotted;
        }
        .faceBox img {
            width:80px;
            max-height:100px;
        }
        .faceBox [data-name="場所"] {
            min-width:75px;
            max-width:75px;
            border-right: 1px gray dotted;
            border-bottom: 1px gray dotted;
        }
        .faceBox [data-name="入退室"] {
            min-width:100px;
            max-width:100px;
            border-right: 1px gray dotted;
            border-bottom: 1px gray dotted;
        }
        .faceBox [data-name="勤務者"] {
            min-width:175px;
            max-width:175px;
            border-right: 1px gray dotted;
        }
        .faceBox [data-name="勤務者"][data-user_id="0"] {
            color:red;
        }
        .inputTbl2 th,.inputTbl2 td {
            border: 1px rgb(204, 204, 204) solid;
            padding: 2px 5px;
            white-space:nowrap;
        /*	vertical-align: text-top; */
            text-align: left;
        }

        .inputTbl2 th {
            color: rgb(255,255,255);
            background-color: rgb(0, 123, 187);
        }

        .inputTbl2 .left {
            text-align: left;
        }

        .inputTbl2 .center {
            text-align: center;
        }

        .inputTbl2 .right {
            text-align: right;
        }

        .inputTbl2 caption {
            caption-side: top;
            text-align: left;
        }

        .inputTbl2 .border-left-none {
            border-left-width: 0px;
        }

        .inputTbl2 .border-right-none {
            border-right-width: 0px;
        }

    </style>
@endpush
@push('after-scripts')
    <script src="{{ mix('js/capture-history.js') }}"></script>
@endpush
