
<?php 
    include 'header.php'; 

    $kdk = $_GET['kdk'];
    $jekel = $_GET['jekel'];
    $tgl_d = $_GET['tanggal_d'];
    $tgl_s = $_GET['tanggal_s'];
                if ($jekel=='1') {
                    $lp='Laki-laki' ;
                } else {
                    $lp='Perempuan' ;
                }
                
    $tgl_ini=date('d-m-Y') ;
    $tgl_ini2=date('Y-m-d') ; 
    
    $oleh=$_SESSION['id_kar'];
?>            
<div class="container">
  <div class="my-4 border-bottom">
    <h4 class="fw-semibold fs-4">Laporan Anggota <?php echo $lp ; ?>
    </h4>  
  </div>
  <section class="content">
    <div class="row">
      <section class="col-lg-14">
        <div class="box box-info">
          <div class="box-header">
          <div class="box-body">
            <form method="get" action="">
              <div class="row">

              </div>
            </form>
          </div>
        </div>
        
        <div class="box box-info">
          <div class="box-header">
            <h6 class="box-title"></h6>
          </div>
          <div class="box-body">
              <div class="row">
                <div class="col-lg-10">
                  <table class="table table-bordered">
                    <tr>
                      <th width="30%">DARI TANGGAL</th>
                      <th width="1%">:</th>
                      <td><?php echo date('d-m-Y', strtotime($tgl_d)); ?></td>
                    </tr>
                    <tr>
                      <th>SAMPAI TANGGAL</th>
                      <th>:</th>
                      <td><?php echo date('d-m-Y', strtotime($tgl_s)); ?></td>
                    </tr>
                    <tr>
                      <th>Menu Lanjutan </th>
                      <th>:</th>
                      <td>
                           
                <?php if ($jekel=='1') { ; ?>
                    <a href="angg_daftar_jekel.php?jekel<>1&tanggal_d=<?php echo $tgl_d ?>&tanggal_s=<?php echo $tgl_s ?>" class="btn btn-success btn-sm"><i class="bi bi-person-square"></i> &nbsp PEREMPUAN</a>
                <?php } else { ; ?>
                    <a href="angg_daftar_jekel.php?jekel=1&tanggal_d=<?php echo $tgl_d ?>&tanggal_s=<?php echo $tgl_s ?>" class="btn btn-success btn-sm"><i class="bi bi-person-square"></i> &nbsp Laki-laki</a>
                <?php } ; ?>
                      
                      <a href="lap_profil_kop_tgl_tgl_tenan.php?toleh=3&xtgl_d=<?php echo $tgl_d ?>&xtgl_s=<?php echo $tgl_s ?>" class="btn btn-info btn-sm pull-right"><i class="bi bi-reply"></i> &nbsp; Kembali</a> 
                      </td>
                    </tr>                       
                    <tr>
                      <th>Keterangan </th>
                      <th>:</th>
                      <td>
                <?php if ($jekel=='1') { ; ?>
                    Sebenarnya sebutan <?php echo $lp ; ?> pada judul hanya karena dalam database SUDAH terisi data 1
                <?php } else { ; ?>
                    Sebenarnya sebutan <?php echo $lp ; ?> pada judul hanya karena dalam database SUDAH terisi data 2 atau belum diisi, Jika belum maka EDIT-lah
                <?php } ; ?>                          
                        
                      </td>
                    </tr>                                           
                  </table>
                </div>
              </div>
              <div class="table-responsive">
                <table class="table table-bordered table-striped" id="table-datatable">
          <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="1%" class="text-center">Alamat</th>
              <th width="1%" class="text-center">RT</th>
              <th width="1%" class="text-center">RW</th>
              <th width="1%" class="text-center">KTP</th>
              <th width="1%" class="text-center">KK</th>
              <th width="1%" class="text-center">Pekerjaan</th>
              <th width="1%" class="text-center">No WA</th>
              <th width="1%" class="text-center">LP</th>
              <th width="2%" class="text-center">Tanggal</th>
              <th width="1%" class="text-center">EDIT</th>
            </tr>
          </thead>
          <tbody>
            <?php 
            $no=1;
            $data = mysqli_query($koneksi,"SELECT * FROM anggota WHERE tglmasuk>='$tgl_d' and tglmasuk<='$tgl_s' and jekel='$jekel' ");
            while($d = mysqli_fetch_array($data)){
                $noang  =$d['angg_no'] ;
                $rt   =$d['rt'] ;
                $rw   =$d['rw'] ;
                $kerja   =$d['pekerjaan'] ;
                $usaha   =$d['usaha'] ;
                $jekel   =$d['jekel'] ;
                if ($jekel=='1') {
                    $lp='L' ;
                } else {
                    $lp='P';
                }
                $no_hp=$d['hp'] ;
                        $foto_diri  =$d['foto_diri'] ;
                        $angg_id    =$d['angg_id'] ;
                        $noang      =$d['angg_no'] ;
 
               $sql2 = mysqli_query($koneksi, "SELECT pekerjaan AS akerjaan FROM kdpekerjaan WHERE id='$kerja' ");
                       list($akerjaan) = mysqli_fetch_array($sql2);     
               $sql3 = mysqli_query($koneksi, "SELECT usaha AS atusaha FROM kdusaha WHERE id='$usaha' ");
                       list($atusaha) = mysqli_fetch_array($sql3);                            
               $sql4 = mysqli_query($koneksi, "SELECT count(angg_no) AS t_ang_sim FROM angg_simp_trans WHERE angg_no='$noang' ");
                       list($t_ang_sim) = mysqli_fetch_array($sql4);
               $sql5 = mysqli_query($koneksi, "SELECT count(m_angg_no) AS t_permoh FROM permohonan WHERE m_angg_no='$noang' ");
                       list($t_permoh) = mysqli_fetch_array($sql5);
                       
               $tno_angg=$t_ang_sim+$t_permoh ;           
                       
              ?>
              <tr>
                <td><?php echo $no++; ?></td>
                <td>
                  <center>
                    <a href="angg_foto_tampil.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: 20px;height: auto">
                        <?php } ?>                    
                    </a>                                   
                  </center>         
                </td>                 
                <td style="text-align:left; font-size: 8pt; font-weight:normal;"><a data-toggle='tooltip' data-placement='top' title='Lihat Kartu Anggota <?php echo $d['nama']; ?>' style='margin-right:3px' class="btn btn-warning btn-sm" href="angg_kartu.php?id=<?php echo $angg_id; ?>"><?php echo $d['angg_no'] ?></td>
                <td style="text-align:left; font-size: 10pt; font-weight:normal;"><?php echo $d['nama']; ?></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['rt']; ?></td>
                <td style="text-align:left; font-size: 9pt; font-weight:normal;"><?php echo $d['rw']; ?></td>
                <td style="text-align:left; font-size: 8pt; font-weight:normal;"><a data-toggle='tooltip' data-placement='top' title='Upload/lihat Foto KTP No. <?php echo $d['ktp']; ?>' style='margin-right:3px' class="btn btn-secondary btn-sm" href="angg_foto_ktp.php?id=<?php echo $angg_id; ?>"><?php echo 'KTP'; ?></td>
                <td style="text-align:left; font-size: 8pt; font-weight:normal;"><a data-toggle='tooltip' data-placement='top' title='Upload/lihat Foto KK No. <?php echo $d['kk']; ?>' style='margin-right:3px' class="btn btn-success btn-sm" href="angg_foto_kk.php?id=<?php echo $angg_id; ?>"><?php echo 'KK'; ?></td>
                <td style="text-align:left; font-size: 9pt; font-weight:normal;"><?php echo $akerjaan; ?></td>
                <td style="text-align:left; font-size: 9pt; font-weight:normal;"><?php echo $no_hp; ?></td>
                <td style="text-align:left; font-size: 9pt; font-weight:normal;"><?php echo $lp; ?></td>
                <td style="text-align:left; font-size: 9pt; font-weight:normal;"><?php echo date('d/m/Y', strtotime($d['tglmasuk'])); ?></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>
                <?php if($tno_angg<=0) {;?>
                  <a onclick="return confirm('Yakin ingin hapus data No <?php echo $d['angg_no']; ?> a/n <?php echo $d['nama']; ?> - <?php echo $d['alamat']; ?> ?')" class="btn btn-danger btn-sm" href="angg_hapus.php?id=<?php echo $d['angg_id'] ?>&oleh=<?php echo $oleh ?>">
                    <i class="bi bi-trash"></i>
                  </a>
                <?php };?>  
                
