<LINK href="images/index.css" rel="stylesheet" type="text/css">
<script type="text/javascript">
    function refreshAndClose() {
        window.opener.location.reload(true);
        window.close();
    }
</script>
<body onbeforeunload="refreshAndClose();">
<link rel="stylesheet" type="text/css" media="all" href="jsDatePick_ltr.min.css" />
<script type="text/javascript" src="jsDatePick.min.1.3.js"></script>
<script type="text/javascript">
	window.onload = function(){
		new JsDatePick({
			useMode:2,
			target:"inputField",
			dateFormat:"%d/%m/%Y"
		});
	};
</script>
<script language="javascript">
String.prototype.reverse = function() {
var s = "";
var i = this.length;
while (i>0) {
s += this.substring(i-1,i);
i--;
}
return s;
}
function numberFormat(obj,separator,frontsymbol,endsymbol){
//replace frontsymbol and endsymbol
obj.value=obj.value.replace(frontsymbol,"");
obj.value=obj.value.replace(endsymbol,"");
//replace . with ""
var i;
for (i=0;i<obj.value.length;i++){
if (obj.value.charAt(i)==separator){
obj.value=obj.value.replace(separator,"");
}
}

//end
var strvalue=parseFloat(obj.value);
if (isNaN(strvalue)){strvalue=0;}
var s=new String(strvalue);
var p="";
var j=0;
for (i=s.length-1;i>=0;i-=1){
p+=s.substr(i,1);
j++
if (j>2){
p+=separator;
j=0;
}
}
p=p.reverse();
if (p.substr(0,1)==separator){
p=p.substr(1,p.length-1);
}
obj.value=frontsymbol+p+endsymbol;
} 
</script>
<?PHP
mysql_connect("localhost","root","benk")or die(mysql_error());
mysql_select_db("cma_tilang") or die(mysql_error());
if($_POST['tbSimpan']){
$nilai2=$_POST['nilai'];
    $nilai= str_replace(".", "", $nilai2);
	
	$month=$_POST['month'];
	$tglsidang=$_POST['tglsidang'];
	$today = date("d/m/Y H:i:s");  
	$error = "";
if ($month == ""){$error = "BULAN DATA HARUS DI PILIH<BR>";}
  //  $nilaiB=$_POST['txNilaiB'];
    //$hasil=$nilaiA+$nilaiB;
	if ($error == ""){
    $sql="INSERT INTO t_tilang SET t_nilai='$nilai', t_bulan='$month', t_tglinput='$today', t_tglsidang='$tglsidang'";
    $query=mysql_query($sql) or die(mysql_error());
	echo "SILAHKAN TUTUP JENDELA INI";
    }
	}
	?>
<form action="" method="post">
<table width="100%" border="0" cellpadding="8" cellspacing="8">
    <tr>
        <td colspan="3"><strong>BACA:</strong> Pilih Bulan Input Data Anda Masukkan dalam bulan yang sama setiap penyetoran bulan berjalan. Input dilakukan pula terhadap Pemasukan Biaya Perkara, Hasil Lelang, Pembayaran Denda Perkara Pidana </td>
    </tr>
    <tr>
      <td width="23%">Data Tilang Bulan </td>
      <td width="2%">:</td>
      <td width="75%"><select name="month" id="month">
        <option value="01">JANUARI</option>
        <option value="02">FEBRUARI</option>
        <option value="03">MARET</option>
        <option value="04">APRIL</option>
        <option value="05">MEI</option>
        <option value="06">JUNI</option>
        <option value="07">JULI</option>
        <option value="08">AGUSTUS</option>
        <option value="09">SEPTEMBER</option>
        <option value="10">OKTOBER</option>
        <option value="11">NOPEMBER</option>
        <option value="12">DESEMBER</option>
        <option value="" selected>--PILIH BULAN--</option>
      </select></td>
    </tr>
    <tr>
      <td width="23%">Hasil Dari Sidang Tanggal </td>
      <td width="2%">:</td>
      <td><input name="tglsidang" type="text" id="inputField"></td>
    </tr>
    <tr>
        <td>Pendapatan PNPB Rp.</td>
        <td>:</td>
        <td><input name="nilai" type="text" id="nilai" onKeyUp="numberFormat(this,'.','','')"></td>
    </tr>
    <tr>
        <td>&nbsp;
        </td>
        <td>&nbsp;</td>
        <td><input type="submit" value="Simpan" name="tbSimpan"></td>
    </tr>
</table>
</form>