<?php 
    session_start();
    include 'header.php'; 

    $tgl_ini    =$_GET['tgl'];
    $tgl_ini2   = date('Y-m-d', strtotime($tgl_ini));
    
    $tgl_sekarang=date('Y-m-d') ;
    $tgl_sebelum_skrg = date('Y-m-d', strtotime($tgl_sekarang . ' -1 day'));
    
    $oleh=$_SESSION['id_kar'];
    $kdc=$_SESSION['kdc'];
?>            
<div class="container">

    <div class="container">
        
    </div>

<?php     
    $sql2 = mysqli_query($koneksi, "SELECT kota,keuangan,gambar FROM kdkanca WHERE kd='$kdc'");
    list($kota,$keuangan,$gambar) = mysqli_fetch_array($sql2);
        
    $tgl_sebelum = date('d-m-Y', strtotime($tgl_ini . ' -1 day'));
    $tgl_sesudah = date('d-m-Y', strtotime($tgl_ini . ' +1 day'));

?> 

<div>
<center>
  <img src="../gambar/<?php echo $gambar ?>" style="width: 350px; height: auto;">
</center>     
</div>

<div>
<center>
  <h5 class="fw-semibold my-3">TUGAS <?php echo $tgl_ini; ?></h5>
</center>     
</div>

<center>
<div class="table-responsive" style="width: 350px;">
  <table class="table table-bordered table-striped" id="table-datatable1" style="background-color: transparent;">
    <thead>
      <tr>
        <th width="5%" class="text-center" style="text-align:left; font-size: 10pt; font-weight:normal; background-color: transparent;">No</th>
        <th width="60%" class="text-center" style="text-align:left; font-size: 10pt; font-weight:normal; background-color: transparent;">Jenis</th>
        <th width="30%" class="text-center" style="text-align:left; font-size: 10pt; font-weight:normal; background-color: transparent;">Jumlah</th>
        <th width="5%" class="text-center" style="text-align:left; font-size: 10pt; font-weight:normal; background-color: transparent;">Opsi</th>
      </tr>
    </thead>
    <tbody>
      <?php 
      $ao=$_SESSION['id_kar'] ;
      $no = 1; 
      $naw = mysqli_query($koneksi,"SELECT * FROM nawal WHERE kt='D' ORDER BY noperk ASC"); 
      while($n = mysqli_fetch_array($naw)){ 
        $noperk=$n['noperk'] ; 
        
        $perk = str_replace('Pend. ', '', $n['perk']);
        $perk = htmlspecialchars($perk, ENT_QUOTES);
        
        $jor = mysqli_query($koneksi,"select sum(masuk-keluar) AS tsaldo from anggota_trans_ao where kdj='$noperk' and tanggal='$tgl_ini2' and ao='$ao' and hapus<>'HAPUS' "); 
        $j = mysqli_fetch_assoc($jor); 
      ?>
      <tr style="background-color: transparent;">
        <td style="text-align:center; font-size: 10pt; font-weight:bold; background-color: transparent;"><?php echo $no++; ?></td>
        <td style="text-align:left; font-size: 10pt; font-weight:bold; background-color: transparent;"><?php echo $perk; ?></td>
        <td style="text-align:right; font-size: 10pt; font-weight:bold; background-color: transparent;"><?php echo "  " . number_format("$j[tsaldo]", 0, ",", "."); ?></td>
        <td>
            <?php if ($tgl_sekarang==$tgl_ini2) { ;?>
                <a data-toggle='tooltip' data-placement='top' title='Tambah Trans <?php echo $perk; ?> ' class="btn btn-success btn-sm" href="tugas_trans_jenis_tgl_sd_tgl.php?kdj=<?php echo $n['noperk'] ?>"><i class="bi bi-plus-lg"></i></a>
            <?php } else { ;?>
                <a data-toggle='tooltip' data-placement='top' title='Buka Data Trans <?php echo $perk; ?> Khusus Tanggal <?php echo $tgl_ini ; ?> ' class="btn btn-primary btn-sm" href="tugas_daftar_jenis_tgl_sd_tgl.php?kdj=<?php echo $n['noperk'] ?>&tgl=<?php echo $tgl_ini ?>"><i class="bi bi-eye"></i></a>
            <?php } ;?>
        </td>
      </tr>
      <?php } ?>
    </tbody>
                        <?php 
                $sql2 = mysqli_query($koneksi, "SELECT sum(masuk-keluar) AS tjumlah FROM anggota_trans_ao where ao='$ao' and tanggal='$tgl_ini2' and hapus<>'HAPUS' ");
                list($tjumlah) = mysqli_fetch_array($sql2);

            	        ?>						
							<tr>
        <td>
            <a data-toggle='tooltip' data-placement='top' title='Buka Data Trans <?php echo $tgl_sebelum ?> ' class="btn btn-warning btn-sm" href="index_tanggal.php?tgl=<?php echo $tgl_sebelum ?>"><i class="bi bi-arrow-left"></i></a>
        </td>							    
						    	<td colspan="1" style="font-weight: bold;text-align: center;">Total </td>																																									
								<td align='right'><style="font-weight: bold;">
								    <?php echo "" . number_format("$tjumlah", 0, ",", "."); ?>
								</td>    
        <td>
            <?php if ($tgl_ini2==$tgl_sebelum_skrg) { ;?>
           
                <a data-toggle='tooltip' data-placement='top' title='Buka Data Trans <?php echo $tgl_sesudah ?> ' class="btn btn-danger btn-sm" href="index.php"><i class="bi bi-arrow-right"></i></a>
            
            <?php } else { ;?>
                <a data-toggle='tooltip' data-placement='top' title='Buka Data Trans <?php echo $tgl_sesudah ?> ' class="btn btn-danger btn-sm" href="index_tanggal.php?tgl=<?php echo $tgl_sesudah ?>"><i class="bi bi-arrow-right"></i></a>
            <?php } ;?>
        </td>
							</tr>                 
  </table>
</div>
</center>

<center>
                      <td>
                          <a href="tugas_donatur.php" class="btn btn-primary btn-sm pull-right"><i class="bi bi-plus"></i> &nbsp; DONATUR</a> 
                          <a href="index.php" class="btn btn-warning btn-sm pull-right"><i class="bi bi-reply"></i> &nbsp; Hari Ini</a> 
                      </td>
</center>  


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