{% extends "base.html" %}

{% block title %}
	&raquo; Supplier Contracts &raquo; {{batch.contract.name}} &raquo; Batches &raquo; 
 	{{batch.reference}} &raquo; Add Bill
{% endblock %}

{% block inside_head %}
	<style>
		label {
			width: 6em;
			float: left;
		}
	</style>
{% endblock %}

{% block nav %}
	<a href="/e/supplier_contracts">Supplier Contracts</a> &raquo; 
	<a href="/e/supplier_contracts/{{batch.contract.id}}">{{batch.contract.name}}</a>
 	&raquo; 
	<a href="/e/supplier_batches?supplier_contract_id={{batch.contract.id}}">Batches</a>
 	&raquo; 
	<a href="/e/supplier_batches/{{batch.id}}">{{batch.reference}}</a> &raquo; 
	Add Bill
{% endblock %}

{% block content %}
	{% if supply %}
		<form action="/e/supplier_batches/{{batch.id}}/add_bill" method="post">
			<fieldset>
				<legend>Add A Bill</legend>

				<label>MPAN Core</label> {{input_text('mpan_core')}}

				<label>Reference</label> {{input_text('reference')}}

				<label>Issue Date</label> {{input_date('issue')}}

				<label>Start Date</label> {{input_date('start', start_date)}}

				<label>Finish Date</label> {{input_date('finish')}}

				<label>kWh</label> {{input_text('kwh', '0')}}

				<label>Net</label> {{input_text('net', '0')}}

				<label>VAT</label> {{input_text('vat', '0')}}

				<label>Gross</label> {{input_text('gross', '0')}}

				<label>Account</label> {{input_text('account', account)}}

				<label>Type</label> 

				<select name="bill_type_id">
					{% for bill_type in bill_types %}
						<p>{{normal_bill_type_id}} {{bill_type.id}}</p>
						{{input_option(
							'bill_type_id', bill_type.id, bill_type.code, normal_bill_type_id)}}
					{% endfor %}
				</select>

				<label>Breakdown</label>
				{{input_textarea('breakdown', '{}', 10, 80, show_pos=True)}}

				<input type="submit" value="Add">
			</fieldset>
		</form>

	{% else %}

		<form action="/e/supplier_batches/{{batch.id}}/add_bill">
			<fieldset>
				<legend>Find Supply</legend>
				<label>MPAN Core</label> {{input_text('mpan_core')}}
				<input type="submit" value="Find">
			</fieldset>
		</form>

	{% endif %}
{% endblock %}
