<?php
  session_start();
  include '_connect.php';
  $sql = "SELECT * FROM [EHONGDB].[dbo].[EMPLOYEE]";
  $select=$conn->prepare($sql);
  $select->execute();
?>
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title>EHONGMD | หนังสือแจ้งกรมบังคับคดี</title>
  <?php include '_plugin.php'; ?>
</head>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">

<?php
include '_header.php';
// include '_crm_menu.php'; onkeydown="return false"
?>
<link type="text/css" rel="stylesheet" href="jquery.autocomplete.css" />
<script type="text/javascript" src="jquery-1.11.2.min.js"></script>
<script type="text/javascript" src="jquery.autocomplete.js"></script>
<script type="text/javascript">
  var states = [
<?php
$province = "";
  while ($result = $select->fetch())
  {
  $province .= "'" . $result['FNAME'] . "',";
  }
  echo rtrim($province, ",");
?>
        ];
        $(function () {
            $("input").autocomplete({
                source: [states]
            });
        });
</script>

<script>
function showUser(str) {
  if (str=="") {
    document.getElementById("txtHint").innerHTML="";
    return;
  }
  if (window.XMLHttpRequest) {
    // code for IE7+, Firefox, Chrome, Opera, Safari
    xmlhttp=new XMLHttpRequest();
  } else { // code for IE6, IE5
    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
  xmlhttp.onreadystatechange=function() {
    if (this.readyState==4 && this.status==200) {
      document.getElementById("txtHint").innerHTML=this.responseText;
    }
  }
  xmlhttp.open("GET","show.php?FNAME="+str,true);
  xmlhttp.send();
}
</script>

  <!-- <div class="content-wrapper">
    <section class="content">
      <div class="row">
        <section class="col-lg-12 connectedSortable">
          <div class="box box-success">
            <div class="box-body chat" id="chat-box">
            </div>
          </div>
        </section>
      </div>
    </section>
  </div> -->

  <!-- <div class="content-wrapper"> -->
    <!-- Content Header (Page header) -->

    <!-- Main content -->
<section class="content">
  <div class="row">
    <div class="col-md-3">
      <div class="box box-primary">
        <div class="box-header">
          <h3 class="box-title">ค้นหารายชื่อพนักงาน</h3>
        </div>
        <!-- <form role="form" name="frmSearch" method="POST" action="api_insert.php"> -->
        <div class="box-body">
          <div class="form-group">
            <div class="input-group">
              <div class="input-group-addon">
                <i class="fa fa-address-card-o"></i>
              </div>
              <input type="text" name="states" onkeyup="showUser(this.value)" class="form-control" id="" placeholder="รายชื่อพนักงาน">

            </div>
          </div>
        </div>
        <div id="txtHint"></div>
      <!-- </form> -->
      </div>
  <!-- ค้นหา -->
    </div>
  <!-- ตาราง -->
    <div class="col-md-9">

      <div class="box box-success">
        <div class="box-header">
          <h3 class="box-title">รายชื่อพนักงาน</h3>
          <p class="text-red">หนังสือแจ้งกรมบังคับคดี</p>
        </div>
        <div class="box-body">
          <div class="form-group">
            <?php include 'show_add.php'; ?>
          </div>
        </div>
      </div>
    </div>
  </div>
</section>
    <br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
    <br><br><br><br><br><br><br><br><br>
    <!-- /.content -->
  <!-- </div> -->
</div>
<?php
// include '_footer.php';
include '_form.php';
?>
  <!-- /.control-sidebar -->
  <!-- Add the sidebar's background. This div must be placed
       immediately after the control sidebar -->
  <div class="control-sidebar-bg"></div>
</div>
<!-- ./wrapper -->
<?php include '_script.php'; ?>
</body>
</html>
