<ol class="breadcrumb">
	<li><a href="#/">Dashboard</a></li>
	<li><a href="#/employees">Employees</a></li>
	<li class="active">{{vm.action}} Employee</li>
</ol>

<div class="container-fluid">
	<div class="row">
		<div class="col-md-12">
			<form name="form" class="form-horizontal" ng-submit="vm._save(vm.employee)" novalidate>
				<input type="hidden" ng-if="vm.action == 'Edit'" name="id" id="id" ng-model="vm.employee.id">
				<input type="hidden" class="form-control" name="city" id="city" ng-model="vm.employee.location.city">
				<input type="hidden" class="form-control" name="state" id="state" ng-model="vm.employee.location.state">
				<input type="hidden" class="form-control" name="zip_code" id="zip_code" ng-model="vm.employee.location.zip_code">
				<input type="hidden" class="form-control" name="lat" id="lat" ng-model="vm.employee.location.lat">
				<input type="hidden" class="form-control" name="lng" id="lng" ng-model="vm.employee.location.lng">
				<div class="panel panel-midnightblue">
					<div class="panel-heading">
						<h2>{{vm.action}} Employee</h2>
					</div>
					<div class="panel-body">
						<p>Fields with <span style="color: #cc0000;">*</span> are required.</p>
						<div class="form-group">
							<label for="name" class="col-sm-2 control-label">Name <span style="color: #cc0000;">*</span></label>
							<div class="col-sm-8">
								<input type="text" class="form-control" name="name" id="name" ng-model="vm.employee.name" ng-required="true" ng-minlength="3">
								<p class="help-block" ng-show="form.name.$touched && form.name.$error.required">Value is required.</p>
								<p class="help-block" ng-show="form.name.$touched && form.name.$error.minlength">Value is too short.</p>
							</div>
						</div>
						<div class="form-group">
							<label for="phone" class="col-sm-2 control-label">Phone <span style="color: #cc0000;">*</span></label>
							<div class="col-sm-8">
								<div class="input-group">							
									<span class="input-group-addon">
										<i class="ti ti-mobile"></i>
									</span>
									<input type="text" class="form-control" name="phone" id="phone" ui-mask="(999) 999-9999" ng-model="vm.employee.contacts.phone" ng-required="true">
								</div>
								<p class="help-block" ng-show="form.phone.$touched && form.phone.$error.required">Value is required.</p>
							</div>
						</div>
						<div class="form-group">
							<label for="phone_secondary" class="col-sm-2 control-label">Secondary Phone</label>
							<div class="col-sm-8">
								<div class="input-group">							
									<span class="input-group-addon">
										<i class="ti ti-mobile"></i>
									</span>
									<input type="text" class="form-control" name="phone_secondary" id="phone_secondary" ui-mask="(999) 999-9999" ng-model="vm.employee.contacts.phone_secondary">
								</div>
							</div>
						</div>
						<div class="form-group">
							<label for="email" class="col-sm-2 control-label">Email <span style="color: #cc0000;">*</span></label>
							<div class="col-sm-8">
								<div class="input-group">							
									<span class="input-group-addon">
										<i class="ti ti-email"></i>
									</span>
									<input type="email" class="form-control" name="email" id="email" ng-model="vm.employee.contacts.email" ng-required="true">
								</div>
								<p class="help-block" ng-show="form.email.$touched && form.email.$error.required">Value is required.</p>
								<p class="help-block" ng-show="form.email.$touched && form.email.$error.email">Invalid email.</p>
							</div>
						</div>
						<div class="form-group">
							<label for="address" class="col-sm-2 control-label">Address</label>
							<div class="col-sm-8">
								<input type="text" g-places-autocomplete force-selection="true" options="{componentRestrictions: {country: 'us'}}" class="form-control" name="address" id="address" ng-model="vm.employee.location.address" ng-change="vm._parseAddress(vm.employee.location.address)" autocomplete="off">
							</div>
						</div>
						<div class="form-group">
							<label for="color" class="col-sm-2 control-label">Color <span style="color: #cc0000;">*</span></label>
							<div class="col-sm-8">
								<div class="input-group">							
									<span class="input-group-addon">
										<i class="ti ti-paint-bucket"></i>
									</span>
									<input type="text" data-colorpicker class="form-control cpicker" name="color" id="color" data-color-format="hex" ng-model="vm.employee.preferences.color" ng-required="true">
								</div>
								<p class="help-block" ng-show="form.color.$touched && form.color.$error.required">Value is required.</p>
							</div>
						</div>
						<div class="form-group">
							<label for="image" class="col-sm-2 control-label">Image</label>
							<div class="col-sm-8">
								<a class="btn btn-default" ngf-multiple="false" ngf-select="vm._uploadImage($file)" ngf-resize="{width: 150, height: 150, centerCrop: true, quality: 1.0}" ngf-pattern="'image/*'" ngf-accept="'image/*'" ngf-max-size="1MB" ngf-model-invalid="invalidFiles">Select</a>
								<a ng-if="vm.employee.preferences.image" class="btn btn-danger" ng-click="vm.employee.preferences.image = ''">Remove</a>
								<a ng-if="vm.employee.preferences.image && !vm._editing" class="btn btn-info" ng-click="vm._viewImage(vm.employee.image_full)">View</a>
								<span ng-if="invalidFiles">Invalid File. Select Another One.</span>
								<p class="help-block">Only Images up to 1MB. Will be resized to 150px (Width) / 150px (Height).</p>
							</div>
						</div>
						<div class="form-group">
							<label for="salary" class="col-sm-2 control-label">Salary</label>
							<div class="col-sm-8">
								<div class="input-group">							
									<span class="input-group-addon">
										<i class="ti ti-money"></i>
									</span>
									<input type="text" class="form-control" name="salary" id="salary" ng-model="vm.employee.salary" ng-pattern="/^[0-9]+(\.[0-9]{1,2})?$/">
									<span class="input-group-addon">
										<i class="ti ti-time"></i>
									</span>
									<select class="form-control" name="salary_recurrency" id="salary_recurrency" ng-model="vm.employee.salary_recurrency">
										<option value="">-- Recurrency --</option>
										<option value="Daily">Daily</option>
										<option value="Weekly">Weekly</option>
										<option value="Fortnightly">Fortnightly</option>
										<option value="Monthly">Monthly</option>
										<option value="By Job">By Job</option>
									</select>
								</div>
								<p class="help-block" ng-show="form.salary.$touched && form.salary.$error.pattern">Decimal is required.</p>
							</div>
						</div>
						<div class="form-group">
							<label for="about" class="col-sm-2 control-label">About</label>
							<div class="col-sm-8">
								<textarea class="form-control" name="about" id="about" ng-model="vm.employee.about" rows="5"></textarea>
							</div>
						</div>
						<div class="form-group">
							<label for="send_to_quickbooks" class="col-sm-2 control-label">Send To Quickbooks? <span style="color: #cc0000;">*</span></label>
							<div class="col-sm-8">
								<div class="radio-inline">
									<label>
										<input type="radio" name="send_to_quickbooks" id="send_to_quickbooks" value="0" ng-model="vm.employee.send_to_quickbooks" ng-required="true"> No
									</label>
								</div>
								<div class="radio-inline">
									<label>
										<input type="radio" name="send_to_quickbooks" id="send_to_quickbooks" value="1" ng-model="vm.employee.send_to_quickbooks" ng-required="true"> Yes
									</label>
								</div>
								<p class="help-block" ng-show="form.send_to_quickbooks.$touched && form.send_to_quickbooks.$error.required">Value is required.</p>
							</div>
						</div>
					</div>
					<div class="panel-footer">
						<div class="row">
							<div class="col-sm-8 col-sm-offset-2">
								<button type="submit" ng-disabled="!form.$valid" class="btn-primary btn">Save</button>
								<a href="#/employees" class="btn-default btn">Cancel</a>
							</div>
						</div>
					</div>
				</div>
			</form>
		</div>
	</div>
</div>
