@extends('backend.layout.main')

@section('content')
@if(session()->has('not_permitted'))
    <div class="alert alert-danger alert-dismissible text-center">
        <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        {{session()->get('not_permitted')}}
    </div>
@endif

<section class="forms">
    <div class="container-fluid">
        <div class="card">
            <div class="card-header d-flex flex-wrap align-items-center justify-content-between">
                <div>
                    <h4 class="mb-1">Update Customer</h4>
                    <small class="text-muted">Edit the customer’s contact information.</small>
                </div>
                <a href="{{route('customer.index')}}" class="btn btn-outline-secondary mt-2 mt-md-0">Back to Customers</a>
            </div>
            <div class="card-body">
                {!! Form::open(['route' => ['customer.update', $lims_customer_data->id], 'method' => 'put']) !!}
                <div class="row">
                    <div class="col-md-6">
                        <div class="form-group">
                            <label>{{trans('file.name')}} *</label>
                            <input type="text" name="customer_name" value="{{old('customer_name', $lims_customer_data->name)}}" required class="form-control">
                            @error('customer_name') <span class="text-danger">{{$message}}</span> @enderror
                        </div>
                    </div>
                    <div class="col-md-6">
                        <div class="form-group">
                            <label>{{trans('file.Email')}}</label>
                            <input type="email" name="email" value="{{old('email', $lims_customer_data->email)}}" placeholder="example@example.com" class="form-control">
                            @error('email') <span class="text-danger">{{$message}}</span> @enderror
                        </div>
                    </div>
                    <div class="col-md-6">
                        <div class="form-group">
                            <label>{{trans('file.Phone Number')}} *</label>
                            <input type="text" name="phone_number" value="{{old('phone_number', $lims_customer_data->phone_number)}}" required class="form-control">
                            @error('phone_number') <span class="text-danger">{{$message}}</span> @enderror
                        </div>
                    </div>
                    <div class="col-md-6">
                        <div class="form-group">
                            <label>{{trans('file.Address')}} *</label>
                            <input type="text" name="address" value="{{old('address', $lims_customer_data->address)}}" required class="form-control">
                            @error('address') <span class="text-danger">{{$message}}</span> @enderror
                        </div>
                    </div>
                    <div class="col-md-12 mt-2">
                        <button type="submit" class="btn btn-primary">Save Changes</button>
                        <a href="{{route('customer.index')}}" class="btn btn-link">Cancel</a>
                    </div>
                </div>
                {!! Form::close() !!}
            </div>
        </div>
    </div>
</section>
@endsection

@push('scripts')
<script type="text/javascript">
    $("ul#people").siblings('a').attr('aria-expanded', 'true');
    $("ul#people").addClass("show");
    $("ul#people #customer-list-menu").addClass("active");
</script>
@endpush
