{% extends "base.html" %}

{% block title %}
	&raquo; MOP Contracts &raquo; {{batch.contract.name}} &raquo; Batches &raquo; 
 	{{batch.reference}} &raquo; Edit
{% endblock %}

{% block nav %}
	<a href="/e/mop_contracts">MOP Contracts</a> &raquo; 
	<a href="/e/mop_contracts/{{batch.contract.id}}">{{batch.contract.name}}</a>
	&raquo; 
	<a href="/e/mop_batches?mop_contract_id={{batch.contract.id}}">Batches</a>
	&raquo; 
	<a href="/e/mop_batches/{{batch.id}}">{{batch.reference}}</a>
	&raquo; Edit
{% endblock %}

{% block content %}

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

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

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

		<form method="post" action="/e/mop_batches/{{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">
				<a href="/e/mop_batches/{{batch.id}}/edit">Cancel</a>
			</fieldset>
		</form>

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

		<form action="/e/mop_batches/{{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="/e/mop_batches/{{batch.id}}/edit">
			<fieldset>
				<legend>Delete this batch</legend>
				 <input type="submit" name="confirm_delete" value="Delete">
			</fieldset>
		</form>

	{% endif %}
{% endblock %}
