@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.board.group.list.index') }}">
        <div class="row g-2">
            <div class="col-auto">
                <select name="field" id="field" class="form-select">
                    <option value="tb_board_group.id" @if($params->field == 'tb_board_group.id') selected @endif>PK</option>
                    <option value="tb_board_group.code" @if($params->field == 'tb_board_group.code') selected @endif>CODE</option>
                    <option value="tb_board_group.name" @if($params->field == 'tb_board_group.name') 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-auto align-self-center">
            전체 : {{ $boardGroupData->total }} / {{ $boardGroupData->rows }}
        </div>
        <div class="col text-end">
            <button type="button" class="btn btn-outline-dark btn-list-update btn-list-selected disabled" data-list-update-url="{{ route('admin.board.group.list.index.update') }}">선택수정</button>
            <button type="button" class="btn btn-outline-dark btn-list-delete btn-list-selected disabled" data-list-delete-url="/admin/board/group/list/destroy">선택삭제</button>
            <a href="{{ route('admin.board.group.list.create') }}" class="btn btn-success">새로등록</a>
        </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>PK</th>
                        <th>CODE</th>
                        <th>제목</th>
                        <th>순서</th>
                        <th>게시판 수</th>
                        <th>게시글 수</th>
                        <th>댓글 수</th>
                        <th>등록일시</th>
                        <th>비고</th>
                    </tr>
                </thead>
                <tbody>
                    @if($boardGroupData->rows > 0)
                        @foreach($boardGroupData->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->id }}
                                @if($row->boardRows > 0)
                                    <br/><span class="badge bg-danger">삭제 불가</span>
                                @endif
                            </td>
                            <td>
                                <input type="text" name="code[{{ $row->id }}]" class="form-control" value="{{ $row->code }}" />
                            </td>
                            <td>
                                <input type="text" name="name[{{ $row->id }}]" class="form-control" value="{{ $row->name }}" />
                            </td>
                            <td>
                                <input type="number" name="sort[{{ $row->id }}]" class="form-control" value="{{ $row->sort }}" />
                            </td>
                            <td>{{ $row->boardRows }}</td>
                            <td>{{ $row->postRows }}</td>
                            <td>{{ $row->commentRows }}</td>
                            <td>{!! $row->createdAt !!}</td>
                            <td>
                                <a href="{{ $row->editURL }}" class="btn btn-primary btn-sm">수정</a>
                            </td>
                        </tr>
                        @endforeach
                    @else
                        <tr>
                            <td colspan="10">
                                No data.
                            </td>
                        </tr>
                    @endif
                </tbody>
            </table>

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