{% extends '../template.html' %}
{% block style %}
<link href="{% nav public %}css/infomodal.css" rel="stylesheet">
{% endblock %}
{% block subcontent %}
<h2>List Transaksi Keuangan</h2>
<h3>Saldo Kas Kecil : {{ kas.akhir | currency}}</h3>
<br/>
<h3>
	Tanggal : <input type="text" id="date_picker" value="{{tgl}}">
	Cari: <input type="text" id="find"/>
	<a style="margin-left:30px" class="btn-success btn" href="{% nav registrasi_keuangan_kas %}?tgl={{tgl_get}}&xls=y"><i class="far fa-file-excel"></i></a>
</h3>
<br/><br/>
<a href="{% nav registrasi_keuangan_new %}" class="big_btn">Tambah</a>
<br/><br/>
{% if data.length > 0 %}
<table class="data">
	<tr>
		<th>Tanggal</th>
		<th>Nomor</th>
		<th>Uraian</th>
		<th>Debit</th>
		<th>Kredit</th>
		<th></th>
	</tr>
	{% for row in data %}
		<tr class="order_histori_{{row.id}} orders" valign="top">
			<td>{{row.tgl}}</td>
			<td>{{row.no_transaksi}}</td>
			<td>{{row.uraian}}</td>
			<td>{{row.debit | currency}}</td>
			<td>{{row.kredit | currency}}</td>
			<td style="width:100px">
				<a href="{% nav registrasi_keuangan_edit %}/{{ row.id }}" class="btn btn-default"><i class="far fa-edit"></i></a>
				<a onclick="return confirm('Apakah Anda Yakin Ingin Menghapus Data Ini ?');" class="btn btn-default" href="{% nav registrasi_keuangan_del %}/{{ row.id }}"><i class="far fa-trash-alt"></i></a>
			</td>
		</tr>
	{% endfor %}
</table>
{% else %}
	- Transaksi Masih Kosong -<br/><br/>
{% endif %}
<br/><br/>
<table class="data">
	<tr>
		<th>Debit</th>
		<th>Kredit</th>
		<th>Saldo</th>
	</tr>
	<tr>
		<td>{{ kas.debit | currency}}</td>
		<td>{{ kas.kredit | currency}}</td>
		<td>{{ kas.saldo | currency}}</td>
	</tr>
</table>
<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">
	var modal = document.getElementById('infoModal');
	$(document).ready(function() {
		menuSelected("mKeuangan","smKas");
		$("#find").keyup(function() {
			$this = $(this);
			$(".orders").hide();
			if ($this.val().trim() != '') {
				$(".orders").each(function() {
					$va = $(this).find('td');
					if ((
						$va.eq(1).text().toLowerCase().indexOf($this.val().toLowerCase()) >= 0 || 
						$va.eq(2).text().toLowerCase().indexOf($this.val().toLowerCase()) >= 0 || 
						$va.eq(3).text().toLowerCase().indexOf($this.val().toLowerCase()) >= 0)
					) {
						console.debug($va.eq(2).text().toLowerCase().indexOf($this.val().toLowerCase()));
						$(this).show();
					}
				});
			} else {
				$(".orders").show();
			}
		});
		$("#date_picker").glDatePicker({
			cssName: "android",
			selectedDate:new Date("{{tgl_js}}"),
			startDate: new Date("{{tgl_js}}"),
		    allowOld: true,
			onChange: function(target, newDate)
				{
					var month= ["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Des"];
					target.val
					(
						newDate.getDate()  + "-" +
						month[newDate.getMonth()] + "-" +
						newDate.getFullYear() 
					);
					
					location.href = "{% nav registrasi_keuangan_kas %}?tgl=" + newDate.getDate()  + "-" + (newDate.getMonth() + 1) + "-" + newDate.getFullYear();
				}
		});
		$('.hapus').on("click", function(){
			if (confirm('hapus nomor kunjungan '+$(this).attr("nomor")+'?')) {
				location.href = '{% nav registrasi_keuangan_del %}/'+$(this).attr("idt");
			}
		});
	});
</script>
{% endblock %}