{% extends "base.html" %}

{% block title %}
	&raquo; Report Runs &raquo; {{run.id}}
{% endblock %}

{% block nav %}
	<a href="/report_runs">Report Runs</a> &raquo; {{run.id}}
{% endblock %}

{% block content %}
	<table>
		<caption>Monthly Duration Report</caption>
		<thead>
			<tr>
				<th>Date Created</th>
				<th>Created By</th>
				<th>Title</th>
				<th>State</th>
				<th>Delete</th>
				<th>Download Spreadsheet</th>
			</tr>
		</thead>
		<tbody>
			<tr>
				<td>{{run.date_created|date_format}}</td>
				<td>{{run.creator}}</td>
				<td>{{run.title}}</td>
				<td>{{run.state}}</td>
				<td>
					<form action="/report_runs/{{run.id}}">
						<fieldset style="border: none;">
							<input type="submit" name="delete" value="Delete">
						</fieldset>
					</form>
				</td>
				<td><a href="/report_runs/{{run.id}}/spreadsheet">Download</a></td>
			</tr>
		</tbody>
	</table>

	{% if org_rows|length > 0 %}
		<table class="sticky">
			<caption>
				Organisation Level
			</caption>
			<thead>
				<tr>
					{% for title in org_rows[0].data.titles %}
						<th>{{title}}</th>
					{% endfor %}
				</tr>
			</thead>
			<tbody>
				{% for org_row in org_rows %}
					<tr>
						{% for title in org_row.data.titles %}
							<td>{{org_row.data['values'][title]}}</td>
						{% endfor %}
					</tr>
				{% endfor %}
			</tbody>
		</table>
	{% endif %}

	<form hx-delete="/report_runs/{{run.id}}"
			hx-confirm="Are you sure you want to delete this report run?" >
		<fieldset>
			<legend>Delete Report Run</legend>
			<input type="submit" name="delete" value="delete"> 
		</fieldset>
	</form>
{% endblock %}
