<script type="text/ng-template" id="clients/modals/duplicates.html">
	<div class="modal-header">
		<h3 class="modal-title">Merge duplicates</h3>
	</div>
	<div class="modal-body">
		<div class="row">
			<div class="col-sm-4">
				<select name="client_type" ng-model="search.type" class="form-control">
					<option value="client">Client</option>
					<option value="customer">Customer</option>
				</select>
			</div>
			<div class="col-sm-8">
				<input type="text" class="form-control search-query" placeholder="Search for {[{ search.type }]}" ng-model="search.query">
			</div>
		</div>
		<div style="height: 200px; overflow-y: scroll; margin-top: 10px; margin-bottom: 10px;">
			<p class="text-center" ng-show="loading">Loading...</p>
			<p class="text-center" ng-show="clients.length === 0">No results</p>
			<table class="table table-condensed" ng-hide="loading || clients.length === 0">
				<thead class="table-header">
					<th>ID</th>
					<th>Name</th>
					<th></th>
				</thead>
				<tbody>
					<tr ng-repeat="client in clients">
						<td>{[{ client.id }]}</td>
						<td>{[{ client.name }]}</td>
						<td><span class="btn btn-default btn-xs pull-right" ng-disabled="exists(client)" ng-click="select(client)">Select</span></td>
					</tr>
				</tbody>
			</table>
		</div>

		{{-- Bottom area --}}
		<div class="headline">
			<h4><i class="fa fa-user"></i> Clients to merge</h4>
		</div>

		<p class="text-center" ng-show="data.length === 0">Nothing attached</p>
		<table class="table table-condensed">
			<tbody>
				<tr ng-repeat="client in data">
					<td>{[{ client.id }]}</td>
					<td>{[{ client.name }]}</td>
					<td><span class="btn btn-default btn-xs pull-right" ng-click="remove(client)">Remove</span></td>
				</tr>
			</tbody>
		</table>
		<small>These clients will be merged with the current client and then deleted.</small>
	</div>
	<div class="modal-footer">
		<button class="btn btn-default" ng-click="cancel()">Cancel</button>
		<button class="btn btn-primary" ng-disabled="data.length === 0" ng-click="merge()">Merge Clients</button>
	</div>
</script>