<!-- $o = Supplier::class -->
<div class="row">
	<div class="col-12">
		<h3>Supplier Details @include('adminlte::widget.success_button')</h3>
		<hr>

		<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">
						<!-- Supplier Active -->
						<div class="col-12 col-sm-3">
							<div class="form-group left">
								<div class="custom-control custom-switch custom-switch-off-danger custom-switch-on-success">
									<input type="checkbox" class="custom-control-input" id="active" name="active" {{ old('active',$o->active) ? 'checked' : '' }}>
									<label class="custom-control-label" for="active">Active</label>
								</div>
							</div>
						</div>

						<!-- Supplier Name -->
						<div class="col-12 col-sm-9">
							@include('adminlte::widget.form_text',[
								'label'=>'Supplier Name',
								'id'=>'name',
								'old'=>'name',
								'name'=>'name',
								'value'=>$o->name ?? '',
							])
						</div>
					</div>

					<div class="row">
						<!-- Address Lines -->
						<div class="col-12">
							<div class="form-group">
								<label for="address1">Address Lines</label>
								<input type="text" style="border-bottom-left-radius:0;border-bottom-right-radius:0;" class="form-control @error('address1') is-invalid @enderror" id="address1" name="address1" value="{{ old('address1',$o->address1) }}">
								<input type="text" style="border-top-left-radius:0;border-top-right-radius:0;" class="form-control" id="address2" name="address2" value="{{ old('address2',$o->address2) }}">
								<span class="invalid-feedback" role="alert">
									@error('address1')
										{{ $message }}
									@else
										Atleast 1 address line required.
									@enderror
								</span>
							</div>
						</div>
					</div>

					<div class="row">
						<!-- City -->
						<div class="col-12">
							@include('adminlte::widget.form_text',[
								'label'=>'City',
								'id'=>'city',
								'old'=>'city',
								'name'=>'city',
								'value'=>$o->city ?? '',
							])
						</div>
					</div>

					<div class="row">
						<!-- State -->
						<div class="col-12 col-sm-9">
							@include('adminlte::widget.form_text',[
								'label'=>'State',
								'id'=>'state',
								'old'=>'state',
								'name'=>'state',
								'value'=>$o->state ?? '',
							])
						</div>

						<!-- Postal Code -->
						<div class="col-12 col-sm-3">
							@include('adminlte::widget.form_text',[
								'label'=>'Post Code',
								'id'=>'postcode',
								'old'=>'postcode',
								'name'=>'postcode',
								'value'=>$o->postcode ?? '',
							])
						</div>
					</div>
				</div>

				<div class="offset-1 col-4">
					<div class="row">
						<!-- Accounts Email -->
						<div class="col-12">
							@include('adminlte::widget.form_text',[
								'label'=>'Accounts Email',
								'id'=>'supplier_details.accounts',
								'old'=>'supplier_details.accounts',
								'name'=>'supplier_details[accounts]',
								'value'=>($o->detail ? $o->detail->accounts : ''),
							])
						</div>
					</div>

					<div class="row">
						<!-- Support Email -->
						<div class="col-12">
							@include('adminlte::widget.form_text',[
								'label'=>'Support Email',
								'id'=>'supplier_details.support',
								'old'=>'supplier_details.support',
								'name'=>'supplier_details[support]',
								'value'=>($o->detail ? $o->detail->support : ''),
							])
						</div>
					</div>

					<div class="row">
						<!-- Payment Details -->
						<div class="col-12">
							@include('adminlte::widget.form_text',[
								'label'=>'Payment Details',
								'id'=>'supplier_details.payments',
								'old'=>'supplier_details.payments',
								'name'=>'supplier_details[payments]',
								'value'=>($o->detail ? $o->detail->support : ''),
							])
						</div>
					</div>

					@if($o->api_class())
						<hr>
						<p class="h6"><i class="fa-fw fas fa-sitemap"></i> <strong>{{ $o->api_class() }}</strong></p>

						<div class="row">
							<!-- API Details -->
							<div class="col-12">
								@include('adminlte::widget.form_text',[
									'label'=>'API Key',
									'id'=>'api_key',
									'old'=>'api_key',
									'name'=>'api_key',
									'value'=>($o->detail ? Arr::get($o->detail->connections,'api_key') : ''),
								])
							</div>
						</div>

						<div class="row">
							<!-- API Details -->
							<div class="col-12">
								@include('adminlte::widget.form_text',[
									'label'=>'API Secret',
									'id'=>'api_secret',
									'old'=>'api_secret',
									'name'=>'api_secret',
									'value'=>($o->detail ? Arr::get($o->detail->connections,'api_secret') : ''),
								])
							</div>
						</div>
					@endif
				</div>
			</div>

			<div class="row">
				<!-- Notes -->
				<div class="col-12">
					<div class="form-group has-validation">
						<label for="notes">Notes</label>
						<textarea class="form-control @error('supplier_details.notes') is-invalid @enderror" id="notes" name="supplier_details[notes]" placeholder="Notes...">{{ old('supplier_details.notes',($o->detail ? $o->detail->notes : '')) }}</textarea>
						<span class="invalid-feedback" role="alert">
							@error('supplier_details.notes')
								{{ $message }}
							@enderror
						</span>
					</div>
				</div>
			</div>

			<div class="row">
				<!-- Buttons -->
				<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 ($o->exists)Save @else Add @endif</button>
					@endcan
				</div>
			</div>
		</form>
	</div>
</div>