{% extends "base.html" %}

{% block title %}
	Gas Industry Contracts &raquo; {{g_rate_script.g_contract.name}} &raquo;
 	Rate Scripts &raquo; {{g_rate_script.start_date|hh_format}} &raquo; Edit
{% endblock %}

{% block nav %}
	<a href="/g/industry_contracts">Gas Industry Contracts</a> &raquo;
	<a
	 		href="/g/industry_contracts/{{g_rate_script.g_contract.id}}"
			>{{g_rate_script.g_contract.name}}</a> &raquo;
	<a
	 		href="/g/industry_rate_scripts/{{g_rate_script.id}}"
			>Rate Script {{g_rate_script.start_date|hh_format}}</a> &raquo; Edit
{% endblock %}

{% block content %}
	{% if request.method == 'GET' and request.values.delete %}
		<form method="post" action="/g/industry_rate_scripts/{{g_rate_script.id}}/edit">
			<fieldset>
				<legend>
					Are you sure you want to delete this rate script?
				</legend>
				<input type="submit" name="delete" value="Delete">
			</fieldset>
		</form>
		<p>
			<a href="/g/industry_rate_scripts/{{g_rate_script.id}}/edit">Cancel</a>
		</p>
	{% else %}
		<form action="/g/industry_rate_scripts/{{g_rate_script.id}}/edit" method="post">
			<fieldset>
				<legend>Update Rate Script</legend>	
				<label>Start Date</label> {{ input_date('start', g_rate_script.start_date) }}
				<label>Finish Date Ended?</label>
				{{input_checkbox('has_finished', g_rate_script.finish_date != None) }}
				<label>Finish Date</label>
					{{ input_date('finish', g_rate_script.finish_date) }}
				<label>Script</label>
				{{ input_textarea('script', g_rate_script.script, 40, 80, show_pos=True) }}
				<input type="submit" value="Update">
				<input type="reset" value="Reset">
			</fieldset>
		</form>

		{% if g_rate_script.g_contract.name == 'dn' %}

			<form enctype="multipart/form-data" method="post"
					action="/g/industry_rate_scripts/{{g_rate_script.id}}/edit">
				<fieldset>
					<legend>DN Rate Importer</legend>	
					<label>
						<a href="https://www.gasgovernance.co.uk/DNcharges">Charges Spreadsheet</a>
					</label>
					<input type="file" name="dn_file" size="45"
							value="{{request.values.import_file}}">
					<input type="submit" name="import" value="Import">
				</fieldset>
			</form>

		{% endif %}

		<form action="/g/industry_rate_scripts/{{g_rate_script.id}}/edit">
			<fieldset>
				<legend>Delete this Rate Script</legend>	
				<input type="submit" name="delete" value="Delete">
			</fieldset>
		</form>
	{% endif %}
{% endblock %}