<!---- FORM EDIT ANGGOTA  ---------->  

                  <form action="@_angg_edit_jekel_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 style="background-color: <?php echo$_SESSION['warna_bag']; ?>; padding: 15px; border-radius: 15px; box-shadow: 0 0 15px <?php echo$_SESSION['warna_bag']; ?>;">
                            <div class="form-group" style="width:100%">
                              <label><font color="#000fff">Nama Anggota</font></label>
                              <input type="hidden" name="tid" required="required" class="form-control" value="<?php echo $d['angg_id']; ?>">
                              <input type="hidden" name="t_kk" required="required" class="form-control" value="<?php echo $d['kk']; ?>">
                              <input type="hidden" name="t_ktp" required="required" class="form-control" value="<?php echo $d['ktp']; ?>">
                              <input type="hidden" name="tanggal_d" required="required" class="form-control" value="<?php echo $tgl_d; ?>">
                              <input type="hidden" name="tanggal_s" required="required" class="form-control" value="<?php echo $tgl_s; ?>">
                              <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><font color="#000fff">Alamat</font></label>
                              <input type="text" name="talamat" required="required" class="form-control" placeholder="Alamat .." value="<?php echo $d['alamat']; ?>"
                            </div>
            	<div class="form-group">
                    <label class="form-label">RT <font color='#ff0000'><i>(2 digit pakai NUMERIK misalnya : 01 atau 10)</i></font color></label>
                    <input type="text" minlength="2" maxlength="2" name="rt" required="required" class="form-control" placeholder="Isikan RT .." value="<?php echo $d['rt']; ?>">
            	</div>                         
            	<div class="form-group">
                    <label class="form-label">RW <font color='#ff0000'><i>(2 digit pakai NUMERIK misalnya : 01 atau 10)</i></font color></label>
                    <input type="text" minlength="2" maxlength="2" name="rw" required="required" class="form-control" placeholder="Isikan RW .."  value="<?php echo $d['rw']; ?>">
            	</div>                                   

                            <div class="form-group">
                              <label><font color="#000fff">No. KTP</font></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><font color="#000fff">No KK</font></label>
                              <input type="text" minlength="1" maxlength = "16" name="tkk" required="required" class="form-control" placeholder="Nomor KK .." value="<?php echo $d['kk']; ?>"
                            </div>     
                            <div class="form-group">
                              <label><font color="#000fff">Jenis Kelamin </font></label>
                                <select class="form-control" name="tjekel" required="required">
                                  <option value="">- Pilih Jenis Kelamin -</option>
                                  <?php $jk = mysqli_query($koneksi,"select * from kdjekel "); while($j = mysqli_fetch_array($jk)){ ?>
                                  <option value="<?php echo $j['id'] ?>" <?php if($i['jekel'] == $j['id']) { echo 'selected'; } ?>><?php echo $j['nama'] ?></option>
                                  <?php } ?>
                                </select>                              
                            </div> 

                            <div class="form-group">
                              <label><font color="#000fff">Nomor HP </font></label>
                              <input type="text" name="hp" required="required" class="form-control" value="<?php echo $d['hp']; ?>"
                            </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>
                    </div>
                  </form>
               
<!---- FORM EDIT ANGGOTA  ---------->     
                </td>
              </tr>
              <?php 
            }
            ?>
          </tbody>
        
        </table>
        
        
              </div>

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

</div>
<?php include 'footer.php'; ?>