


<!DOCTYPE html>
<html>
<head>
  <title>Cetak Neraca TGL sd TGL</title>
</head>
<body>

  <style type="text/css">
    body{
      font-family: arial;
    }

    .table{
      width: 100%;
    }

    th,td{
    }
    .table,
    .table th,
    .table td {
      padding: 5px;
      border: 1px solid black;
      border-collapse: collapse;
    }
  </style>
  <?php 
    session_start();
    include '../koneksi.php';
    include '../fungsi_indotgl.php';
    include 'fungsi_penyebut.php' ;

    $tgl=date('Y-m-d') ;
    $bln = date('m');
    $bulan=($bln) ;
    $tgl_indo=tgl_indo($tgl);
            //////////////////////////////////////////////////////////////////////////// 
            $kdc   =$_SESSION['kdc'];
            $oleh   =$_GET['toleh'];
            //////////////////////////////////////////////////////////////////////////// 
            $oleh   =$_SESSION['id_kar'];
            $xx     = $oleh ;
            $tabel_tujuan   = "nawal_".$xx; 
            $tabel_asal     = "nawal";
            ////////////////////////////////////////////////////////////////////////////     
                $sql0 = mysqli_query($koneksi, "SELECT tgl_htg,tgl_sd FROM $tabel_tujuan WHERE mutasid>=1 limit 1 ");
                list($tgl_htg,$tgl_sd) = mysqli_fetch_array($sql0);            
              $tgl_d    = $tgl_htg;
              $tgl_s    = $tgl_sd;
              
              $tgl_ke_1 =date('2025-01-01');        
              $tgl_p    =strtotime("$tgl_d");
              $tgl_lalu =date('Y-m-d', strtotime("-1 day", $tgl_p));
            
            //////////////////////////////////////////////////////////////////////////// 
        $sql2 = mysqli_query($koneksi, "SELECT kota,ttd_2,nama_ttd_2,gambar FROM kdkanca WHERE kd='$kdc'");
        list($kota,$ttd_2,$nama_ttd_2,$gambar) = mysqli_fetch_array($sql2);
        
    ?>  
