{% extends "base.html" %}

{% block title %}
	&raquo; MOP Contracts &raquo; {{rate_script.contract.name}} &raquo; 
	{{rate_script.start_date|hh_format}} &raquo; Edit
{% endblock %}

{% block nav %}
	<a href="/mop_contracts">MOP Contracts</a> &raquo; 
	<a
			href="/mop_contracts/{{rate_script.contract.id}}"
	>{{rate_script.contract.name}}</a> &raquo; 
	<a
		 href="/mop_rate_scripts/{{rate_script.id}}"
	>{{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">
						<form
								method="post"
							 	action="/mop_rate_scripts/{{rate_script.id}}/edit">
							<fieldset>
								<input type="submit" name="delete" value="Delete">
								<a
								 		href="/mop_rate_scripts/{{rate_script.id}}/edit"
									 	class="btn">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="section-data">
					<div class="standardForm textWidthAuto">
						<form
								method="post"
								action="/mop_rate_scripts/{{rate_script.id}}/edit">
							<fieldset>
								<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>
								<fieldset>
									<legend>Script</legend>
									{{input_textarea('script', rate_script.script, 40, 80,
										show_pos=True)}}
								</fieldset>
								<input type="submit" value="Update">
							</fieldset>
						</form>
					</div>
				</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="submit" name="delete" value="Delete">
							</fieldset>
						</form>
					</div>
				</div>
			</div>
		</div>
	{% endif %}
{% endblock %}
