{% extends "base.html" %}

{% block title %}
	&raquo; Supplies &raquo; 
	Supply {{channel.era.supply.id}} Era
 	{{channel.era.start_date|hh_format}} &raquo; 
	Channel {% if channel.imp_related %}Import{% else %}Export{% endif %}
	{{channel.channel_type}}
{% endblock %}

{% block nav %}
	<a href="/e/supplies">Supplies</a> &raquo; 
	<a href="/e/supplies/{{channel.era.supply.id }}">Supply
	{{channel.era.supply.name}}
 	Era {{channel.era.start_date|hh_format}}</a> &raquo; 
	<a href="/e/channels/{{channel.id}}">Channel
	{% if channel.imp_related %}Import{% else %}Export{% endif %}
	{{channel.channel_type}}</a> &raquo; Edit
{% endblock %}

{% block content %}
	{% if request.method == 'GET' and request.values.delete %}

		<form method="post">
			<fieldset>
				<legend>Are you sure you want to delete this channel?</legend>	
				<input type="submit" name="delete" value="Delete">
				<a href="/e/channels/{{channel.id}}/edit">Cancel</a>
			</fieldset>
		</form>
		
	{% else %}
	
		<form method="post" action="/e/channels/{{channel.id}}/edit">
			<fieldset>
				<legend>Delete HH Data</legend>	
				<label>From</label> {{input_date('start', None, 'minute')}}
				<label>To</label> {{input_date('finish', None, 'minute')}}
				<input type="submit" name="delete_data" value="Delete">
			</fieldset>
		</form>

		<form method="post" action="/e/channels/{{channel.id}}/edit">
			<fieldset>
				<label>Insert HH datum</label>	
				<label>Start Date </label> {{input_date('start', None, 'minute')}}
				<label>Value</label> {{input_text('value', '')}}
				<label>Status </label>
				<select name="status">
					{{input_option('status', 'E', 'E')}}
					{{input_option('status', 'A', 'A')}}
				</select>	
				<input type="submit" name="insert" value="Insert">
			</fieldset>
		</form>

		<form action="/e/channels/{{channel.id}}/edit">
			<fieldset>
				<label>Delete this channel</label>	
				<input type="hidden" name="channel_id" value="{{channel.id}}">
				<input type="hidden" name="start_year" value="{{now.year}}">
				<input type="hidden" name="start_month" value="{{now.month}}">
				<input type="submit" name="delete" value="Delete">
			</fieldset>
		</form>
			
	{% endif %}

{% endblock %}
