{% extends "base.html" %}

{% block title %}
	&raquo; Supplier Contracts &raquo; {{bill.batch.contract.name}} &raquo;
 	Batches &raquo; {{bill.batch.reference}} &raquo; Bills &raquo; {{bill.id}}
{% endblock %}

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

{% block content %}
	{% if request.values.confirm_delete %}

		<form method="post" action="">
			<fieldset>
				<legend>Are you sure you want to delete this bill?</legend>	
				<input type="submit" name="delete" value="Delete">
				<a href="/supplier_bills/{{bill.id}}/edit">Cancel</a>
			</fieldset>
		</form>

	{% else %}

		<p>
			<a href="/e/supplies/{{bill.supply.id}}">Supply</a>
		</p>

		<form action="" method="post">
			<fieldset>
				<legend>Update This Bill</legend>	
				<label>Reference</label> {{input_text('reference', bill.reference)}}
				<label>Account</label> {{input_text('account', bill.account)}}
				<fieldset>
					<legend>Issue Date</legend>
					{{input_date('issue', bill.issue_date)}}
				</fieldset>
				<fieldset>
					<legend>Start Date</legend>
					{{input_date('start', bill.start_date)}}
				</fieldset>
				<fieldset>
					<legend>Finish Date</legend>
					{{input_date('finish', bill.finish_date)}}
				</fieldset>
				<label>kWh</label> {{input_text('kwh', '' ~ bill.kwh)}}
				<label>Net</label> {{input_text('net', '' ~ bill.net)}}
				<label>VAT</label> {{input_text('vat', '' ~ bill.vat)}}
				<label>Gross</label> {{input_text('gross', '' ~ bill.gross)}}
				<label>Type</label>
				<select name="bill_type_id">
					{% for type in bill_types %}
						{{input_option('type_id', type.id, type.code + ' ' + type.description, initial=bill.bill_type.id)}}
					{% endfor %}
				</select>
				
				<label>Breakdown</label>
				{{input_textarea('breakdown', bill.breakdown, 10, 80, show_pos=True)}}
				<input type="submit" name="update" value="Update">
			</fieldset>
		</form>

		<h3>Example Breakdown</h3>

		<pre>
{'raw_lines': ['"net-gbp", "unrestricted-kwh", "unrestricted-rate", "unrestricted-gbp"',
'"100", "1000", "0.1", "100"'],
'unrestricted-kwh': 1000, 'unrestricted-rate': 0.1, 'unrestricted-gbp': 100}
		</pre>

		<form action="">
			<fieldset>
				<legend>Delete This Bill</legend>	
				<input type="submit" name="confirm_delete" value="Delete">
			</fieldset>
		</form>
	{% endif %}
{% endblock %}
