
<?php 
    include 'header.php'; 
    $id = $_GET['id'];
    $noang = $_GET['no'];
    
        $data = mysqli_query($koneksi, "select * from anggota where angg_id='$id'");
        $d = mysqli_fetch_assoc($data);  
            $noang=$d['angg_no'];
            
                $sql3 = mysqli_query($koneksi, "SELECT count(m_nomor) AS tpermohonan FROM permohonan WHERE hapus<>'HAPUS' and m_angg_no='$noang'");
                list($tpermohonan) = mysqli_fetch_array($sql3); 
                
                $sql4 = mysqli_query($koneksi, "SELECT count(norek) AS tpinj_no FROM pinjaman WHERE angg_no='$noang'");
                list($tpinj_no) = mysqli_fetch_array($sql4);    
?>              

<div class="container">
  <div class="my-2 border-bottom">
        <h6 class="fw-semibold fs-6"></h6>
  </div>
  <div class="row justify-content-center">
    <div class="col-lg-8">

       <div class="card">
    <div class="card-header d-flex justify-content-between">
      <span class="card-title fw-semibold align-self-start mb">KARTU HISTORI ANGGOTA</span>
      <button type="button" class="btn btn-primary btn-sm align-self-end" data-bs-toggle="modal" data-bs-target="#exampleModal">
        <a href="!!!_cari_nama.php" class="btn btn-primary btn-sm"><i class="bi bi-reply-all"></i> &nbsp Kembali</a> 
      </button>
    </div>
          <div class="box-body">
            <form method="get" action="">
              <div class="row">
                <div class="col-lg-10">
                  <table class="table table-bordered">
                    <tr>
                      <th width="35%">Foto</th>
                      <th width="1%">:</th>
                      <td>                    
                            <?php if($d['foto_diri'] == ""){ ?>
                              <img src="../gambar/user.png" style="width: 25px;height: auto">
                              <font color='#ff0000'  style="text-align:left; font-size: 8pt; font-weight:normal;"><i>Belum ada foto....</i></font><br>
                            <?php }else{ ?>
                              <img src="../gambar/diri/<?php echo $d['foto_diri'] ?>" style="width: 100px;height: auto">
                            <?php } ?>
                      </td>
                    </tr>                      
                    <tr>
                      <th width="35%">Nomor Anggota</th>
                      <th width="1%">:</th>
                      <td><?php echo $d['angg_no'] ?></td>
                    </tr>
                    <tr>
                      <th>Nama / (Suami / Istri) </th>
                      <th>:</th>
                      <td><?php echo $d['nama'] ?> / <?php echo $d['suami'] ?></td>
                    </tr>
                    <tr>
                      <th>Alamat</th>
                      <th>:</th>
                      <td><?php echo $d['alamat'] ?></td>
                    </tr>
                    <tr>
                      <th>Nomor KTP / KK</th>
                      <th>:</th>
                      <td><?php echo $d['ktp'] ?> / <?php echo $d['kk'] ?></td>
                    </tr>   
                    <tr>
                      <th>Jenis Kelamin / Status</th>
                      <th>:</th>
                      <td><?php echo $d['jekel'] ?> / <?php echo $d['marital'] ?></td>
                    </tr> 
                    <tr>
                      <th>Pekerjaan</th>
                      <th>:</th>
                      <td><?php echo $d['pekerjaan'] ?></td>
                    </tr>                       
                    <tr>
                      <th>Tanggal Daftar </th>
                      <th>:</th>
                      <td><?php echo date('d-m-Y', strtotime($d['tglmasuk'])); ?></td>
                    </tr>                    
                    <tr>
                      <th>Lihat / Ganti Foto </th>
                      <th>:</th>
                      <td><a href="angg_foto_tampil.php?id=<?php echo $id ?>" class="btn btn-warning btn-sm"><i class="bi bi-camera"></i> &nbsp Lihat/Ubah Foto-foto <?php echo $d['nama'] ?></a> </td>
                    </tr>
                    <tr>
                      <th>Lihat Map Domisili </th>
                      <th>:</th>
                      <td>
                        <?php if($d['a_latitude'] == "" && $d['a_longitude'] == ""){ ?>
                          <div class="alert alert-danger">Lokasi g-map belum diisi.</div>
                          <div class="form-group mb-2">
                                  <a href="angg_isi_map.php?id=<?php echo $id ?>" class="btn btn-info btn-sm"><i class="bi bi-geo-alt"></i> &nbsp Isi Kode MAP</a> 
                          </div>                   
                        <?php }else{ ?>
                            <div class="form-group mb-2">
                                <a href="https://www.google.com/search?q=google+map+<?php echo $d['a_latitude'] ?>%2C+<?php echo $d['a_longitude'] ?>" target="_blank" class="btn btn-warning btn-sm pull-right"><i class="bi bi-shop"></i> &nbsp; ke Detail Google Map</a>
                            </div>                
                            <div class="form-group mb-2">
                                <?php if($_SESSION[level]<>'TOP'){ ?>
                                  <a href="angg_isi_map.php?id=<?php echo $id ?>" class="btn btn-danger btn-sm"><i class="bi bi-geo-alt"></i> &nbsp Isi / Ganti Kode MAP</a> 
                                <?php } ?>
                            </div> 
                        <?php } ?>
                      </td>
                    </tr>                    
                  </table>
                </div>
              </div>
              </div>
            </form>
          </div>
          
          
