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

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

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

	<h4 class="subheader">Message Description</h4>
	<div class="form-group">
		<label for="assigned_to" class="col-sm-3 control-label label-required">Message for:</label>
		<div class="col-sm-9">
			<select name="assigned_to" ng-model="data.assigned_to" class="form-control" required>
				<option value="">Select User</option>
				@foreach(App\Models\User::getActiveList()->pluck('name', 'id') as $id => $name)
					<option value="{{ $id }}">{{ $name }}</option>
				@endforeach
			</select>
		</div>
	</div>
	<div class="form-group" ng-show="clientManager.isCustomer()">
		<label for="contact_number" class="col-sm-3 control-label label-required">Telephone number:</label>
		<div class="col-sm-9">
			<input type="text" name="contact_number" ng-model="data.contact_number" class="form-control" ng-required="clientManager.isCustomer()">
		</div>
	</div>
	<div class="form-group">
		<label for="message" class="col-sm-3 control-label label-required">Message:</label>
		<div class="col-sm-9">
			<textarea name="message" ng-model="data.message" class="form-control" summernote summernote-height="200"></textarea>
		</div>
	</div>

	<div class="alert alert-warning" ng-if="! formIsValid()">
		<p class="lead"><i class="fa fa-warning"></i> The following are required before saving the job:</p>
		<ul>
			<li ng-if="!clientManager.isSelected()">You need to select a customer from the left hand side.</li>
			<li ng-if="!data.assigned_to">Message for is required.</li>
			<li ng-if="!data.message || data.message.trim() === ''">Message is required.</li>
			<li ng-if="clientManager.isCustomer() && (!data.contact_number || data.contact_number.trim() === '')">Telephone number is required for customers.</li>
		</ul>
	</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="!formIsValid()">
			Save
		</button>
	</div>

</form>