{% extends "base.html" %}

{% block title %}
	&raquo; Supplier Contracts &raquo; {{supplier_rate_script.contract.name}} &raquo; 
 	Rate Scripts &raquo; {{supplier_rate_script.start_date|date_format}} &raquo; Edit
{% endblock %}

{% block nav %}
	<a href="/e/supplier_contracts">Supplier Contracts</a> &raquo; 
	<a href="/e/supplier_contracts/{{supplier_rate_script.contract.id}}"
		>{{supplier_rate_script.contract.name}}</a> &raquo; 
	<a href="/e/supplier_rate_scripts/{{supplier_rate_script.id}}"
		>Rate Script {{supplier_rate_script.start_date|date_format}}</a> &raquo; Edit
{% endblock %}

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

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

	<form hx-delete="/e/supplier_rate_scripts/{{supplier_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 %}
