<?php 
    include 'header.php'; 
//    include '../fungsi_indotgl.php';
    include 'fungsi_penyebut.php';

	$oleh=$_SESSION['id_kar'];
	$kdc=$_SESSION['kdc'];

    $hari=$hari_ini ;
    $tgl1=date('Y-m-d');
    $tgl2=date('d-m-Y');
    
    $tgl_ini=date('d-m-Y') ;
    $tgl_ini2=date('Y-m-d') ;
    
?>

<div class="container">
 <div class="my-2 border-bottom">
   <h5 class="fw-semibold fs-5">Rekap Customer Kanca <?php echo $kdc ?> s/d tgl <?php echo $tgl_ini ?></h5>
 </div>
  <div class="row justify-content-center">
    <div class="col-lg-10">
       <div class="card">
    <div class="card-header d-flex justify-content-between">
      <span class="card-title fw-semibold"><font color='#ff0000'  style="text-align:left; font-size: 11pt; font-weight:normal;"><i>Halo <?php echo $nama_kary; ?>,  - dimulai dari TAMBAH Customer, kemudian TAMBAH Permohonan. Kemudian klik DAFTAR Permohonan untuk melanjutkan pengisian data Permohonan....</i></font><br></span>
      <button type="button" class="btn btn-primary btn-sm align-self-end" data-bs-toggle="modal" data-bs-target="#exampleModal">
       <a href="index.php" class="btn btn-primary btn-sm"><i class="bi bi-reply-all"></i> &nbsp Kembali</a> 
      </button>
    </div>
    <div class="card-body">
      <div class="table-responsive">
        <table class="table table-bordered table-striped" id="table-datatable">
          <thead>
             <tr>
                <th Style="text-align:center" colspan="3" bgcolor="#D3D3D3">Kabupaten / Kota</th>
                <th Style="text-align:center" colspan="2" bgcolor="#DCDCDC">CUSTOMER</th>
                <th Style="text-align:center" colspan="2" bgcolor="#DCDCDC">PERMOHONAN</th>
                <th Style="text-align:center" colspan="2" bgcolor="#DCDCDC">PEMEGANG SAHAM</th>
             </tr>           
            <tr>
              <th width="1%" class="text-center">No.</th>
              <th width="1%" class="text-center">KD</th>
              <th width="15%" class="text-center">Nama</th>
              <th width="1%" class="text-center">Org</th>
              <th width="15%" class="text-center">Opsi</th>
              <th width="1%" class="text-center">Org</th>
              <th width="15%" class="text-center">Opsi</th>              
              <th width="1%" class="text-center">Org</th>
              <th width="15%" class="text-center">Opsi</th>
            </tr>
          </thead>
          <tbody>
            <?php 
            $no=1;
            $tgl_skr= date('Y-m-d');
            $data = mysqli_query($koneksi,"SELECT * FROM kdkabupaten WHERE yt='Y' ORDER BY kabupaten ASC");
            while($d = mysqli_fetch_array($data)){
                $kd=$d['kd'];

                $sql1 = mysqli_query($koneksi, "SELECT count(angg_no) AS tangg_no_1 FROM anggota WHERE kd_kab='$kd' and hapus<>'HAPUS' ");
                list($tangg_no_1) = mysqli_fetch_array($sql1);

                $sql2 = mysqli_query($koneksi, "SELECT count(m_nomor) AS tmoho_no_1 FROM permohonan WHERE m_kd_kab='$kd' and hapus<>'HAPUS' ");
                list($tmoho_no_1) = mysqli_fetch_array($sql2);

                $sql2 = mysqli_query($koneksi, "SELECT count(angg_no) AS tpinj_no_1 FROM angg_saham WHERE kd_kab='$kd' ");
                list($tpinj_no_1) = mysqli_fetch_array($sql2);                
              ?>
              <tr>
                <td align='center'><?php echo $no++  ; ?></td>
                <td align='center'><?php echo $d['kd']; ?></td>
                <td><?php echo $d['kabupaten']; ?></td>
                <td align='right'><?php echo "" . number_format("$tangg_no_1", 0, ",", "."); ?></td>
                <td>   
                  <?php if($_SESSION[level]<>'TOP'){; ?>
                        <a class="btn btn-success btn-sm" title="Tambah Customer Baru <?php echo $d['kabupaten']; ?>" href="angg_rkp_adm_tambah.php?id=<?php echo $d['kd'] ?>&kab=<?php echo $d['kabupaten']; ?>&kdc=<?php echo $kdc; ?>"><i>Tambah </i></a>
                  <?php } ?>    
                  <?php if ($tangg_no_1>0) { ;?>
                    <a class="btn btn-primary btn-sm" title="Lihat Daftar Customer <?php echo $d['kabupaten']; ?>" href="angg_rkp_adm_daftar.php?id=<?php echo $d['kd'] ?>&kab=<?php echo $d['kabupaten']; ?>&kdc=<?php echo $kdc; ?>"><i>Daftar</i></a>                      
                  <?php } ?>
                </td>
                <td align='right'><?php echo "" . number_format("$tmoho_no_1", 0, ",", "."); ?></td>
                <td>
                  <?php if ($tangg_no_1>0) { ;?>    
                    <?php if($_SESSION[level]<>'TOP'){ ?>
                        <a class="btn btn-warning btn-sm" title="Input Permohonan Baru <?php echo $d['kabupaten']; ?>" href="a1_permohonan_tambah.php?kdk=<?php echo $d['kd'] ?>&kab=<?php echo $d['kabupaten']; ?>&kdc=<?php echo $kdc; ?>"><i>Tambah </i></a>
                    <?php } ?>
                  <?php } ?>
                  <?php if ($tmoho_no_1>0) { ;?>
                        <a class="btn btn-danger btn-sm" title="Lihat Daftar Permohonan <?php echo $d['kabupaten']; ?>" href="a1_permohonan_daftar.php?kdk=<?php echo $d['kd'] ?>&kab=<?php echo $d['kabupaten']; ?>&kdc=<?php echo $kdc; ?>"><i>Daftar</i></a> 
                  <?php } ?>        
                </td>              
                <td align='right'><?php echo "" . number_format("$tpinj_no_1", 0, ",", "."); ?></td>
                <td>
                    <?php if($_SESSION[level]<>'TOP'){ ?>
                            <a class="btn btn-secondary btn-sm" title="Tambah Pemegang Saham <?php echo $d['kabupaten']; ?>" href="angg_saham_tambah.php?id=<?php echo $d['kd'] ?>&kab=<?php echo $d['kabupaten']; ?>&kdc=<?php echo $kdc; ?>"><i>Tambah </i></a>
                    <?php } ?>
                    <?php if ($tpinj_no_1>0) { ;?>  
                        <a class="btn btn-info btn-sm" title="Lihat Daftar Pemegang Saham <?php echo $d['kabupaten']; ?>" href="angg_saham_daftar.php?kdk=<?php echo $d['kd'] ?>&kab=<?php echo $d['kabupaten']; ?>&kdc=<?php echo $kdc; ?>"><i>Daftar</i></a> 
                    <?php } ?>
                </td>       


          
                </td>
              </tr>
              <?php 
            }
            ?>
          </tbody>
      
                        <?php 
                            $sql11 = mysqli_query($koneksi, "SELECT count(angg_no) AS tangg_no_11 FROM anggota WHERE hapus<>'HAPUS' ");
                            list($tangg_no_11) = mysqli_fetch_array($sql11);
            
                            $sql21 = mysqli_query($koneksi, "SELECT count(m_nomor) AS tmoho_no_11 FROM permohonan WHERE hapus<>'HAPUS' ");
                            list($tmoho_no_11) = mysqli_fetch_array($sql21);
            
                            $sql2 = mysqli_query($koneksi, "SELECT count(angg_no) AS tpinj_no_1 FROM angg_saham WHERE hapus<>'HAPUS' ");
                            list($tpinj_no_1) = mysqli_fetch_array($sql2);   
            	        ?>						
							<tr>
						    	<td colspan="3" style="font-weight: bold;text-align: center;">Total </td>																																									
								<td align='right'><style="font-weight: bold;"><?php echo "" . number_format("$tangg_no_11", 0, ",", "."); ?></td>
								<td>
                                  <?php if ($tangg_no_11>0) { ;?>
                                    <a class="btn btn-primary btn-sm" title="Lihat Daftar Customer <?php echo $d['kabupaten']; ?>" href="angg_rkp_adm_daftar_all.php?id=<?php echo $kdc; ?>"><i>Daftar (All) </i></a>                      
                                  <?php } ?>
								</td>
								<td align='right'><style="font-weight: bold;"><?php echo "" . number_format("$tmoho_no_11", 0, ",", "."); ?></td>
								<td align='right'><style="font-weight: bold;"><?php echo "" ?></td>
								
								<td align='right'><style="font-weight: bold;"><?php echo "" . number_format("$tpinj_no_1", 0, ",", "."); ?></td>
								<td>
                                  <?php if ($tpinj_no_1>0) { ;?>
                                    <a class="btn btn-primary btn-sm" title="Lihat Daftar Semua Pemegang Saham" href="angg_saham_daftar_all.php?"><i>Daftar (All) </i></a>                      
                                  <?php } ?>
								</td>								
							</tr>    

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