{% extends "base.html" %}

{% block title %}
	&raquo; Supplies &raquo; {{era.supply.name}} &raquo;
 	Era {{era.start_date|hh_format}} Attach
	{% if is_import %}
		Import
	{% else %}
		Export
	{% endif %}
 	Connection Agreement
{% endblock %}

{% block nav %}
	<a href="/e/supplies">Supplies</a> &raquo; 
	<a href="/e/supplies/{{era.supply.id}}">{{era.supply.id}}</a> &raquo; 
 	Era {{era.start_date|hh_format}} Attach
	{% if is_import %}
		Import
	{% else %}
		Export
	{% endif %}
 	Connection Agreement
{% endblock %}

{% block content %}
	<form method="post" action="/e/eras/{{era.id}}/attach_ca">
		<fieldset>
			<input type="hidden" name="is_import"
				{% if is_import %}
					value="true"
				{% else %}
					value="false"
				{% endif %}
			>
			<legend>Attach Existing Connection Agreement</legend>	
			<label>Connection Agreement</label>
			<select name="ca_id">
				{% for ca in cas  %}
					{{input_option('ca_id', ca.id, ca.id|string + ' : ' + ca.start_date|hh_format + ' : ' + ca.properties.get('title'))}}
				{% endfor %}
			</select>
			<input type="submit" name="attach" value="Attach">
		</fieldset>
	</form>

	<form method="post" action="/e/eras/{{era.id}}/attach_ca">
		<fieldset>
			<input type="hidden" name="is_import"
				{% if is_import %}
					value="true"
				{% else %}
					value="false"
				{% endif %}
			>
			<legend>Create New Connection Agreement</legend>	

			<label>Title</label> {{input_text('title')}}

			<label>Start Date</label> {{input_date('start', era.start_date)}}

			<label>Finish Date</label> {{input_date('finish', finish_date, has_is_ended=True)}}

			<input type="submit" name="create" value="Create">
		</fieldset>
	</form>
{% endblock %}
