<?php
include 'verifikasi.php';?>
<?php
mysql_select_db($database_sistem, $sistem);
$query_perkir = "SELECT * FROM akun_tb where perkiraan='$_GET[perkir_number]'";
$perkir = mysql_query($query_perkir, $sistem) or die(mysql_error());
$row_perkir = mysql_fetch_assoc($perkir);
$totalRows_perkir = mysql_num_rows($perkir);
?>
<script type="text/javascript" src="js/jquery-2.1.4.min.js"></script>

<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td colspan="2"><table width="150" border="0" cellspacing="0" cellpadding="0" class="isi_tabel">
      <tr>
        <td valign="top"><a href="?section=Transaksi&amp;module=jupnl_kas"><img src="images/dompet1.png" width="50" height="50" /></a></td>
        <td valign="bottom"><p><a href="?section=Transaksi&amp;module=jupnl_bank"><img src="images/bank.png" width="60" height="50" /></a></p></td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td colspan="2"><h3 style="color:#033">Form Transaksi Pengeluaran Kas Bulan <?php echo $bulan;?> Tahun <?php echo $tahun;?> </h3></td>
  </tr>
  <tr>
    <td colspan="2"><hr /></td>
  </tr>
  <tr>
    <td width="25%" valign="top"><form name="postform" method="post" action="?section=Transaksi&module=view_proses_pnl">
      <table width="90%" border="0" cellspacing="5" cellpadding="5" class="isi_tabel">
        <tr>
          <td>Tanggal Transaksi</td>
          <td valign="top">:</td>
          <td valign="top"><label for="tanggal"></label>
            <input name="from" type="text" required="required" id="from" onclick="if(self.gfPop)gfPop.fPopCalendar(document.postform.from);return false;" readonly="readonly"/>
            <a href="javascript:void(0)" onclick="if(self.gfPop)gfPop.fPopCalendar(document.postform.from);return false;"><img src="js/calender/calender.jpeg" alt="" name="popcal" width="34" height="29" id="popcal" style="border:none" align="absmiddle" border="0" /></a></td>
        </tr>
        <tr>
          <td width="152">Voucher (BKU)</td>
          <td width="3" valign="top">:</td>
          <td width="145" valign="top"><label for="reg"></label>
            <input name="reg" type="hidden" disabled="disabled" required="required" id="reg" value="<?php echo $_SESSION['kode'].'-'.$reg;?>" readonly="readonly" />
            <input name="voucher" type="text" required="required" id="voucher" placeholder="-" /></td>
          </tr>
        <tr>
          <td>No. Akun</td>
          <td valign="top">:</td>
          <td valign="top"><label for="akun">
            <input name="akun" type="text" id="akun" size="5" readonly="readonly" required="required" value="<?php echo $row_perkir['akun'];?>" />
          </label></td>
          </tr>
        <tr>
          <td>No. Perkiraan</td>
          <td valign="top">:</td>
          <td valign="top"><label for="perkir">
            <input name="perkiraan" type="text" id="perkiraan" value="<?php echo $row_perkir['perkiraan'];?>" size="5" required="required" readonly="readonly" />
          </label></td>
          </tr>
        <tr>
          <td valign="top">Nama Perkiraan</td>
          <td valign="top">:</td>
          <td valign="top"><label for="perkir"></label>
            <textarea name="perkir" type="text" id="perkir" cols="30" rows="2"   placeholder="Nama Perkiraan" readonly="readonly" required="required"><?php echo $row_perkir['keterangan'];?></textarea></td>
        </tr>
        <tr>
          <td valign="top">Keterangan</td>
          <td valign="top">:</td>
          <td valign="top"><label for="keterangan"></label>
            <textarea name="keterangan" cols="30" rows="2" required="required" id="keterangan" placeholder="Keterangan"></textarea></td>
        </tr>
        <tr>
          <td>Nominal</td>
          <td valign="top">:</td>
          <td valign="top"><label for="nominal"></label>
            <input name="nominal" type="text" required="required" id="rupiah" placeholder="0">
            <input name="jenis" type="hidden" id="jenis" value="Pengeluaran" /></td>
          </tr>
        <tr>
          <td>&nbsp;</td>
          <td valign="top">&nbsp;</td>
          <td valign="top"><input name="show" type="text" disabled="disabled" id="rupiah2" style="opacity:10" readonly="readonly" /></td>
        </tr>
        <tr>
          <td>&nbsp;</td>
          <td valign="top">&nbsp;</td>
          <td valign="top"><input type="submit" name="rekam" id="rekam" value="Rekam Data Transaksi" class="button" /></td>
        </tr>
        <tr>
          <td>&nbsp;</td>
          <td valign="top">&nbsp;</td>
          <td valign="top"><input type="reset" name="reset" id="reset" value="Reset" class="button" /></td>
        </tr>
        <tr>
          <td colspan="3">&nbsp;</td>
          </tr>
        </table>
      </form>

    </td>
    <td width="50%" valign="top">
    <link href="SpryAssets/SpryTabbedPanels.css" rel="stylesheet" type="text/css">

		<script src="media/js/jquery.dataTables.js"></script>

    <script type="text/javascript" charset="utf-8">
          $(document).ready(function(){
            $('#transaksi, #dataakun').dataTable({
					     "oLanguage": {
						      "sLengthMenu": "Tampilkan _MENU_ data per halaman",
						      "sSearch": "Pencarian: ", 
						      "sZeroRecords": "Maaf, tidak ada data yang ditemukan",
						      "sInfo": "Menampilkan _START_ s/d _END_ dari _TOTAL_ data",
						      "sInfoEmpty": "Menampilkan 0 s/d 0 dari 0 data",
						      "sInfoFiltered": "(di filter dari _MAX_ total data)",
						      "oPaginate": {
						          "sFirst": "<<",
						          "sLast": ">>", 
						          "sPrevious": "<", 
						          "sNext": ">"
					       }
				      },
              "sPaginationType":"full_numbers",
              "bJQueryUI":true
            });
          })    
        </script>
    <table  id="dataakun" class="display" width="100%" border="0" align="left" cellpadding="1" cellspacing="1" bgcolor="#FFFFFF">
      <thead>
        <tr height="40" class="form_body">
          <th width="7%" height="30" align="center">No</th>
          <th width="10%" align="center">Akun</th>
          <th width="10%" align="center">Perkiraan</th>
          <th width="30%" height="30" align="center">Keterangan</th>
          <th width="17%" align="center">Proses</th>
        </tr>
      </thead>
      <tbody>
        <?php        mysql_select_db("csabrude_akurat");
					          $sql = mysql_query("SELECT * FROM akun_tb WHERE kelompok='Pengeluaran' or kelompok='Asset' or kelompok='Aktiva' or kelompok='Hutang' order by akun, perkiraan asc");
					        $no = 1;
                    while ($r = mysql_fetch_array($sql))
					 {
						                       echo "
		  <tr height='30' class='isi_tabel'> 									   
          <td align='center'>$no</td>
          <td align='center'>$r[akun]</td>
          <td align='center'>$r[perkiraan]</td>
          <td align='left'>$r[keterangan]</td>
		  <td align='center'>";?>
      <a href="?section=Transaksi&amp;module=jupnl_kas_pick&amp;perkir_number=<?php echo $r['perkiraan'];?>"><img src="images/tambah.png" height="20" width="20" /></a><?php echo "</td>
          </tr>";
                     $no++;
                    }
                    ?>
                    </tbody>
    </table></td>
  </tr>
  <tr class="judul_tabel">
    <td colspan="2"><hr /></td>
  </tr>
  <tr class="judul_tabel">
    <td colspan="2"><h3 style="color:#033">Jurnal Pengeluaran Kas</h3></td>
  </tr>
  <tr>
    <td colspan="2">

        <table  id="transaksi" class="display" width="100%" border="0" align="left" cellpadding="1" cellspacing="1" bgcolor="#FFFFFF">
    <thead>
      <tr height="40" class="form_body">
        <th width="7%" height="30" align="center">No</th>
        <th width="12%" align="center">Tgl</th>
        <th width="22%" align="center">Keterangan</th>
        <th width="13%" align="center">Akun Debet</th>
        <th width="13%" align="center">Akun Kredit</th>
        <th width="16%" height="20" align="center">Debet</th>
        <th width="17%" height="20" align="center">Kredit</th>
        <th width="17%" align="center">Proses</th>
      </tr>
      </thead>
      <tbody>
      <?php        mysql_select_db("csabrude_akurat");
					          $sql = mysql_query("SELECT * FROM transaksi_tb WHERE bulan='$bulan' AND tahun='$tahun' AND kode_unit='$_SESSION[kode]' and jenis_rincian='Pengeluaran' and transaksi='Kas' order by waktu_catat desc");
					        $no = 1;
                    while ($r = mysql_fetch_array($sql))
					 {
						                       echo "
		  <tr height='25' class='isi_tabel'> 									   
          <td align='center'>$no(a)</td>
          <td align='center'>$r[tgl_update]</td>
          <td align='left'>Pengeluaran Kas</td>
          <td align='center'>-</td>
          <td align='center'>1110</td>
          <td align='right'>-</td>
          <td align='right'>";?><?php echo formatRupiah($r['kredit']);?><?php echo "</td>
		   <td align='center'>";?><a href="?section=Transaksi&module=hapus_trn&register=<?php echo $r['Id_transaksi'];?>"><img src="images/cross.png" height="20" width="20" /></a><?php echo "</td>
          </tr>
		   <tr height='30' class='isi_tabel'> 									   
          <td align='center'>$no(b)</td>
          <td align='center'></td>
          <td align='left'>$r[keterangan]</td>
          <td align='center'>$r[no_perkiraan]</td>
          <td align='center'>-</td>
          <td align='right'>";?><?php echo formatRupiah($r['kredit']);?><?php echo "</td>
          <td align='right'>-</td>
		  <td align='center'></td>
          </tr>";
                     $no++;
                    }
                    ?>
                    </tbody>
    </table></td>
  </tr>
