<form id='clientForm' name='clientForm' ng-submit="submit()" class="basic-form">
	@csrf
	<div class="row">
		<div class="col-sm-4 offset1">
			<input type="hidden" name="id" ng-model="data.id">

			<fieldset>
				<legend>Basic Details</legend>
				<div class="alert alert-warning" ng-if="duplicate_data.total > 0">
					<i class="fa fa-exclamation-triangle"></i>
					<ng-pluralize count="duplicate_data.total"
						when="{'one': 'I\'ve found another customer with these details.',
								'other': 'I\'ve found another {} customers with these details.'}">
					</ng-pluralize> <a href="{!! URL::to('clients') !!}#/client/{[{ client.id }]}" ng-repeat="client in duplicate_data.data | limitTo:5">{[{ client.name }]}<span class="muted">, </span></a>
				</div>
				<div class="form-group">
					<label for="company_name" class="col-sm-3 control-label">Company Name</label>
					<div class="col-sm-9">
						<input type="text" name="company_name" ng-model="data.name" required class="col-sm-12" arch-change="lookupDuplicates(data.name)">
					</div>
				</div>
				<div class="form-group">
					<label for="first_name" class="col-sm-3 control-label">First Name</label>
					<div class="col-sm-9">
						<input type="text" name="first_name" ng-model="data.sites[0].users[0].first_name" required class="col-sm-12">
					</div>
				</div>
				<div class="form-group">
					<label for="last_name" class="col-sm-3 control-label">Last Name</label>
					<div class="col-sm-9">
						<input type="text" name="last_name" ng-model="data.sites[0].users[0].last_name" required class="col-sm-12">
					</div>
				</div>
				<div class="form-group">
					<label for="position" class="col-sm-3 control-label">Position</label>
					<div class="col-sm-9">
						<input type="text" name="position" ng-model="data.sites[0].users[0].position" placeholder="Director" required class="col-sm-12">
					</div>
				</div>
			</fieldset>

			<fieldset>
				<legend>Contact Details</legend>
				<div class="input-prepend col-sm-12">
					<span class="add-on"><i class="fa fa-envelope"></i></span>
					<input type="text" name="email" ng-model="data.sites[0].users[0].email" class="col-sm-11" required placeholder="E-mail" arch-change="lookupDuplicates(data.sites[0].users[0].email)" maxlength="128">
				</div>
				<div class="input-prepend col-sm-12">
					<input type="text" name="phone" ng-model="data.sites[0].users[0].phone" ng-required="! data.sites[0].users[0].mobile" class="col-sm-11" placeholder="Phone" arch-change="lookupDuplicates(data.phone)" numbers-only maxlength="15">
				</div>
				<div class="input-prepend col-sm-12">
					<input type="text" name="mobile" ng-model="data.sites[0].users[0].mobile" ng-required="! data.sites[0].users[0].phone" ng-change="fillPrimaryPhone()" class="col-sm-11" arch-change="lookupDuplicates(data.mobile)" placeholder="Mobile phone" numbers-only maxlength="15">
				</div>

			</fieldset>
		</div>

		<div class="col-sm-4 offset1">
			<fieldset>
				<legend>Address Details</legend>
				<div class="input-prepend col-sm-12">
					<span class="add-on"><i class="fa fa-tag"></i></span>
					<input type="text" name="site_name" ng-model="data.sites[0].name" class="col-sm-11" required placeholder="Site Name" maxlength="128">
				</div>
				<div class="input-prepend col-sm-12">
					<span class="add-on"><i class="fa fa-home"></i></span>
					<input type="text" name="address" ng-model="data.sites[0].address" class="col-sm-11" required placeholder="Address Line 1" maxlength="128">
				</div>
				<div class="input-prepend col-sm-12">
					<span class="add-on"><i class="fa fa-home"></i></span>
					<input type="text" name="address2" ng-model="data.sites[0].address2" class="col-sm-11" placeholder="Address Line 2" maxlength="128">
				</div>
				<div class="input-prepend input-append col-sm-12">
					<span class="add-on"><i class="fa fa-home"></i></span>
					<input type="text" name="postcode" ng-model="data.sites[0].postcode" required class="col-sm-11" placeholder="Postcode">
					<span class="add-on" ng-click="lookupPostcode(data.sites[0].postcode)" title="Find the address"><i class="{[{ postcode.icon }]}"></i></span>
				</div>
				<div class="input-prepend col-sm-12">
					<span class="add-on"><i class="fa fa-phone"></i></span>
					<input type="text" name="primary_phone" ng-model="data.sites[0].primary_phone" class="col-sm-11" required numbers-only placeholder="Primary Phone" maxlength="128">
				</div>

			</fieldset>
		</div>

	</div>


	<div class="form-actions">
		<button class="btn btn-primary" ng-disabled="duplicate_data.total" data-loading-text="Saving..." data-success-text="Saved.." ng-hide="data.id">Create</button>
	</div>

</form>