{% extends "base.html" %}

{% block title %}
	&raquo; {{dc_rate_script.contract.name}} &raquo; Rate Scripts &raquo; 
	{{dc_rate_script.start_date|hh_format}} &raquo; Edit
{% endblock %}

{% block nav %}
	<a href="/e/dc_contracts">DC Contracts</a> &raquo; 
	<a href="/e/dc_contracts/{{dc_rate_script.contract.id}}"
		>{{dc_rate_script.contract.name}}</a> &raquo; 
	<a href="/e/dc_rate_scripts/{{dc_rate_script.id}}"
		>{{dc_rate_script.start_date|hh_format}}</a>
	&raquo; Edit
{% endblock %}

{% block content %}

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

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

		<form action="/e/dc_rate_scripts/{{dc_rate_script.id}}/edit" method="post">
			<fieldset>
				<legend>Update Rate Script</legend>
				<fieldset>
					<legend>Start date</legend>
					{{ input_date('start', dc_rate_script.start_date) }}
				</fieldset>
				<fieldset>
					<legend>Finish date</legend>
					<label>Ended?</label>
						{{input_checkbox('has_finished', dc_rate_script.finish_date != None)}}
					</label>
					{{ input_date('finish', dc_rate_script.finish_date) }}
				</fieldset>
				<label>Script</label>
				{{ input_textarea('script', dc_rate_script.script, 40, 80, show_pos=True) }}
				<input type="submit" value="Update">
				<input type="reset" value="Reset">
			</fieldset>
		</form>

		{% if rate_script_example %}
				<h4>Example</h4>
				<pre>{{rate_script_example}}</pre>
		{% endif %}

		<form action="/e/dc_rate_scripts/{{dc_rate_script.id}}/edit">
			<fieldset>
				<legend>Delete this Rate Script</legend>

				<input type="submit" name="delete" value="Delete">
			</fieldset>
		</form>

	{% endif %}
{% endblock %}
