{% extends "base.html" %}

{% block inside_head %}
	<script type="text/javascript" language="javascript">

		function collapseBills(collapseId) {
			var collapsibles = document.getElementsByClassName('collapsible_' + collapseId);
			for (var i = 0; i < collapsibles.length; i++) {
				collapsibles[i].style.display = 'none';
			}
			var expanders = document.getElementsByClassName('expander_' + collapseId);
			for (var i = 0; i < expanders.length; i++) {
				expanders[i].style.display = 'table-cell';
			}
			var collapsers = document.getElementsByClassName('collapser_' + collapseId);
			for (var i = 0; i < collapsers.length; i++) {
				collapsers[i].style.display = 'none';
			}
		}

		function expandBills(collapseId) {
			var collapsibles = document.getElementsByClassName('collapsible_' + collapseId);
			for (var i = 0; i < collapsibles.length; i++) {
				collapsibles[i].style.display = 'table-row';
			}
			var expanders = document.getElementsByClassName('expander_' + collapseId);
			for (var i = 0; i < expanders.length; i++) {
				expanders[i].style.display = 'none';
			}
			var collapsers = document.getElementsByClassName('collapser_' + collapseId);
			for (var i = 0; i < collapsers.length; i++) {
				collapsers[i].style.display = 'table-cell';
			}
		}
	</script>
	<style>
		details[open] summary span {
			display: none;
		}
	</style>

{% endblock %}

{% block title %}
    &raquo; Supplies &raquo; {{supply.id}}
{% endblock %}

{% block nav %}
	<a href="/supplies">Supplies</a> &raquo; {{supply.id}}
 	[<a href="/e/supplies/{{supply.id}}/edit">edit</a>]
{% endblock %}

