{% extends "base.html" %}

{% block title %}
	Gas Contracts &raquo; {{g_bill.g_batch.g_contract.name}} &raquo;
 	Batches &raquo; {{g_bill.g_batch.reference}} &raquo; Bills &raquo;
 	{{g_bill.id}} &raquo; Add Read
{% endblock %}

{% block nav %}
	<a href="/g/supplier_contracts">Gas Contracts</a> &raquo;
	<a
	 		href="/g/supplier_contracts/{{g_bill.g_batch.g_contract.id}}"
			>{{g_bill.g_batch.g_contract.name}}</a> &raquo;
	<a
	 		href="/g/batches?g_contract_id={{g_bill.g_batch.g_contract.id}}"
			>Batches</a> &raquo;
	<a
	 		href="/g/batches/{{g_bill.g_batch.id}}"
			>{{g_bill.g_batch.reference}}</a> &raquo;
	<a href="/g/bills/{{g_bill.id}}">Bill {{g_bill.id}}</a> &raquo; Add Read
{% endblock %}

{% block content %}
	<form action="/g/bills/{{g_bill.id}}/add_read" method="post">
		<fieldset>
			<label>Meter Serial Number</label> {{input_text('msn', '')}}
			<label>Units</label>
			<select name="g_unit_id">
				{% for g_unit in g_units %}
					{{
						input_option(
							'g_unit_id', g_unit.id, g_unit.code + ' ' +
							g_unit.description)}}
				{% endfor %}
			</select>
			<label>Correction Factor</label> {{input_text('correction_factor', '1')}}
			<label>Calorific Value</label> {{input_text('calorific_value', '1')}}
			<fieldset>
				<legend>Previous Read</legend>
				<label>Date</label>
				{{input_date('prev_date', None)}}

				<label>Value</label> {{input_text('prev_value', 0)}}
				<label>Type</label>
				<select name="prev_type_id">
					{% for g_read_type in g_read_types %}
						{{
							input_option(
								'prev_type_id', g_read_type.id,
								g_read_type.code + ' ' +
								g_read_type.description)}}
					{% endfor %}
				</select>
			</fieldset>

			<fieldset>
				<legend>Present Read</legend>
				<label>Date</label>
				{{input_date('pres_date', None)}}
				<label>Value</label> {{input_text('pres_value', 0)}}
				<label>Type</label>
				<select name="pres_type_id">
					{% for g_read_type in g_read_types %}
						{{
							input_option(
								'pres_type_id', g_read_type.id,
								g_read_type.code + ' ' +
								g_read_type.description)}}
					{% endfor %}
				</select>
			</fieldset>
			<input type="submit" value="Add">
		</fieldset>
	</form>
{% endblock %}
