
<?php if ($tpermohonan>3) { ?>

    <div class="card-header d-flex justify-content-between">
      <span class="card-title fw-semibold align-self-start mb">PERMOHONAN PINJAMAN</span>
      <button type="button" class="btn btn-primary btn-sm align-self-end" data-bs-toggle="modal" data-bs-target="#exampleModal">
        <a href="javascript:history.go(-1)" 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>
            <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;">Keterangan</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]' and left(add_ket,4)<>'Digg' ");
                list($tnomor1) = mysqli_fetch_array($sql1);
                $sql2 = mysqli_query($koneksi, "SELECT count(nomor) AS tnomor2 FROM jam_sertif WHERE nomor='$p[m_nomor]' and left(add_ket,4)<>'Digg' ");
                list($tnomor2) = mysqli_fetch_array($sql2);
                $sql3 = mysqli_query($koneksi, "SELECT count(nomor) AS tnomor3 FROM jam_lain WHERE nomor='$p[m_nomor]' and left(add_ket,4)<>'Digg'");
                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['add_ket']; ?></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="card-header d-flex justify-content-between">
      <span class="card-title fw-semibold align-self-start mb">FOTO-FOTO ANALISA PERMOHONAN</span>
    </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="card-header d-flex justify-content-between">
      <span class="card-title fw-semibold align-self-start mb">FOTO-FOTO ANALISA PERMOHONAN</span>
    </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="card-header d-flex justify-content-between">
      <span class="card-title fw-semibold align-self-start mb">DATA TIM PEMUTUS KREDIT</span>
    </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;">No Perm</th>
              <th width="20%" class="text-center" style="text-align:left; font-size: 9pt; font-weight:normal;">Adm. Kredit</th>
              <th width="20%" class="text-center" style="text-align:left; font-size: 9pt; font-weight:normal;">Bag. Pemasaran</th>
              <th width="20%" class="text-center" style="text-align:left; font-size: 9pt; font-weight:normal;">Supervisor</th>
              <th width="20%" class="text-center" style="text-align:left; font-size: 9pt; font-weight:normal;">Direktur</th>
              <th width="1%" class="text-center">Buka</th>
            </tr>
          </thead>
          <tbody>
            <?php 
            $no=1;
            $karyawan = mysqli_query($koneksi,"SELECT * FROM permohonan WHERE m_nomor='$xx_nomor' ");
            while($k = mysqli_fetch_array($karyawan)){
                $k_id=$k['id'];
                $k_jab=$k['acc'];

                $permoh_acc4 = mysqli_query($koneksi,"select * from permoh_acc where acc_jab='ACC4' and m_nomor='$xx_nomor' ");
                $acc4 = mysqli_fetch_assoc($permoh_acc4);
                $kar_acc4 = mysqli_query($koneksi,"select * from karyawan where acc='ACC4' ");
                $kar4 = mysqli_fetch_assoc($kar_acc4);                
                $jasa4=$acc4['acc_jasa']/12;
                $pokok4=number_format("$acc4[acc_pokok]", 0, ",", ".");                 
                $ket4=''.$acc4['acc_ket'].' (ACC Pokok '.$pokok4.' selama : '.$acc4['acc_jkw'].' bulan, bunga '.$jasa4.'% per bulan)';
                
                $permoh_acc3 = mysqli_query($koneksi,"select * from permoh_acc where acc_jab='ACC3' and m_nomor='$xx_nomor' ");
                $acc3 = mysqli_fetch_assoc($permoh_acc3);
                $kar_acc3 = mysqli_query($koneksi,"select * from karyawan where acc='ACC3' ");
                $kar3 = mysqli_fetch_assoc($kar_acc3);
                $jasa3=$acc3['acc_jasa']/12;
                $pokok3=number_format("$acc3[acc_pokok]", 0, ",", ".");                 
                $ket3=''.$acc3['acc_ket'].' (ACC Pokok '.$pokok3.' selama : '.$acc3['acc_jkw'].' bulan, bunga '.$jasa3.'% per bulan)';
                
                $permoh_acc2 = mysqli_query($koneksi,"select * from permoh_acc where acc_jab='ACC2' and m_nomor='$xx_nomor' ");
                $acc2 = mysqli_fetch_assoc($permoh_acc2);
                $kar_acc2 = mysqli_query($koneksi,"select * from karyawan where acc='ACC2' ");
                $kar2 = mysqli_fetch_assoc($kar_acc2);
                $jasa2=$acc2['acc_jasa']/12;
                $pokok2=number_format("$acc2[acc_pokok]", 0, ",", ".");                 
                $ket2=''.$acc2['acc_ket'].' (ACC Pokok '.$pokok2.' selama : '.$acc2['acc_jkw'].' bulan, bunga '.$jasa2.'% per bulan)';
                
                $permoh_acc1 = mysqli_query($koneksi,"select * from permoh_acc where acc_jab='ACC1' and m_nomor='$xx_nomor' ");
                $acc1 = mysqli_fetch_assoc($permoh_acc1);                
                $kar_acc1 = mysqli_query($koneksi,"select * from karyawan where acc='ACC1' ");
                $kar1 = mysqli_fetch_assoc($kar_acc1);
                $jasa1=$acc1['acc_jasa']/12;
                $pokok1=number_format("$acc1[acc_pokok]", 0, ",", ".");                 
                $ket1=''.$acc1['acc_ket'].' (ACC Pokok '.$pokok1.' selama : '.$acc1['acc_jkw'].' bulan, bunga '.$jasa1.'% per bulan)';
                
                $id_ku=$_SESSION['id_kar'] ;
                $sqla = mysqli_query($koneksi, "SELECT acc AS tacc_a FROM karyawan WHERE id='$id_ku'");
                list($tacc_a) = mysqli_fetch_array($sqla);
                if($tacc_a=='ACC1') { ;
                    $sqlb = mysqli_query($koneksi, "SELECT id AS tid_acc,jabatan FROM karyawan WHERE acc='ACC2'");
                    list($tid_acc,$jabatan) = mysqli_fetch_array($sqlb);
                    $sqlc = mysqli_query($koneksi, "SELECT hp AS thp FROM karyawan_iden WHERE id='$tid_acc'");
                    list($thp) = mysqli_fetch_array($sqlc);
                } ;                  
                if($tacc_a=='ACC2') { ;
                    $sqlb = mysqli_query($koneksi, "SELECT id AS tid_acc,jabatan FROM karyawan WHERE acc='ACC1'");
                    list($tid_acc,$jabatan) = mysqli_fetch_array($sqlb);
                    $sqlc = mysqli_query($koneksi, "SELECT hp AS thp FROM karyawan_iden WHERE id='$tid_acc'");
                    list($thp) = mysqli_fetch_array($sqlc);
                } ;

                if($tacc_a=='ACC3') { ;
                    $sqlb = mysqli_query($koneksi, "SELECT id AS tid_acc,jabatan FROM karyawan WHERE acc='ACC2'");
                    list($tid_acc,$jabatan) = mysqli_fetch_array($sqlb);
                    $sqlc = mysqli_query($koneksi, "SELECT hp AS thp FROM karyawan_iden WHERE id='$tid_acc'");
                    list($thp) = mysqli_fetch_array($sqlc);
                } ;
                if($tacc_a=='ACC4') { ;
                    $sqlb = mysqli_query($koneksi, "SELECT id AS tid_acc,jabatan FROM karyawan WHERE acc='ACC3'");
                    list($tid_acc,$jabatan) = mysqli_fetch_array($sqlb);
                    $sqlc = mysqli_query($koneksi, "SELECT hp AS thp FROM karyawan_iden WHERE id='$tid_acc'");
                    list($thp) = mysqli_fetch_array($sqlc);
                } ;                
              ?>
              <tr>
                <td><?php echo $no++; ?></td>
                <td style="text-align:left; font-size: 8pt; font-weight:normal;"><?php echo $xx_nomor ?></td>
                <td style="text-align:left; font-size: 8pt; font-weight:normal;"><?php echo $ket4; ?></td>
                <td style="text-align:left; font-size: 8pt; font-weight:normal;"><?php echo $ket3; ?></td>
                <td style="text-align:left; font-size: 8pt; font-weight:normal;"><?php echo $ket2; ?></td>
                <td style="text-align:left; font-size: 8pt; font-weight:normal;"><?php echo $ket1; ?></td>                
                <td>    
                  <button type="button" class="btn btn-danger btn-sm" data-bs-toggle="modal" data-bs-target="#edit_acc_<?php echo $d['user_id'] ?>">
                    <i class="bi bi-eyeglasses"></i>
                  </button>
                  <form action="xxxx" method="post">
                    <div class="modal fade" id="edit_acc_<?php echo $d['user_id'] ?>" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
                      <div class="modal-dialog modal-lg" role="document">
                        <div class="modal-content">
                          <div class="modal-header">
                            <h1 class="modal-title fs-5" id="exampleModalLabel">Detail ACC Pinjaman oleh : <?php echo $tacc_a ?> </h1>
                            <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                          </div>
                          <div class="modal-body">

                   <div class="col-lg-12">
                    <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="1%" class="text-center">Isi</th>
                              <th width="1%" class="text-center">WA</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>
                                    <?php if($tacc_a==$k['acc']) { ; ?>
                                        <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>
                                    <?php } ?>
                                </td>
                                <td>
                                    <?php if($tacc_a==$k['acc']) { ; ?>
                                        <?php if($tacc_a=='ACC1') { ; ?>
                                            <a data-toggle='tooltip' data-placement='top' title='Mengirim WA <?php echo $xx_nomor ?> a/n <?php echo $d['nama'] ?> kpd <?php echo $kpd ?> HP No  <?php echo $thp ?>' style='margin-right:3px' class="btn btn-secondary btn-sm" href="01_permohonan_wa_dari_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'] ?>&kpd=<?php echo $jabatan ?>&hp_no=<?php echo $thp ?>"><i class="bi bi-envelope-open"></i></a>
                                        <?php } else { ?>
                                            <a data-toggle='tooltip' data-placement='top' title='Mengirim WA <?php echo $xx_nomor ?> a/n <?php echo $d['nama'] ?> kpd <?php echo $kpd ?> HP No  <?php echo $thp ?>' 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'] ?>&kpd=<?php echo $jabatan ?>&hp_no=<?php echo $thp ?>"><i class="bi bi-envelope-open"></i></a>
                                        <?php } ?>    
                                    <?php } ?>
                                </td>       
                              </tr>
                              <?php } ?>
                          </tbody>
                        </table>
                       </div> 
                       </div>
                    </div>        


                  </form>





                  
                </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 } ?>