{% extends "base.html" %}

{% block title %}
	Gas Supplies &raquo; {{g_supply.id}} &raquo; Edit
{% endblock %}

{% block nav %}
	<a href="/g/supplies">Gas Supplies</a> &raquo;
	<a href="/g/supplies/{{g_supply.id}}">{{g_supply.id}}</a> &raquo; Edit
{% endblock %}

{% block content %}
	<form method="post" action="/g/supplies/{{g_supply.id}}/edit">
		<fieldset>
			<legend>Update this supply</legend>
			<label>Name</label> {{input_text('name', g_supply.name)}}
			<label>MPRN</label> {{input_text('mprn', g_supply.mprn)}}
			<label>Exit Zone</label>
			<select name="g_exit_zone_id">
				{% for g_exit_zone in g_exit_zones %}
					{{input_option(
						'g_exit_zone_id', g_exit_zone.id, g_exit_zone.code, initial=g_supply.g_exit_zone.id)}}
				{% endfor %}
			</select>
			<input type="submit" value="Update">
		</fieldset>
	</form>

	<form hx-delete="/g/supplies/{{g_supply.id}}/edit"
			hx-confirm="Are you sure you want to delete this supply?">
		<fieldset>
			<legend>Delete this supply</legend>
			<input type="submit" value="Delete">
		</fieldset>
	</form>

	<form method="post" action="/g/supplies/{{g_supply.id}}/edit">
		<fieldset>
			<legend>Insert a new era</legend>
			<label>Start date</label> {{input_date('start', None)}}
			<input type="submit" name="insert_g_era" value="Insert">
		</fieldset>
	</form>

	<table>
		<caption>Existing Eras</caption>
		<thead>
			<tr>
				<th>Start date</th>
				<th>Finish date</th>
			</tr>
		</thead>
		<tbody>
			{% for g_era in g_eras %}
				<tr>
					<td>{{g_era.start_date|date_format}}</td>
					<td>{{g_era.finish_date|date_format}}</td>
				</tr>
			{% endfor %}
		</tbody>
	</table>
{% endblock %}
