<form id='orderForm' name='orderForm' ng-submit="save()" class="form-horizontal form-edit" editable-form confirm-on-exit>

	@include('bookings::templates.bookings_projects_header')
	
	@csrf

	@include('bookings::templates.location')


	<h4 class="subheader">Parts to Order</h4>
	<div class="control-group">
		<span ng-init="vat = {!! Config::get('settings.vat') !!}"></span>
		<div class="row">
			<div class="col-sm-12">
				<div class="col-sm-3"></div>
				<div class="col-sm-3">
					<div request-existing-part="parts" related="data" related-type="task"  virtual-mode="true"></div>
				</div>
				<div class="col-sm-2">
					<div request-non-existing-part="parts" related="data" related-type="task"  virtual-mode="true" ></div>
				</div>
				<div class="col-sm-4"></div>
			</div
			<!-- 26-1-17 nadeem - spoke to Phil and Neal who said this search box was unnecessary  -->
			<!-- <div class="col-sm-5">
				<input class="form-control" type="text" placeholder="Search parts in stock" ng-model="part_search" search-clear="true" search-callback="addPart(ev, data)" autocomplete="off" product-search>
			</div> -->
		</div>
		<br>
		<table class="table table-condensed">
			<thead>
				<th></th>
				<th>Name</th>
				<th class="centered">Price</th>
				<th class="centered">Quantity</th>
				<th class="centered">VAT</th>
				<th class="centered">Total</th>
				<th></th>
			</thead>
			<tbody>
				<tr ng-repeat="part in data.parts">
					<td><span class="text-warning" ng-show="part.on_order == '1'" tooltip="On order"><i class="fa fa-clock-o"></i></span></td>
					<td><a ng-href="#/stock?query={[{part.stock.name}]}" style="color:black">{[{ part.stock.name }]}</a></td>
					<td class="centered"> <b>£ </b><input ng-model="part.price" numbers-only class="col-sm-3"/></td>
					<td class="centered"><input ng-model="part.quantity" type="number" min="1" class="col-sm-3"/></td>
					<td class="centered">{[{ part.price * vat * part.quantity / 100 | currency:"£" }]}</td>
					<td class="centered"><span e-class="input-tiny" onaftersave="updateTotalPrice(part)">{[{ (part.price * part.quantity * (1 + vat/100)) | currency:"£" }]}</span></td>
					<td><a href="#" ng-click="removePart(part)" data-eat-click><span class="text-danger">Remove</span></a></td>
				</tr>
				<tr >
					<td colspan="7" ng-if="parts.length == 0"> <br><strong>No parts found for this {[{related_type}]}.</strong><br></td>
				</tr>
			</tbody>
		</table>
		<br>
		<div class="text-right parts-row" ng-show="parts.length > 0">
			<div>Subtotal: {[{ subtotal() | currency:"£" }]}</div>
			<div>Tax: {[{ tax() | currency:"£" }]}</div>
			<div><strong>Total: {[{ total() | currency:"£" }]}</strong></div>
		</div>
		<hr>
	</div>

	<div class="form-actions">
		<input type="hidden" name="client_id" ng-model="data.client_id" required>
		<input type="hidden" name="type" value="support">
		<button class="btn btn-primary" data-loading-text="Saving..." ng-disabled="!clientManager.isSelected() || parts.length == 0 ">
			Save
		</button>
	</div>



	<script type="text/ng-template" id="modals/request-existing-part.html">
		@include('bookings::templates.modals.request-existing-part')
	</script>
	<script type="text/ng-template" id="modals/request-non-existing-part.html">
		@include('bookings::templates.modals.request-non-existing-part')
	</script>



</form>