<?php
include 'verifikasi.php';?>
<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=jupdp_kas"><img src="images/dompet1.png" width="50" height="50" /></a></td>
        <td valign="bottom"><p><a href="?section=Transaksi&amp;module=jupdp_bank"><img src="images/bank.png" width="60" height="50" /></a></p></td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td colspan="2"><h3><span style="color:#036">Form Transaksi Penerimaan Kas Bulan <?php echo $bulan;?> Tahun <?php echo $tahun;?></span></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=proses_trn">
      <table id="myTable" width="90%" border="0" cellspacing="5" cellpadding="5" class="isi_tabel">
        <tr>
          <td width="150">Tanggal Transaksi</td>
          <td width="5" valign="top">:</td>
          <td valign="top"><label for="tanggal"></label>
            <input type="hidden" id="from" name="from" value="<?php echo $_POST['from'];?>" required="required"/><?php echo $_POST['from'];?></td>
        </tr>
        <tr>
          <td>Voucher (BTU)</td>
          <td width="5" valign="top">:</td>
          <td width="145" valign="top"><label for="reg"></label>
            <input name="reg" type="hidden" style=" color: #F00" required="required" id="reg" value="<?php echo $_SESSION['kode'].'-'.$reg;?>" /><?php echo $_POST['voucher'];?></td>
          </tr>
        <tr>
          <td>No. Akun</td>
          <td valign="top">:</td>
          <td valign="top"><label for="akun">
            <input name="akun" type="hidden" id="akun" size="5" readonly="readonly" required="required" value="<?php echo $_POST['akun'];?>" />
          </label><?php echo $_POST['akun'];?></td>
          </tr>
        <tr>
          <td>No. Perkiraan</td>
          <td valign="top">:</td>
          <td valign="top"><label for="perkir">
            <input name="perkiraan" type="hidden" id="perkiraan" value="<?php echo $_POST['perkiraan'];?>" size="5" required="required" readonly="readonly" />
          </label><?php echo $_POST['perkiraan'];?></td>
          </tr>
        <tr>
          <td valign="top">Nama Perkiraan</td>
          <td valign="top">:</td>
          <td valign="top"><label for="perkir"></label>
            <input  name="perkir" type="hidden" id="perkir" size="100" readonly="readonly" required="required" value="<?php echo $_POST['perkir'];?>"><?php echo $_POST['perkir'];?></td>
        </tr>
        <tr>
          <td valign="top">Keterangan</td>
          <td valign="top">:</td>
          <td valign="top"><label for="keterangan"></label>
            <input type="hidden" name="keterangan" size="200"  required="required" id="keterangan" value="<?php echo $_POST['voucher'].' | '.$_POST['keterangan'];?>"><?php echo $_POST['keterangan'];?></td>
        </tr>
        <tr>
          <td rowspan="2">Nominal</td>
          <td rowspan="2" valign="top">:</td>
          <td valign="top"><label for="nominal"></label>
            <input type="hidden" name="nominal" id="rupiah" value="<?php echo $_POST['nominal'];?>" required="required">
            Rp. <?php echo formatRupiah($_POST['nominal']);?>,-</td>
          </tr>
        <tr>
          <td valign="top"><input name="jenis" type="hidden" id="jenis" value="Pendapatan" /></td>
        </tr>
        <tr>
          <td colspan="3" align="center">Lanjutkan Proses Rekam Data? <a href="?section=Transaksi&module=Transaksi">Batal &lt;&lt;---</a></td>
          </tr>
        <tr>
          <td colspan="3" align="center"><input class="button" type="submit" name="rekam" id="rekam" value="Rekam Data Transaksi"></td>
          </tr>
        </table>
      </form>
 <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>

    </td>
    <td width="40%" valign="top"><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='Pendapatan' 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&module=jupdp_kas_pick&perkir_number=<?php echo $r['perkiraan'];?>"><img src="images/tambah.png" height="20" width="20" /></a><?php echo "</td>
          </tr>";
                     $no++;
                    }
                    ?>
                    </tbody>
      <tr>
        <td></tbody></td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td colspan="2" valign="top"><hr /></td>
  </tr>
  <tr>
    <td colspan="2" valign="top"><h3><span style="color:#036">Jurnal Penerimaan Kas</span></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='Pendapatan' and transaksi='Kas' order by waktu_catat desc");
					        $no = 1;
                    while ($r = mysql_fetch_array($sql))
					 {
						                       echo "
		  <tr height='30' class='isi_tabel'> 									   
          <td align='center'>$no(a)</td>
          <td align='center'>$r[tgl_update]</td>
          <td align='left'>Penerimaan Kas</td>
          <td align='center'>1110</td>
          <td align='center'>-</td>
          <td align='right'>";?><?php echo formatRupiah($r['debet']);?><?php echo "</td>
          <td align='right'>-</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'>-</td>
          <td align='center'>$r[no_perkiraan]</td>
          <td align='right'>-</td>
          <td align='right'>";?><?php echo formatRupiah($r['debet']);?><?php echo "</td>
		  <td align='right'></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>
