{% extends "base.html" %}

{% block title %}
	&raquo; Parties &raquo; {{party.name}}
{% endblock %}

{% block nav %}
	<a href="/e/parties">Parties</a> &raquo; {{ party.name }}
{% endblock %}

{% block content %}
	<table>
		<tr>
			<th>Name</th>
			<td>{{party.name}}</td>
		</tr>
		<tr>
			<th>Participant</th>
			<td>
				<a
						href="/e/participants/{{party.participant.id}}"
						>{{party.participant.name}}</a>
			</td>
		</tr>
		<tr>
			<th>Role</th>
			<td>
				<a
						href="/e/market_roles/{{party.market_role.id}}"
						>{{party.market_role.description}}</a>
			</td>
		</tr>
			{% if party.market_role.code == 'R' %}
				<tr>
					<th>DNO Code</th>
					<td>{{party.dno_code}}</td>
				</tr>
			{% endif %}
		<tr>
			<th>Valid From</th>
			<td>{{party.valid_from|hh_format}}</a>
			</td>
		</tr>
		<tr>
			<th>Valid To</th>
			<td>{{party.valid_to|hh_format}}</a>
		</tr>
	</table>
	<br>
	<br>
	<table>
		<caption>Contracts</caption>
		<thead>
			<tr>
				<th>Name</th>
				<th>Start Date</th>
				<th>Finish Date</th>
			</tr>
		</thead>
		<tbody>
			{% for contract in party.contracts %}
				<tr>
					<td>
						{% if contract.market_role.code == 'C' %}
							<a
									href="/e/dc_contracts/{{contract.id}}"
									>{{contract.name}}</a>
						{% elif contract.market_role.code == 'R' %}
							<a
									href="/e/dno_contracts/{{contract.id}}"
									>{{contract.name}}</a>
						{% elif contract.market_role.code == 'X' %}
							<a
									href="/e/supplier_contracts/{{contract.id}}"
									>{{contract.name}}</a>
						{% elif contract.market_role.code == 'M' %}
							<a
									href="/e/mop_contracts/{{contract.id}}"
									>{{contract.name}}</a>
						{% endif %}
					</td>
					<td>{{contract.start_rate_script.start_date|hh_format}}</td>
					<td>{{contract.finish_rate_script.finish_date|hh_format}}</td>
				</tr>
			{% endfor %}
		</tbody>
	</table>
{% endblock %}
