{% extends "base.html" %}

{% block title %}
	&raquo; Supplier Contracts &raquo; {{bill.batch.contract.name}} &raquo;
 	Batches &raquo; {{bill.batch.reference}} &raquo; Bills &raquo; {{bill.id}} &raquo;
 	Add Read
{% 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; Add Read
{% endblock %}

{% block content %}
	<form action="/e/supplier_bills/{{bill.id}}/add_read" method="post">
		<fieldset>
			<legend>Add New Register Read</legend>	
			<label>MPAN</label> {{input_text('mpan', mpan_str)}}
			<label>Coefficient</label> {{input_text('coefficient', coefficient)}}
			<label>Meter Serial Number</label> {{input_text('msn', msn)}}
			<label>Units</label> {{input_text('units', 'kWh')}}
			<label>TPR</label>
			<select name="tpr_id">
				{% for tpr in tprs %}
					{{input_option('tpr_id', tpr.id, tpr.code)}}
				{% endfor %}
			</select>
			<fieldset>
				<legend>Previous Read</legend>
				<fieldset>
					<label>Date</label> {{input_date('previous', previous_date)}}
				</fieldset>
				<label>Value</label> {{input_text('previous_value', previous_value)}}
				<label>Type</label>
				<select name="previous_type_id">
					{% for read_type in read_types %}
						{{input_option('previous_type_id', read_type.id, read_type.code + ' ' + read_type.description, previous_type_id)}}
					{% endfor %}
				</select>
			</fieldset>
			<fieldset>
				<legend>Present Read</legend>
				<fieldset>
					<label>Date</label>
					{{input_date('present', None)}}
				</fieldset>
				<label>Value</label> {{input_text('present_value', 0)}}
				<label>Type</label>
				<select name="present_type_id">
					{% for read_type in read_types %}
						{{input_option('present_type_id', read_type.id, read_type.code + ' ' + read_type.description, estimated_read_type_id)}}
					{% endfor %}
				</select>
			</fieldset>
			<input type="submit" value="Add">
		</fieldset>
	</form>
{% endblock %}
