<?php
$cate_id = "mnu_adm_query"; //현재 메뉴 ID 필수!!!

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" max="9999-12-31" name="fdate" class="dpicker form-control" value="<?=$_REQUEST['fdate']?>">
          </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> 쿼리 로그 기록</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> 쿼리 로그 기록</span>
              </h5>
              <div class="cont_hfix">

                <table class="table table-bordered mt-3">
                  <colgroup>
                    <col width="5%">
                    <col width="7%">
                    <col width="8%">
                    <col width="10%">
                    <col width="*">
                    <col width="20%">
                    <col width="15%">
                    <col width="5%">
                    <col width="8%">
                  </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),'host_name'   );" class="text-decoration-none text-white">Host Name</a></th>
                      <th><a href="javascript:sort_page_move(form2qry(document.sform),'db_name'     );" class="text-decoration-none text-white">DB Name</a></th>
                      <th><a href="javascript:sort_page_move(form2qry(document.sform),'query_date'  );" class="text-decoration-none text-white">Date</a></th>
                      <th><a href="javascript:sort_page_move(form2qry(document.sform),'query_string');" class="text-decoration-none text-white">Query</a></th>
                      <th><a href="javascript:sort_page_move(form2qry(document.sform),'query_params' );" class="text-decoration-none text-white">Params</a></th>
                      <th><a href="javascript:sort_page_move(form2qry(document.sform),'visit_sess'  );" class="text-decoration-none text-white">Session</a></th>
                      <th><a href="javascript:sort_page_move(form2qry(document.sform),'member_id'   );" class="text-decoration-none text-white">Mem ID</a></th>
                      <th><a href="javascript:sort_page_move(form2qry(document.sform),'query_result');" class="text-decoration-none text-white">결과</a></th>
                    </tr>
                  </thead>
                  <tbody>
                  <?php
                  $_REQUEST['no_echo'] = true;
                  $_REQUEST['mode'] = "getQryLogPage";
                  include "./visit_sql.ajax.php";
                  $qry_log_list = $retval['data'];

                  foreach( $qry_log_list->rows as $row ){
                  ?>
                  <tr class="text-center">
                    <td><?=$qry_log_list->line_cnt--?></td>
                    <td><?=$row['host_name']?></td>
                    <td><?=$row['db_name']?></td>
                    <td><?=getDT_datetime($row['query_date'])?></td>
                    <td><?=$row['query_string']?></td>
                    <td><?=$row['query_params']?></td>
                    <td><?=$row['visit_sess']?></td>
                    <td><?=$row['member_id']?></td>
                    <td style="overflow: hidden; white-space: nowrap;"><?=$row['query_result']?></td>
                  </tr>
                  <?php
                  }
                  if( count($qry_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)$qry_log_list->pages as $page ){?>
                    <li><?=$page?></li>
                    <?php }?>
                  </ul>
                </nav>
              </div>
            </div>
          </div>
        </div>
<?php

include _ADM_INC_PATH_ ."/footer.html";