{% extends "base.html" %}

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

{% block nav %}
	<a href="/e/dc_contracts">DC Contracts</a> &raquo;
 	<a href="/e/dc_contracts/{{bill.batch.contract.id}}">{{bill.batch.contract.name}}</a> &raquo;
	<a href="/e/dc_contracts/{{bill.batch.contract.id}}/batches">Batches</a> &raquo;
	<a href="/e/dc_batches/{{bill.batch.id}}">{{bill.batch.reference}}</a> &raquo;
	<a href="/e/dc_bills/{{bill.id}}">Bill {{bill.id}}</a> &raquo; Edit
{% endblock %}

{% block content %}

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

	<form action="/e/dc_bills/{{bill.id}}/edit" 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)}}
			<label>Example Breakdown</label>
			<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>
			<input type="submit" name="update" value="Update">
		</fieldset>
	</form>

	<form hx-delete="/e/dc_bills/{{bill.id}}/edit"
	    hx-confirm="Are you sure you want to delete this bill?">
		<fieldset>
			<input type="submit" name="delete" value="Delete">
		</fieldset>
	</form>
      
{% endblock %}
