{% extends "base.html" %}

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

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

{% block content %}

	{% if request.method == 'GET' and request.values.confirm_delete %}
		<div class="layer-section">
			<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">
							<fieldset>
								<input type="hidden" name="mop_batch_id" value="{{batch.id}}">

								<input type="submit" name="delete" value="Delete">
								<a class="btn" href="/mop_batches/{{batch.id}}/edit">Cancel</a>
							</fieldset>
						</form>
					</div>
				</div>
			</div>
		</div>

	{% elif 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="/mop_batches/{{batch.id}}/edit">
							<fieldset>
								<input type="submit" name="delete_bills" value="Delete">
								<a href="/mop_batches/{{batch.id}}/edit">Cancel</a>
							</fieldset>
						</form>
					</div>
				</div>
			</div>
		</div>

	{% else %}
		
		<div class="layer-section">
			<div class="section-header">
				<h2>Update batch</h2>
			</div>
			<div class="section-content">
				<div class="section-data">
					<div class="standardForm">
						<form method="post">
							<fieldset>
								<input type="hidden" name="mop_batch_id" value="{{batch.id}}">
								<div class="row">
									<div class="col-sm-4">
										<label>
											Reference {{input_text('reference', batch.reference)}}
										</label>
									</div>
								</div>
								<div class="row">
								    <div class="col-sm-4">
										<label>
											Description {{input_text('description', batch.description)}}
										</label>
									</div>
								</div>
								<input type="submit" name="update" value="Update">
							</fieldset>
						</form>
					</div>
				</div>
			</div>
		</div>

		<div class="layer-section">
			<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="">
							<fieldset>
								<input type="submit" name="confirm_delete_bills" value="Delete">
							</fieldset>
						</form>
					</div>
				</div>
			</div>
		</div>
		
		<div class="layer-section">
			<div class="section-header">
				<h2>Delete this batch</h2>
			</div>
			<div class="section-content">
				<div class="section-data">
					<div class="standardForm">
						<form>
							<fieldset>
								<input type="hidden" name="mop_batch_id" value="{{batch.id}}">
								 <input type="submit" name="confirm_delete" value="Delete">
							</fieldset>
						</form>
					</div>
				</div>
			</div>
		</div>
			
	{% endif %}
{% endblock %}
