



<!DOCTYPE html>
<html>
<head>
  <title>Cetak Transaksi</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);
    
    $id = $_GET['id'];
    $tgl_d=$_GET['tgl_d'];
    $tgl_s=$_GET['tgl_s'];
    
        $tgl_s =date('Y-m-d');            
        $oleh=$_SESSION['id'];
        $kdc=$_SESSION['kdc'];
    
    $nawal = mysqli_query($koneksi,"select * from nawal where noperk='$id'");
    $n = mysqli_fetch_assoc($nawal);  
    $awalk=$n['awalk'];
    $awald=$n['awald'];
    $awal=$awald+$awalk;
    

    
    $xn1=substr($n['noperk'],-5,1);
    $xn2=substr($n['noperk'],-5,2);
    $xn3=substr($n['noperk'],-5,3);

    $n_kode_1 = mysqli_query($koneksi,"select * from n_kode_1 where kd1='$xn1'");
    $n1 = mysqli_fetch_assoc($n_kode_1); 
    $n_kode_2 = mysqli_query($koneksi,"select * from n_kode_2 where kd='$xn2'");
    $n2 = mysqli_fetch_assoc($n_kode_2);
    $n_kode_3 = mysqli_query($koneksi,"select * from n_kode_3 where kd='$xn3'");
    $n3 = mysqli_fetch_assoc($n_kode_3);    

    $sql1 = mysqli_query($koneksi, "SELECT count(noperk) AS tnoperk,sum(debet) AS tdbt,sum(kredit) AS tkrd FROM jor WHERE noperk='$id' ");
        list($tnoperk,$tdbt,$tkrd) = mysqli_fetch_array($sql1);

            //////////////////////////////////////////////////////////////////////////// 
        $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>
	

	<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="11"><?php echo $n['perk'] ?></th>
            </tr>  
            <tr>
                <th Style="text-align:center" colspan="11">Dari <?php echo date('d-m-Y', strtotime($tgl_dr)); ?> s/d <?php echo date('d-m-Y', strtotime($tgl_sd)); ?></th>
            </tr>  
            <tr>
              <th width="5%" class="text-center" style="border-top: 2px solid #000; border-bottom: 2px solid #000;">No</th>
              <th width="5%" class="text-center" style="border-top: 2px solid #000; border-bottom: 2px solid #000;">NoTrans</th>
              <th width="8%" class="text-center" style="border-top: 2px solid #000; border-bottom: 2px solid #000;">Tanggal</th>
              <th width="45%" class="text-center" style="border-top: 2px solid #000; border-bottom: 2px solid #000;">Keterangan</th>
              <th width="5%" class="text-center" style="border-top: 2px solid #000; border-bottom: 2px solid #000;">Kd</th>
              <th width="10%" class="text-center" style="border-top: 2px solid #000; border-bottom: 2px solid #000;">Debet</th>
              <th width="10%" class="text-center" style="border-top: 2px solid #000; border-bottom: 2px solid #000;">Kredit</th>
              <th width="12%" class="text-center" style="border-top: 2px solid #000; border-bottom: 2px solid #000;">Saldo</th>
            </tr>
            
                  </thead>
          <tbody>
            <?php 
              $no   = 1;
              $awal = 0;
              $debet  = 0;
              $kredit  = 0;
            $jor = mysqli_query($koneksi,"SELECT * FROM jor WHERE noperk=$id ORDER BY id ASC ");
            while($p = mysqli_fetch_array($jor)){
                if (($n['klp']<='20') or ($n['klp']>='50')) { ;
                    $kredit=$p['kredit'] ;
                    $debet=$p['debet'] ;                    
                } else {
                    $debet=$p['kredit'] ;
                    $kredit=$p['debet'] ;                    
                }
                if ($p[unit]<>'01') {;
                    $unit='02' ;
                } else { ;
                    $unit='01' ;
                }
                
                $kas = mysqli_query($koneksi,"select * from kas where notrans='$p[notrans]'");
                    $k = mysqli_fetch_assoc($kas);  
              ?>
              <tr>
                <td style="text-align:center; font-size: 10pt; font-weight:normal;"><?php echo $no++; ?></td>
                <td style="text-align:center; font-size: 10pt; font-weight:normal;"><?php echo $p['notrans'] ?></td>
                <td style="text-align:center; font-size: 10pt; font-weight:normal;"><?php echo date('d/m/Y', strtotime($p['tanggal'])); ?></td>
                <td style="text-align:left; font-size: 10pt; font-weight:normal;"><?php echo $p['keterangan'] ?></td>
                <td style="text-align:center; font-size: 10pt; font-weight:normal;"><?php echo $k['oleh'] ?>-<?php echo $unit ?></td>
                <td style="text-align:right; font-size: 10pt; font-weight:normal;"><?php echo "" . number_format("$p[debet]", 0, ",", "."); ?></td>
                <td style="text-align:right; font-size: 10pt; font-weight:normal;"><?php echo "" . number_format("$p[kredit]", 0, ",", "."); ?></td>
                <td align='right' style="font-weight: bold;">
                        <?php 
                            // SALDO                      
                        if($kredit-$debet>0){
                          $awal = $awal - ($kredit-$debet);
                        }else if($debet-$kredit>0){
                          $awal = $awal + ($debet-$kredit);
                        } 
                        echo "" . number_format("$awal", 0, ",", ".")."";
                        ?>	
                                    <?php   
                                    // DEBIT  
                                    if($kredit-$debet>0){
                                        $deb = $deb +($kredit-$debet);
                                    }   
                                    ?>

                                    <?php   
                                    // KREDIT  
                                    if($debet-$kredit>0){
                                        $kre = $kre + ($debet-$kredit);
                                    }
                                    ?>
                </td>           
                
                <?php };?>  

  <tr>
    <td colspan="11" style="border-bottom: 1px solid #000;"></td>
  </tr>
            
          </tbody>
          
        </table>
        
            <br />
            <div>
                <?php echo $kota ; ?>, <?php echo $tgl_indo ; ?>
            </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>