</table>
<p>&nbsp;</p>
<script type="text/javascript">
		
		var rupiah = document.getElementById('rupiah');
		rupiah.addEventListener('keyup', function(e){
			// tambahkan 'Rp.' pada saat form di ketik
			// gunakan fungsi formatRupiah() untuk mengubah angka yang di ketik menjadi format angka
			rupiah.value = formatRupiah(this.value, 'Rp. ');
		});
			var rupiah = document.getElementById('rupiah2');
		rupiah.addEventListener('keyup', function(e){
			// tambahkan 'Rp.' pada saat form di ketik
			// gunakan fungsi formatRupiah() untuk mengubah angka yang di ketik menjadi format angka
			rupiah.value = formatRupiah(this.value, 'Rp. ');
		});
 
		/* Fungsi formatRupiah */
		function formatRupiah(angka, prefix){
			var number_string = angka.replace(/[^,\d]/g, '').toString(),
			split   		= number_string.split(','),
			sisa     		= split[0].length % 3,
			rupiah     		= split[0].substr(0, sisa),
			ribuan     		= split[0].substr(sisa).match(/\d{3}/gi);
 
			// tambahkan titik jika yang di input sudah menjadi angka ribuan
			if(ribuan){
				separator = sisa ? '.' : '';
				rupiah += separator + ribuan.join('.');
			}
 
			rupiah = split[1] != undefined ? rupiah + ',' + split[1] : rupiah;
			return prefix == undefined ? rupiah : (rupiah ? 'Rp. ' + rupiah : '');
		}
	</script>