<!DOCTYPE html PUBLIC "-//W3C//DTD       XHTML       1.0       Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><title>Untitled Document</title></head><body><img src="../gambar/<?php echo $gambar; ?>"></a><div align="center"></div>
  <center>
    <h3></h3>
  </center>
	<table border="0" width="100%" style="border-collapse:collapse;" align="center">
    	<tr class="tableheader">
            <tr class="tr-title">
              <thead>
            <tr>
                <th Style="text-align:center" colspan="7" >LAPORAN POSISI KEUANGAN</th>
            </tr>  
            <tr>
                <th Style="text-align:center" colspan="7" >Per <?php echo date('d-m-Y', strtotime($tgl_d)); ?> dan <?php echo date('d-m-Y', strtotime($tgl_s)); ?></th>
            </tr>             
            <tr>
                <th style="border-top: 1px solid black; border-bottom: 1px solid black; border-right: 4px solid white; text-align:center; background-color: #DCDCDC;" colspan="3">Akunt Buku Besar</th>
                <th style="border-top: 1px solid black; border-bottom: 1px solid black; border-right: 4px solid white; text-align:center; background-color: #DCDCDC;" colspan="1">Per <?php echo date('d-m-Y', strtotime($tgl_s)); ?></th>
                <th style="border-top: 1px solid black; border-bottom: 1px solid black; text-align:center; background-color: #DCDCDC;" colspan="1">Per <?php echo date('d-m-Y', strtotime($tgl_lalu)); ?></th>
            </tr>
          </thead>
                  
          <tbody>
            <?php
                $sqlx = mysqli_query($koneksi, "SELECT nama FROM n_kode_1 WHERE kd1='1' limit 1 ");
                list($nama) = mysqli_fetch_array($sqlx);
                $batas_klp='20';
            ?>
                <tr>
                    <td colspan="2" style="font-weight: bold;text-align: center;?>;"></td>
                    <td colspan="1" style="font-weight: bold;text-align: left;?>;"><?php echo $nama ?></td>
                    <td align='right' style="font-weight: bold; ?>;"><?php echo ""?></td>
                    <td align='right' style="font-weight: bold; ?>;"><?php echo ""?></td>
                </tr>
            <?php 
            $no=1;
            $nol=0;
            //and (awald<>0 and awalk<>0 and mutasid<>0 and mutasik<>0)
            $data = mysqli_query($koneksi,"SELECT * FROM $tabel_tujuan WHERE klp<'$batas_klp' and kt<>'X' and (awald+awalk+mutasid+mutasik)<>0 order by noperk ASC ");
            while($w = mysqli_fetch_array($data)){
              ?>
                          <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>
                            </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 klp<'$batas_klp' ");
                list($awald,$awalk,$tmutd,$tmutk,$takhird,$takhirk) = mysqli_fetch_array($sql2);

                $laba_rugi_a=($awald-$awalk);
                $laba_rugi_b=($tmutd-$tmutk);
                $laba_rugi_c=($takhird-$takhirk);
                $nol=0 ;
                $total_balance_a=($awalk+$laba_rugi_a);
                $total_balance_b=($tmutk+$laba_rugi_b);
                $total_balance_c=($takhirk+$laba_rugi_c);
            	        ?>						
			<tr>
			  	<td colspan="3" style="border-top: 1px solid black; border-bottom: 1px solid black; border-right: 4px solid white; text-align:center; background-color: #DCDCDC;">Total <?php echo $nama ?> </td>																																									
				<td style="border-top: 1px solid black; border-bottom: 1px solid black; border-right: 4px solid white; text-align:right; background-color: #DCDCDC;"><?php echo "" . number_format("$takhird", 0, ",", "."); ?></td>    
				<td style="border-top: 1px solid black; border-bottom: 1px solid black; border-right: 4px solid white; text-align:right; background-color: #DCDCDC;"><?php echo "" . number_format("$awald", 0, ",", "."); ?></td>    
			</tr>             
          <tbody>
                <tr>
                    <td colspan="2" style="font-weight: bold;text-align: center;?>;"></td>
                    <td colspan="1" style="font-weight: bold;text-align: left;?>;">LIABILITAS & EKUITAS</td>
                    <td align='right' style="font-weight: bold; ?>;"><?php echo ""?></td>
                    <td align='right' style="font-weight: bold; ?>;"><?php echo ""?></td>
                </tr>
                
            <?php
                $sqlx = mysqli_query($koneksi, "SELECT nama FROM n_kode_1 WHERE kd1='2' limit 1 ");
                list($nama) = mysqli_fetch_array($sqlx);
                $batas_klp_b='30';
            ?>
                <tr>
                    <td colspan="2" style="font-weight: bold;text-align: center;?>;"></td>
                    <td colspan="1" style="font-weight: bold;text-align: left;?>;"><?php echo $nama ?></td>
                    <td align='right' style="font-weight: bold; ?>;"><?php echo ""?></td>
                    <td align='right' style="font-weight: bold; ?>;"><?php echo ""?></td>
                </tr>
            <?php
            ////////////////////////////////////////////////////////////////////////////////////////////// MULAI PASIVA
            $no=1;
            $nol=0;
            //and (awald<>0 and awalk<>0 and mutasid<>0 and mutasik<>0)
            $data = mysqli_query($koneksi,"SELECT * FROM $tabel_tujuan WHERE klp>'$batas_klp' and klp<'$batas_klp_b' and kt<>'X' and (awald+awalk+mutasid+mutasik)<>0 order by noperk ASC ");
            while($w = mysqli_fetch_array($data)){
              ?>
                          <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>
                            </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 klp>'$batas_klp' and klp<'$batas_klp_b' ");
                list($awald,$awalk,$tmutd,$tmutk,$takhird,$takhirk) = mysqli_fetch_array($sql2);

                $laba_rugi_a=($awald-$awalk);
                $laba_rugi_b=($tmutd-$tmutk);
                $laba_rugi_c=($takhird-$takhirk);
                $nol=0 ;
                $total_balance_a=($awalk+$laba_rugi_a);
                $total_balance_b=($tmutk+$laba_rugi_b);
                $total_balance_c=($takhirk+$laba_rugi_c);
            	        ?>						
							<tr>
						    	<td colspan="3" style="border-top: 1px solid black; border-bottom: 1px solid black; border-right: 4px solid white; text-align:center;">Total <?php echo $nama ?> </td>																																									
								<td style="border-top: 1px solid black; border-bottom: 1px solid black; border-right: 4px solid white; text-align:right;"><?php echo "" . number_format("$takhirk", 0, ",", "."); ?></td>
								<td style="border-top: 1px solid black; border-bottom: 1px solid black; border-right: 4px solid white; text-align:right;"><?php echo "" . number_format("$awalk", 0, ",", "."); ?></td>								
							</tr>          
		
          <tbody>
            <?php
                $sqlx = mysqli_query($koneksi, "SELECT nama FROM n_kode_1 WHERE kd1='3' limit 1 ");
                list($nama) = mysqli_fetch_array($sqlx);
                $batas_klp_c='40';
            ?>
                <tr>
                    <td colspan="2" style="font-weight: bold;text-align: center;?>;"></td>
                    <td colspan="1" style="font-weight: bold;text-align: left;?>;"><?php echo $nama ?></td>
                    <td align='right' style="font-weight: bold; ?>;"><?php echo ""?></td>
                    <td align='right' style="font-weight: bold; ?>;"><?php echo ""?></td>
                </tr>
            <?php 
            $no=1;
            $nol=0;
            //and (awald<>0 and awalk<>0 and mutasid<>0 and mutasik<>0)
            $data = mysqli_query($koneksi,"SELECT * FROM $tabel_tujuan WHERE klp>'$batas_klp_b' and klp<'$batas_klp_c' and kt<>'X' and (awald+awalk+mutasid+mutasik)<>0 order by noperk ASC ");
            while($w = mysqli_fetch_array($data)){
              ?>
                          <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>
                            </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 klp>'$batas_klp_b' and klp<'$batas_klp_c' ");
                list($awald,$awalk,$tmutd,$tmutk,$takhird,$takhirk) = mysqli_fetch_array($sql2);

                $laba_rugi_a=($awald-$awalk);
                $laba_rugi_b=($tmutd-$tmutk);
                $laba_rugi_c=($takhird-$takhirk);
                $nol=0 ;
                $total_balance_a=($awalk+$laba_rugi_a);
                $total_balance_b=($tmutk+$laba_rugi_b);
                $total_balance_c=($takhirk+$laba_rugi_c);
            	        ?>						
							<tr>
						    	<td colspan="3" style="border-top: 1px solid black; border-bottom: 1px solid black; border-right: 4px solid white; text-align:center;">Total <?php echo $nama ?> </td>																																									
								<td style="border-top: 1px solid black; border-bottom: 1px solid black; border-right: 4px solid white; text-align:right;"><?php echo "" . number_format("$takhirk", 0, ",", "."); ?></td>
								<td style="border-top: 1px solid black; border-bottom: 1px solid black; border-right: 4px solid white; text-align:right;"><?php echo "" . number_format("$awalk", 0, ",", "."); ?></td>								
							</tr>          

 
                        <?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 klp<'40' ");
                list($awald,$awalk,$tmutd,$tmutk,$takhird,$takhirk) = mysqli_fetch_array($sql2);

                $laba_rugi_a=($awald-$awalk);
                $laba_rugi_b=($tmutd-$tmutk);
                $laba_rugi_c=($takhird-$takhirk);
                $nol=0 ;
                $total_balance_a=($awalk+$laba_rugi_a);
                $total_balance_b=($tmutk+$laba_rugi_b);
                $total_balance_c=($takhirk+$laba_rugi_c);
            	        ?>						
			<tr>
			  	<td colspan="3" style="border-top: 1px solid black; border-bottom: 1px solid black; border-right: 4px solid white; text-align:center; background-color: #DCDCDC;">Total LIABILITAS & EQUITAS </td>																																									
				<td style="border-top: 1px solid black; border-bottom: 1px solid black; border-right: 4px solid white; text-align:right; background-color: #DCDCDC;"><?php echo "" . number_format("$takhird", 0, ",", "."); ?></td>    
				<td style="border-top: 1px solid black; border-bottom: 1px solid black; border-right: 4px solid white; text-align:right; background-color: #DCDCDC;"><?php echo "" . number_format("$awald", 0, ",", "."); ?></td>    
			</tr>               




							
        </table>
            <br />
            <div>
                <?php echo $kota ; ?>, <?php echo $tgl_indo ; ?>
            </div>
            <div>
                <?php
                echo $ttd_2;
                ?>
            </div>
                <p>
                <br />
                <br />
                </p>            
            <div>
                <?php
                echo $nama_ttd_2;
                ?>
            </div>
              </div>
    </h5>
</body>

    <script>
		window.load = print_d();
		function print_d(){
			window.print();
		}
	</script>
</html>