<?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-1">
      <div class="col-sm-12">
        <!-- <h1 class="m-0 text-dark">Laporan Neraca []</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 ">Cari Murid</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
          
          
          $username=$_SESSION['kode'];
          if(isset($_POST['c_register'])){
            $id = $_POST['c_register'];


            if($_POST['c_register']=='Pilih')
              //$where="where a.id like '%".$id."%' OR a.nama like '%".$id."%' OR a.ibuh like '%".$id."%' OR a.alamat like '%".$id."%' a.kode='$username' GROUP BY a.id ";
             /*  $where ="WHERE a.kode = '$username' 
              AND (a.id LIKE '%$id%' OR a.id LIKE '%$id%' OR a.nama LIKE '%$id%' OR a.alamat LIKE '%$id%') GROUP BY a.id ";            
                  else
                  $where="WHERE a.kode = '$username' 
              AND (a.id LIKE '%$id%' OR a.id LIKE '%$id%' OR a.nama LIKE '%$id%' OR a.alamat LIKE '%$id%') GROUP BY a.id ";
    
              }else{ */  
              $where ="WHERE (a.id LIKE '%$id%' OR a.id LIKE '%$id%' OR a.nama LIKE '%$id%' OR a.alamat LIKE '%$id%') GROUP BY a.id ";            
              else
              $where="WHERE (a.id LIKE '%$id%' OR a.id LIKE '%$id%' OR a.nama LIKE '%$id%' OR a.alamat LIKE '%$id%') GROUP BY a.id ";

          }else{
            
            $id="";

            $where="where a.id='$id' AND a.kode='$username' GROUP by a.id ";
           
          }
          ?>
          <form role="form" id="quickForm" action="home.php?home=<?php echo md5("cariregister");?>" method="post">
            <div class="form-group row">
              <label for="nama" class="col-2 m-3">Cari Murid</label>
              <input type="text" name="c_register" id="c_register"  class="form-control col-sm-5" placeholder="ketik Nama/Alamat/No Register/Ayah">
              <div class="form-group row">
                <button type="submit" class="  btn btn-info"  ><i class="fas fa-search"></i></button>
               </div>
              
                     
          </form>                   
          <hr>

          <!-- <table id="example3" class="table table-bordered table-hover" width="148%"> -->
          <table class="table table-bordered table-hover" width="148%">
            <thead>
              <tr align="center">
                <th width="5%" >No</th>
                <th width="7%" >Register</th>
                <th width="10%">NIK</th>
                <th width="15%">Nama</th>
                <th width="15%">Alamat</th>
                <th width="5%">RT/RW</th>
                <th width="10%">Kec</th>
                <th width="10%">Kab</th>
                <th width="10%">No. Hp</th>
              </tr>
            </thead>
            <tbody>
              <?php
              include 'koneksi.php';
              $queryb = "SELECT a.id as id,a.nik as nik,a.nama as nama,a.alamat as alamat,a.rtrw as rtrw, b.kec as kec,b.kab as kab,a.nohp as nohp from registrasi a left join alamat b ON a.desa=b.k_desa and a.kec=b.k_kec and a.kab=b.k_kab $where  ";
                $querya       =mysqli_query($koneksi,$queryb);
                if(mysqli_num_rows($querya)){
                $no=0;
                while ($data = mysqli_fetch_assoc($querya)) {
                  extract($data);
                 $no++;
                  /*https://www.niagahoster.co.id/blog/undefined-index-php/
                  cara mengatasi Undefined variable  php terbaru*/
                  ?>
                  <tr>
                    <td><?php echo $no; ?></td>
                    <!-- <td><?php echo date('d-m-Y',strtotime($tanggal)); ?></td> -->
                    <td><?php echo $id; ?></td>
                    <td><?php echo $nik; ?></td>
                    <td><?php echo $nama; ?></td>
                    <td><?php echo $alamat ?></td>
                    <td><?php echo $rtrw; ?></td>
                    <td><?php echo $kec; ?></td>
                    <td><?php echo $kab; ?></td>
                    <td><?php echo $nohp; ?></td>
                  </tr>
                <?php }}?>
              </tbody>
              </table>

              <?php if(isset($_POST['par1'])){
               /* $_SESSION['laporan']['judul']="Laporan Buku Besar";
                $_SESSION['laporan']['unit']="BMT UGT";*/
                ?>
                <a href="laporan/lap_buku_besar_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 -->


