{% 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="/dc_contracts">DC Contracts</a> &raquo; 
	<a href="/dc_contracts/{{dc_rate_script.contract.id}}">{{dc_rate_script.contract.name}}</a> &raquo; 
	<a href="/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 %}
		<div class="layer-section">
			<div class="section-header">
				<h2>Are you sure you want to delete this rate script?</h2>
			</div>
			<div class="section-content">
				<div class="section-data">
					<div class="standardForm widthAuto">
						<form method="post">
							<fieldset>
								<input type="hidden" name="dc_rate_script_id"
							 		value="{{dc_rate_script.id}}">
								<input type="submit" name="delete" value="Delete">
								<a href="/dc_rate_scripts/{{dc_rate_script.id}}/edit">Cancel</a>
							</fieldset>
						</form>
					</div>
				</div>
			</div>
		</div>
				
		{% else %}

		<div class="layer-section">
			<div class="section-header">
				<h2>Update Rate Script</h2>
			</div>
			<div class="section-content">
				<div class="standardForm textWidthAuto ">
					
					<form method="post">
						<fieldset>
							<input
							    type="hidden" name="dc_rate_script_id"
									value="{{dc_rate_script.id}}">
							<div class="section-data">
									<fieldset>
										<legend>Start date</legend>
										{{ input_date('start', dc_rate_script.start_date) }}
									</fieldset>
							</div>
							<div class="section-data">
									<fieldset>
										<legend>Finish date</legend>
										<label>
											Ended?
										 	{{input_checkbox('has_finished', dc_rate_script.finish_date != None)}}
										</label>
										{{ input_date('finish', dc_rate_script.finish_date) }}
									</fieldset>
							</div>
							<div class="section-data">
								
								Script
								<br>
								{{ input_textarea('script', dc_rate_script.script, 40, 80,
								show_pos=True) }}
								<div>
									<input type="submit" value="Update">
									<input type="reset" value="Reset">
								</div>
							</div>
						</fieldset>
					</form>
				</div>
				{% if rate_script_example %}
					<div class="section-data">
						<br>
						<h4>Example</h4>
						<pre>{{rate_script_example}}</pre>
					</div>
				{% endif %}
			</div>
		</div>

		<div class="layer-section">
			<div class="section-header">
				<h2>Delete this Rate Script</h2>
			</div>
			<div class="section-content">
				<div class="section-data">
					<div class="standardForm">
						<form>
							<fieldset>

								<input type="hidden" name="dc_rate_script_id"
										value="{{dc_rate_script.id}}">
								<input type="submit" name="delete" value="Delete">
							</fieldset>
						</form>
					</div>
				</div>
			</div>
		</div>

	{% endif %}
{% endblock %}
