{% extends '../template.html' %}
{% block style %}
{% endblock %}
{% block subcontent %}

<h2>List Piket: <input type="text" id="date_picker" value="{{tgl}}"></h2>
<form method="post">
	<input type="hidden" name="tgl" value="{{tgl_get}}">
	<table class="orderhistory data">
		<tr>
			<th>Poli</th>
			{% for s in shift %}
			<th>{{s.nama}}</th>
			{% endfor %}
		</tr>
		{% for p in poli %}
		<tr class="orders" valign="top">
			<td>{{p.nama}}</td>
			{% for s in shift %}
			<td>
				<select class="{{p.id}}_{{s.id}}" name="dokter[]" style="width:100px">
					<option value="" style="color:gray">-</option>
					{% for d in p.dokter %}
					<option value="{{p.id}},{{s.id}},{{d.id}}">{{d.nama}}</option>
					{% endfor %}
				</select>
			</td>
			{% endfor %}
		</tr>
		{% endfor %}
	</table>
	<br/><input type="submit" class="btn btn-success" value="Simpan" />
</form>
<div id="current_time" year="{{current.year}}" month="{{current.mon}}" day="{{current.mday}}" hour="{{current.hours}}" minute="{{current.minutes}}" second="{{current.seconds}}"></div>

{% endblock %}
{% block script %}
<script type="text/javascript" src="{% nav public %}js/glDatePicker.min.js"></script>
<script type="text/javascript">
	$(document).ready(function() {
		menuSelected("mAdministrasi","smPiket");
		{% for d in data %}
			$('.{{d.id_poli}}_{{d.id_shift}}').val('{{d.id_poli}},{{d.id_shift}},{{d.id_dokter}}');
			<!-- var data = new Array(); -->
			<!-- alert('{{data.length}}'); -->
			<!-- $.each(data,function() { -->
				<!-- $('.'+this.id_poli+'_'+this.id_shift).val(this.id_poli+','+this.id_shift+','+this.id_dokter); -->
			<!-- }); -->
		{% endfor %}
		$("#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_administrasi_piket %}?tgl=" + newDate.getDate()  + "-" + (newDate.getMonth() + 1) + "-" + newDate.getFullYear();
				}
		});
	});
</script>
{% endblock %}