<?php
ob_start();
?>

<?php include 'header.php'; ?>

<div class="container">

  <div class="my-2 border-bottom">
    <h5 class="fw-semibold fs-5">Laporan Kenaikan (Penurunan) Aset Bersih </h5>
  </div>

  <section class="content">
    <div class="row">
      <section class="col-lg-12">
         
        <div class="box box-info">
          <div class="box-header">
            <h6 class="box-title"></h6>
          </div>
          <div class="box-body">
            <?php 
            $tgl=date('Y-m-d') ;
            $bln = date('m');
            $bulan=($bln) ;
            //////////////////////////////////////////////////////////////////////////// 
        $oleh = $_GET['toleh'];
        $tabel_tujuan = "nawal_".$oleh;
        $tabel_asal = "nawal";

        $tgl_d = $_GET['xtgl_d'];
        $tgl_s = $_GET['xtgl_s'];

        $tgl_ke_1 = date('2025-01-01');
        $tgl_p = strtotime("$tgl_d");
        $tgl_lalu = date('Y-m-d', strtotime("-1 day", $tgl_p));
            //////////////////////////////////////////////////////////////////////////// 
              ?>
              <div class="row">
                <div class="col-lg-8">
                  <table class="table table-bordered">
                    <tr>
                      <th width="40%">DARI TANGGAL</th>
                      <th width="1%">:</th>
                      <td><?php echo date('d-m-Y', strtotime($tgl_d)); ?></td>
                    </tr>
                    <tr>
                      <th>SAMPAI TANGGAL</th>
                      <th>:</th>
                      <td><?php echo date('d-m-Y', strtotime($tgl_s)); ?></td>
                    </tr>
                    <tr>
                      <th>Menu Lain</th>
                      <th>:</th>
                      <td>
                      <a href="lap_akunt_rl_tgl_tgl_tenan_print.php?toleh=<?php echo $oleh ?>&xtgl_d=<?php echo $tgl_d ?>&xtgl_s=<?php echo $tgl_s ?>" target="_blank" class="btn btn-warning btn-sm"><i class="bi bi-printer"></i> &nbsp Print</a>
                      <a href="lap_akunt_rl_tgl_tgl_tenan_pdf.php?toleh=<?php echo $oleh ?>&xtgl_d=<?php echo $tgl_d ?>&xtgl_s=<?php echo $tgl_s ?>" target="_blank" class="btn btn-info btn-sm"><i class="bi bi-file-earmark-pdf"></i> &nbsp Print PDF</a>
                      <a href="lap_akunt_rl_tgl_tgl_tenan_excell.php?toleh=<?php echo $oleh ?>&xtgl_d=<?php echo $tgl_d ?>&xtgl_s=<?php echo $tgl_s ?>" class="btn btn-success btn-sm"><i class="bi bi-file-word"></i> &nbsp Excell</a>

                      <a href="javascript:history.go(-1)" class="btn btn-primary btn-sm"><i class="bi bi-reply-all"></i> &nbsp Kembali</a> 
                      </td>
                    </tr>   
                  </table>
                </div>
              </div>

              <div class="table-responsive">
                <table class="table table-bordered table-striped" id="table-datatable1">
                  <thead>
              <thead>
            <tr>
                <th width="55%" Style="text-align:center" colspan="3" bgcolor="#D3D3D3">Keterangan</th>
                <th width="15%" Style="text-align:center" colspan="1" bgcolor="#DCDCDC">S/d <?php echo date('d-m-Y', strtotime($tgl_s)); ?></th>
                <th width="15%" Style="text-align:center" colspan="1" bgcolor="#DCDCDC">S/d <?php echo date('d-m-Y', strtotime($tgl_lalu)); ?></th>
                <th width="15%" Style="text-align:center" colspan="1" bgcolor="#DCDCDC">Antara</th>
            </tr>     
              </thead>
          <tbody>
            <?php
                $kd4='4';
                $sqlx = mysqli_query($koneksi, "SELECT nama FROM n_kode_1 WHERE kd1='$kd4' limit 1 ");
                list($nama) = mysqli_fetch_array($sqlx);
            ?>
                <tr>
                    <td colspan="3" style="font-weight: bold;text-align: center;background-color: <?php echo$_SESSION['warna_bag']; ?>;"><?php echo $nama ?></td>
                    <td align='right' style="font-weight: bold;background-color: <?php echo$_SESSION['warna_bag']; ?>;"><?php echo ""?></td>
                    <td align='right' style="font-weight: bold;background-color: <?php echo$_SESSION['warna_bag']; ?>;"><?php echo ""?></td>
                    <td align='right' style="font-weight: bold;background-color: <?php echo$_SESSION['warna_bag']; ?>;"><?php echo ""?></td>
                </tr>
            <?php 
            $no=1;
            $nol=0;
            //
            $data = mysqli_query($koneksi,"SELECT * FROM $tabel_tujuan WHERE nosub='411' and kt<>'X' and (awald+awalk+akhird+akhirk)<>0 order by noperk ASC ");
            while($w = mysqli_fetch_array($data)){
              $antara=$w['akhirk']-$w['awalk'];
              ?>
                          <tr>
                            <td><?php echo $no++; ?></td>
                            <td style="text-align:left; font-size: 11pt; font-weight:normal;"><?php echo $w['noperk'] ?></td>
                            <td style="text-align:left; font-size: 11pt; font-weight:normal;"><?php echo $w['perk']; ?></td>
                            <td style="text-align:right; font-size: 11pt; font-weight:normal;"><?php echo "" . number_format("$w[akhirk]", 0, ",", "."); ?></td>
                            <td style="text-align:right; font-size: 11pt; font-weight:normal;"><?php echo "" . number_format("$w[awalk]", 0, ",", "."); ?></td>
                            <td style="text-align:right; font-size: 11pt; font-weight:normal;"><?php echo "" . number_format("$antara", 0, ",", "."); ?></td>
                            </tr>       
                        </div>
                      </div>
                    </div>
              <?php } ?>
          </tbody>
                        <?php 
                $sql2 = mysqli_query($koneksi, "SELECT sum(awald) AS tawald,sum(awalk) AS tawalk,sum(mutasid) AS tmutd,sum(mutasik) AS tmutk,sum(akhird) AS takhird,sum(akhirk) AS takhirk FROM $tabel_tujuan WHERE kt<>'X' and nosub='411' ");
                list($awald,$awalk,$tmutd,$tmutk,$takhird,$takhirk) = mysqli_fetch_array($sql2);
                  $phu_4_ak=($takhirk);
                  $phu_4_aw=($awalk);
                  $jantara=$takhirk-$awalk;
            	        ?>						
							<tr>
						    	<td colspan="3" style="font-weight: bold;text-align: center;background-color: #B0C4DE;">Jumlah <?php echo $nama ?> </td>																																									
								<td style="font-weight: bold;text-align: right;background-color: #B0C4DE;"><?php echo "" . number_format("$takhirk", 0, ",", "."); ?></td>    
								<td style="font-weight: bold;text-align: right;background-color: #B0C4DE;"><?php echo "" . number_format("$awalk", 0, ",", "."); ?></td>
                <td style="font-weight: bold;text-align: right;background-color: #B0C4DE;"><?php echo "" . number_format("$jantara", 0, ",", "."); ?></td>    
							</tr>              
 

          <tbody>
            <?php
                $kd5='5';
                $sqlx = mysqli_query($koneksi, "SELECT nama FROM n_kode_1 WHERE kd1='$kd5' limit 1 ");
                list($nama) = mysqli_fetch_array($sqlx);
            ?>
                <tr>
                    <td colspan="3" style="font-weight: bold;text-align: center;background-color: <?php echo$_SESSION['warna_bag']; ?>;"><?php echo $nama ?></td>
                    <td align='right' style="font-weight: bold;background-color: <?php echo$_SESSION['warna_bag']; ?>;"><?php echo ""?></td>
                    <td align='right' style="font-weight: bold;background-color: <?php echo$_SESSION['warna_bag']; ?>;"><?php echo ""?></td>
                    <td align='right' style="font-weight: bold;background-color: <?php echo$_SESSION['warna_bag']; ?>;"><?php echo ""?></td>
                </tr>
            <?php 
            $no=1;
            $nol=0;
            //
            $data = mysqli_query($koneksi,"SELECT * FROM $tabel_tujuan WHERE nosub='511' and kt<>'X' and (awald+awalk+akhird+akhirk)<>0 order by noperk ASC ");
            while($w = mysqli_fetch_array($data)){
              $antara=$w['akhird']-$w['awald'];
              ?>
                          <tr>
                            <td><?php echo $no++; ?></td>
                            <td style="text-align:left; font-size: 11pt; font-weight:normal;"><?php echo $w['noperk'] ?></td>
                            <td style="text-align:left; font-size: 11pt; font-weight:normal;"><?php echo $w['perk']; ?></td>
                            <td style="text-align:right; font-size: 11pt; font-weight:normal;"><?php echo "" . number_format("$w[akhird]", 0, ",", "."); ?></td>
                            <td style="text-align:right; font-size: 11pt; font-weight:normal;"><?php echo "" . number_format("$w[awald]", 0, ",", "."); ?></td>
                            <td style="text-align:right; font-size: 11pt; font-weight:normal;"><?php echo "" . number_format("$antara", 0, ",", "."); ?></td>
                            </tr>       
                        </div>
                      </div>
                    </div>
              <?php } ?>
          </tbody>
                        <?php 
                $sql2 = mysqli_query($koneksi, "SELECT sum(awald) AS tawald,sum(awalk) AS tawalk,sum(mutasid) AS tmutd,sum(mutasik) AS tmutk,sum(akhird) AS takhird,sum(akhirk) AS takhirk FROM $tabel_tujuan WHERE kt<>'X' and nosub='511' ");
                list($awald,$awalk,$tmutd,$tmutk,$takhird,$takhirk) = mysqli_fetch_array($sql2);
                  $phu_5_ak=($takhird);
                  $phu_5_aw=($awald);
                  $jantara=$takhird-$awald;
                      ?>            
              <tr>
                  <td colspan="3" style="font-weight: bold;text-align: center;background-color: #B0C4DE;">Jumlah <?php echo $nama ?> </td>                                                                                  
                <td style="font-weight: bold;text-align: right;background-color: #B0C4DE;"><?php echo "" . number_format("$takhird", 0, ",", "."); ?></td>    
                <td style="font-weight: bold;text-align: right;background-color: #B0C4DE;"><?php echo "" . number_format("$awald", 0, ",", "."); ?></td>
                <td style="font-weight: bold;text-align: right;background-color: #B0C4DE;"><?php echo "" . number_format("$jantara", 0, ",", "."); ?></td>      
              </tr>              
          </tbody>
        

 
                <?php 
                  $phu_ktr_ak=($phu_4_ak-$phu_5_ak);
                  $phu_ktr_aw=($phu_4_aw-$phu_5_aw);  
                  $tantaran_shu_k=$phu_ktr_ak-$phu_ktr_aw ;
                ?>						
                <tr>
                    <td colspan="3" style="font-weight: bold;text-align: center;background-color: #00FFFF;">Kenaikan (Penurunan) Aset Bruto</td>                   
                    <td align='right' style="font-weight: bold;background-color: #00FFFF;"><?php echo "" . number_format("$phu_ktr_ak", 0, ",", "."); ?></td>
                    <td align='right' style="font-weight: bold;background-color: #00FFFF;"><?php echo "" . number_format("$phu_ktr_aw", 0, ",", "."); ?></td>
                    <td align='right' style="font-weight: bold;background-color: #00FFFF;"><?php echo "" . number_format("$tantaran_shu_k", 0, ",", "."); ?></td>
                </tr>			

          <tbody>
            <?php
                $kd6='6';
                $sqlx = mysqli_query($koneksi, "SELECT nama FROM n_kode_1 WHERE kd1='$kd6' limit 1 ");
                list($nama) = mysqli_fetch_array($sqlx);
            ?>
                <tr>
                    <td colspan="3" style="font-weight: bold;text-align: center;background-color: <?php echo$_SESSION['warna_bag']; ?>;"><?php echo $nama ?></td>
                    <td align='right' style="font-weight: bold;background-color: <?php echo$_SESSION['warna_bag']; ?>;"><?php echo ""?></td>
                    <td align='right' style="font-weight: bold;background-color: <?php echo$_SESSION['warna_bag']; ?>;"><?php echo ""?></td>
                    <td align='right' style="font-weight: bold;background-color: <?php echo$_SESSION['warna_bag']; ?>;"><?php echo ""?></td>
                </tr>
            <?php 
            $no=1;
            $nol=0;
            //
            $data = mysqli_query($koneksi,"SELECT * FROM $tabel_tujuan WHERE noperk>'40000' and nosub<>'511' and nosub<>'411' and kt<>'X' and (awald+awalk+akhird+akhirk)<>0 order by noperk ASC ");
            while($w = mysqli_fetch_array($data)){
              $jumlah_aw=$w[awalk]-$w[awald];
              $jumlah_ak=$w[akhirk]-$w[akhird];
              $jumlah_an=$jumlah_ak-$jumlah_aw;
              ?>
                          <tr>
                            <td><?php echo $no++; ?></td>
                            <td style="text-align:left; font-size: 11pt; font-weight:normal;"><?php echo $w['noperk'] ?></td>
                            <td style="text-align:left; font-size: 11pt; font-weight:normal;"><?php echo $w['perk']; ?></td>
                            <td style="text-align:right; font-size: 11pt; font-weight:normal;"><?php echo "" . number_format("$jumlah_ak", 0, ",", "."); ?></td>
                            <td style="text-align:right; font-size: 11pt; font-weight:normal;"><?php echo "" . number_format("$jumlah_aw", 0, ",", "."); ?></td>
                            <td style="text-align:right; font-size: 11pt; font-weight:normal;"><?php echo "" . number_format("$jumlah_an", 0, ",", "."); ?></td>
                            </tr>       
                        </div>
                      </div>
                    </div>
              <?php } ?>
          </tbody>
                        <?php 
                $sql2 = mysqli_query($koneksi, "SELECT sum(awalk-awald) AS tawal,sum(mutasik-mutasik) AS tmutasi,sum(akhirk-akhird) AS takhir FROM $tabel_tujuan WHERE noperk>'40000' and nosub<>'511' and nosub<>'411' and kt<>'X' ");
                list($tawal,$tmutasi,$takhir) = mysqli_fetch_array($sql2);
                      $tantar=$takhir-$tawal ;
                      ?>            
              <tr>
                  <td colspan="3" style="font-weight: bold;text-align: center;background-color: #B0C4DE;">Jumlah <?php echo $nama ?> </td>                                                                                  
                <td style="font-weight: bold;text-align: right;background-color: #B0C4DE;"><?php echo "" . number_format("$takhir", 0, ",", "."); ?></td>    
                <td style="font-weight: bold;text-align: right;background-color: #B0C4DE;"><?php echo "" . number_format("$tawal", 0, ",", "."); ?></td>  
                <td style="font-weight: bold;text-align: right;background-color: #B0C4DE;"><?php echo "" . number_format("$tantar", 0, ",", "."); ?></td>   
              </tr>
                        <?php 
                $sql2 = mysqli_query($koneksi, "SELECT sum(awalk-awald) AS tawal,sum(mutasik-mutasik) AS tmutasi,sum(akhirk-akhird) AS takhir FROM $tabel_tujuan WHERE kt<>'X' and noperk>'40000' ");
                list($tawal,$tmutasi,$takhir) = mysqli_fetch_array($sql2);
                    $shu_antar=$takhir-$tawal;
                ?>            
                <tr>
                    <td colspan="3" style="font-weight: bold;text-align: center;background-color: #00FFFF;">Kenaikan (Penurunan) Aset Bersih </td>                   
                    <td align='right' style="font-weight: bold;background-color: #00FFFF;"><?php echo "" . number_format("$takhir", 0, ",", "."); ?></td>
                    <td align='right' style="font-weight: bold;background-color: #00FFFF;"><?php echo "" . number_format("$tawal", 0, ",", "."); ?></td>
                    <td align='right' style="font-weight: bold;background-color: #00FFFF;"><?php echo "" . number_format("$shu_antar", 0, ",", "."); ?></td>
                </tr>                                 
          </tbody>                				
        </table>
              </div>

              <?php 

            ?>

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

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