{% extends "base.html" %}

{% block title %}
	&raquo; MOP Contracts &raquo; {{contract.name}}
{% endblock %}

{% block nav %}
	<a href="/mop_contracts">MOP Contracts</a> &raquo; 
	<a href="/mop_contracts/{{contract.id}}">{{contract.name}}</a>
	&raquo; Edit
{% endblock %}

{% block content %}
	{% if request.method == 'GET' and request.values.view == 'confirm_delete' %}
		
		<div class="layer-section">
			<div class="section-header">
				<h2>Are you sure you want to delete this contract?</h2>
			</div>
			<div class="section-content">
				<div class="section-data">
					<div class="standardForm">
						<form method="post">
							<fieldset>
								<input type="hidden" name="mop_contract_id"
									value="{{contract.id}}">
								<input type="submit" name="delete" value="Delete">
								<a href="/mop_contracts/{{contract.id}}/edit">Cancel</a>
							</fieldset>
						</form>
					</div>
				</div>
			</div>
		</div>
			
		{% else %}
		
		<div class="layer-section">
			<div class="section-header">
				<h2>Update Contract</h2>
				
			</div>
			<div class="section-content">
				<div class="standardForm">
					<div class="section-data ">
						<form method="post">
							<fieldset>
								<input type="hidden" name="mop_contract_id"
									value="{{contract.id}}">
								<div class="row">
									<div class="col-sm-6">
										<label>Party</label>
										<select name="party_id">
											{% for party in parties %}
												{{
											 			input_option('party_id', party.id,
													 	party.participant.code + ' : ' +
													 	party.name, contract.party.id) }}
											{% endfor %}
										</select>
									</div>
									<div class="col-sm-6">
										<label>Name </label>
										{{input_text('name', contract.name)}}
									</div>
								</div>
								<br>	
								<label>Charge script</label>
								<br>	
								{{
										input_textarea(
											'charge_script', contract.charge_script, 40, 80)}}
								<br>	
								<br>	
								<label>Properties</label>
								<br>	
								{{input_textarea('properties', contract.properties, 40, 80)}}
								
								<br>	
								<br>	
								<label>Example</label>
								<code><pre>
has.importer=yes
file.type=.df2
hostname=example.com
username=username
password=password
directory0=downloads1
directory1=downloads2
								</pre></code>
								<input type="submit" value="Update">
							</fieldset>
						</form>						
					</div>
				</div>
			</div>
		</div>
		<!-- Layer Section -->
        <div class="layer-section">
        	<!-- Section Header -->
        	<div class="section-header">
        		<h2>Update State</h2>	
        	</div>
        	<!-- End Section Header -->
        	<!-- Section Content -->
        	<div class="section-content">
        		<div class="section-data">
        		    <div class="standardForm">
        		        <form method="post">
							<fieldset>
								<input type="hidden" name="mop_contract_id" value="{{contract.id}}">
								<label>State</label>
								{{input_textarea('state', contract.state, 40, 80)}}
								<input type="submit" name="update_state" value="Update">
							</fieldset>
						</form>
        		    </div>
        		</div>
        	</div>
        	<!-- End Section Content -->
        </div>
        <!-- End Layer Section -->
			
		<div class="layer-section">
			<div class="section-header">
				<h2>Delete this contract</h2>
			</div>
			<div class="section-content">
				<div class="section-data">
					<form >
						<fieldset>
							<input type="hidden" name="mop_contract_id" value="{{contract.id}}">
							<input type="hidden" name="view" value="confirm_delete">
							<input type="submit" value="Delete">
						</fieldset>
					</form>
				</div>
			</div>
		</div>
	{% endif %}
{% endblock %}
