<?php
$cate_id = "mnu_board_list"; //현재 메뉴 ID 필수!!!
include_once "{$_SERVER['DOCUMENT_ROOT']}/common.inc.php";
include_once _ADM_INC_PATH_ ."/auth_check.php";

//검색필드
$sfields = array(
  "board_name" => "게시판명",
  "brard_id" => "게시판코드",
);

include _ADM_INC_PATH_ ."/header.html";
?>

        <form method="get" name="sform" id="sform" class="sform form-inline" action="<?=$_SERVER['PHP_SELF']?>">
          <label> <span>검색필드 :</span>
            <select name="member_auth" id="member_auth" class="form-select-sm form-control-sm" data-defval="<?=$_REQUEST['sfld']?>">
              <?=getSelectOptions($sfields,"- 전체 -")?>
            </select>
          </label>
          <label> <span>검색 내용 :</span> <input type="text" name="stxt" class="form-control form-control-sm" value="<?=$_REQUEST['stxt']?>"></label>
          <button type="submit" class="btn btn-primary btn-sm">검색</button>
        </form>

        <div id="cmd_bar" class="mb-2">
          <div class="h4"><i class="bi bi-files-alt"></i> 게시판 리스트</div>
          <div class="text-right">
            <a href="./board_put.php" class="btn btn-primary"> <i class="bi bi-list-task"></i> 게시판 추가</a>
          </div>
        </div>

        <div class="container-fluid mt-3">
          <div class="row">
            <div class="col">
              <h5 class="d-flex justify-content-between">
                <span><i class="bi bi-subtract"></i> 게시판 정보</span>
              </h5>
              <div class="cont_hfix">

                <table class="table table-bordered mt-3">
                  <colgroup>
                    <col width="5%">
                    <col width="*">
                    <col width="*">
                    <col width="*">
                    <col width="*">
                    <col width="*">
                    <col width="8%">
                    <col width="8%">
                  </colgroup>
                  <thead class="sticky-top">
                    <tr class="text-center bg-dark text-light">
                      <th>번호</th>
                      <th><a href="javascript:sort_page_move(form2qry(document.sform),'board_id'    );" class="text-decoration-none text-white">게시판 코드</a></th>
                      <th><a href="javascript:sort_page_move(form2qry(document.sform),'board_name'  );" class="text-decoration-none text-white">게시판 명</a></th>
                      <th><a href="javascript:sort_page_move(form2qry(document.sform),'board_admin' );" class="text-decoration-none text-white">관리자</a></th>
                      <th><a href="javascript:sort_page_move(form2qry(document.sform),'read_level'  );" class="text-decoration-none text-white">읽기권한</a></th>
                      <th><a href="javascript:sort_page_move(form2qry(document.sform),'write_level' );" class="text-decoration-none text-white">쓰기권한</a></th>
                      <th><a href="javascript:sort_page_move(form2qry(document.sform),'con_num'     );" class="text-decoration-none text-white">게시물수</a></th>
                      <th>바로가기</th>
                    </tr>
                  </thead>
                  <tbody class="table-sm">
                    <?php
                    $_REQUEST['no_echo'] = true;
                    $_REQUEST['mode'] = "getBoardList";
                    include "./board.ajax.php";
                    $brd_list = $retval['data'];

                    foreach( $brd_list->rows as $brd ){
                      switch( $brd['read_level'] ){
                        case "M":
                          $brd['read_level_txt'] = "<span class='text-info'>회원이상</span>"; break;
                        break;
                        case "A":
                          $brd['read_level_txt'] = "<span class='text-danger'>관리자만</span>"; break;
                        break;
                        default:
                          $brd['read_level_txt'] = "<span class='text-success'>전체가능</span>"; break;
                        break;
                      }
                      switch( $brd['write_level'] ){
                        case "M":
                          $brd['write_level_txt'] = "<span class='text-info'>회원이상</span>"; break;
                        break;
                        case "A":
                          $brd['write_level_txt'] = "<span class='text-danger'>관리자만</span>"; break;
                        break;
                        default:
                          $brd['write_level_txt'] = "<span class='text-success'>전체가능</span>"; break;
                        break;
                      }
                    ?>
                    <tr class="hand text-center">
                      <td><?=$brd_list->line_cnt--?></td>
                      <td><a href="./board_put.php?board_id=<?=$brd['board_id']?>"><?=$brd['board_id']?></a></td>
                      <td><a href="./board_put.php?board_id=<?=$brd['board_id']?>"><?=$brd['board_name']?></a></td>
                      <td><?=$brd['board_admin']?></td>
                      <td><?=$brd['read_level_txt']?></td>
                      <td><?=$brd['write_level_txt']?></td>
                      <td><?=number_format($brd['con_num'])?></td>
                      <td><a href="<?=_HOME_URL_."/kbrd/kbrd_list.php?board_id={$brd['board_id']}"?>" class="btn btn-sm btn-success" onclick="function(e){alert(1); e.stopPropagation();}" target="_blank">바로가기</a></td>
                    </tr>
                    <?php
                    }
                    if( count($brd_list->rows) < 1 ){
                    ?>
                    <tr>
                      <td colspan="20" class="text-center text-danger">※ <?=cUtil\Mlang::getText("결과가 존재하지 않습니다.");?></td>
                    </tr>
                    <?php
                    }
                    ?>
                  </tbody>
                </table>
                <nav aria-label="Page navigation example">
                  <ul class="pagination justify-content-center align-items-center">
                    <?php foreach( (array)$brd_list->pages as $page ){?>
                    <li><?=$page?></li>
                    <?php }?>
                  </ul>
                </nav>
              </div>
            </div>
          </div>
        </div>

<?php
include _ADM_INC_PATH_ ."/footer.html";
?>
