<?php
if( !$cate_area ) return;

include_once "{$_SERVER['DOCUMENT_ROOT']}/common.inc.php";
include_once _ADM_INC_PATH_ ."/auth_check.php";

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

        <form method="get" name="sform" id="sform" class="sform form-inline" action="<?=$_SERVER['PHP_SELF']?>">
          <label> <span>로그인 날짜 :</span>
            <input type="date" max="9999-12-31" name="sdate" class="dpicker form-control form-control-sm" value="<?=$_REQUEST['sdate']?>"> ~ <input type="date" name="fdate" class="dpicker form-control" value="<?=$_REQUEST['fdate']?>">
          </label>
          <label> <span>성공여부 :</span>
            <select name="login_success" id="login_success" class="form-select-sm form-control-sm" data-defval="<?=$_REQUEST['login_success']?>">
              <?=getSelectOptions($GLOBALS['_varsLoginResult'],"- 전체 -")?>
            </select>
          </label>
          <label>검색 내용 : <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>
          <label> <span>라인수 :</span>
          <select name="viewnum" id="viuewnum" class="form-select-sm form-control-sm" data-defval="<?=$_REQUEST['viewnum']?:20?>" onchange="this.form.submit()">
            <option value="">라인수</option>
            <option value="10">10개</option>
            <option value="20">20개</option>
            <option value="30">30개</option>
            <option value="50">50개</option>
            <option value="100">100개</option>
          </select>
          </label>
          <?=hidden_input("ofld",$_REQUEST['ofld'])?>
          <?=hidden_input("oasc",$_REQUEST['oasc'])?>
        </form>

        <div id="cmd_bar" class="mb-2">
          <div class="h4"><i class="bi bi-files-alt"></i> <?=$cate_title?> 로그인 기록</div>
          <div class="text-right">
          </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> <?=$cate_title?> 로그인 기록</span>
              </h5>
              <div class="cont_hfix">

                <table class="table table-bordered mt-3">
                  <colgroup>
                    <col width="5%">
                    <col width="10%">
                    <col width="10%">
                    <col width="*">
                    <col width="5%">
                    <col width="10%">
                    <col width="15%">
                    <col width="10%">
                    <col width="10%">
                  </colgroup>
                  <thead class="sticky-top">
                    <tr class="text-center bg-dark text-light">
                      <th>No</th>
                      <th><a href="javascript:sort_page_move(form2qry(document.sform),'member_id'    );" class="text-decoration-none text-white">회원 ID</a></th>
                      <th><a href="javascript:sort_page_move(form2qry(document.sform),'member_name'  );" class="text-decoration-none text-white">회원명</a></th>
                      <th><a href="javascript:sort_page_move(form2qry(document.sform),'login_date'   );" class="text-decoration-none text-white">접속일자</a></th>
                      <th><a href="javascript:sort_page_move(form2qry(document.sform),'login_success');" class="text-decoration-none text-white">성공여부</a></th>
                      <th><a href="javascript:sort_page_move(form2qry(document.sform),'ip_addr'      );" class="text-decoration-none text-white">IP 주소</a></th>
                      <th><a href="javascript:sort_page_move(form2qry(document.sform),'browser'      );" class="text-decoration-none text-white">접속브라우저</a></th>
                      <th><a href="javascript:sort_page_move(form2qry(document.sform),'con_domain'   );" class="text-decoration-none text-white">접속주소</a></th>
                      <th><a href="javascript:sort_page_move(form2qry(document.sform),'os'           );" class="text-decoration-none text-white">운영체제</a></th>
                    </tr>
                  </thead>
                  <tbody>
                  <?php
                  $_REQUEST['no_echo'] = true;
                  $_REQUEST['mode'] = "getMemberLogList";
                  include "./member.ajax.php";
                  $mem_log_list = $retval['data'];

                  foreach( $mem_log_list->rows as $row ){
                    switch( $row['login_success'] ){
                      case "1" :
                        $row['login_result'] = "성공"; break;
                      default :
                        $row['login_result'] = "<span class='text-danger'>실패</span>"; break;
                    }
                  ?>
                  <tr class="text-center">
                    <td><?=$mem_log_list->line_cnt--?></td>
                    <td><a href="./member_log_list.php?stxt=<?=$row['member_id']?>"><?=$row['member_id']?></a></td>
                    <td><a href="./member_put.php?member_id=<?=$row['member_id']?>"><?=$row['member_name']?></a></td>
                    <td><?=$row['login_date']?></td>
                    <td><?=$row['login_result']?></td>
                    <td><?=$row['ip_addr']?></td>
                    <td><?=$row['browser']?></td>
                    <td><?=$row['con_domain']?></td>
                    <td><?=$row['os']?> <?=$row['os_bit']?></td>
                  </tr>
                  <?php
                  }
                  if( count($mem_log_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)$mem_log_list->pages as $page ){?>
                    <li><?=$page?></li>
                    <?php }?>
                  </ul>
                </nav>
              </div>
            </div>
          </div>
        </div>
<?php

include _ADM_INC_PATH_ ."/footer.html";