<?php
include 'verifikasi.php';?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

mysql_select_db($database_sistem, $sistem);
$query_daftar_bank = "SELECT * FROM bank_tb WHERE bank_tb.kode_unit='$_SESSION[kode]';";
$daftar_bank = mysql_query($query_daftar_bank, $sistem) or die(mysql_error());
$row_daftar_bank = mysql_fetch_assoc($daftar_bank);
$totalRows_daftar_bank = mysql_num_rows($daftar_bank);

?>
<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 Bank Bulan <?php echo $bulan;?> Tahun <?php echo $tahun;?></h3> </td>
  </tr>
  <tr>
    <td colspan="2"><hr /></td>
  </tr>
  <tr>
    <td width="50%" valign="top"><form name="postform" method="post" action="?section=Transaksi&module=proses_trn_bank">
      <table id="myTable" width="90%" border="0" cellspacing="4" cellpadding="4" class="isi_tabel">
        <tr>
          <td>Tanggal Transaksi</td>
          <td 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 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" style=" color: #F00" required="required" id="reg" value="<?php echo $_SESSION['kode'].'-'.$reg;?>" />
            <?php echo $_POST['voucher'];?></td>
          </tr>
        <tr>
          <td>No. Rekening</td>
          <td valign="top">:</td>
          <td valign="top"><label for="akun3">
            <input name="no_rek" type="hidden" id="no_rek" size="5" readonly="readonly" required="required" value="<?php echo $_POST['no_rek'];?>" />
          </label>
            <?php echo $_POST['no_rek'];?></td>
          </tr>
        <tr>
          <td>Jenis Transaksi</td>
          <td valign="top">:</td>
          <td valign="top"><label for="akun2">
            <input name="jenis" type="hidden" id="jenis" size="5" readonly="readonly" required="required" value="<?php echo $_POST['jenis'];?>" />
          </label>
            <?php echo $_POST['jenis'];?></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"><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>Nominal
            <input type="hidden" name="account" id="account" value="Bank" /></td>
          <td 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 colspan="3">Lanjutkan Proses Rekam Data? <a href="?section=Transaksi&amp;module=jupnl_bank">Batal &lt;&lt;---</a></td>
          </tr>
        <tr>
          <td colspan="3"><input class="button" type="submit" name="rekam" id="rekam" value="Rekam Data Transaksi" /> <input class="button" type="reset" name="reset" id="reset" value="Reset" disabled="disabled"></td>
          </tr>
        </table>
      </form>
    </td>
    <td width="50%" align="left" 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, #dataakunpnl').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="dataakunpnl" 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_bank_pick&amp;perkir_number=<?php echo $r['perkiraan'];?>&amp;rek=<?php echo $_POST['no_rek'];?>&amp;jenis=<?php echo $_POST['jenis'];?>"><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 Bank</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_bank_tb WHERE bulan='$bulan' AND tahun='$tahun' AND kode_unit='$_SESSION[kode]' and transaksi='Bank' and (jenis_rincian='Auto Kredit' or jenis_rincian='Tarik Tunai') and no_rek='$_POST[no_rek]' 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 Bank</td>
          <td align='center'>-</td>
          <td align='center'>";?>
          <?php 
		  if($r['no_perkiraan']=='1130'){
			  echo '1130';
		  }else{
			   echo '1120';
		  }?>
          <?php echo"</td>
          <td align='right'>-</td>
          <td align='right'>";?><?php echo formatRupiah($r['kredit']);?><?php echo "</td>
		  <td></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'>";?>
          <?php 
		  if($r['jenis_rincian']=='Tarik Tunai'){
			  echo '1110';
		  }else{
			   echo $r['no_perkiraan'];
		  }?>
          <?php echo"</td>
          <td align='center'>-</td>
          <td align='right'>";?><?php echo formatRupiah($r['kredit']);?><?php echo "</td>
          <td align='right'>-</td>
		  <td align='center'>";?><a href="?section=Transaksi&module=hapus_trn_bank&register=<?php echo $r['Id_transaksi'];?>"><img src="images/cross.png" height="20" width="20" /></a><?php echo "</td>

          </tr>";
                     $no++;
                    }
                    ?>
                    </tbody>
    </table></td>
  </tr>
</table>
<p>&nbsp;</p>
<?php
mysql_free_result($daftar_bank);
?>
<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>