{% block content %}
	<table>
		<tr>
			<th>Name</th>
			<td>{{ supply.name }}</td>
		</tr>
		<tr>
			<th>Source</th>
			<td>
				{{ supply.source.code }} - {{ supply.source.name }}
				{% if supply.source.code == 'gen' %}
				( {{ supply.generator_type.code }} {{ supply.generator_type.name }})
				{% endif %}
			</td>
		</tr>
		<tr>
			<th>GSP Group</th>
			<td>
				{{ supply.gsp_group.code }} {{ supply.gsp_group.description }}
			</td>
		</tr>
		{% if system_properties['supply_links'] %}
		<tr>
			<th>Links</th>
			<td>
				<ul>
					{% for link in system_properties['supply_links'] %}
						<li>
							<a href="{{link.url}}supply_id={{site.id}}">{{link.name}}</a>
						</li>
					{% endfor %}
				</ul>
			</td>
		</tr>
		{% endif %}
		<tr>
			<th>
				<a href="/e/supplies/{{supply.id}}/notes">Notes</a>
			</th>
			<td>
				{% if note %}
					<pre style="white-space pre-wrap;">
						{%- if note.timestamp -%}<em>{{note.timestamp|hh_format}}</em>{%- endif %}
						{%- if truncated_line -%}
							<details><summary><span>{{truncated_line}}</span></summary>{{note.body}}</details>
						{%- else %} {{note.body}}
						{%- endif -%}
					</pre>
				{% endif %}
			</td>
		</tr>
	</table>

	{% for era_bundle in era_bundles %}
		{% set era = era_bundle['era'] %}
		{% set physical_site = era_bundle['physical_site'] %}
		{% set other_sites = era_bundle['other_sites'] %}
		<table>
			<caption>Era [<a href="/e/eras/{{era.id}}/edit">edit</a>]</caption>
			<thead>
				<tr>
					<th rowspan="2">From</th>
					<th rowspan="2">To</th>
					<th rowspan="2">Sites</th>
					<th rowspan="2"><span title="Energisation Status">ES</span></th>
					<th rowspan="2"><span title="Profile Class">PC</span></th>
					<th rowspan="2"><span title="Meter Serial Number">MSN</span></th>
					<th rowspan="2"><span title="Meter Timeswitch Class">MTC</span></th>
					<th rowspan="2"><span title="Metering Code Of Practice">CoP</span></th>
					<th rowspan="2"><span title="Communications Type">Comm</span></th>
					<th rowspan="2">
						<span title="Standard Settlement Configuration">SSC</span>
					</th>
					<th rowspan="2"><span title="Properties">Props</span></th>
					<th colspan="2"><span title="Meter Operator">MOP</span></th>
					<th colspan="2"><span title="Data Collector">DC</span></th>
					<th rowspan="2">
						Channels [<a href="/e/eras/{{era.id}}/add_channel">add</a>]
				 	</th>
					<th rowspan="2"><span title="Line Loss Factor Class">LLFC</span></th>
					<th rowspan="2">MPAN Core</th>
					<th rowspan="2">kVA</th>
					<th colspan="2">Supplier</th>
				</tr>
				<tr>
					<th>Contract</th>
					<th>Account</th>
					<th>Contract</th>
					<th>Account</th>
					<th>Contract</th>
					<th>Account</th>
				</tr>
			</thead>
			<tbody>
				<tr>
					<td rowspan="4">
						<span title="{{ era.start_date|hh_format }}"
							>{{ era.start_date|hh_format(modifier='date') }}</span>
					</td>
					<td rowspan="4">
							<span title="{{ era.finish_date|hh_format }}"
								>{{ era.finish_date|hh_format(modifier='date') }}</span>
					</td>
					<td rowspan="4">
							<a href="/sites/{{physical_site.id}}"
								 title="{{physical_site.name}}">{{ physical_site.code }}</a>
							{% if other_sites %}
								(also
								{% for other_site in other_sites %}
									<a href="/sites/{{ other_site.id }}"
										 title="{{other_site.name}}">{{ other_site.code }}</a>
								{%- endfor -%}
								)
							{% endif %}
					</td>
					<td rowspan="4">
						<a
								href="/e/energisation_statuses/{{era.energisation_status.id}}"
								title="{{era.energisation_status.description}}"
						>{{era.energisation_status.code}}</a>
					</td>
					<td rowspan="4">
							<a href="/e/pcs/{{era.pc.id}}"
								 title="{{era.pc.name}}">{{era.pc.code}}</a>
					</td>
					<td rowspan="4">{{ era.msn }}</td>
					<td rowspan="4">
							<a href="/e/mtc_participants/{{era.mtc_participant.id}}" title="{{era.mtc_participant.description}}">{{era.mtc_participant.mtc.code}}</a>
					</td>
					<td rowspan="4">
							<a href="/e/cops/{{era.cop.id}}" title="{{era.cop.description}}">{{era.cop.code}}</a>
					</td>
					<td rowspan="4">
							<a href="/e/comms/{{era.comm.id}}" title="{{era.comm.description}}">{{era.comm.code}}</a>
					</td>
					<td rowspan="4">
							{% if era.ssc %}
							<a href="/e/sscs/{{era.ssc.id}}" title="{{era.ssc.description}}">{{era.ssc.code}}</a>
							{% endif %}
					</td>
					<td rowspan="4">{{era.properties}}</td>
					<td rowspan="4">
						<a href="/e/mop_contracts/{{era.mop_contract.id}}">{{era.mop_contract.name}}</a>
					</td>
					<td rowspan="4">
						{{era.mop_account}}
					</td>
					<td rowspan="4">
						<a href="/e/dc_contracts/{{era.dc_contract.id}}">{{era.dc_contract.name}}</a>
					</td>
					<td rowspan="4">{{era.dc_account}}</td>
					<th colspan="6">Import</th>
					</tr>
					<tr>
						<td>
							{% for channel in era_bundle['imp_channels'] %}
								<a href="/e/channels/{{channel.id}}">{{channel.channel_type}}</a>
							{% endfor %}
						</td>
						<td>
							{% if era.imp_mpan_core %}
								<a href="/e/llfcs/{{era.imp_llfc.id}}" title="{{era.imp_llfc.description}}">
									{{era.imp_llfc.code}}
								</a>
							{% endif %}
						</td>
						<td>
							{% if era.imp_mpan_core %}
								<a title="{{supply.dno.dno_name}}" href="/e/dnos/{{supply.dno.id}}">{{supply.dno.dno_code}}</a> {{era.imp_mpan_core[3:]}}
							{% endif %}
						<td>
							{% if era.imp_mpan_core %}
								{{ era.imp_sc }}
							{% endif %}
						</td>
						<td>
							{% if era.imp_mpan_core %}
								<a href="/e/supplier_contracts/{{era.imp_supplier_contract.id}}">{{era.imp_supplier_contract.name}}</a>
							{% endif %}
						</td>
						<td>
							{% if era.imp_mpan_core %}
								{{ era.imp_supplier_account }}
								{% if era_bundle['imp_shared_supplier_accounts'] %}(
									{%- for sup in era_bundle['imp_shared_supplier_accounts'] -%}
									{%- if not loop.first    -%} {%- endif -%}
								<a href="/e/supplies/{{sup.id}}">{{sup.id}}</a>
								{%- endfor -%}
								)
								{% endif %}
							{% endif %}
						</td>
					</tr>
					<tr>
							<th colspan="6">Export</th>
					</tr>
					<tr>
							<td>
									{% for channel in era_bundle['exp_channels'] %}
									<a href="/e/channels/{{channel.id}}">{{channel.channel_type}}</a>
									{% endfor %}
							</td>
							<td>
									{% if era.exp_mpan_core %}
									<a href="/e/llfcs/{{era.exp_llfc.id}}" title="{{era.exp_llfc.description}}">{{era.exp_llfc.code}}</a>
									{% endif %}
							</td>
							<td>
									{% if era.exp_mpan_core %}
									<a title="{{era.supply.dno.dno_code}}" href="/e/dnos/{{era.supply.dno.id}}">{{era.supply.dno.dno_code}}</a> {{era.exp_mpan_core[3:]}}
									{% endif %}
							</td>
							<td>
								{% if era.exp_mpan_core %}
									{{ era.exp_sc }}
								{% endif %}
							</td>
							<td>
									{% if era.exp_mpan_core %}
									<a href="/e/supplier_contracts/{{era.exp_supplier_contract.id}}">{{era.exp_supplier_contract.name}}</a>
									{% endif %}
							</td>
							<td>
								{% if era.exp_mpan_core %}
									{{ era.exp_supplier_account }}
									{% if era_bundle['exp_shared_supplier_accounts'] %}(
									{%- for sup in era_bundle['exp_shared_supplier_accounts'] -%}
									{%- if not loop.first    -%} {%- endif -%}
									<a href="/e/supplies/{{sup.id}}">{{sup.id}}</a>
									{%- endfor -%}
									)
									{% endif %}
									{% endif %}
							</td>
						</tr>
					</tbody>
				</table>

				<table>
					{% set imp_bills = era_bundle['imp_bills'] %}
					<caption>
						Import Supplier Bills
						[<a href="/e/eras/{{era.id}}/add_supplier_bill">add</a>]
					</caption>
					<thead>
							<tr>
									<th rowspan="2">View</th>
									<th rowspan="2">From</th>
									<th rowspan="2">To</th>
									<th rowspan="2">Batch</th>
									<th rowspan="2">Reference</th>
									<th rowspan="2">kWh</th>
									<th rowspan="2">Net</th>
									<th rowspan="2">VAT</th>
									<th rowspan="2">Type</th>
									{% for tpr in imp_bills['inner_headers'] %}
									<th colspan="4">
											{% if tpr == None %}
											MD
											{% else %}
											<a href="/e/tprs/{{tpr.id}}">{{tpr.code}}</a>
											{% endif %}
									</th>
									{% endfor %}
									{% for i in range(imp_bills['num_outer_cols']) %}
									<th colspan="5">
											{{ loop.index }}
									</th>
									{% endfor %}
							</tr>
							<tr>
									{% for tpr in imp_bills['inner_headers'] %}
									<th colspan="2">Previous</th>
									<th colspan="2">Present</th>
									{% endfor %}
									{% for i in range(imp_bills['num_outer_cols']) %}
									<th>TPR</th>
									<th colspan="2">Previous</th>
									<th colspan="2">Present</th>
									{% endfor %}
							</tr>
					</thead>
					<tbody>
							{% for bill_dict in imp_bills['bill_dicts'] %}
							{% set read_rows = bill_dict['read_rows'] %}
							{% set bill = bill_dict['bill'] %}
							{% set rows_high = bill_dict['rows_high'] %}
							{% if bill_dict.first_collapsible %}
							<tr style="background-color: silver; cursor: pointer;">
									<td style="text-decoration: none; padding-top: 0px; padding-bottom: 0px; font-size: x-small;"
											colspan="{{9 + imp_bills['inner_headers']|length * 4 + imp_bills['num_outer_cols'] * 5}}"
											class="expander_{{bill_dict.collapse_id}}"
											onClick="expandBills({{bill_dict.collapse_id}})">
											+
									</td>
									<td style="text-decoration: none; display: none; padding-top: 0px; padding-bottom: 0px; font-size: x-small;"
											colspan="{{9 + imp_bills['inner_headers']|length * 4 + imp_bills['num_outer_cols'] * 5}}"
											class="collapser_{{bill_dict.collapse_id}}"
											onClick="collapseBills({{bill_dict.collapse_id}})">
											-
									</td>
							</tr>
							{% endif %}

							<tr {% if bill_dict.collapsible %}
									class="collapsible_{{bill_dict.collapse_id}}"
									style="display: none; background-color: silver;"
									{% endif %}>
									<td rowspan="{{ rows_high }}">
											<a href="/e/supplier_bills/{{bill.id}}">View</a>
									</td>
									<td rowspan="{{ rows_high }}">
											<label title="{{bill.start_date|hh_format}}">{{bill.start_date|hh_format('date')}}</label>
									</td>
									<td rowspan="{{ rows_high }}">
											<label title="{{ bill.finish_date|hh_format }}">{{ bill.finish_date|hh_format('date') }}</label>
									</td>
									<td rowspan="{{ rows_high }}">
											<a href="/e/supplier_batches/{{bill.batch.id}}">{{bill.batch.reference}}</a>
									</td>
									<td rowspan="{{ rows_high }}">{{ bill.reference }}</td>
									<td rowspan="{{ rows_high }}">{{ bill.kwh }}</td>
									<td rowspan="{{ rows_high }}">{{ bill.net }}</td>
									<td rowspan="{{ rows_high }}">{{ bill.vat }}</td>
									<td rowspan="{{ rows_high }}">
											<a href="/bill_types/{{bill.bill_type.id}}"
												 title="{{bill.bill_type.description}}">{{bill.bill_type.code}}</a>
									</td>
									{% for read_row in read_rows %}
									{% if not loop.first %}
							<tr {% if bill_dict.collapsible %}
									class="collapsible_{{bill_dict.collapse_id}}"
									style="display: none; background-color: silver;"
									{% endif %}>
									{% endif %}
									{% for read in read_row['inner_reads'] %}
									<td style="border-right: none;">
											{% if read %}
											<a title="{{ read.previous_date|hh_format }} {{ read.msn }}">{{ read.previous_value }}</a>
											{% endif %}
									</td>
									<td style="border-left: none; text-align: right;">
											{% if read %}
											{{ read.previous_type.code }}
											{% endif %}
									</td>
									<td style="border-right: none;">
											{% if read %}
											<a title="{{ read.present_date|hh_format }} {{ read.msn }}">{{ read.present_value }}</a>
											{% endif %}
									</td>
									<td style="border-left: none; text-align: right;">
											{% if read %}
											{{ read.present_type.code }}
											{% endif %}
									</td>
									{% endfor %}
									{% for read in read_row['outer_reads'] %}
									<td>
											{% if read %}
											{% if read.tpr %}
											<a href="/e/tprs/{{read.tpr.id}}">{{read.tpr.code}}</a>
											{% else %}
											MD
											{% endif %}
											{% endif %}
									</td>
									<td style="border-right: none;">
											{% if read %}
											<a title="{{read.previous_date|hh_format}} {{read.msn}}">{{read.previous_value}}</a>
											{% endif %}
									</td>
									<td style="border-left: none; text-align: right;">
											{% if read %}
											{{read.previous_type.code}}
											{% endif %}
									</td>
									<td style="border-right: none;">
											{% if read %}
											<a title="{{read.present_date|hh_format}} {{read.msn}}">{{read.present_value}}</a>
											{% endif %}
									</td>
									<td style="border-left: none; text-align: right;">
											{% if read %}
											{{read.present_type.code}}
											{% endif %}
									</td>
									{% if not loop.first %}
							</tr>
							{% endif %}
							{% endfor %}
							{% endfor %}
							</tr>
							{% endfor %}
					</tbody>
			</table>

			<table>
					{% set exp_bills = era_bundle['exp_bills'] %}
					<caption>Export Supplier Bills</caption>
					<thead>
							<tr>
									<th rowspan="2">View</th>
									<th rowspan="2">From</th>
									<th rowspan="2">To</th>
									<th rowspan="2">Batch</th>
									<th rowspan="2">Reference</th>
									<th rowspan="2">kWh</th>
									<th rowspan="2">Net</th>
									<th rowspan="2">VAT</th>
									<th rowspan="2">Type</th>
									{% for tpr in exp_bills['inner_headers'] %}
									<th colspan="4">
											{% if tpr == None %}
											MD
											{% else %}
											<a href="/e/tprs/{{tpr.id}}">{{tpr.code}}</a>
											{% endif %}
									</th>
									{% endfor %}
									{% for i in range(exp_bills['num_outer_cols']) %}
									<th colspan="5">
											{{ loop.index }}
									</th>
									{% endfor %}
							</tr>

							<tr>
									{% for tpr in exp_bills['inner_headers'] %}
									<th colspan="2">Previous</th>
									<th colspan="2">Present</th>
									{% endfor %}
									{% for i in range(exp_bills['num_outer_cols']) %}
									<th>TPR</th>
									<th colspan="2">Previous</th>
									<th colspan="2">Present</th>
									{% endfor %}
							</tr>
					</thead>
					<tbody>
							{% for bill_dict in exp_bills['bill_dicts'] %}
							{% set read_rows = bill_dict['read_rows'] %}
							{% set bill = bill_dict['bill'] %}
							{% set rows_high = bill_dict['rows_high'] %}
							<tr>
									<td rowspan="{{ rows_high }}">
											<a href="/e/supplier_bills/{{bill.id}}">View</a>
									</td>
									<td rowspan="{{ rows_high }}">
											<label title="{{ bill.start_date|hh_format }}">{{ bill.start_date|hh_format('date') }}</label>
									</td>
									<td rowspan="{{ rows_high }}">
											<label title="{{ bill.finish_date|hh_format }}">{{ bill.finish_date|hh_format('date') }}</label>
									</td>
									<td rowspan="{{ rows_high }}">
											<a href="/e/supplier_batches/{{bill.batch.id}}">{{bill.batch.reference}}</a>
									</td>
									<td rowspan="{{ rows_high }}">{{ bill.reference }}</td>
									<td rowspan="{{ rows_high }}">{{ bill.kwh }}</td>
									<td rowspan="{{ rows_high }}">{{ bill.net }}</td>
									<td rowspan="{{ rows_high }}">{{ bill.vat }}</td>
									<td rowspan="{{ rows_high }}">
											<a href="/bill_types/{{bill.bill_type.id}}" title="{{bill.bill_type.description}}">{{bill.bill_type.code}}</a>
									</td>

									{% for read_row in read_rows %}
									{% for read in read_row['inner_reads'] %}
									<td style="border-right: none;">
											{% if read %}
											<label title="{{ read.previous_date|hh_format }} {{ read.msn }}">{{ read.previous_value }}</label>
											{% endif %}
									</td>
									<td style="border-left: none;">
											{% if read %}
											{{ read.previousType.code }}
											{% endif %}
									</td>
									<td style="border-right: none;">
											{% if read %}
											<label title="{{ read.presentDate|hh_format }} {{ read.msn }}">{{ read.presentValue }}</label>
											{% endif %}
									</td>
									<td style="border-left: none;">
											{% if read %}
											{{ read.presentType.code }}
											{% endif %}
									</td>
									{% endfor %}
									{% if loop.first %}
									{% for read in read_row['outer_reads'] %}
									<td>
											{% if read.tpr %}
											<a href="/e/tprs/{{read.tpr.id}}">{{read.tpr.code}}</a>
											{% else %}
											MD
											{% endif %}
									</td>
									<td style="border-right: none;">
											<label title="{{ read.previous_date|hh_format }} {{ read.msn }}">{{ read.previous_value }}</label>
									</td>
									<td style="border-left: none;">
											{{ read.previous_type.code }}
									</td>
									<td style="border-right: none;">
											<label title="{{ read.present_date|hh_format }} {{ read.msn }}">{{ read.present_value }}</label>
									</td>
									<td style="border-left: none;">
											{{ read.present_type.code }}
									</td>
									{% endfor %}
									{% endif %}
									{% endfor %}
							</tr>
							{% endfor %}
					</tbody>
			</table>

                <table>
                    <caption>DC Bills</caption>
                    <thead>
                        <tr>
                            <th>View</th>
                            <th>Batch</th>
                            <th>Reference</th>
                            <th>Account</th>
                            <th>Issue Date</th>
                            <th>From</th>
                            <th>To</th>
                            <th>kWh</th>
                            <th>Net</th>
                            <th>VAT</th>
                            <th>Gross</th>
                            <th>Type</th>
                        </tr>
                    </thead>
                    <tbody>
                        {% for bill_dict in era_bundle['dc_bills']['bill_dicts'] %}
                        {% set bill = bill_dict['bill'] %}
                        <tr>
                            <td>
                                <a href="/e/dc_bills/{{bill.id}}">view</a>
                            </td>
                            <td>
                                <a href="/e/dc_batches/{{bill.batch.id}}">{{bill.batch.reference}}</a>
                            </td>
                            <td>{{ bill.reference }}</td>
                            <td>{{ bill.account }}</td>
                            <td>{{ bill.issue_date|hh_format }}</td>
                            <td>{{ bill.start_date|hh_format }}</td>
                            <td>{{ bill.finish_date|hh_format }}</td>
                            <td>{{ bill.kwh }}</td>
                            <td>{{ bill.net }}</td>
                            <td>{{ bill.vat }}</td>
                            <td>{{ bill.gross }}</td>
                            <td>
                                <a href="/bill_types/{{bill.bill_type.id}}" title="{{bill.bill_type.description}}">{{bill.bill_type.code}}</a>
                            </td>
                        </tr>
                        {% endfor %}
                    </tbody>
                </table>

                <table>
                    <caption>MOP Bills</caption>
                    <thead>
                        <tr>
                            <th>View</th>
                            <th>Batch</th>
                            <th>Reference</th>
                            <th>Account</th>
                            <th>Issue Date</th>
                            <th>From</th>
                            <th>To</th>
                            <th>kWh</th>
                            <th>Net</th>
                            <th>VAT</th>
                            <th>Gross</th>
                            <th>Type</th>
                        </tr>
                    </thead>
                    <tbody>
                        {% for bill_dict in era_bundle['mop_bills']['bill_dicts'] %}
                        {% set bill = bill_dict['bill'] %}
											<tr>
											<td><a href="/e/mop_bills/{{bill.id}}">view</a></td>
											<td>
												<a href="/e/mop_batches/{{bill.batch.id}}">{{bill.batch.reference}}</a>
											</td>
											<td>{{ bill.reference }}</td>
											<td>{{ bill.account }}</td>
											<td>{{ bill.issue_date|hh_format }}</td>
											<td>{{ bill.start_date|hh_format }}</td>
											<td>{{ bill.finish_date|hh_format }}</td>
											<td>{{ bill.kwh }}</td>
											<td>{{ bill.net }}</td>
											<td>{{ bill.vat }}</td>
											<td>{{ bill.gross }}</td>
											<td>
											<a href="/bill_types/{{bill.bill_type.id}}" title="{{bill.bill_type.description}}">{{bill.bill_type.code}}</a>
										</td>
									</tr>
								{% endfor %}
							</tbody>
						</table>
			{% endfor %}

			<ul>
				<li>
					kWh, kVA, MD etc. by month:
					<a href="/e/supplies/{{supply.id}}/months?is_import=true&amp;year={{last_month_start.year}}&amp;years=1">Import</a>
					<a href="/e/supplies/{{supply.id}}/months?is_import=false&amp;year={{last_month_start.year}}&amp;years=1">Export</a>
				</li>
				<li>
					<a href="/e/supplies/{{ supply.id }}/hh_data?months=1&amp;finish_year={{ now.year }}&amp;finish_month={{ now.month }}">Raw HH data</a>
				</li>
				<li>
					<a href="/e/supplies/{{supply.id}}/virtual_bill?start_year={{last_month_start.year}}&amp;start_month={{last_month_start.month}}&amp;start_day={{last_month_start.day}}&amp;start_hour={{last_month_start.hour}}&amp;start_minute={{last_month_start.minute}}&amp;finish_year={{last_month_finish.year}}&amp;finish_month={{last_month_finish.month}}&amp;finish_day={{last_month_finish.day}}&amp;finish_hour={{last_month_finish.hour}}&amp;finish_minute={{last_month_finish.minute}}">Supplier Virtual Bill</a>
				</li>
			</ul>

	<h2>Reports</h2>

	<form action="/reports/291">
		<fieldset>
			<input type="hidden" name="supply_id" value="{{supply.id}}">
			<legend>Virtual Bills</legend>
			<label>From</label> {{input_date('start', last_month_start)}}
			<label>To</label> {{input_date('finish', last_month_finish)}}
			<input type="submit" value="Download">
		</fieldset>
	</form>

	<form action="/reports/241">
		<fieldset>
			<input type="hidden" name="supply_id" value="{{supply.id}}">
			<legend>Daily Supplier Virtual Bills</legend>
			<label>Import / Export</label>
			<select name="is_import">
				<option value="true">Import</option>
				<option value="false">Export</option>
			</select>
			<label>From</label> {{input_date('start', last_month_start, 'day')}}
			<label>To</label> {{input_date('finish', last_month_finish, 'day')}}
			<input type="submit" value="Download">
		</fieldset>
		<p>
			(Note that unless a month is entirely in the past, all the days for that month
			will be estimates)
		</p>
	</form>

	<form action="/reports/387">
		<fieldset>
			<input type="hidden" name="supply_id" value="{{supply.id}}">
			<legend>Virtual Bills By Half-Hour</legend>
			<label>From</label> {{input_date('start', last_month_start)}}
			<label>To</label> {{input_date('finish', last_month_finish)}}
			<input type="submit" value="Download">
		</fieldset>
	</form>

	<form action="/reports/169">
		<fieldset>
			<legend>HH Data: Day Per Row</legend>
			<input type="hidden" name="supply_id" value="{{supply.id}}">
			<label>Import / Export</label>
			<select name="imp_related">
				<option value="true">Import</option>
				<option value="false">Export</option>
			</select>
			<label>Channel Type</label>
			<select name="channel_type">
				<option value="ACTIVE">ACTIVE</option>
				<option value="REACTIVE_IMP">REACTIVE_IMP</option>
				<option value="REACTIVE_EXP">REACTIVE_EXP</option>
			</select>
			<label>From</label> {{input_date('start', last_month_start, resolution='day') }}
			<label>To</label> {{ input_date('finish', last_month_finish, resolution='day') }}
			<input type="submit" value="Download">
		</fieldset>
	</form>

	<form action="/reports/187" method="post">
		<fieldset>
			<legend>HH Data: HH Per Row</legend>
			<input type="hidden" name="supply_id" value="{{supply.id}}">
			<label>From</label> {{ input_date('start', last_month_start) }}
			<label>To</label> {{ input_date('finish', last_month_finish) }}
			<input type="submit" value="Download">
		</fieldset>
	</form>

	<form action="/reports/41?supply_id">
		<fieldset>
			<legend>TRIAD</legend>
			<input type="hidden" name="supply_id" value="{{ supply.id }}">
			<label>For financial year ending March</label>
			<input name="year" value="{{triad_year}}" size="4" maxlength="4">
			<input type="submit" value="Download">
		</fieldset>
	</form>

	<form action="/reports/59" method=post>
		<fieldset>
			<input type="hidden" name="supply_id" value="{{supply.id}}">
			<input type="hidden" name="compression" value="true">
			<legend>Duration</legend>
			<label>From</label> {{ input_date('start', last_month_start) }}
			<label>To</label> {{ input_date('finish', last_month_finish) }}
			<input type="submit" value="Download">
		</fieldset>
	</form>

	<form action="/reports/247" method="post">
		<fieldset>
			<input type="hidden" name="supply_id" value="{{supply.id}}">
			<legend>Monthly Duration</legend>
			<label>Months Long</label>
			{{ input_number('months', initial='1', size='2', maxlength='2', required=True) }}
			<label>Final Month</label>
			{{ input_date('finish', last_month_finish, 'month') }}
			<label>Include bill check tabs?</label>
			{{input_checkbox('is_bill_check')}}
			<input type="submit" value="Download">
		</fieldset>
	</form>

	<form action="/reports/33">
		<input type="hidden" name="supply_id" value="{{supply.id}}">
		<fieldset>
			<legend>Snapshot</legend>
			<label>At</label> {{ input_date('date', last_month_finish) }}
			<input type="submit" value="Download">
		</fieldset>
	</form>

	<form action="/reports/219">
		<input type="hidden" name="supply_id" value="{{ supply.id }}">
		<fieldset>
			<legend>Register Reads</legend>
			<label>Months Long</label> <input name="months" maxlength="2" size="2" value="1">
			<label>Final Month</label> {{ input_date('end', last_month_finish, 'month') }}
			<input type="submit" value="Download">
		</fieldset>
	</form>

	<form action="/reports/207">
		<input type="hidden" name="supply_id" value="{{supply.id}}">
		<fieldset>
			<legend>CRC</legend>
			<label>For financial year starting April</label>
			<input name="year" value="{{ last_month_start.year }}" size="4" maxlength="4">
			<input type="submit" value="Download">
		</fieldset>
	</form>
{% endblock %}
