@extends('layouts.app')

@section('htmlheader_title')
	Areafix/Filefix Message
@endsection

@section('content')
	<div class="row">
		<div class="col-12">
			<h1>Areafix/Filefix to {{ $o->name }} - {{ $zo->domain->name }}</h1>
		</div>
	</div>

	@includeWhen(session()->has('success'),'widgets.success',['msg'=>session()->get('success')])

	<form class="needs-validation" method="post" novalidate>
		@csrf

		<div class="row pt-0">
			<div class="col-2">
				<label for="to" class="form-label">To</label>
				<div class="input-group">
					<span class="input-group-text"><i class="bi bi-ui-radios"></i></span>
					<select class="form-select @error('to') is-invalid @enderror" id="to" name="to">
						@foreach (config('fido.areafilefix') as $name)
							<option value="{{ $name }}" @if(old('to' === $name ))selected @endif>{{ $name }}</option>
						@endforeach
					</select>
					<span class="invalid-feedback" role="alert">
						@error('to')
							{{ $message }}
						@enderror
					</span>
				</div>
			</div>

			<div class="offset-2 col-3">
				<label for="tftn_id" class="form-label">Address</label>
				<div class="input-group">
					<span class="input-group-text"><i class="bi bi-ui-radios"></i></span>
					<select class="form-select @error('tftn_id') is-invalid @enderror" id="tftn_id" name="tftn_id">
						@foreach ($o->akas->where('zone_id',$zo->id) as $ao)
							<option value="{{ $ao->id }}" @if(old('tftn_id' === $ao->id))selected @endif>{{ $ao->ftn }}</option>
						@endforeach
					</select>
					<span class="invalid-feedback" role="alert">
						@error('tftn_id')
							{{ $message }}
						@enderror
					</span>
				</div>
			</div>
		</div>

		<div class="row">
			<div class="col-3">
				<label for="subject" class="form-label">Subject</label>
				<div class="input-group">
					<span class="input-group-text @error('subject') is-invalid @enderror"><i class="bi bi-wifi"></i></span>
					<input type="text" class="form-control" id="subject" placeholder="Areafix Password" name="subject" value="{{ old('subject',$ao->pass_fix) }}">
					<span class="invalid-feedback" role="alert">
						@error('subject')
							{{ $message }}
						@enderror
					</span>
				</div>
			</div>

			<div class="offset-1 col-3">
				<label for="fftn_id" class="form-label">From</label>
				<div class="input-group">
					<span class="input-group-text"><i class="bi bi-ui-radios"></i></span>
					<select class="form-select @error('fftn_id') is-invalid @enderror" id="fftn_id" name="fftn_id">
						@foreach ($setup->system->akas->where('zone_id',$zo->id) as $ao)
							<option value="{{ $ao->id }}" @if(old('fftn_id' === $ao->id))selected @endif>{{ $ao->ftn }}</option>
						@endforeach
					</select>
					<span class="invalid-feedback" role="alert">
						@error('fftn_id')
							{{ $message }}
						@enderror
					</span>
				</div>
			</div>
		</div>

		<div class="row">
			<!-- Message -->
			<div class="col-12">
				<label for="msg" class="form-label">Message</label>
				<textarea class="form-control @error('msg') is-invalid @enderror" rows=10 name="msg" placeholder="Message...">{{ old('msg') }}</textarea>
				<span class="invalid-feedback" role="alert">
					@error('msg')
						{{ $message }}
					@enderror
				</span>
			</div>
		</div>

		<div class="row">
			<div class="col-12">
				<button type="submit" class="btn btn-success" name="submit" value="send">Send</button>
			</div>
		</div>
	</form>
@endsection

@section('page-css')
@append
@section('page-scripts')

	<script type="text/javascript">
		$(document).ready(function() {
		});
	</script>
@append