{% extends "base.html" %}

{% block title %}
	&raquo; Supplier Contracts &raquo; {{bill.batch.contract.name}} &raquo; Batches &raquo; 
 	{{bill.batch.reference}} &raquo; Bills &raquo; {{bill.id}}
{% endblock %}

{% block nav %}
	&raquo; <a href="/supplier_contracts">Supplier Contracts</a> &raquo; 
	<a href="/supplier_contracts/{{bill.batch.contract.id}}">{{bill.batch.contract.name}}</a> &raquo; 
	<a href="/supplier_batches?supplier_contract_id={{bill.batch.contract.id}}">Batches</a> &raquo; 
	<a href="/supplier_batches/{{bill.batch.id}}">{{bill.batch.reference}}</a> &raquo; 
	<a href="/supplier_bills/{{bill.id}}">Bill {{bill.id}}</a>
 	&raquo; Edit
{% endblock %}

{% block content %}
	{% if request.values.confirm_delete %}
	<!-- Layer Section -->
	<div class="layer-section">
		<!-- Section Header -->
		<div class="section-header">
			<h2>Are you sure you want to delete this bill?</h2>	
		</div>
		<!-- End Section Header -->
		<!-- Section Content -->
		<div class="section-content">
			<div class="section-data">
				<div class="standardForm">
					<form method="post" action="">
						<fieldset>
							<input type="submit" name="delete" value="Delete">
							<input type="reset" value="Cancel" onClick="window.location='/supplier_bills/{{bill.id}}/edit'" />
						</fieldset>
					</form>
				</div>
			</div>	
		</div>
		<!-- End Section Content -->
	</div>
	<!-- End Layer Section -->
	
		
	{% else %}
	<!-- Layer Section -->
	<div class="layer-section">
		<!-- Section Header -->
		<div class="section-header">
			<h2>Update This Bill</h2>	
		</div>
		<!-- End Section Header -->
		<!-- Section Content -->
		<div class="section-content">
			<div class="section-data">
				<form action="" method="post">
					<fieldset>
						<div class="standardForm">
							<p>
								<a href="/supplies/{{bill.supply.id}}">Supply</a>
							</p>
							<div class="row">
								<div class="col-sm-6">
									<label>
										Reference {{input_text('reference', bill.reference)}}
									</label>
								</div>
								<div class="col-sm-6">
									<label>
										Account {{input_text('account', bill.account)}}
									</label>
								</div>
							</div>
						</div>
						<div class="standardForm textWidthAuto">
							<fieldset>
								<legend>Issue Date</legend>
								{{input_date('issue', bill.issue_date)}}
							</fieldset>
							<fieldset>
								<legend>Start Date</legend>
								{{input_date('start', bill.start_date)}}
							</fieldset>
							<fieldset>
								<legend>Finish Date</legend>
								{{input_date('finish', bill.finish_date)}}
							</fieldset>
						</div>
						<div class="standardForm">
							<div class="row">
								<div class="col-sm-4">
									<label>
										kWh {{input_text('kwh', '' ~ bill.kwh)}}
									</label>
								</div>
								<div class="col-sm-4">
									<label>
										Net {{input_text('net', '' ~ bill.net)}}
									</label>
								</div>
								<div class="col-sm-4">
									<label>
										VAT {{input_text('vat', '' ~ bill.vat)}}
									</label>
								</div>
							</div>
							<div class="row">
								<div class="col-sm-4">
									<label>Gross {{input_text('gross', '' ~ bill.gross)}}</label>
								</div>
								<div class="col-sm-4">
									<label>Type
										<select name="bill_type_id">
											{% for type in bill_types %}
												{{input_option('type_id', type.id, type.code + ' ' + type.description, initial=bill.bill_type.id)}}
											{% endfor %}
										</select>
									</label>
								</div>
							</div>
						</div>
						
						<label>
							Breakdown <br>
							{{input_textarea('breakdown', bill.breakdown, 10, 80)}}
						</label>
						<br>
						Example Breakdown

						<pre>
		{'raw_lines': ['"net-gbp", "unrestricted-kwh", "unrestricted-rate", "unrestricted-gbp"',
		'"100", "1000", "0.1", "100"'],
		'unrestricted-kwh': 1000, 'unrestricted-rate': 0.1, 'unrestricted-gbp': 100}          </pre>
						<br>
						<input type="submit" name="update" value="Update">
					</fieldset>
				</form>
			</div>
		</div>
		<!-- End Section Content -->
	</div>
	<!-- End Layer Section -->
	
	<!-- Layer Section -->
<div class="layer-section">
	<!-- Section Header -->
	<div class="section-header">
		<h2>Delete This Bill</h2>	
	</div>
	<!-- End Section Header -->
	<!-- Section Content -->
	<div class="section-content">
		<div class="section-data">
			<div class="standardForm">
				<form action="">
					<fieldset>
						<input type="submit" name="confirm_delete" value="Delete">
					</fieldset>
				</form>
			</div>
		</div>
	</div>
	<!-- End Section Content -->
</div>
<!-- End Layer Section -->

		
		<br>
		
	{% endif %}
{% endblock %}
