{% extends "base.html" %}

{% block title %}
	Gas Contracts &raquo; {{g_batch.g_contract.name}} &raquo; Batches &gt;
 	{{g_batch.reference}}
{% endblock %}

{% block nav %}
	<a href="/g/suppleir_contracts">Gas Supplier Contracts</a> &raquo;
	<a
	 		href="/g/supplier_contracts/{{g_batch.g_contract.id}}"
			>{{g_batch.g_contract.name}}</a> &raquo;
	<a
	 		href="/g/batches?g_contract_id={{g_batch.g_contract.id}}"
			>Batches</a> &raquo;
	<a href="/g/batches/{{g_batch.id}}">{{g_batch.reference}}</a> &raquo; Edit
{% endblock %}

{% block content %}

	{% if request.method == 'GET' and request.values.confirm_delete_bills %}

			<form method="post" action="/g/batches/{{g_batch.id}}/edit">
				<fieldset>
					<legend>Are you sure you want to delete all the bills in this batch?</legend>	
					<input type="submit" name="delete_bills" value="Delete">
					<p><a href="/g/batches/{{g_batch.id}}/edit">Cancel</a></p>
				</fieldset>
			</form>

	{% elif request.method == 'GET' and request.values.confirm_delete %}

		<form method="post" action="/g/batches/{{g_batch.id}}/edit">
			<fieldset>
				<legend>Are you sure you want to delete this batch and all its bills?</legend>	
				<input type="submit" name="delete" value="Delete">
			</fieldset>
		</form>

		<p><a href="/g/batches/{{g_batch.id}}/edit">Cancel</a></p>

	{% else %}
		<form action="/g/batches/{{g_batch.id}}/edit" method="post">
			<fieldset>
				<legend>Update batch</legend>	
				<label>Reference</label>
				{{input_text('reference', g_batch.reference)}}
				<label>Description</label>
				{{input_text('description', g_batch.description)}}
				<input type="submit" name="update" value="Update">
			</fieldset>
		</form>

		<form action="/g/batches/{{g_batch.id}}/edit">
			<fieldset>
				<legend>Delete all the bills in this batch</legend>	
				<input type="submit" name="confirm_delete_bills" value="Delete">
			</fieldset>
		</form>

		<form action="/g/batches/{{g_batch.id}}/edit">
			<fieldset>
				<legend>Delete this batch</legend>	
				<input type="submit" name="confirm_delete" value="Delete">
			</fieldset>
		</form>

	{% endif %}
	</div>
{% endblock %}
