<?php
/*error_reporting(E_ALL^(E_NOTICE|E_WARNING));
ini_set('display_errors',1);
error_reporting(0);*/
?>
<!-- Content Header (Page header) -->
<div class="content-header">
  <div class="container-fluid">
    <div class="row mb-2">
      <div class="col-sm-12">
        <h1 class="m-0 text-dark"></h1>
      </div><!-- /.col -->
    </div><!-- /.row -->
  </div><!-- /.container-fluid -->
</div>
<!-- /.content-header -->

<!-- Main content -->
    <section class="content">
      <div class="container-fluid">
        <div class="row">
          <div class="col-12">
            <!-- Default box -->
            <div class="card">
              <div class="card-header bg-info">
                <h3 class="card-title "> Daftar Alamat</h3>
                <div class="card-tools">
                  <button type="button" class="btn btn-tool" data-card-widget="collapse" title="Collapse">
                    <i class="fas fa-minus"></i>
                  </button>
                  <button type="button" class="btn btn-tool" data-card-widget="remove" title="Remove">
                    <i class="fas fa-times"></i>
                  </button>
                </div>
              </div>
              <!-- /.card-header -->
        <div class="card-body">
          <?php
          
          
         
          if(isset($_POST['k_kode'])){
            $k_kode = $_POST['k_kode'];


            if($_POST['k_kode']=='')
              $where="where dusun !='' ";
            else
              $where=" where dusun='$k_kode' OR desa='$k_kode' OR kec='$k_kode'OR kab='$k_kode' OR kab='$k_kode' ";

          }else{
            
            $k_kode="";

            $where="where dusun='$k_kode' OR kec='$k_kode' ";
           
          }
          ?>
          <form role="form" id="quickForm" action="home.php?home=<?php echo md5("lap_alamat");?>" method="post">
            <div class="form-group row">
              <label for="nama" class="col-2 m-3">Cari Alamat</label>
              <input type="text" name="k_kode" id="k_kode"  class="form-control col-sm-5" placeholder="ketik alamat/desa/kec/kab/provinsi">
              <div class="form-group row">
                <button type="submit" class="  btn btn-info"  ><i class="fas fa-search"></i></button>
               </div>
              
                 </div>    
          </form>                   
          <hr>
        

          <!-- <table id="example3" class="table table-bordered table-hover">
           -->
           <table id="sortTable" class="table table-bordered table-hover" width="100%">
            <thead>
              <tr>
                
                <th width="7%">No </th> 
                <th width="30%">Dusun</th>
                <th width="30%">RT/RW</th> 
                <th width="30%">Des</th>
                <th width="30%">Kec</th> 
                <th width="30%">Kab</th>
                <th width="30%">Provinsi</th> 
                
                
                
              </tr>
            </thead>
            <tbody>
              <?php
              $saldo=0;
              $queryak      = "SELECT * from alamat $where ";
              $result     = $mysqli->query($queryak);
              $num_result = $result->num_rows;
              if ($num_result > 0) {
                $no = 0;
                while ($data = mysqli_fetch_assoc($result)) {
                  extract($data);
                  $no++;
                  ?>
                  <tr>
                    
                    <td><?php echo $no; ?></td>
                  
                    <td align="left"><?php echo $k_dusun.":".$dusun; ?></td>
                    <td><?php echo $k_rtrw.":".$rtrw; ?></td>
                    <td><?php echo $k_desa.":".$desa; ?></td>
                    <td><?php echo $k_kec.":".$kec; ?></td>
                    <td><?php echo $k_kab.":".$kab; ?></td>
                    <td><?php echo $k_prov.":".$provinsi; ?></td>
                  </tr>
                <?php }}?>
              </table>
              </tbody>

              <script type="text/javascript" charset="utf8" src="./assets/jquery.dataTables.js"></script>
              <link rel="stylesheet" type="text/css" href="./assets/jquery.dataTables.css">
                  <script>
              $('#sortTable').DataTable(); //https://www.sahretech.com/2020/04/cara-membuat-pencarian-sorting-dan.html?m=1/ cara buat sorter table
              </script>
              <?php if(isset($_POST['par1'])){
                                
                /*$_SESSION['kode_akun']['kantor']=$_SESSION['kantor'];
                $_SESSION['kode_akun']['kode']['sqlj']=$queryj;*/
          
                
              ?>
                <a href="laporan/lap_alamat_pdf.php" target="_blank" style="float: right;margin-top: 10px;" class="btn btn-success"><i class="fa fa-print"></i> Cetak PDF</a>

              <?php } ?>
            </div>
            <!-- /.card-body -->
          </div>
          <!-- /.card -->
        </div>
        <!-- /.col -->
      </div>
      <!-- /.row -->
    </section>
    <!-- /.content -->

