


<?php include 'header.php'; ?>
<?php 
    include '../koneksi.php';
    $kata_cari = $_POST['kata_cari'];
    $rand = rand();

if (!empty($kata_cari))
{
?>
<div class="container">
 <div class="my-2 border-bottom">
   <h2 class="fw-semibold fs-3"></h2>
 </div>
  <div class="row justify-content-center">
    <div class="col-lg-12">
        
        <?php 
        /////////////////////   ALERT   ////////////////////////
        if(isset($_GET['alert'])){
          if($_GET['alert'] == "sukses"){
            echo "<div class='alert alert-success'>Data anggota berhasil diganti!</div>";
          }
        }
        ?>
        
       <div class="card">
    <div class="card-header d-flex justify-content-between">
      <span class="card-title fw-semibold align-self-start mb">Daftar Pemegang Saham</span>
      <button type="button" class="btn btn-primary btn-sm align-self-end" data-bs-toggle="modal" data-bs-target="#exampleModal">
       <a href="!!!_cari_persero.php" class="btn btn-primary btn-sm"><i class="bi bi-reply-all"></i> &nbsp Kembali</a> 
      </button>
    </div>
    <div class="card-body">
      <div class="table-responsive">
        <table class="table table-bordered table-striped" id="table-datatable1">
          <thead>
            <tr>
              <th width="1%" class="text-center" style="text-align:left; font-size: 9pt; font-weight:normal;">No</th>
              <th width="1%" class="text-center" style="text-align:left; font-size: 9pt; font-weight:normal;">Foto</th>
              <th width="1%" class="text-center" style="text-align:left; font-size: 9pt; font-weight:normal;">NoAng</th>
              <th width="16%" class="text-center">NAMA</th>
              <th width="16%" class="text-center">Tanggal Lahir</th>
              <th width="21%" class="text-center">Alamat</th>
              <th width="10%" class="text-center">Kecamatan</th>
              <th width="10%" class="text-center">KTP</th>
              <th width="10%" class="text-center">KK</th>
              <th width="4%" class="text-center">Tanggal</th>
              <th width="12%" class="text-center">OPSI</th>
            </tr>
          </thead>
          <tbody>
            <?php 
            $no=1;
                // jika yang diklik kolom NIM
            //    if ($_GET['by'] == "noang") $orderBy = "noang";
                // jika yang diklik kolom NAMA MHS
            //    else if ($_GET['by'] == "nama") $orderBy = "nama";
                // jika tidak ada yang diklik (default)
            //    else $orderBy = "nama";

            $query = mysqli_query($mysqli, "SELECT * FROM angg_saham WHERE nama like '%".$kata_cari."%' OR alamat like '%".$kata_cari."%' OR kec like '%".$kata_cari."%' ")
                                            or die('Ada kesalahan pada query tampil data user: '.mysqli_error($mysqli));
            while ($d = mysqli_fetch_assoc($query)) { 
                $noang=$d['angg_no'] ;

                $sql2 = mysqli_query($koneksi, "SELECT count(pinj_angg_no) AS tno_pinj FROM pinjaman WHERE pinj_angg_no='$noang' ");
                list($tno_pinj) = mysqli_fetch_array($sql2);
                
                $sql3 = mysqli_query($koneksi, "SELECT SUM(simp_d) AS tmut_d, SUM(simp_k) AS tmut_k FROM simpanan WHERE angg_no='$noang'");
                list($tmut_d,$tmut_k) = mysqli_fetch_array($sql3); 
                $s_simp=($tmut_d-$tmut_k) ;
                
                $sql4 = mysqli_query($koneksi, "SELECT count(angg_no) AS tno_angg FROM simpanan WHERE angg_no='$noang' and left(jam,7)='Migrasi' ");
                list($tno_angg) = mysqli_fetch_array($sql4); 
                           
              ?>
              <tr>
                <td><?php echo $no++; ?></td>
                
                <td style="text-align:left; font-size: 9pt; font-weight:normal;"><?php echo $d['angg_no'] ?></td>
                <td style="text-align:left; font-size: 9pt; font-weight:normal;"><?php echo $d['nama']; ?></td>
                <td style="text-align:left; font-size: 9pt; font-weight:normal;"><?php echo $d['tpt_tgl_lhr']; ?></td>
                <td style="text-align:left; font-size: 9pt; font-weight:normal;"><?php echo $d['alamat']; ?></td>
                <td style="text-align:left; font-size: 9pt; font-weight:normal;"><?php echo $d['kec']; ?></td>
                <td style="text-align:left; font-size: 9pt; font-weight:normal;"><?php echo $d['ktp']; ?></td>
                <td style="text-align:left; font-size: 9pt; font-weight:normal;"><?php echo $d['kk']; ?></td>
                <td style="text-align:left; font-size: 9pt; font-weight:normal;"><?php echo date('d/m/Y', strtotime($d['tglmasuk'])); ?></td>
                <td>
<!--                  <center>
                    <?php
                        $foto_diri  =$d['foto_diri'] ;
                        $angg_id    =$d['angg_id'] ;
                        $noang      =$d['angg_no'] ;
                    ?>
                    <a href="!!!_angg_kartu.php?id=<?php echo $angg_id ?>&no=<?php echo $noang ?>" data-placement='top' title='Lihat Detail & Foto <?php echo $d['angg_no'] ?> a/n <?php echo $d['nama']; ?>' >								    
                        <?php if($foto_diri == ""){ ?>
                          <img src="../gambar/user.png" style="width: 20px;height: auto">  
                        <?php }else{ ?>
                          <img src="../gambar/diri/<?php echo $foto_diri ?>" style="width: 30px;height: auto">
                        <?php } ?>                    
                    </a>                                   
                  </center>         
                </td>                 
                <td>    
                <a class="btn btn-warning btn-sm" title="Edit Data Customer <?php echo $d['nama'] ?>" data-bs-toggle="modal" data-bs-target="#edit_custom_<?php echo $d['angg_id'] ?>"><i class="bi bi-gear"></i></a>
<!---- FORM EDIT ANGGOTA  ---------->                  
<!--                  <form action="!!!_angg_update_act.php" method="post">
                    <div class="modal fade" id="edit_custom_<?php echo $d['angg_id'] ?>" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
                      <div class="modal-dialog" role="document">
                        <div class="modal-content">
                          <div class="modal-header">
                            <h1 class="modal-title fs-5" id="exampleModalLabel">Edit Data Customer Id <?php echo $d['angg_id']; ?> NoCust <?php echo $d['angg_no']; ?></h1>
                            <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                          </div>
                          <div class="modal-body">
                            <div class="form-group" style="width:100%">
                              <label>Nama Customer</label>
                              <input type="hidden" name="ekdkab" readonly="readonly" class="form-control" placeholder="Kd Kabupaten .." value="<?php echo $d['kd_kab']; ?>"
                              <input type="hidden" name="tid" required="required" class="form-control" value="<?php echo $d['angg_id']; ?>">
                              <input type="text" name="tnama" required="required" class="form-control" placeholder="Nama Anggota .." value="<?php echo $d['nama']; ?>" style="width:100%">
                            </div>
                            <div class="form-group">
                              <label>Alamat</label>
                              <input type="text" name="talamat" required="required" class="form-control" placeholder="Alamat .." value="<?php echo $d['alamat']; ?>"
                            </div>
                            <div class="form-group">
                              <label>Kabupaten</label>
                              <input type="text" name="ekab" readonly="readonly" class="form-control" placeholder="Kabupaten .." value="<?php echo $d['kab']; ?>"
                            </div>                                        
                        	<div class="form-group">
                                <label class="form-label">Kecamatan <?php echo $d['kec']; ?> <font color='#ff0000'><i>(Pilih Kecamatan)</i></font color></label>
                                <select class="form-control" name="tkd_kec" required="required">
                                  <option value="">- Pilih Kecamatan -</option>
                                  <?php 
                                  $kec = mysqli_query($koneksi,"select * from kdkecamatan WHERE kdkab='$d[kd_kab]' ");
                                  while($rx = mysqli_fetch_array($kec)){
                                    ?>
                                    <option value="<?php echo $rx['kd'] ?>"><?php echo $rx['kd'] ?> - <?php echo $rx['kecamatan'] ?></option>
                                    <?php 
                                  }
                                  ?>
                                </select>
                        	</div>          
                      
                            <div class="form-group">
                              <label>Tempat Tgl Lahir</label>
                              <input type="text" name="ttempat" required="required" class="form-control" placeholder="tempat .." value="<?php echo $d['tpt_tgl_lhr']; ?>"
                            </div>
                            <div class="form-group">
                              <label>Umur (Th)</label>
                              <input type="text" name="tumur" required="required" class="form-control" placeholder="Umur .." value="<?php echo $d['umur']; ?>"
                            </div>                            
                            <div class="form-group">
                              <label>No. KTP</label>
                              <input type="text" minlength="16" maxlength = "16" name="tktp" required="required" class="form-control" placeholder="Nomor KTP .." value="<?php echo $d['ktp']; ?>"
                            </div>                
                        
                            <div class="form-group">
                              <label>No KK</label>
                              <input type="text" minlength="16" maxlength = "16" name="tkk" required="required" class="form-control" placeholder="Nomor KK .." value="<?php echo $d['kk']; ?>"
                            </div>                
                            <div class="form-group">
                              <label>Nama Suami/Istri/Orang Tua</label>
                              <input type="text" name="tsuami" required="required" class="form-control" value="<?php echo $d['suami']; ?>"
                            </div>              
                            <div class="form-group">
                              <label>Nama Tersebut sebagai </label>
                              <input type="text" name="tsebagai" required="required" class="form-control" value="<?php echo $d['sebagai']; ?>"
                            </div>                                          
                            <div class="form-group">
                              <label>Janis Kelamin</label>
                              <input type="text" name="tjekel" required="required" class="form-control" value="<?php echo $d['jekel']; ?>"
                            </div>              
                            <div class="form-group">
                              <label>Pekerjaan</label>
                              <input type="text" name="tpekerjaan" required="required" class="form-control" value="<?php echo $d['pekerjaan']; ?>"
                            </div>              
                            <div class="form-group">
                              <label>Status Marital</label>
                              <input type="text" name="tmarital" required="required" class="form-control" value="<?php echo $d['marital']; ?>"
                            </div>                                          
                          </div>
                          <div class="modal-footer">
                            <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Tutup</button>
                            <button type="submit" class="btn btn-primary">Simpan</button>
                          </div>
                        </div>
                      </div>
                    </div>
                  </form>
<!---- FORM EDIT ANGGOTA  

                </td>  ---------->     
              </tr>
              <?php 
            }
            ?>
          </tbody>
        </table>
      </div>
    </div>

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

</div>
<?php include 'foot_ku.php'; ?>
<?php
}
else
{
   die("Maaf, Anda harus mengisi kata kunci");
}
?>
<?php include 'footer.php'; ?>