@extends('layouts.master')
@section('content')
    <div class="az-content-breadcrumb">
        <span>Employees list</span>
        <span>Edit Employees</span>
        {{-- <span>Forms</span> --}}
        {{-- <span>Form Layouts</span> --}}
    </div>
    <h2 class="az-content-title" style="display: inline">Edit Employees <span>
        {{-- <a href="{{ url('employee') }}"
                class="btn btn-az-primary" style="float: right">Employees List</a> --}}

                <a href="{{ url('employee') }}" class="btn border" style="float: right"><i
                    class="fa-solid fa-bars-staggered"></i>
                Back to Employees
            </a>

            </span></h2>
    {{-- <h2 style="float: right" class="az-content-title"></h2> --}}
    {{-- <div class="az-content-body pd-lg-l-40 d-flex flex-column"> --}}
    <div class="row">
        <div class="col-md-12 col-lg-12 col-xl-12">
            <div class="card card-body pd-40">
                <h5 class="card-title mg-b-20">Edit Employees Details</h5>
                <form id="myForm" method="POST" action="{{ url('employee/update/' . \Crypt::encrypt($edit->id_employee)) }}">
                    @csrf
                    @if (count($errors) > 0)
                        <div class="p-1">
                            @foreach ($errors->all() as $error)
                                <div class="alert alert-warning alert-danger fade show" role="alert">{{ $error }}
                                    <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                                        <span aria-hidden="true">&times;</span>
                                    </button>
                                </div>
                            @endforeach
                        </div>
                    @endif
                    <div class="row row-sm mg-b-20">
                        <div class="col-md-4">
                            <div class="form-group">
                                <label class="az-content-label tx-11 tx-medium tx-gray-600">Employee Name</label>
                                <input type="text" value="{{ $edit->employee_name }}" name="employee_name"
                                    class="form-control" required />
                            </div>
                        </div>
                        <div class="col-md-4">
                            <div class="form-group">
                                <label class="az-content-label tx-11 tx-medium tx-gray-600">Employee Number</label>
                                <input type="text" value="{{ $edit->employee_no }}" name="employee_no"
                                    class="form-control" required />
                            </div>
                        </div>

                        <div class="col-md-4">
                            <div class="form-group">
                                <label class="az-content-label tx-11 tx-medium tx-gray-600">Employee Email</label>
                                <input type="text" value="{{ $edit->employee_email }}" name="employee_email"
                                    class="form-control" required />
                            </div>
                        </div>


                    </div>

                    <div class="row row-sm mg-b-20">
                        <div class="col-md-6">
                            <div class="form-group">
                                <label class="az-content-label tx-11 tx-medium tx-gray-600">Employee Address</label>
                                <input type="text"  value="{{ $edit->employee_address }}" name="employee_address" class="form-control" required />
                            </div>
                        </div>
                        <div class="col-md-6">
                            <label class="az-content-label tx-11 tx-medium tx-gray-600">Phone 1</label>
                            <input type="text" value="{{ $edit->employee_phone1 }}"  name="phone_1" class="form-control" required />
                        </div>
                    </div>
                    <div class="row row-sm mg-b-20">
                        <div class="col-md-6">
                            <label class="az-content-label tx-11 tx-medium tx-gray-600">Phone 2</label>
                            <input type="text" value="{{ $edit->employee_phone2 }}" name="phone_2" class="form-control" required />

                        </div>

                        <div class="col-md-6">
                            <label class="az-content-label tx-11 tx-medium tx-gray-600">Departments</label>
                            <select class="form-control" value="{{ $edit->department_id }}" name="department" id="department">
                                <option value="1" {{ $edit->department_id == 1 ? 'selected' : '' }}>Administrator</option>
                                <option value="0" {{ $edit->department_id == 0 ? 'selected' : '' }}>Head</option>
                            </select>
                        </div>
                    </div>
                    <div class="row row-sm mg-b-20">
                        <div class="col-md-6">
                            <label class="az-content-label tx-11 tx-medium tx-gray-600">City</label>
                            <select class="form-control"  value="{{ $edit->city_id }}" name="city" id="city">
                                <option value="1" {{ $edit->city_id == 1 ? 'selected' : '' }}>Karachi</option>
                                <option value="0" {{ $edit->city_id == 0 ? 'selected' : '' }}>Hydeabad</option>
                            </select>

                        </div>

                        {{-- <div class="col-md-4">
                            <label class="az-content-label tx-11 tx-medium tx-gray-600">Employee Type</label>
                            <select class="form-control" value="{{ $edit->emp_type }}" name="employee_type" id="employee_type">
                                <option value="1" {{ $edit->emp_type == 1 ? 'selected' : '' }}>Other</option>
                                <option value="0" {{ $edit->emp_type == 0 ? 'selected' : '' }}>SalesMan</option>
                                <option value="" {{ $edit->emp_type == 1 ? 'selected' : '' }}>Trainer</option>
                            </select>
                        </div> --}}
                        <div class="col-md-6">
                            <label class="az-content-label tx-11 tx-medium tx-gray-600">Status</label>
                            <select class="form-control" name="status" id="status">
                                <option value="1" {{ $edit->status == 1 ? 'selected' : '' }}>Active</option>
                                <option value="0" {{ $edit->status == 0 ? 'selected' : '' }}>In Active</option>
                            </select>
                        </div>
                    </div>

                    <a type="button" href="{{ url('/employee') }}" class="btn btn-danger btn-block mt-2">
                        Cancel
                    </a>
                    <button type="submit" class="btn btn-az-primary btn-block mt-2" style="float: right">
                        Update
                    </button>
                </form>
            </div>
            <!-- card -->
        </div>
        <!-- col -->
    </div>






    {{-- </div><!-- az-content-body --> --}}
@endsection
@push('scripts')
    <script>
        document.addEventListener('keydown', function(event) {
            if ((event.ctrlKey || event.metaKey) && event.key === 's') {
                event.preventDefault();

                document.getElementById('myForm').submit();
            }

            if (event.key === 'Enter') {
                event.preventDefault();
            }
        });
    </script>
@endpush
