{% extends "base.html" %}

{% block title %}
	&raquo; MOP Contracts &raquo; {{contract.name}}
{% endblock %}

{% block nav %}
	<a href="/e/mop_contracts">MOP Contracts</a> &raquo; 
	{{contract.name}}
	[<a href="/e/mop_contracts/{{contract.id}}/edit">edit</a>]
{% endblock %}

{% block content %}
	<table>
		<tbody>
			<tr>
				<th>Party</th>
				<td>
					<a
							href="/e/parties/{{contract.party.id}}">{{contract.party.name}}</a>
				</td>
			</tr>
			<tr>
				<th>Name</th>
				<td>{{contract.name}}</td>
			</tr>
			<tr>
				<th>Start Date</th>
				<td>{{contract.start_rate_script.start_date|hh_format}}</td>
			</tr>
			<tr>
				<th>Finish Date</th>
				<td>{{contract.finish_rate_script.finish_date|hh_format}}</td>
			</tr>
		</tbody>
	</table>
	<br>
	<br>
	<table>				
		<caption>Rate Scripts
			[<a href="/e/mop_contracts/{{contract.id}}/add_rate_script">add</a>]
		</caption>
		<thead>
			<tr>
				<th></th>
				<th>From</th>
				<th>To</th>
			</tr>
		</thead>
		<tbody>
			{% for rate_script in rate_scripts %}
				<tr>
					<td>
						<a href="/e/mop_rate_scripts/{{rate_script.id}}">view</a>
					</td>
					<td>{{rate_script.start_date|hh_format}}</td>
					<td>{{rate_script.finish_date|hh_format}}</td>
				</tr>
			{% endfor %}
		</tbody>
	</table>
	<br>
	<ul>
		<li>
			<a href="/e/mop_batches?mop_contract_id={{contract.id}}">Batches</a>
		</li>
	</ul>
	<br>
	<form action="/reports/231">
		<fieldset>
			<input
					type="hidden" name="mop_contract_id" value="{{contract.id}}">

			From {{input_date('start', last_month_start)}} to
			{{input_date('finish', last_month_finish)}}
			<input type="submit" value="Download"/>
		</fieldset>
	</form>
	<br>
	<h2>Script</h2>
		<pre>{{contract.charge_script}}</pre>

{% endblock %}
