
<!DOCTYPE html>
<html>
<head>
  <title>Cetak LAPORAN ARUS KAS</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';

    $tgl=date('Y-m-d') ;
    $bln = date('m');
    $bulan=($bln) ;
            //////////////////////////////////////////////////////////////////////////// 
            $kdc   =$_SESSION['kdc'];
            $oleh 			= $_GET['toleh'];
            $tabel_tujuan   = "nawal_".$oleh; 
            $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,keuangan,gambar FROM kdkanca WHERE kd='$kdc'");
        list($kota,$keuangan,$gambar) = mysqli_fetch_array($sql2);
        $jabatan='Bidang Akuntansi';
        
    ?>  
<!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 ARUS KAS</th>
            </tr>  
            <tr>
                <th Style="text-align:center" colspan="7" >Dari <?php echo date('d-m-Y', strtotime($tgl_d)); ?> s/d <?php echo date('d-m-Y', strtotime($tgl_s)); ?></th>
            </tr>             
            <tr>
                <th style="border-top: 2px solid black; border-bottom: 1px solid black; border-right: 1px solid white;" colspan="3" bgcolor="#B0C4DE">Keterangan</th>
                <th style="border-top: 2px solid black; border-bottom: 1px solid black; border-right: 0px solid white;" colspan="1" bgcolor="#B0C4DE">Jumlah </th>
            </tr>
          </thead>
                  
          <tbody>
            <?php
                $sqlx = mysqli_query($koneksi, "SELECT nama FROM n_arus_kas WHERE kd='10' limit 1 ");
                list($nama) = mysqli_fetch_array($sqlx);
            ?>
                <tr>
                    <td colspan="1" style="border-top: 1px solid black; border-bottom: 1px solid black; border-right: 0px solid white; text-align:center; background-color: #DCDCDC;"></td>
                    <td colspan="2" style="border-top: 1px solid black; border-bottom: 1px solid black; border-right: 1px solid white; text-align:left; background-color: #DCDCDC;"><?php echo $nama ?></td>
                    <td colspan="1" style="border-top: 1px solid black; border-bottom: 1px solid black; border-right: 0px solid white; text-align:center; background-color: #DCDCDC;"></td>
                </tr>
            <?php 
            $no=1;
            $nol=0;
            //
            $data = mysqli_query($koneksi,"SELECT * FROM n_arus_kas WHERE kd>'10' and kd<'49' order by kd ASC ");
            while($z = mysqli_fetch_array($data)){
            	$kdz=$z['kd'];
				$sql_11 = mysqli_query($koneksi, "SELECT sum(mutasik-mutasid) AS tmutasi_11 FROM $tabel_tujuan WHERE ry='11' ");
                	list($tmutasi_11) = mysqli_fetch_array($sql_11);
				$sql_12 = mysqli_query($koneksi, "SELECT sum(mutasik-mutasid) AS tmutasi_12 FROM $tabel_tujuan WHERE ry='12' ");
                	list($tmutasi_12) = mysqli_fetch_array($sql_12);
				$sql_13 = mysqli_query($koneksi, "SELECT sum(mutasik-mutasid) AS tmutasi_13 FROM $tabel_tujuan WHERE ry='13' ");
                	list($tmutasi_13) = mysqli_fetch_array($sql_13);  
				$sql_14 = mysqli_query($koneksi, "SELECT sum(mutasik-mutasid) AS tmutasi_14 FROM $tabel_tujuan WHERE ry='14' ");
                	list($tmutasi_14) = mysqli_fetch_array($sql_14);
				$sql_15 = mysqli_query($koneksi, "SELECT sum(mutasik-mutasid) AS tmutasi_15 FROM $tabel_tujuan WHERE ry='15' ");
                	list($tmutasi_15) = mysqli_fetch_array($sql_15);
                $sql_16 = mysqli_query($koneksi, "SELECT sum(mutasik-mutasid) AS tmutasi_16 FROM $tabel_tujuan WHERE ry='16' ");
                          list($tmutasi_16) = mysqli_fetch_array($sql_16);
                $sql_17 = mysqli_query($koneksi, "SELECT sum(mutasik-mutasid) AS tmutasi_17 FROM $tabel_tujuan WHERE ry='17' ");
                          list($tmutasi_17) = mysqli_fetch_array($sql_17);
                $sql_18 = mysqli_query($koneksi, "SELECT sum(mutasik-mutasid) AS tmutasi_18 FROM $tabel_tujuan WHERE ry='18' ");
                          list($tmutasi_18) = mysqli_fetch_array($sql_18);
                $sql_19 = mysqli_query($koneksi, "SELECT sum(mutasik-mutasid) AS tmutasi_19 FROM $tabel_tujuan WHERE ry='19' ");
                          list($tmutasi_19) = mysqli_fetch_array($sql_19);
                $sql_20 = mysqli_query($koneksi, "SELECT sum(mutasik-mutasid) AS tmutasi_20 FROM $tabel_tujuan WHERE ry='20' ");
                          list($tmutasi_20) = mysqli_fetch_array($sql_20);
                $sql_21 = mysqli_query($koneksi, "SELECT sum(mutasik-mutasid) AS tmutasi_21 FROM $tabel_tujuan WHERE ry='21' ");
                          list($tmutasi_21) = mysqli_fetch_array($sql_21);
                $sql_22 = mysqli_query($koneksi, "SELECT sum(mutasik-mutasid) AS tmutasi_22 FROM $tabel_tujuan WHERE ry='22' ");
                          list($tmutasi_22) = mysqli_fetch_array($sql_22);
                                            
                	if ($kdz=='11')	{
                		$jumlah=$tmutasi_11;		
                	} else if ($kdz=='12')	{
                		$jumlah=$tmutasi_12;
                	} else if ($kdz=='13')	{
                		$jumlah=$tmutasi_13 ;
                	} else if ($kdz=='14')	{
                		$jumlah=$tmutasi_14 ;
                	} else if ($kdz=='15')	{
                		$jumlah=$tmutasi_15 ;
                	} else if ($kdz=='16')	{
                		$jumlah=$tmutasi_16 ;
                	} else if ($kdz=='17')	{
                		$jumlah=$tmutasi_17 ;
                	} else if ($kdz=='18')	{
                		$jumlah=$tmutasi_18 ;
                  } else if ($kdz=='19')  {
                    $jumlah=$tmutasi_19 ;
                  } else if ($kdz=='20')  {
                    $jumlah=$tmutasi_20 ;
                  } else if ($kdz=='21')  {
                    $jumlah=$tmutasi_21 ;
                  } else if ($kdz=='22')  {
                    $jumlah=$tmutasi_22 ;                		                		
                	} else {
                		$jumlah=0 ;
                	}
                  $total_01=$tmutasi_11+($tmutasi_12)+$tmutasi_13+$tmutasi_14+($tmutasi_15)+$tmutasi_16+($tmutasi_17)+$tmutasi_18+$tmutasi_19+($tmutasi_20)+$tmutasi_21+$tmutasi_22  ;

                $nilai=$jumlah ;
                if ($nilai < 0) {
                    $xnilai= '(' . number_format($nilai*-1).')';
                } else {
                    $xnilai= '' . number_format($nilai).'';
                }

                $nilai_a=$total_01;
                if ($nilai_a < 0) {
                    $xnilai_a= '(' . number_format($nilai_a*-1).')';
                } else {
                    $xnilai_a= '' . number_format($nilai_a).'';
                }                          
              ?>
                          <tr>
                            <td><?php echo $no++; ?></td>
                            <td style="text-align:left; font-size: 11pt; font-weight:normal;"> </td>
                            <td style="text-align:left; font-size: 11pt; font-weight:normal;"><?php echo $z['nama']; ?></td>
                            <td style="text-align:right; font-size: 11pt; font-weight:normal;"><?php echo $xnilai; ?></td>
                            </tr>       
                        </div>
                      </div>
                    </div>
              <?php } ?>
          </tbody>
            <tr>
                <th style="font-weight: bold;text-align: center; border-top: 2px solid black; border-bottom: 1px solid black; border-right: 0px solid white;" colspan="1" bgcolor="#B0C4DE"></th>
                <th style="font-weight: bold;text-align: left; border-top: 2px solid black; border-bottom: 1px solid black; border-right: 1px solid white;" colspan="2" bgcolor="#B0C4DE">Jumlah Arus Kas dari <?php echo $nama ?></th>
                <th style="font-weight: bold;text-align: right; border-top: 2px solid black; border-bottom: 1px solid black; border-right: 0px solid white;" colspan="1" bgcolor="#B0C4DE"><?php echo $xnilai_a; ?> </th>
            </tr>








          <tbody>
            <?php
                $sqlx = mysqli_query($koneksi, "SELECT nama FROM n_arus_kas WHERE kd='50' limit 1 ");
                list($nama) = mysqli_fetch_array($sqlx);
            ?>
                <tr>
                    <td colspan="1" style="border-top: 1px solid black; border-bottom: 1px solid black; border-right: 0px solid white; text-align:center; background-color: #DCDCDC;"></td>
                    <td colspan="2" style="border-top: 1px solid black; border-bottom: 1px solid black; border-right: 1px solid white; text-align:left; background-color: #DCDCDC;"><?php echo $nama ?></td>
                    <td colspan="1" style="border-top: 1px solid black; border-bottom: 1px solid black; border-right: 0px solid white; text-align:center; background-color: #DCDCDC;"></td>
                </tr>
            <?php 
            $no=1;
            $nol=0;
            //
            $data = mysqli_query($koneksi,"SELECT * FROM n_arus_kas WHERE kd>'50' and kd<'69' order by kd ASC ");
            while($z = mysqli_fetch_array($data)){
              $kdz=$z['kd'];
        $sql_51 = mysqli_query($koneksi, "SELECT sum(mutasid) AS tmutasi_51 FROM $tabel_tujuan WHERE ry='51' ");
                  list($tmutasi_51) = mysqli_fetch_array($sql_51);
        $sql_52 = mysqli_query($koneksi, "SELECT sum(mutasik) AS tmutasi_52 FROM $tabel_tujuan WHERE ry='51' ");
                  list($tmutasi_52) = mysqli_fetch_array($sql_52);
        $sql_53 = mysqli_query($koneksi, "SELECT sum(mutasid) AS tmutasi_53 FROM $tabel_tujuan WHERE ry='52' ");
                  list($tmutasi_53) = mysqli_fetch_array($sql_53);  
        $sql_54 = mysqli_query($koneksi, "SELECT sum(mutasik) AS tmutasi_54 FROM $tabel_tujuan WHERE ry='52' ");
                  list($tmutasi_54) = mysqli_fetch_array($sql_54);
        $sql_55 = mysqli_query($koneksi, "SELECT sum(mutasid) AS tmutasi_55 FROM $tabel_tujuan WHERE ry='55' ");
                  list($tmutasi_55) = mysqli_fetch_array($sql_55);

                                            
                  if ($kdz=='51') {
                    $jumlah=$tmutasi_51*-1;    
                  } else if ($kdz=='52')  {
                    $jumlah=$tmutasi_52*-1;
                  } else if ($kdz=='53')  {
                    $jumlah=$tmutasi_53 ;
                  } else if ($kdz=='54')  {
                    $jumlah=$tmutasi_54 ;
                  } else if ($kdz=='55')  {
                    $jumlah=$tmutasi_55*-1 ;
                  } else {
                    $jumlah=0 ;
                  }
                  $total_51=($tmutasi_51*-1)+($tmutasi_52*-1)+$tmutasi_53+$tmutasi_54+($tmutasi_55*-1) ;

                $nilai=$jumlah ;
                if ($nilai < 0) {
                    $xnilai= '(' . number_format($nilai*-1).')';
                } else {
                    $xnilai= '' . number_format($nilai).'';
                }

                $nilai_a=$total_51;
                if ($nilai_a < 0) {
                    $xnilai_a= '(' . number_format($nilai_a*-1).')';
                } else {
                    $xnilai_a= '' . number_format($nilai_a).'';
                }                          
              ?>
                          <tr>
                            <td><?php echo $no++; ?></td>
                            <td style="text-align:left; font-size: 11pt; font-weight:normal;"> </td>
                            <td style="text-align:left; font-size: 11pt; font-weight:normal;"><?php echo $z['nama']; ?></td>
                            <td style="text-align:right; font-size: 11pt; font-weight:normal;"><?php echo $xnilai; ?></td>
                            </tr>       
                        </div>
                      </div>
                    </div>
              <?php } ?>
          </tbody>
            <tr>
                <th style="font-weight: bold;text-align: center; border-top: 2px solid black; border-bottom: 1px solid black; border-right: 0px solid white;" colspan="1" bgcolor="#B0C4DE"></th>
                <th style="font-weight: bold;text-align: left; border-top: 2px solid black; border-bottom: 1px solid black; border-right: 1px solid white;" colspan="2" bgcolor="#B0C4DE">Jumlah Arus Kas dari <?php echo $nama ?></th>
                <th style="font-weight: bold;text-align: right; border-top: 2px solid black; border-bottom: 1px solid black; border-right: 0px solid white;" colspan="1" bgcolor="#B0C4DE"><?php echo $xnilai_a; ?> </th>
            </tr>




          <tbody>
            <?php
                $sqlx = mysqli_query($koneksi, "SELECT nama FROM n_arus_kas WHERE kd='70' limit 1 ");
                list($nama) = mysqli_fetch_array($sqlx);
            ?>
                <tr>
                    <td colspan="1" style="border-top: 1px solid black; border-bottom: 1px solid black; border-right: 0px solid white; text-align:center; background-color: #DCDCDC;"></td>
                    <td colspan="2" style="border-top: 1px solid black; border-bottom: 1px solid black; border-right: 1px solid white; text-align:left; background-color: #DCDCDC;"><?php echo $nama ?></td>
                    <td colspan="1" style="border-top: 1px solid black; border-bottom: 1px solid black; border-right: 0px solid white; text-align:center; background-color: #DCDCDC;"></td>
                </tr>
            <?php 
            $no=1;
            $nol=0;
            //
            $data = mysqli_query($koneksi,"SELECT * FROM n_arus_kas WHERE kd>'70' and kd<'89' order by kd ASC ");
            while($z = mysqli_fetch_array($data)){
              $kdz=$z['kd'];
        $sql_71 = mysqli_query($koneksi, "SELECT sum(mutasik) AS tmutasi_71 FROM $tabel_tujuan WHERE ry='71' ");
                  list($tmutasi_71) = mysqli_fetch_array($sql_71);
        $sql_72 = mysqli_query($koneksi, "SELECT sum(mutasid) AS tmutasi_72 FROM $tabel_tujuan WHERE ry='71' ");
                  list($tmutasi_72) = mysqli_fetch_array($sql_72);
        $sql_73 = mysqli_query($koneksi, "SELECT sum(mutasik) AS tmutasi_73 FROM $tabel_tujuan WHERE ry='73' ");
                  list($tmutasi_73) = mysqli_fetch_array($sql_73);  
        $sql_74 = mysqli_query($koneksi, "SELECT sum(mutasid) AS tmutasi_74 FROM $tabel_tujuan WHERE ry='73' ");
                  list($tmutasi_74) = mysqli_fetch_array($sql_74);
        $sql_75 = mysqli_query($koneksi, "SELECT sum(mutasik-mutasid) AS tmutasi_75 FROM $tabel_tujuan WHERE ry='75' ");
                  list($tmutasi_75) = mysqli_fetch_array($sql_75);

                  if ($kdz=='71') {
                    $jumlah=$tmutasi_71;    
                  } else if ($kdz=='72')  {
                    $jumlah=$tmutasi_72*-1;
                  } else if ($kdz=='73')  {
                    $jumlah=$tmutasi_73 ;
                  } else if ($kdz=='74')  {
                    $jumlah=$tmutasi_74*-1 ;
                  } else if ($kdz=='75')  {
                    $jumlah=$tmutasi_75 ;
                  } else {
                    $jumlah=0 ;
                  }
                  $total_71=$tmutasi_71+($tmutasi_72*-1)+$tmutasi_73+($tmutasi_74*-1)+$tmutasi_75 ;

                $nilai=$jumlah ;
                if ($nilai < 0) {
                    $xnilai= '(' . number_format($nilai*-1).')';
                } else {
                    $xnilai= '' . number_format($nilai).'';
                }

                $nilai_a=$total_71;
                if ($nilai_a < 0) {
                    $xnilai_a= '(' . number_format($nilai_a*-1).')';
                } else {
                    $xnilai_a= '' . number_format($nilai_a).'';
                }                    
              ?>
                          <tr>
                            <td><?php echo $no++; ?></td>
                            <td style="text-align:left; font-size: 11pt; font-weight:normal;">  </td>
                            <td style="text-align:left; font-size: 11pt; font-weight:normal;"><?php echo $z['nama']; ?></td>
                            <td style="text-align:right; font-size: 11pt; font-weight:normal;"><?php echo $xnilai; ?></td>

                            </tr>       
                        </div>
                      </div>
                    </div>
              <?php } ?>
          </tbody>
            <tr>
                <th style="font-weight: bold;text-align: center; border-top: 2px solid black; border-bottom: 1px solid black; border-right: 0px solid white;" colspan="1" bgcolor="#B0C4DE"></th>
                <th style="font-weight: bold;text-align: left; border-top: 2px solid black; border-bottom: 1px solid black; border-right: 1px solid white;" colspan="2" bgcolor="#B0C4DE">Jumlah Arus Kas dari <?php echo $nama ?></th>
                <th style="font-weight: bold;text-align: right; border-top: 2px solid black; border-bottom: 1px solid black; border-right: 0px solid white;" colspan="1" bgcolor="#B0C4DE"><?php echo $xnilai_a; ?> </th>
            </tr>




          <tbody>
                <?php 
                  $naik_turun=$total_01+$total_51+$total_71 ;
                ?>
            <tr>
                <th style="font-weight: bold;text-align: center; border-top: 1px solid black; border-bottom: 1px solid black; border-right: 0px solid white;" colspan="1" bgcolor="#FFFFFF"></th>
                <th style="font-weight: bold;text-align: left; border-top: 1px solid black; border-bottom: 1px solid black; border-right: 1px solid white;" colspan="2" bgcolor="#FFFFFF">KENAIKAN (PENURUNAN)</th>
                <th style="font-weight: bold;text-align: right; border-top: 1px solid black; border-bottom: 1px solid black; border-right: 0px solid white;" colspan="1" bgcolor="#FFFFFF"><?php echo "" . number_format("$naik_turun", 0, ",", "."); ?> </th>
            </tr>
                <?php 
                  $sql_89 = mysqli_query($koneksi, "SELECT sum(awald) AS t_awald FROM $tabel_tujuan WHERE ry='00' ");
                  list($t_awald) = mysqli_fetch_array($sql_89);
                ?>
            <tr>
                <th style="font-weight: bold;text-align: center; border-top: 1px solid black; border-bottom: 1px solid black; border-right: 0px solid white;" colspan="1" bgcolor="#FFFFF0"></th>
                <th style="font-weight: bold;text-align: left; border-top: 1px solid black; border-bottom: 1px solid black; border-right: 1px solid white;" colspan="2" bgcolor="#FFFFF0">SALDO AWAL KAS</th>
                <th style="font-weight: bold;text-align: right; border-top: 1px solid black; border-bottom: 1px solid black; border-right: 0px solid white;" colspan="1" bgcolor="#FFFFF0"><?php echo "" . number_format("$t_awald", 0, ",", "."); ?> </th>
            </tr>
                <?php 
                  $t_akhirnya=$naik_turun+$t_awald;
                ?>
            <tr>
                <th style="font-weight: bold;text-align: center; border-top: 1px solid black; border-bottom: 1px solid black; border-right: 0px solid white;" colspan="1" bgcolor="#FFFFF0"></th>
                <th style="font-weight: bold;text-align: left; border-top: 1px solid black; border-bottom: 1px solid black; border-right: 1px solid white;" colspan="2" bgcolor="#FFFFF0">SALDO AKHIR KAS</th>
                <th style="font-weight: bold;text-align: right; border-top: 1px solid black; border-bottom: 1px solid black; border-right: 0px solid white;" colspan="1" bgcolor="#FFFFF0"><?php echo "" . number_format("$t_akhirnya", 0, ",", "."); ?></th>
            </tr>
                <?php 
                  $sql_99 = mysqli_query($koneksi, "SELECT sum(akhird) AS t_akhird FROM $tabel_tujuan WHERE ry='00' ");
                  list($t_akhird) = mysqli_fetch_array($sql_99);
                    $selisih=$t_akhird-$t_akhirnya;
                    if ($selisih<>0) { ;
                ?>
                <tr>
                    <td align='right' style="font-weight: bold;background-color: <?php echo$_SESSION['warna_bag']; ?>;"><?php echo ""?></td>
                    <td colspan="2" style="font-weight: bold;text-align: left;background-color: <?php echo$_SESSION['warna_bag']; ?>;">Kas Setara Kas Neraca Akhir</td>
                    <td align='right' style="font-weight: bold;background-color: <?php echo$_SESSION['warna_bag']; ?>;"><?php echo "" . number_format("$t_akhird", 0, ",", "."); ?></td>
                </tr>                
                <tr>
                    <td align='right' style="font-weight: bold;background-color: <?php echo$_SESSION['warna_bag']; ?>;"><?php echo ""?></td>
                    <td colspan="2" style="font-weight: bold;text-align: left;background-color: <?php echo$_SESSION['warna_bag']; ?>;">Selisih</td>
                    <td align='right' style="font-weight: bold;background-color: <?php echo$_SESSION['warna_bag']; ?>;"><?php echo "" . number_format("$selisih", 0, ",", "."); ?></td>
                </tr>
                <?php } ?>  

















							
        </table>
        
            <br />
            <div>
<?php 
date_default_timezone_set('Asia/Jakarta');
$tgl = date('d-m-Y');

$bulan = array(
  1 => 'Januari',
  'Februari',
  'Maret',
  'April',
  'Mei',
  'Juni',
  'Juli',
  'Agustus',
  'September',
  'Oktober',
  'November',
  'Desember'
);

$tgl = date('d');
$bln = date('n');
$thn = date('Y');
//echo $tgl . ' ' . $bulan[$bln] . ' ' . $thn;
?>
                <?php echo $kota ; ?>, <?php echo $tgl . ' ' . $bulan[$bln] . ' ' . $thn; ?>
            </div>
            <div>
                <?php
                echo $jabatan;
                ?>
            </div>
                <p>
                <br />
                <br />
                </p>            
            <div>
                <?php
                echo $keuangan;
                ?>
            </div>
            
              </div>

    </h5>

</body>

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