{% extends "base.html" %}

{% block title %}
	&raquo; Fake Batch Updater
{% endblock %}

{% block nav %}
	Fake Batch Updater
{% endblock %}

{% block content %}
	<p>
	{% if importer %}
		<ul>
			<li><a href="#controls">Controls</a></li>
			<li><a href="#log">Log</a></li>
			<li><a href="#batches">Fake Batches</a></li>
		</ul>

		<h4 id="controls">Controls</h4>

		<table>
			<tr>
				<th>Is Going?</th>
				<td>{{importer.going.is_set()}}</td>
			</tr>
			<tr>
				<th>Import Now</th>
				<td>
					<form method="post">
						<fieldset {% if importer.going.is_set() %}disabled{% endif %}>
							<input type="submit" value="Import" name="import">
						</fieldset>
					</form>
				</td>
			</tr>
			{% if importer.going.is_set() %}
				<tr>
					<th>Progress</th>
					<td>{{importer.progress}}</td>
				</tr>
			{% endif %}
		</table>


		<h4 id="log">Log</h4>

		<ul>
			{% for message in importer.messages %}
				<li>{{message}}</li>
			{% endfor %}
		</ul>

		<h4 id="batches">Fake Batches</h4>

		<table>
			<caption>Electricity</caption>
			<thead>
				<tr>
					<th>View</th>
					<th>Reference</th>
					<th>Contract Name</th>
				</tr>
			</thead>
			<tbody>
				{% for batch in e_fake_batches %}
					<tr>
						<th><a href="/e/supplier_batches/{{batch.id}}">View</a></th>
						<td>{{ batch.reference }}</td>
						<td>{{ batch.contract.name }}</td>
					</tr>
				{% endfor %}
			</tbody>
		</table>

		<table>
			<caption>Gas</caption>
			<thead>
				<tr>
					<th>View</th>
					<th>Reference</th>
					<th>Contract Name</th>
				</tr>
			</thead>
			<tbody>
				{% for batch in g_fake_batches %}
					<tr>
						<th><a href="/g/batches/{{batch.id}}">View</a></th>
						<td>{{ batch.reference }}</td>
						<td>{{ batch.g_contract.name }}</td>
					</tr>
				{% endfor %}
			</tbody>
		</table>

	{% else %}
		<p>Importer not present.</p>
	{% endif %}
{% endblock %}
