<?php
  //error_reporting(0);
?>
<?php
  if (isset($_POST['btn_1'])) {
    $RGT_CODE_NAME = $_REQUEST['RGT_CODE_NAME'];
    $RGT_NO = $_REQUEST['RGT_NO'];

    if ($RGT_CODE_NAME != "") {
      $ECHORGT_CODE_NAME = $RGT_CODE_NAME;
      $ECHORGT_CODE_NAME_1 = "AND a.RGT_CODENAME  LIKE '%$RGT_CODE_NAME%'";
    } else {
      $ECHORGT_CODE_NAME = "";
      $ECHORGT_CODE_NAME_1 = "";
    }

    if ($RGT_NO != "") {
      $ECHORGT_NO = $RGT_NO;
      $ECHORGT_NO_1 = "AND df.RGT_NO IN ('$RGT_NO')";
    } else {
      $ECHORGT_NO = "";
      $ECHORGT_NO_1 = "";
    }
  }
  else {
    $ECHORGT_CODE_NAME = "";
    $ECHORGT_NO = "";
    $ECHORGT_CODE_NAME_1 = "";
    $ECHORGT_NO_1 = "";
  }
?>
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title>EHONGMD | ข้อมูลเอกสารแผนกทะเบียน</title>
  <link rel="shortcut icon" href="dist/img/logo_1.png" />
  <?php
    include '_plugin.php';
    include '_connect.php';
  ?>
</head>
<body class="hold-transition skin-red sidebar-mini">
<div class="wrapper">
<?php
include '_header.php';
include '_menu.php';
?>
  <div class="content-wrapper">
    <section class="content">
      <div class="row">
      <!-- ค้นหา -->
      <!-- ตาราง -->
      <script src="bower_components/jquery/dist/jquery.min.js"></script>

      <div class="col-md-12">
        <div class="box box-success">
          <div class="box-header with-border">
            <h3 class="box-title">EHONGMD | ค้นหาข้อมูลเอกสารแผนกทะเบียน</h3>
          </div>
          <!-- target="_blank" lettersum.php-->
          <form role="form" action="" method="POST" enctype="multipart/form-data" >
            <div class="box-body">
              <div class="row">

                <div class="col-md-4">
                  <p>ชื่อเอกสาร</p>
                  <input type="text" class="form-control" placeholder="ชื่อเอกสาร" name="RGT_CODE_NAME" value="<?php echo $ECHORGT_CODE_NAME; ?>">
                </div>

                <div class="col-md-2">
                  <div class="form-group">
                    <p>ประเภทเอกสาร</p>
                    <select class="form-control" name="RGT_NO">
                      <?php
                        $sql_2 = "SELECT * FROM CONFIG.dbo.RGT_DOCUMENTTYPE WHERE RGT_NO in ('$ECHORGT_NO') ORDER BY RGT_ID";
                        // echo $sql_1;
                        $select_2=$conn_z->prepare($sql_2);
                        $select_2->execute();
                        $item = 1;
                        while($fetch_2=$select_2->fetch()){
                      ?>
                      <option value="<?php echo $fetch_2['RGT_NO']; ?>"><?php echo $fetch_2['RGT_NO']." : ".$fetch_2['RGT_NAME']; ?></option>
                      <?php } ?>
                      <option value="">เลือกประเภทเอกสาร</option>
                      <?php
                        $sql_1 = "SELECT * FROM CONFIG.dbo.RGT_DOCUMENTTYPE ORDER BY RGT_ID";
                        // echo $sql_1;
                        $select=$conn_z->prepare($sql_1);
                        $select->execute();
                        $item = 1;
                        while($fetch=$select->fetch()){
                      ?>
                      <option value="<?php echo $fetch['RGT_NO']; ?>"><?php echo $fetch['RGT_NO']." : ".$fetch['RGT_NAME']; ?></option>
                      <?php } ?>
                    </select>
                  </div>
                </div>

              </div>
            </div>

            <div class="box-footer">
              <input type="submit" name="btn_1" id="" class="btn btn-success" value="ค้นหา">
            </div>

          </form>
        </div>
      </div>

        <?php
          if (isset($_POST['btn_1'])) {
            include 'reg_indexfileecho.php';
          }
          else {
            include 'reg_indexfileecho.php';
          }
        ?>

      </div>
    </section>
  </div>
</div>

<?php
// include '_footer.php';
// include '_form.php';
?>
<div class="control-sidebar-bg"></div>
<?php
  include '_script_2.php';
  include 'scroll0.php';
?>
</body>
</html>
