{% extends '../template.html' %}
{% block style %}
{% endblock %}
{% block subcontent %}
<h2>Keuangan - Saldo Awal</h2>

{% if data.length > 0 %}
<form method="post">
	<input type="submit" class="btn btn-success btnSimpan" value="Simpan"/><br/><br/>
	<table class="data">
		<tr class="table_head">
			<td style="width:50px;padding-left:30px">Kode</td>
			<td style="width:400px">Akun</td>
			<td style="width:100px" align="right">Saldo</td>
		</tr>
		{% for j in jenis %}
		<tr>
			<td colspan=3><b>{{j.nama}}</b></td>
		</tr>
		{% for row in data %}
		{% if row.id_jenis == j.id %}
		<tr class="orders" valign="top">
			<td style="padding-left:30px">{{row.kode}}-{{row.subkode}}</td>
			<td>{{row.nama}}</td>
			<td align="right"><input type="text" name="{{row.id}}" value="{{row.awal}}" onkeyup="currency(this)" style="text-align:right"/></td>
		</tr>
		{% endif %}
		{% endfor %}
		{% endfor %}
	</table>
	<br/><input type="submit" class="btn btn-success btnSimpan" value="Simpan"/>
</form>
{% else %}
	- Belum Ada Akun -<br/>
{% endif %}
<br/><br/><br/>
{% endblock %}
{% block script %}
<script type="text/javascript" src="{% nav public %}js/glDatePicker.min.js"></script>
<script type="text/javascript" src="{% nav public %}js/infomodal.js"></script>
<script type="text/javascript">
	$(document).ready(function() {
		menuSelected("mSetting","smSaldoAwal");
	});
	function currency(angka){
		var number_string = angka.value.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);

		if(ribuan){
			separator = sisa ? '.' : '';
			rupiah += separator + ribuan.join('.');
		}
		if(split[1] != undefined){
			if(split[1].length > 2){
				split[1] = '0.'+split[1];
				split[1] = parseFloat(split[1]).toFixed(2);
				split[1] = split[1].toString().substr(2);
			}
		}

		rupiah = split[1] != undefined ? rupiah + ',' + split[1] : rupiah;
		angka.value = rupiah;
		
		updateTotal();
	}
</script>
{% endblock %}