<!-- ////////////////////////// SIMPANAN //////////////// -->          
<?php if ($tpermohonan>0) { ?>
 <div class="my-3 border-bottom">
   <h6 class="fw-semibold fs-5"> Permohonan Pinjaman :</h5>
 </div>
    <div class="card-body">
      <div class="table-responsive">
        <table class="table table-bordered table-striped" id="table-datatable1">
          <thead>
            <tr>
            <tr>
              <th width="1%" class="text-center" style="text-align:left; font-size: 10pt; font-weight:normal;">No</th>
              <th width="1%" class="text-center" style="text-align:left; font-size: 10pt; font-weight:normal;">Nomor</th>
              <th width="1%" class="text-center" style="text-align:left; font-size: 10pt; font-weight:normal;">Tanggal</th>
              <th width="1%" class="text-center" style="text-align:left; font-size: 10pt; font-weight:normal;">Jumlah</th>
              <th width="1%" class="text-center" style="text-align:left; font-size: 10pt; font-weight:normal;">Jkw</th>
              <th width="18%" class="text-center" style="text-align:left; font-size: 10pt; font-weight:normal;">Jaminan</th>
              <th width="18%" class="text-center" style="text-align:left; font-size: 10pt; font-weight:normal;">Tujuan</th>
              <th width="18%" class="text-center" style="text-align:left; font-size: 10pt; font-weight:normal;">Proses</th>
              <th width="24%" class="text-center">OPSI</th>
            </tr>
            </tr>
          </thead>
          <tbody>
            <?php 
            $no=1;
            $permohonan = mysqli_query($koneksi,"SELECT * FROM permohonan WHERE hapus<>'HAPUS' and m_angg_no=$d[angg_no] ");
            while($p = mysqli_fetch_array($permohonan)){
                $xx_nomor=$p['m_nomor'] ;
                $sql1 = mysqli_query($koneksi, "SELECT count(nomor) AS tnomor1 FROM jam_bpkb WHERE nomor='$p[m_nomor]' ");
                list($tnomor1) = mysqli_fetch_array($sql1);
                $sql2 = mysqli_query($koneksi, "SELECT count(nomor) AS tnomor2 FROM jam_sertif WHERE nomor='$p[m_nomor]' ");
                list($tnomor2) = mysqli_fetch_array($sql2);
                $sql3 = mysqli_query($koneksi, "SELECT count(nomor) AS tnomor3 FROM jam_lain WHERE nomor='$p[m_nomor]' ");
                list($tnomor3) = mysqli_fetch_array($sql3);                
                
                if ($tnomor1>0) { ;
                  $ket1 = $tnomor1.' BPKB' ;
                } else {
                  $ket1 = '' ;  
                };
                
                if ($tnomor2>0) { ;
                  $ket2 = $tnomor2.' Sertif' ;
                } else {
                  $ket2 = '' ;  
                };                
                if ($tnomor3>0) { ;
                  $ket3 = $tnomor3.' Lain' ;
                } else {
                  $ket3 = '' ;  
                };     
                
                $ket_jam = $ket1.', '.$ket2.', '.$ket3 ;
                
              ?>
              <tr>
                <td><?php echo $no++; ?></td>
                <td style="text-align:left; font-size: 10pt; font-weight:normal;"><?php echo $p['m_nomor'] ?></td>
                <td style="text-align:left; font-size: 10pt; font-weight:normal;"><?php echo date('d/m/Y', strtotime($p['m_tanggal'])); ?></td>
                <td style="text-align:right; font-size: 10pt; font-weight:normal;"><?php echo "" . number_format("$p[m_pokok]", 0, ",", "."); ?></td>
                <td style="text-align:right; font-size: 10pt; font-weight:normal;"><?php echo "" . number_format("$p[m_jkw]", 0, ",", "."); ?></td>
                <td style="text-align:left; font-size: 10pt; font-weight:normal;"><?php echo $ket_jam ; ?></td>
                <td style="text-align:left; font-size: 10pt; font-weight:normal;"><?php echo $p['m_sektor']; ?></td>
                <td style="text-align:left; font-size: 10pt; font-weight:normal;"><?php echo $p['cair']; ?></td>
                <td>
                    <?php if($tnomor1>=1){ ?>    
                        <a data-toggle='tooltip' data-placement='top' title='Lihat Jaminan BPKB <?php echo $norek ?> a/n <?php echo $angg_nama; ?>' style='margin-right:3px' class="btn btn-primary btn-sm" href="jaminan_bpkb_per_cus.php?nomor=<?php echo $p['m_nomor'] ?>&noang=<?php echo $p['m_angg_no'] ?>"><i class="bi bi-truck"></i></a>
                    <?php } ?>
                    <?php if($tnomor2>=1){ ?>    
                        <a data-toggle='tooltip' data-placement='top' title='Lihat Jaminan Sertifikat <?php echo $norek ?> a/n <?php echo $angg_nama; ?>' style='margin-right:3px' class="btn btn-info btn-sm" href="jaminan_sertif_tambah.php?nomor=<?php echo $p['m_nomor'] ?>&noang=<?php echo $p['m_angg_no'] ?>"><i class="bi bi-credit-card-2-front"></i></a>
                    <?php } ?>  
                    <?php if($tnomor3>=1){ ?>    
                        <a data-toggle='tooltip' data-placement='top' title='Lihat Jaminan Lain-lain <?php echo $norek ?> a/n <?php echo $angg_nama; ?>' style='margin-right:3px' class="btn btn-secondary btn-sm" href="jaminan_lain_tambah.php?nomor=<?php echo $p['m_nomor'] ?>&noang=<?php echo $p['m_angg_no'] ?>"><i class="bi bi-grid"></i></a>
                    <?php } ?>                      
                </td>    
              </tr>
              <?php } ?>
          </tbody>
        </table>
       </div> 
    </div>    
<!-- ////////////////////////// foto - foto analisa  //////////////////-->
<?php if($_SESSION[level]<>'TOP'){ ?>
 <div class="my-3 border-bottom">
   <h6 class="fw-semibold fs-5"> Foto-foto Analisa Permohonan :</h5>
 </div>
    <div class="card-body">
      <div class="table-responsive">
        <table class="table table-bordered table-striped" id="table-datatable1">
          <thead>
            <tr>
            <tr>
              <th width="1%" class="text-center" style="text-align:left; font-size: 10pt; font-weight:normal;">Nomor</th>
              <th width="1%" class="text-center" style="text-align:left; font-size: 10pt; font-weight:normal;">Foto 1</th>
              <th width="1%" class="text-center" style="text-align:left; font-size: 10pt; font-weight:normal;"></th>
              <th width="1%" class="text-center" style="text-align:left; font-size: 10pt; font-weight:normal;">Foto 2</th>
              <th width="1%" class="text-center" style="text-align:left; font-size: 10pt; font-weight:normal;"></th>
              <th width="1%" class="text-center" style="text-align:left; font-size: 10pt; font-weight:normal;">Foto 3</th>
              <th width="1%" class="text-center" style="text-align:left; font-size: 10pt; font-weight:normal;"></th>
              <th width="1%" class="text-center" style="text-align:left; font-size: 10pt; font-weight:normal;">Foto 4</th>
              <th width="1%" class="text-center" style="text-align:left; font-size: 10pt; font-weight:normal;"></th>
              <th width="1%" class="text-center" style="text-align:left; font-size: 10pt; font-weight:normal;">Foto 5</th>
              <th width="1%" class="text-center" style="text-align:left; font-size: 10pt; font-weight:normal;"></th>
              <th width="1%" class="text-center" style="text-align:left; font-size: 10pt; font-weight:normal;">Foto 6</th>
              <th width="1%" class="text-center" style="text-align:left; font-size: 10pt; font-weight:normal;"></th>
              <th width="1%" class="text-center" style="text-align:left; font-size: 10pt; font-weight:normal;">Foto 7</th>              
              <th width="1%" class="text-center" style="text-align:left; font-size: 10pt; font-weight:normal;"></th>
              <th width="1%" class="text-center" style="text-align:left; font-size: 10pt; font-weight:normal;">Foto 8</th>
              <th width="1%" class="text-center" style="text-align:left; font-size: 10pt; font-weight:normal;"></th>
              <th width="1%" class="text-center" style="text-align:left; font-size: 10pt; font-weight:normal;">Foto 9</th>
              <th width="1%" class="text-center" style="text-align:left; font-size: 10pt; font-weight:normal;"></th>
            </tr>
            </tr>
          </thead>
          <tbody>
            <?php 
            $no=1;
            $permohonan = mysqli_query($koneksi,"SELECT * FROM permohonan WHERE hapus<>'HAPUS' and m_angg_no=$d[angg_no] ");
            while($p = mysqli_fetch_array($permohonan)){
                $xx_nomor=$p['m_nomor'] ;
                $permoh_anal = mysqli_query($koneksi,"select * from permoh_anal where m_nomor='$xx_nomor'");
                $an = mysqli_fetch_assoc($permoh_anal);       
              ?>
              <tr>
                <td style="text-align:left; font-size: 10pt; font-weight:normal;"><?php echo $p['m_nomor'] ?></td>
                <td>
                  <center>
                    <?php if($an['foto_1'] == ""){ ?>
                      <img src="../gambar/user.png" style="width: 20px;height: auto">  
                    <?php }else{ ?>
                        <a href="#" class="pop">								    
                           <img width="80" height="80" 
                        src="../gambar/analisa_1/<?php echo $an['foto_1'] ?>" style="width: 30px;height: auto">
                        </a>             
                    <?php } ?>
                  </center> 
                </td>
                <td>  
                  <a data-toggle='tooltip' data-placement='top' title='Isi/Ganti Foto Analisa 1 : <?php echo $xx_nomor ?> a/n <?php echo $d['nama'] ?>' style='margin-right:3px' class="btn btn-success btn-sm" href="jam_foto_analisa_1.php?nomor=<?php echo $p['m_nomor'] ?>&noang=<?php echo $p['m_angg_no'] ?>"><i class="bi bi-columns-gap"></i></a>
                </td>    
                <td>
                  <center>
                    <?php if($an['foto_2'] == ""){ ?>
                      <img src="../gambar/user.png" style="width: 20px;height: auto">  
                    <?php }else{ ?>
                        <a href="#" class="pop">								    
                           <img width="80" height="80" 
                        src="../gambar/analisa_2/<?php echo $an['foto_2'] ?>" style="width: 30px;height: auto">
                        </a>             
                    <?php } ?>
                  </center> 
                </td>
                <td>  
                  <a data-toggle='tooltip' data-placement='top' title='Isi/Ganti Foto Analisa 2 : <?php echo $xx_nomor ?> a/n <?php echo $d['nama'] ?>' style='margin-right:3px' class="btn btn-success btn-sm" href="jam_foto_analisa_2.php?nomor=<?php echo $p['m_nomor'] ?>&noang=<?php echo $p['m_angg_no'] ?>"><i class="bi bi-columns-gap"></i></a>
                </td>    
                <td>
                  <center>
                    <?php if($an['foto_3'] == ""){ ?>
                      <img src="../gambar/user.png" style="width: 20px;height: auto">  
                    <?php }else{ ?>
                        <a href="#" class="pop">								    
                           <img width="80" height="80" 
                        src="../gambar/analisa_3/<?php echo $an['foto_3'] ?>" style="width: 30px;height: auto">
                        </a>             
                    <?php } ?>
                  </center> 
                </td>
                <td>  
                  <a data-toggle='tooltip' data-placement='top' title='Isi/Ganti Foto Analisa 3 : <?php echo $xx_nomor ?> a/n <?php echo $d['nama'] ?>' style='margin-right:3px' class="btn btn-success btn-sm" href="jam_foto_analisa_3.php?nomor=<?php echo $p['m_nomor'] ?>&noang=<?php echo $p['m_angg_no'] ?>"><i class="bi bi-columns-gap"></i></a>
                </td>    
                <td>
                  <center>
                    <?php if($an['foto_4'] == ""){ ?>
                      <img src="../gambar/user.png" style="width: 20px;height: auto">  
                    <?php }else{ ?>
                        <a href="#" class="pop">								    
                           <img width="80" height="80" 
                        src="../gambar/analisa_4/<?php echo $an['foto_4'] ?>" style="width: 30px;height: auto">
                        </a>             
                    <?php } ?>
                  </center> 
                </td>
                <td>  
                  <a data-toggle='tooltip' data-placement='top' title='Isi/Ganti Foto Analisa 4 : <?php echo $xx_nomor ?> a/n <?php echo $d['nama'] ?>' style='margin-right:3px' class="btn btn-success btn-sm" href="jam_foto_analisa_4.php?nomor=<?php echo $p['m_nomor'] ?>&noang=<?php echo $p['m_angg_no'] ?>"><i class="bi bi-columns-gap"></i></a>
                </td>    
                <td>
                  <center>
                    <?php if($an['foto_5'] == ""){ ?>
                      <img src="../gambar/user.png" style="width: 20px;height: auto">  
                    <?php }else{ ?>
                        <a href="#" class="pop">								    
                           <img width="80" height="80" 
                        src="../gambar/analisa_5/<?php echo $an['foto_5'] ?>" style="width: 30px;height: auto">
                        </a>             
                    <?php } ?>
                  </center> 
                </td>
                <td>  
                  <a data-toggle='tooltip' data-placement='top' title='Isi/Ganti Foto Analisa 5 : <?php echo $xx_nomor ?> a/n <?php echo $d['nama'] ?>' style='margin-right:3px' class="btn btn-success btn-sm" href="jam_foto_analisa_5.php?nomor=<?php echo $p['m_nomor'] ?>&noang=<?php echo $p['m_angg_no'] ?>"><i class="bi bi-columns-gap"></i></a>
                </td>    
                <td>
                  <center>
                    <?php if($an['foto_6'] == ""){ ?>
                      <img src="../gambar/user.png" style="width: 20px;height: auto">  
                    <?php }else{ ?>
                        <a href="#" class="pop">								    
                           <img width="80" height="80" 
                        src="../gambar/analisa_6/<?php echo $an['foto_6'] ?>" style="width: 30px;height: auto">
                        </a>             
                    <?php } ?>
                  </center> 
                </td>
                <td>  
                  <a data-toggle='tooltip' data-placement='top' title='Isi/Ganti Foto Analisa 6 : <?php echo $xx_nomor ?> a/n <?php echo $d['nama'] ?>' style='margin-right:3px' class="btn btn-success btn-sm" href="jam_foto_analisa_6.php?nomor=<?php echo $p['m_nomor'] ?>&noang=<?php echo $p['m_angg_no'] ?>"><i class="bi bi-columns-gap"></i></a>
                </td>    
                <td>
                  <center>
                    <?php if($an['foto_7'] == ""){ ?>
                      <img src="../gambar/user.png" style="width: 20px;height: auto">  
                    <?php }else{ ?>
                        <a href="#" class="pop">								    
                           <img width="80" height="80" 
                        src="../gambar/analisa_7/<?php echo $an['foto_7'] ?>" style="width: 30px;height: auto">
                        </a>             
                    <?php } ?>
                  </center> 
                </td>
                <td>  
                  <a data-toggle='tooltip' data-placement='top' title='Isi/Ganti Foto Analisa 7 : <?php echo $xx_nomor ?> a/n <?php echo $d['nama'] ?>' style='margin-right:3px' class="btn btn-success btn-sm" href="jam_foto_analisa_7.php?nomor=<?php echo $p['m_nomor'] ?>&noang=<?php echo $p['m_angg_no'] ?>"><i class="bi bi-columns-gap"></i></a>
                </td>    
                <td>
                  <center>
                    <?php if($an['foto_8'] == ""){ ?>
                      <img src="../gambar/user.png" style="width: 20px;height: auto">  
                    <?php }else{ ?>
                        <a href="#" class="pop">								    
                           <img width="80" height="80" 
                        src="../gambar/analisa_8/<?php echo $an['foto_8'] ?>" style="width: 30px;height: auto">
                        </a>             
                    <?php } ?>
                  </center> 
                </td>
                <td>  
                  <a data-toggle='tooltip' data-placement='top' title='Isi/Ganti Foto Analisa 8 : <?php echo $xx_nomor ?> a/n <?php echo $d['nama'] ?>' style='margin-right:3px' class="btn btn-success btn-sm" href="jam_foto_analisa_8.php?nomor=<?php echo $p['m_nomor'] ?>&noang=<?php echo $p['m_angg_no'] ?>"><i class="bi bi-columns-gap"></i></a>
                </td>   
                <td>
                  <center>
                    <?php if($an['foto_9'] == ""){ ?>
                      <img src="../gambar/user.png" style="width: 20px;height: auto">  
                    <?php }else{ ?>
                        <a href="#" class="pop">								    
                           <img width="80" height="80" 
                        src="../gambar/analisa_9/<?php echo $an['foto_9'] ?>" style="width: 30px;height: auto">
                        </a>             
                    <?php } ?>
                  </center> 
                </td>
                <td>  
                  <a data-toggle='tooltip' data-placement='top' title='Isi/Ganti Foto Analisa 9 : <?php echo $xx_nomor ?> a/n <?php echo $d['nama'] ?>' style='margin-right:3px' class="btn btn-success btn-sm" href="jam_foto_analisa_9.php?nomor=<?php echo $p['m_nomor'] ?>&noang=<?php echo $p['m_angg_no'] ?>"><i class="bi bi-columns-gap"></i></a>
                </td>                    
              </tr>
              <?php } ?>
          </tbody>
        </table>
       </div> 
    </div>    
<?php } else { ?>



 <div class="my-3 border-bottom">
   <h6 class="fw-semibold fs-5"> Foto-foto Analisa Permohonan :</h5>
 </div>
    <div class="card-body">
      <div class="table-responsive">
        <table class="table table-bordered table-striped" id="table-datatable1">
          <thead>
            <tr>
            <tr>
              <th width="1%" class="text-center" style="text-align:left; font-size: 10pt; font-weight:normal;">Nomor</th>
              <th width="1%" class="text-center" style="text-align:left; font-size: 10pt; font-weight:normal;">Foto 1</th>
              <th width="1%" class="text-center" style="text-align:left; font-size: 10pt; font-weight:normal;">Foto 2</th>
              <th width="1%" class="text-center" style="text-align:left; font-size: 10pt; font-weight:normal;">Foto 3</th>
              <th width="1%" class="text-center" style="text-align:left; font-size: 10pt; font-weight:normal;">Foto 4</th>
              <th width="1%" class="text-center" style="text-align:left; font-size: 10pt; font-weight:normal;">Foto 5</th>
              <th width="1%" class="text-center" style="text-align:left; font-size: 10pt; font-weight:normal;">Foto 6</th>
              <th width="1%" class="text-center" style="text-align:left; font-size: 10pt; font-weight:normal;">Foto 7</th>              
              <th width="1%" class="text-center" style="text-align:left; font-size: 10pt; font-weight:normal;">Foto 8</th>
              <th width="1%" class="text-center" style="text-align:left; font-size: 10pt; font-weight:normal;">Foto 9</th>
            </tr>
            </tr>
          </thead>
          <tbody>
            <?php 
            $no=1;
            $permohonan = mysqli_query($koneksi,"SELECT * FROM permohonan WHERE hapus<>'HAPUS' and m_angg_no=$d[angg_no] ");
            while($p = mysqli_fetch_array($permohonan)){
                $xx_nomor=$p['m_nomor'] ;
                $permoh_anal = mysqli_query($koneksi,"select * from permoh_anal where m_nomor='$xx_nomor'");
                $an = mysqli_fetch_assoc($permoh_anal);       
              ?>
              <tr>
                <td style="text-align:left; font-size: 10pt; font-weight:normal;"><?php echo $p['m_nomor'] ?></td>
                <td>
                  <center>
                    <?php if($an['foto_1'] == ""){ ?>
                      <img src="../gambar/user.png" style="width: 20px;height: auto">  
                    <?php }else{ ?>
                        <a href="#" class="pop">								    
                           <img width="80" height="80" 
                        src="../gambar/analisa_1/<?php echo $an['foto_1'] ?>" style="width: 30px;height: auto">
                        </a>             
                    <?php } ?>
                  </center> 
                </td>
                <td>
                  <center>
                    <?php if($an['foto_2'] == ""){ ?>
                      <img src="../gambar/user.png" style="width: 20px;height: auto">  
                    <?php }else{ ?>
                        <a href="#" class="pop">								    
                           <img width="80" height="80" 
                        src="../gambar/analisa_2/<?php echo $an['foto_2'] ?>" style="width: 30px;height: auto">
                        </a>             
                    <?php } ?>
                  </center> 
                </td>
                <td>
                  <center>
                    <?php if($an['foto_3'] == ""){ ?>
                      <img src="../gambar/user.png" style="width: 20px;height: auto">  
                    <?php }else{ ?>
                        <a href="#" class="pop">								    
                           <img width="80" height="80" 
                        src="../gambar/analisa_3/<?php echo $an['foto_3'] ?>" style="width: 30px;height: auto">
                        </a>             
                    <?php } ?>
                  </center> 
                </td>
                <td>
                  <center>
                    <?php if($an['foto_4'] == ""){ ?>
                      <img src="../gambar/user.png" style="width: 20px;height: auto">  
                    <?php }else{ ?>
                        <a href="#" class="pop">								    
                           <img width="80" height="80" 
                        src="../gambar/analisa_4/<?php echo $an['foto_4'] ?>" style="width: 30px;height: auto">
                        </a>             
                    <?php } ?>
                  </center> 
                </td>
                <td>
                  <center>
                    <?php if($an['foto_5'] == ""){ ?>
                      <img src="../gambar/user.png" style="width: 20px;height: auto">  
                    <?php }else{ ?>
                        <a href="#" class="pop">								    
                           <img width="80" height="80" 
                        src="../gambar/analisa_5/<?php echo $an['foto_5'] ?>" style="width: 30px;height: auto">
                        </a>             
                    <?php } ?>
                  </center> 
                </td>
                <td>
                  <center>
                    <?php if($an['foto_6'] == ""){ ?>
                      <img src="../gambar/user.png" style="width: 20px;height: auto">  
                    <?php }else{ ?>
                        <a href="#" class="pop">								    
                           <img width="80" height="80" 
                        src="../gambar/analisa_6/<?php echo $an['foto_6'] ?>" style="width: 30px;height: auto">
                        </a>             
                    <?php } ?>
                  </center> 
                </td>
                <td>
                  <center>
                    <?php if($an['foto_7'] == ""){ ?>
                      <img src="../gambar/user.png" style="width: 20px;height: auto">  
                    <?php }else{ ?>
                        <a href="#" class="pop">								    
                           <img width="80" height="80" 
                        src="../gambar/analisa_7/<?php echo $an['foto_7'] ?>" style="width: 30px;height: auto">
                        </a>             
                    <?php } ?>
                  </center> 
                </td>
                <td>
                  <center>
                    <?php if($an['foto_8'] == ""){ ?>
                      <img src="../gambar/user.png" style="width: 20px;height: auto">  
                    <?php }else{ ?>
                        <a href="#" class="pop">								    
                           <img width="80" height="80" 
                        src="../gambar/analisa_8/<?php echo $an['foto_8'] ?>" style="width: 30px;height: auto">
                        </a>             
                    <?php } ?>
                  </center> 
                </td>
                <td>
                  <center>
                    <?php if($an['foto_9'] == ""){ ?>
                      <img src="../gambar/user.png" style="width: 20px;height: auto">  
                    <?php }else{ ?>
                        <a href="#" class="pop">								    
                           <img width="80" height="80" 
                        src="../gambar/analisa_9/<?php echo $an['foto_9'] ?>" style="width: 30px;height: auto">
                        </a>             
                    <?php } ?>
                  </center> 
                </td>
              </tr>
              <?php } ?>
          </tbody>
        </table>
       </div> 
    </div>    
    
    
    
    
    
<?php } ?>
<!-- ////////////////////////// SELESAI PERMOHONAN  //////////////// --> 
 <div class="my-3 border-bottom">
   <h6 class="fw-semibold fs-5"> Tim Pemutus Kredit :</h5>
 </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: 10pt; font-weight:normal;">No</th>
              <th width="15%" class="text-center" style="text-align:left; font-size: 10pt; font-weight:normal;">Petugas</th>
              <th width="10%" class="text-center" style="text-align:left; font-size: 10pt; font-weight:normal;">Tanggal</th>
              <th width="1%" class="text-center" style="text-align:left; font-size: 10pt; font-weight:normal;">Jumlah</th>
              <th width="1%" class="text-center" style="text-align:left; font-size: 10pt; font-weight:normal;">Jkw</th>
              <th width="8%" class="text-center" style="text-align:left; font-size: 10pt; font-weight:normal;">% bln</th>
              <th width="50%" class="text-center" style="text-align:left; font-size: 10pt; font-weight:normal;">Keterangan</th>
              <th width="14%" class="text-center">OPSI</th>
            </tr>
          </thead>
          <tbody>
            <?php 
            $no=1;
            $karyawan = mysqli_query($koneksi,"SELECT * FROM karyawan WHERE hapus<>'HAPUS' and left(acc,3)='ACC' order by acc ASC ");
            while($k = mysqli_fetch_array($karyawan)){
                $k_id=$k['id'];
                $k_jab=$k['acc'];

                $permoh_acc = mysqli_query($koneksi,"select * from permoh_acc where acc_jab='$k_jab' and m_nomor='$xx_nomor' ");
                $acc = mysqli_fetch_assoc($permoh_acc);
                $jasa=$acc['acc_jasa']/12;
              ?>
              <tr>
                <td><?php echo $no++; ?></td>
                <td style="text-align:left; font-size: 10pt; font-weight:normal;"><?php echo $k['nama'] ?></td>
                <td style="text-align:left; font-size: 10pt; font-weight:normal;"><?php echo date('d/m/Y', strtotime($acc['tanggal'])); ?></td>
                <td style="text-align:right; font-size: 10pt; font-weight:normal;"><?php echo "" . number_format("$acc[acc_pokok]", 0, ",", "."); ?></td>
                <td style="text-align:right; font-size: 10pt; font-weight:normal;"><?php echo "" . number_format("$acc[acc_jkw]", 0, ",", "."); ?></td>
                <td style="text-align:center; font-size: 10pt; font-weight:normal;"><?php echo $jasa ?></td></td>
                <td style="text-align:left; font-size: 10pt; font-weight:normal;"><?php echo $acc['acc_ket']; ?></td>
                <td>
                    <a data-toggle='tooltip' data-placement='top' title='Mengisi Persetujuan <?php echo $xx_nomor ?> a/n <?php echo $d['nama'] ?>' style='margin-right:3px' class="btn btn-success btn-sm" href="01_permohonan_acc.php?id=<?php echo $id ?>&nomor=<?php echo $xx_nomor ?>&noang=<?php echo $d['angg_no'] ?>&oleh=<?php echo $k_id ?>&jab=<?php echo $k_jab ?>&nama_k=<?php echo $k['nama'] ?>"><i class="bi bi-hammer"></i></a>
                    <a data-toggle='tooltip' data-placement='top' title='Mengirim WA <?php echo $xx_nomor ?> a/n <?php echo $d['nama'] ?>' style='margin-right:3px' class="btn btn-secondary btn-sm" href="01_permohonan_wa_ke_bos.php?id=<?php echo $id ?>&nomor=<?php echo $xx_nomor ?>&noang=<?php echo $d['angg_no'] ?>&oleh=<?php echo $k_id ?>&jab=<?php echo $k_jab ?>&nama_k=<?php echo $k['nama'] ?>"><i class="bi bi-envelope-open"></i></a>
                </td>    
              </tr>
              <?php } ?>
          </tbody>
        </table>
       </div> 
    </div>        
<!-- ////////////////////////// MEMBUAT FORM ACC  //////////////// -->         
        <?php } else { ?>
                <font color='#ff0000'  style="text-align:left; font-size: 8pt; font-weight:normal;"><i>Tuan <?php echo $d['nama'] ?> belum ada data PENGAJUAN baru....</i></font><br>
        <?php } ?>
