{% extends "base.html" %}

{% block title %}
	&raquo; Non-core Contracts &raquo; {{rate_script.contract.name}} &raquo; Rate Scripts &raquo; 
	{{ rate_script.start_date|date_format }} &raquo; Edit
{% endblock %}

{% block nav %}
	<a href="/non_core_contracts">Non-core Contracts</a> &raquo; 
	<a href="/non_core_contracts/{{rate_script.contract.id}}"
		>{{rate_script.contract.name}}</a> &raquo; 
	<a href="/non_core_rate_scripts/{{rate_script.id}}"
		>{{rate_script.start_date|date_format}}</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 rate script?</legend>	
				<input type="hidden" name="rate_script_id" value="{{rate_script.id}}">
				<input type="submit" name="delete" value="Delete" />
				<a href="/non_core_rate_scripts/{{rate_script.id}}/edit">Cancel</a>
			</fieldset>
		</form>
	{% else %}
		<form method="post">
			<fieldset>
				<legend>Update Rate Script</legend>	
				<input type="hidden" name="rate_script_id" value="{{rate_script.id}}">
				<fieldset>
					<legend>Start date</legend>
					{{ input_date('start', rate_script.start_date) }}
				</fieldset>
				<fieldset>
					<legend>Finish date</legend>
					<label>
						Ended?
						{{input_checkbox('has_finished', rate_script.finish_date != None)}}
					</label>
					{{ input_date('finish', rate_script.finish_date) }}
				</fieldset>
				<label>Script</label>
				{{ input_textarea('script', rate_script.script, 40, 80) }}
				<input type="submit" value="Update">
			</fieldset>
		</form>

		<form>
			<fieldset>
				<legend>Delete this Rate Script</legend>	
				<input type="hidden" name="rate_script_id" value="{{rate_script.id}}">
				<input type="submit" name="delete" value="Delete">
			</fieldset>
		</form>
	{% endif %}
{% endblock %}
