{% extends 'template.html' %}
{% block subcontent %}
<div>
	<h2>List Kunjungan: <input type="text" id="date_picker" value="{{tgl}}">
		Cari: <input type="text" id="find"/>
	</h2>

	{% if data.length > 0 %}
	<table class="orderhistory data">
		<tr>
			<th>Antrian</th>
			<th>Jam</th>
			<th>No. RM</th>
			<th>Nama</th>
			<th>Usia</th>
			<th>Jns. Kel.</th>
			<th>Golongan</th>
			<th style="width:80px">Status</th>
			<th></th>
		</tr>
		{% for row in data %}
			<tr class="kunjungan_{{row.id}} orders" valign="top">
				<td>{{row.no_kunjungan}}</td>
				<td>{{row.jam}}</td>
				<td>{{row.no_rekmed}}</td>
				<td><abbr title="Alamat : {{row.alamat}} , Telp. {{row.tlp}}">{{row.nama}}</abbr></td>
				<td>{{row.usia}}</td>
				<td>{{row.sex}}</td>
				<td>{{row.golongan}}</td>
				<td class="status">{{row.status}}</td>
				<td class="histori_options">
					<button class="lanjut btn btn-success" idk="{{row.id}}">Periksa</button>
				</td>
			</tr>
		{% endfor %}
	</table>
	<div id="current_time" year="{{current.year}}" month="{{current.mon}}" day="{{current.mday}}" hour="{{current.hours}}" minute="{{current.minutes}}" second="{{current.seconds}}"></div>
	{% else %}
		- Kunjungan Masih Kosong -<br/><br/>
	{% endif %}
</div>
{% endblock %}
{% block script %}
<script type="text/javascript" src="{% nav public %}js/glDatePicker.min.js"></script>
<script type="text/javascript">
	$(document).ready(function() {
		$("#find").keyup(function() {
			$this = $(this);
			$(".orders").hide();
			if ($this.val().trim() != '') {
				$(".orders").each(function() {
					$va = $(this).find('td');
					if ((
						$va.eq(3).text().toLowerCase().indexOf($this.val().toLowerCase()) >= 0 || 
						$va.eq(4).find('abbr').attr('title').toLowerCase().indexOf($this.val().toLowerCase()) >= 0 || 
						$va.eq(4).text().toLowerCase().indexOf($this.val().toLowerCase()) >= 0 || 
						$va.eq(5).text().toLowerCase().indexOf($this.val().toLowerCase()) >= 0)
					) {
						console.debug($va.eq(4).text().toLowerCase().indexOf($this.val().toLowerCase()));
						$(this).show();
					}
				});
			} else {
				$(".orders").show();
			}
		});
		$('.lanjut').on("click", function(){
			var idk = $(this).attr("idk");
			window.location='{% nav perawat_periksa %}?idk='+idk;
		});
		$("#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 perawat_kunjungan %}?tgl=" + newDate.getDate()  + "-" + (newDate.getMonth() + 1) + "-" + newDate.getFullYear();
				}
		});
	});
</script>
{% endblock %}