<!-- ////////////////////////// SELESAI PERMOHONAN  //////////////// --> 



<!-- ////////////////////////// PINJAMAN //////////////// -->          
<?php if ($tpinj_no>0) { ?>
 <div class="my-3 border-bottom">
   <h6 class="fw-semibold fs-5"> PINJAMAN CUSTOMER <?php echo  $noang; ?></h5>
 </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">NO</th>
                      <th width="3%" class="text-center">NoRek</th>
                      <th width="12%" class="text-center">Tanggal</th>
                      <th width="10%" class="text-center">Pokok</th>
                      <th width="2%" class="text-center">X</th>
                      <th width="2%" class="text-center">%</th>
                      <th width="10%" class="text-center">B Pokok</th>
                      <th width="10%" class="text-center">B Bunga</th>
                      <th width="10%" class="text-center">SoAkhir</th>

                      <th width="1%" class="text-center">OPSI</th>
            </tr>
          </thead>
          <tbody>
            <?php 
            $no=1;
            // and pinj_hari=$hari_Indonesia
                $data = mysqli_query($koneksi,"SELECT * FROM pinjaman WHERE angg_no='$noang' ");
            while($d = mysqli_fetch_array($data)){
                $noang      =$d['angg_no'];
                $norek      =$d['norek'];
                $tgl_cair   =$d['tanggal'] ;
                $pokok      =$d['pokok'];
                $jasa       =$d['jasa'];
                $jkw        =$d['jk'];
                $angs       =($pokok+$jasa)/$jkw ;
                
                $sql3 = mysqli_query($koneksi, "SELECT count(norek) AS tangs,sum(byrpokok) AS tbyrp,sum(byrbunga) AS tbyrb FROM pinj_angs WHERE norek='$norek'");
                list($tangs,$tbyrp,$tbyrb) = mysqli_fetch_array($sql3);
                
                $sisa=($pokok)-$tbyrp ;
                $usia_byr=$tbyrjml/$angs ;


/////////////       MENGHITUNG KOLETIFIBILITAS PINJAMAN         ///////////////
                
              ?>
              <tr>
                <td><?php echo $no++; ?></td>
                <td> <a title='Lihat detail data <?php echo $d['pinj_no'] ?>' data-bs-toggle="modal" data-bs-target="#edit_<?php echo $d['pinj_no'] ?>"> <font color='#0000FF'><?php echo $d['norek'] ?></font></td>
                <td style="text-align:center; font-size: 12pt; font-weight:normal;"><?php echo date('d-m-Y', strtotime($tgl_cair)); ?></td>
                <td align='right'><?php echo "" . number_format("$pokok", 0, ",", "."); ?></td>
                <td align='right'><?php echo "" . number_format("$d[jk]", 0, ",", "."); ?></td>
                <td align='right'><?php echo "" . number_format("$d[jasa]", 0, ",", "."); ?></td>
                <td align='right'><?php echo "" . number_format("$tbyrp", 0, ",", "."); ?></td>
                <td align='right'><?php echo "" . number_format("$tbyrb", 0, ",", "."); ?></td>
                <td align='right'><?php echo "" . number_format("$sisa", 0, ",", "."); ?></td>
                <td>    
                  <a data-toggle='tooltip' data-placement='top' title='Kartu Angsuran <?php echo $norek ?> a/n <?php echo $angg_nama; ?>' style='margin-right:3px' class="btn btn-primary btn-sm" href="a1_pinj_kart_per_norek.php?id=<?php echo $norek ?>&noang=<?php echo $noang ?>"><i class="bi bi-person-square"></i></a>
                </td>    
              </tr>
              <?php 
            }
            ?>
          </tbody>
                        <?php 
                            $sql7 = mysqli_query($koneksi, "SELECT sum(pokok) AS tpiut FROM pinjaman WHERE angg_no='$noang'");
                            list($tpiut) = mysqli_fetch_array($sql7);
                            
                            $sql8 = mysqli_query($koneksi, "SELECT sum(byrpokok) AS tbyrjml FROM pinj_angs WHERE angg_no='$noang' ");
                            list($tbyrjml) = mysqli_fetch_array($sql8);
                            
                            $saldo_skr=($tpiut-$tbyrjml) ;
                        ?>
							<tr>
						    	<td colspan="3" style="font-weight: bold;text-align: center;">Total Saldo Pinjaman</td>																																									
								</td>	
								<td align='right'><style="font-weight: bold;">
								    <?php echo "" . number_format("$tpiut", 0, ",", "."); ?>
								</td>	
								<td align='right'><style="font-weight: bold;">
								    <?php echo "" ; ?>
								</td>    
								<td align='right'><style="font-weight: bold;">
								    <?php echo "" ; ?>
								</td>    								
								<td align='right'><style="font-weight: bold;">
								    <?php echo "" . number_format("$tbyrjml", 0, ",", "."); ?>
								</td>
								<td align='right'><style="font-weight: bold;">
								    <?php echo "" ; ?>
								</td>    								
								<td align='right'><style="font-weight: bold;">
								    <?php echo "" . number_format("$saldo_skr", 0, ",", "."); ?>
								</td>
								<td align='right'><style="font-weight: bold;">
								    <?php echo ""?>
								</td>

							
							</tr>          
        </table>
        <?php } else { ?>
                <font color='#ff0000'  style="text-align:left; font-size: 8pt; font-weight:normal;"><i>Tuan <?php echo $d['nama'] ?> belum / tidak pernah transaksi Pinjaman....</i></font><br>
        <?php } ?>
<!-- ////////////////////////// SELESAI pinjaman //////////////// -->       
        
        
      </div>
    </div>
  </div>
</div>
<?php include 'foot_ku.php'; ?>