{% extends "base.html" %}

{% block title %}
	&raquo; DNOs &raquo; {{dno.dno_code}} &raquo; 
 	Rate Scripts &raquo; {{rate_script.start_date|hh_format}} &raquo; Edit
{% endblock %}

{% block nav %}
	<a href="/e/dnos">DNOs</a> &raquo; 
	<a href="/e/dnos/{{dno.id}}">{{dno.dno_code}}</a> &raquo; 
	<a href="/e/dno_rate_scripts/{{rate_script.id}}"
		>Rate Script {{rate_script.start_date|hh_format}}</a> &raquo; Edit
{% endblock %}

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

		<form method="post" action="/e/dno_rate_scripts/{{rate_script.id}}/edit">
			<fieldset>
				<legend>Are you sure you want to delete this rate script?</legend>	
				<input type="submit" name="delete" value="Delete">
				<a href="/e/dno_rate_scripts/{{rate_script.id}}/edit">Cancel</a>
			</fieldset>
		</form>

	{% else %}
	
		<form action="/e/dno_rate_scripts/{{rate_script.id}}/edit" method="post">
			<fieldset>
				<legend>Update Rate Script</legend>	
				<label>Start Date</label>
				{{ input_date('start', rate_script.start_date) }}

				<label>End Date</label>
				{{ input_date('finish', rate_script.finish_date) }}

				<label>Ended?</label>
				{{input_checkbox('has_finished', rate_script.finish_date != None)}}

				<label>Script</label>
				{{ input_textarea('script', rate_script.script, 40, 80, show_pos=True) }}
				<input type="submit" value="Update">
			</fieldset>
		</form>

		<form enctype="multipart/form-data" method="post"
				action="/e/dno_rate_scripts/{{rate_script.id}}/edit">
			<fieldset>
				<legend>DNO Rate Importer</legend>	
				<label>Charging Statement Spreadsheet</label>
				<input type="file" name="dno_file" size="45"
						value="{{request.values.import_file}}">
				<label>GSP Group</label>
				<select name="gsp_group_id">
					{% for gsp_group in gsp_groups %}
						{{input_option('gsp_group_id', gsp_group.id,
								gsp_group.code + ' ' + gsp_group.description)}}
					{% endfor %}
				</select>
				<input type="submit" name="import" value="Import">
			</fieldset>
		</form>

		<form>
			<fieldset>
				<legend>Delete this Rate Script</legend>	
				<input type="submit" name="delete" value="Delete">
			</fieldset>
		</form>

	{% endif %}
{% endblock %}
