{% 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 %}

	<form action="/e/dc_rate_scripts/{{dc_rate_script.id}}/edit" method="post">
		<fieldset>
			<legend>Update Rate Script</legend>
			<label>Start date</label> {{ input_date('start', dc_rate_script.start_date) }}
			<fieldset>
				<legend>Finish date</legend>
				<label>Ended?</label>
					{{input_checkbox('has_finished', dc_rate_script.finish_date != None)}}
				{{ 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 hx-delete="/e/dc_rate_scripts/{{dc_rate_script.id}}/edit"
			hx-confirm="Are you sure you want to delete this rate script?">
		<fieldset>
			<legend>Delete this Rate Script</legend>

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