{% extends "base.html" %}

{% block head %}
	<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jeditable.js/1.7.3/jeditable.min.js"></script>
	<script type="text/javascript">
		$(function () {
	      	$("#monthpicker").datepicker( {
	    		format: "mm/yyyy",
	    		viewMode: "months", 
	    		minViewMode: "months"
			});
			
  			$('.editable_text').editable('/registry/op_edit/', {
  				// select : false,
		     	// style   : 'inherit',
		     	// cssclass   : 'inherit',
  			});
			
			
      	});
	</script>
{% endblock %}
    
{% block logo %}
	<h1><a href="#">{{month}} {{specialty}} 手術病例統計</a></h1>
{% endblock %}

{% block search %}
<form name="input" action="." method="post">{% csrf_token %}
	Month: <input type="text" id="monthpicker" name="month" size="1"> 
	<input type="submit" value="Go" />
</form>
{% endblock %}


{% block content %}
<a href = '.?month={{month}}&xls=1'>匯出 Excel 97-2003 XLS 工作簿</a>
<table class="table table-condensed">
	<thead>
		<td>項目</td>
		<td>手術</td>
		<td>急</td>
		<td></td>
		<td>Morbidity</td>
		<td></td>
		<td>Mortality</td>
		<td></td>
	</thead>
	<tbody>
		{% for cat in cats %}
		<tr>
			<td><pre class="noborder">{{cat.title}}</pre></td>
			<td>{{cat.count}}</td>
			<td>{{cat.emergency}}</td>
			<td>
				{% for r in cat.records %}
					{% if r.Memo %}
					<div>
						<span>{{ r.PatChartNo}} </span><span class="editable_text" id="Memo_{{r.id}}">{{ r.Memo }}</span>
					</div>
					{% endif %}
				{% endfor %}
			</td>
			<td>{{cat.morbidity}}</td>
			<td>
				{% for r in cat.records %}
					{% if r.Morbidity %}
					<div>
						<span>{{ r.PatChartNo}} </span><span class="editable_text" id="Morbidity_{{r.id}}">{{ r.Morbidity }}</span>
					</div>
					{% endif %}
				{% endfor %}
			</td>
			<td>{{cat.mortality}}</td>
			<td>
				{% for r in cat.records %}
					{% if r.Mortality %}
					<div>
						<span>{{ r.PatChartNo}} </span><span class="editable_text" id="Morbidity_{{r.id}}">{{ r.Mortality }}</span>
					</div>
					{% endif %}
				{% endfor %}
			</td>
	    </tr>
		{% endfor %}
	</tbody>
</table>
{% endblock %}
