@use(App\Models\Checkout)

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

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

@section('contentheader_title')
	Payment
@endsection
@section('contentheader_description')
@endsection

@section('main-content')
	<div class="row">
		<div class="col-12">
			<div class="card card-dark">
				<div class="card-header">
					<h1 class="card-title">Payment Configuration</h1>
				</div>

				<div class="card-body">
					<div class="row">
						<div class="col-12 col-lg-4">
							<x-leenooks::form.select id="checkout_id" name="checkout_id" icon="fa-credit-card" label="Payment Name" feedback="Payment Name is required" addnew="New Payment" groupby="active" :options="Checkout::orderBy('active','DESC')->orderBy('name')->get()->map(fn($item)=>['id'=>$item->id,'value'=>$item->name])"/>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
@endsection

@pa(select2,autofocus)

@section('page-scripts')
	<script type="text/javascript">
		$(document).ready(function() {
			$('#checkout_id').select2()
				.on('change',function(item) {
					if (! item.target.value)
						return false;

					window.location.href = '{{ url('a/checkout') }}'+(item.target.value ? '/'+item.target.value : '');
				});
		});
	</script>
@append