@extends('adminlte::layouts.app')

@section('htmlheader_title')
	Setup
@endsection
@section('page_title')
	Setup
@endsection

@section('contentheader_title')
	{{ $site->site_name }}
@endsection
@section('contentheader_description')
	Setup
@endsection

@section('main-content')
	<div class="row">
		<div class="col-12">

			<div class="card card-dark">
				<div class="card-header">
					<h1 class="card-title">Setup Configuration</h1>
					@if(session()->has('success'))
					<span class="ml-3 pt-0 pb-0 pr-1 pl-1 btn btn-outline-success"><small>{{ session()->get('success') }}</small></span>
					@endif
				</div>

				<div class="card-body">
					<form class="g-0 needs-validation" method="POST" enctype="multipart/form-data" role="form">
						@csrf

						<div class="row">
							<div class="col-4">
								<div class="row">
									<div class="col-12">
										<div class="form-group has-validation">
											<label for="site_name">Organisation Name</label>
											<input type="text" class="form-control form-control-border @error('site_name') is-invalid @enderror" id="site_name" name="site_name" placeholder="Site Name..." value="{{ old('site_name',$site->site_name) }}" required>
											<span class="invalid-feedback" role="alert">
												@error('site_name')
													{{ $message }}
												@else
													Organisation Name is required.
												@enderror
											</span>
											<span class="input-helper">System Name used everywhere.</span>
										</div>
									</div>
								</div>

								<div class="row">
									<div class="col-10">
										<div class="form-group has-validation">
											<label for="site_logo">Site Logo</label>
											<input type="file" class="form-control @error('site_logo') is-invalid @enderror" id="site_logo" name="site_logo"><img class="col-12" src="{{ asset($site->site_logo) }}">
											<span class="invalid-feedback" role="alert">
												@error('site_logo')
													{{ $message }}
												@enderror
											</span>
										</div>
									</div>
								</div>

								<div class="row">
									<div class="col-10">
										<div class="form-group has-validation">
											<label for="email_logo">Email Logo</label>
											<input type="file" class="form-control @error('email_logo') is-invalid @enderror" id="email_logo" name="email_logo"><img class="col-12" src="{{ asset($site->email_logo) }}">
											<span class="invalid-feedback" role="alert">
												@error('email_logo')
													{{ $message }}
												@enderror
											</span>
										</div>
									</div>
								</div>
							</div>

							<div class="col-4">
								<div class="row">
									<div class="col-12">
										<div class="form-group has-validation">
											<label for="site_address1">Address Lines</label>
											<input type="text" class="form-control form-control-border @error('site_address1') is-invalid @enderror" id="site_address1" name="site_address1" placeholder="Address1" value="{{ old('site_address1',$site->site_address1) }}" required>
											<input type="text" class="form-control form-control-border" id="site_address2" name="site_address2" placeholder="Address2" value="{{ old('site_address2',$site->site_address2) }}">
											<span class="invalid-feedback" role="alert">
												@error('site_address1')
													{{ $message }}
												@else
													Atleast 1 address line required.
												@enderror
											</span>
										</div>
									</div>
								</div>

								<div class="row">
									<div class="col-12">
										<div class="form-group has-validation">
											<label for="site_address">City</label>
											<input type="text" class="form-control form-control-border @error('site_city') is-invalid @enderror" id="site_city" name="site_city" placeholder="City" value="{{ old('site_city',$site->site_city) }}">
											<span class="invalid-feedback" role="alert">
												@error('site_city')
													{{ $message }}
												@else
													City is required.
												@enderror
											</span>
										</div>
									</div>
								</div>

								<div class="row">
									<div class="col-12" style="display: inline-flex;">
										<div class="form-group has-validation">
											<label for="site_address">State</label>
											<input type="text" class="form-control form-control-border @error('site_state') is-invalid @enderror col-5" id="site_state" name="site_state" placeholder="State" value="{{ old('site_state',$site->site_state) }}">
											<span class="invalid-feedback" role="alert">
												@error('site_state')
													{{ $message }}
												@else
													State is required.
												@enderror
											</span>
										</div>

										<div class="form-group has-validation">
											<label for="site_address">Postal Code</label>
											<input type="text" class="form-control form-control-border @error('site_postcode') is-invalid @enderror col-5" id="site_postcode" name="site_postcode" placeholder="Postal Code" value="{{ old('site_postcode',$site->site_postcode) }}">
											<span class="invalid-feedback" role="alert">
												@error('site_postcode')
													{{ $message }}
												@else
													Postcode is required.
												@enderror
											</span>
										</div>
									</div>
								</div>
							</div>

							<div class="col-4">
								<div class="form-group has-validation">
									<label for="site_phone">Phone</label>
									<input type="text" class="form-control form-control-border @error('site_phone') is-invalid @enderror" id="site_phone" name="site_phone" placeholder="Site Phone" value="{{ old('site_phone',$site->site_phone) }}">
									<span class="invalid-feedback" role="alert">
										@error('site_phone')
											{{ $message }}
										@enderror
									</span>
								</div>

								<div class="form-group has-validation">
									<label for="site_fax">Fax</label>
									<input type="text" class="form-control form-control-border @error('site_fax') is-invalid @enderror" id="site_fax" name="site_fax" placeholder="Site Fax" value="{{ old('site_fax',$site->site_fax) }}">
									<span class="invalid-feedback" role="alert">
										@error('site_fax')
											{{ $message }}
										@enderror
									</span>
								</div>

								<div class="form-group has-validation">
									<label for="site_email">Email</label>
									<input type="email" class="form-control form-control-border @error('site_email') is-invalid @enderror" id="site_email" name="site_email" placeholder="Site Email" value="{{ old('site_email',$site->site_email) }}" required>
									<span class="invalid-feedback" role="alert">
										@error('site_email')
											{{ $message }}
										@else
											Email required.
										@enderror
									</span>
								</div>

								<div class="form-group has-validation">
									<label for="site_tax">Tax Number</label>
									<span class="input-group-prepend">ABN</span>
									<input type="text" class="form-control form-control-border @error('site_tax') is-invalid @enderror" id="site_tax" name="site_tax" placeholder="Site Tax" value="{{ old('site_tax',$site->site_tax) }}" required>
									<span class="invalid-feedback" role="alert">
										@error('site_tax')
											{{ $message }}
										@enderror
									</span>
								</div>
							</div>
						</div>

						<div class="row">
							<div class="col-12">
								<div class="form-group has-validation">
									<label for="site_description">Organisation Description</label>
									<textarea class="form-control @error('site_description') is-invalid @enderror" id="site_description" name="site_description" placeholder="Site Description...">{{ old('site_description',$site->site_description) }}</textarea>
									<span class="input-helper">Brief description of site.</span>
									<span class="invalid-feedback" role="alert">
										@error('site_description')
											{{ $message }}
										@enderror
									</span>
								</div>
							</div>
						</div>

						<div class="row">
							<div class="col-12">
								<a href="{{ url('/home') }}" class="btn btn-danger">Cancel</a>
								@can('wholesaler')
									<button type="submit" name="submit" class="btn btn-success mr-0 float-right">@if ($site->exists)Save @else Add @endif</button>
								@endcan
							</div>
						</div>
					</form>
				</div>
			</div>
		</div>
	</div>
@endsection