{% 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 %}
	{% if request.method == "GET" and request.values.delete %}
		<form method="post" action="/report_runs/{{run.id}}">
			<fieldset>
				<legend>Are you sure you want to delete this report run?</legend>
				<input type="submit" name="delete" value="delete"> 
				<a href="/report_runs/{{run.id}}">Cancel</a>
			</fieldset>
		</form>
	{% else %}
		<table class="etheling">
			<caption>Asset Database Comparison</caption>
			<thead>
				<tr>
					<th>Date Created</th>
					<th>Created By</th>
					<th>State</th>
					<th>Number Of Rows</th>
					<th>Delete</th>
					<th>Download Spreadsheet</th>
					<th>Active Statuses</th>
					<th>Inactive Statuses</th>
					<th>Ignored Statuses</th>
				</tr>
			</thead>
			<tbody>
				<tr>
					<td>{{run.date_created|date_format}}</td>
					<td>{{run.creator}}</td>
					<td>{{run.state}}</td>
					<td>{{rows|length}}</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>
					<td>{{run.data['STATUSES_ACTIVE']}}</td>
					<td>{{run.data['STATUSES_INACTIVE']}}</td>
					<td>{{run.data['STATUSES_IGNORE']}}</td>
				</tr>
			</tbody>
		</table>

		<table class="sticky">
			<caption>
				Sites inactive in the asset database, but with an electricity supply in
				Chellow
			</caption>
			<thead>
				<tr>
					<th>Site Code</th>
					<th>Asset Status</th>
					<th>Chellow Supplies</th>
					<th>Asset Database</th>
					<th>Chellow</th>
				</tr>
			</thead>
			<tbody>
				{% for row in rows %}
					<tr>
						{% for title in row.data.titles %}
							<td>{{row.data['values'][title]}}</td>
						{% endfor %}
						<td>
							<a href="https://sitefile.wwcorp.ad.com/SiteDetails?siteId={{row.data['values']['site_code']}}">view</a>
						</td>
						<td>
							<a href="/sites/{{row.data['values']['site_id']}}">view</a>
						</td>
					</tr>
				{% endfor %}
			</tbody>
		</table>
	{% endif %}
{% endblock %}
