{% 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_contracts">Gas Contracts</a> &raquo;
	<a
	 		href="/g_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 %}
	<div class="layer-section">
		{% if request.method == 'GET' and request.values.confirm_delete_bills %}
			<div class="layer-section">
				<div class="section-header">
					<h2>Are you sure you want to delete all the bills in this batch?</h2>	
				</div>
				<div class="section-content">
					<div class="section-data">
						<div class="standardForm">
							<form method="post" action="/g_batches/{{g_batch.id}}/edit">
								<fieldset>
									<input type="submit" name="delete_bills" value="Delete">
									<p><a href="/g_batches/{{g_batch.id}}/edit">Cancel</a></p>
								</fieldset>
							</form>
						</div>
					</div>
				</div>
			</div>
		{% elif request.method == 'GET' and request.values.confirm_delete %}
			<div class="section-header">
				<h2>Are you sure you want to delete this batch and all its bills?</h2>	
			</div>
			<div class="section-content">
				<div class="section-data">
					<div class="standardForm">
						<form method="post" action="/g_batches/{{g_batch.id}}/edit">
							<fieldset>
								<input type="submit" name="delete" value="Delete">
							</fieldset>
						</form>
						<p><a href="/g_batches/{{g_batch.id}}/edit">Cancel</a></p>
					</div>
				</div>
			</div>
		{% else %}
			<div class="section-header">
				<h2>Update batch</h2>	
			</div>
			<div class="section-content">
				<div class="section-data">
					<div class="standardForm">
						<form action="/g_batches/{{g_batch.id}}/edit" method="post">
							<fieldset>
								<br>
								<label>
									Reference {{input_text('reference', g_batch.reference)}}
								</label>
								<br>
								<label>
									Description {{input_text('description', g_batch.description)}}
								</label>
								<br>
								<br>
								<input type="submit" name="update" value="Update">
							</fieldset>
						</form>
					</div>
				</div>
			</div>
			<div class="section-header">
				<h2>Delete all the bills in this batch</h2>	
			</div>
			<div class="section-content">
				<div class="section-data">
					<div class="standardForm">
						<form action="/g_batches/{{g_batch.id}}/edit">
							<fieldset>
								<input type="submit" name="confirm_delete_bills" value="Delete">
							</fieldset>
						</form>
					</div>
				</div>
			</div>
			<div class="section-header">
				<h2>Delete this batch</h2>	
			</div>
			<div class="section-content">
				<div class="section-data">
					<div class="standardForm">
						<form action="/g_batches/{{g_batch.id}}/edit">
							<fieldset>
								<input type="submit" name="confirm_delete" value="Delete">
							</fieldset>
						</form>
					</div>
				</div>
			</div>
		{% endif %}
	</div>
{% endblock %}
