@extends('employee.layouts.app')
@section('title', 'Perbarui Karier | Career Development and Consultation (CDC)')
@section('navigation')
    <h1 class="my-1 d-flex align-items-center text-dark fw-bolder fs-3">Karier
        <span class="mx-2 border-gray-200 h-20px border-start ms-3"></span>
        <small class="my-1 text-muted fs-7 fw-bold ms-1">Perbarui Karier</small>
    </h1>
@endsection
@section('content')
    <div class="card">
        <div class="pt-4 border card-body">
            <form action="{{ route('careers.update', $careers) }}" method="POST" class="form" autocomplete="off"
                enctype="multipart/form-data">
                @csrf
                @method('PUT')
                <div class="pt-4 mb-4 d-flex flex-column fv-row">
                    <label class="mb-2 d-flex align-items-center fs-6 fw-bold">
                        <span class="required">Gambar Ilustrasi</span>
                        <i class="fas fa-exclamation-circle ms-2 fs-7" data-bs-toggle="tooltip"
                            title="Ilustasi gambar yang merepresentasikan tipe kepribadian"></i>
                    </label>
                    <div class="col-lg-8">
                        <div class="image-input image-input-outline" data-kt-image-input="true"
                            style="background-image: url({{ $careers->image_url ? asset('storage/illustrations/' . $careers->image_url) : asset('assets/employee/media/avatars/blank.png') }})">
                            <div class="image-input-wrapper w-150px h-150px"
                                style="background-image: url({{ $careers->image_url ? asset('storage/illustrations/' . $careers->image_url) : asset('assets/employee/media/avatars/blank.png') }})">
                            </div>
                            <label class="shadow btn btn-icon btn-circle btn-active-color-primary w-25px h-25px bg-body"
                                data-kt-image-input-action="change" data-bs-toggle="tooltip" title="Unggah gambar">
                                <i class="bi bi-pencil-fill fs-7"></i>
                                <input type="file" name="image_url" accept=".png, .jpg, .jpeg" />
                                <input type="hidden" name="avatar_remove" />
                            </label>
                            <span class="shadow btn btn-icon btn-circle btn-active-color-primary w-25px h-25px bg-body"
                                data-kt-image-input-action="cancel" data-bs-toggle="tooltip" title="Batal">
                                <i class="bi bi-x fs-2"></i>
                            </span>
                        </div>
                        <div class="form-text">Format gambar: png, jpg, jpeg dan tidak lebih dari 2 MB.</div>
                        @error('image_url')
                            <div class="fv-plugins-message-container invalid-feedback">
                                <span>{{ $message }}</span>
                            </div>
                        @enderror
                    </div>
                </div>
                <div class="pt-4 mb-8 d-flex flex-column fv-row">
                    <label class="mb-2 d-flex align-items-center fs-6 fw-bold">
                        <span class="required">Kode</span>
                        <i class="fas fa-exclamation-circle ms-2 fs-7" data-bs-toggle="tooltip"
                            title="Kode karier dibuat secara otomatis"></i>
                    </label>
                    <input type="text" class="form-control form-control-solid" placeholder="Kode" name="career_code"
                        value="{{ old('career_code', $careers->career_code) }}" />
                    @error('career_code')
                        <div class="fv-plugins-message-container invalid-feedback">
                            <span>{{ $message }}</span>
                        </div>
                    @enderror
                </div>
                <div class="pt-4 mb-8 d-flex flex-column fv-row">
                    <label class="mb-2 d-flex align-items-center fs-6 fw-bold">
                        <span class="required">Judul Karier</span>
                        <i class="fas fa-exclamation-circle ms-2 fs-7" data-bs-toggle="tooltip"
                            title="Nama profesi/karier"></i>
                    </label>
                    <input type="text" class="form-control form-control-solid" placeholder="Contoh: Data Analyst"
                        name="career_title" value="{{ old('career_title', $careers->career_title) }}" />
                    @error('career_title')
                        <div class="fv-plugins-message-container invalid-feedback">
                            <span>{{ $message }}</span>
                        </div>
                    @enderror
                </div>
                <div class="mb-8 d-flex flex-column fv-row">
                    <label class="mb-2 d-flex align-items-center fs-6 fw-bold">
                        <span class="required">Jurusan</span>
                        <i class="fas fa-exclamation-circle ms-2 fs-7" data-bs-toggle="tooltip"
                            title="Nama departemen/jurusan (Dapat lebih dari 1)"></i>
                    </label>
                    <select class="form-select form-select-solid" data-control="select2"
                        data-placeholder="Contoh: Teknologi Informasi" data-allow-clear="true" multiple="multiple"
                        name="departments[]">
                        @foreach ($departments as $department)
                            <option value="{{ $department->id }}"
                                {{ in_array($department->id, $selectedDepartmentIds) ? 'selected' : '' }}>
                                {{ $department->department_name }}
                            </option>
                        @endforeach
                    </select>
                    @error('careers')
                        <div class="fv-plugins-message-container invalid-feedback">
                            <span>{{ $message }}</span>
                        </div>
                    @enderror
                </div>
                <div class="mb-8 d-flex flex-column">
                    <label class="mb-2 d-flex align-items-center fs-6 fw-bold">
                        <span class="required">Tipe Karier</span>
                        <i class="fas fa-exclamation-circle ms-2 fs-7" data-bs-toggle="tooltip"
                            title="Tipe karier spesifik/umum"></i>
                    </label>
                    <select class="form-select form-select-solid" data-control="select2" data-placeholder="Tipe Karier"
                        data-allow-clear="true" name="is_specific">
                        <option value=""></option>
                        <option value="0" {{ old('is_specific', $careers->is_specific) == '0' ? 'selected' : '' }}>
                            Karier
                            Umum</option>
                        <option value="1" {{ old('is_specific', $careers->is_specific) == '1' ? 'selected' : '' }}>
                            Karier Spesifik</option>
                    </select>
                    @error('is_specific')
                        <div class="fv-plugins-message-container invalid-feedback">
                            <span>{{ $message }}</span>
                        </div>
                    @enderror
                </div>
                <div class="mb-8 d-flex flex-column">
                    <label class="mb-2 d-flex align-items-center fs-6 fw-bold">
                        <span class="required">Deskripsi Karier</span>
                        <i class="fas fa-exclamation-circle ms-2 fs-7" data-bs-toggle="tooltip"
                            title="Deskripsi profesi/karier secara lengkap"></i>
                    </label>
                    <textarea class="form-control form-control-solid" id="kt_docs_ckeditor_classic" name="career_description">{{ old('career_description', $careers->career_description) }}</textarea>
                    @error('career_description')
                        <div class="fv-plugins-message-container invalid-feedback">
                            <span>{{ $message }}</span>
                        </div>
                    @enderror
                </div>
                <div class="d-flex justify-content-end">
                    <a href="{{ route('careers') }}" class="btn btn-light btn-active-light-primary me-2">Kembali</a>
                    <button type="submit" class="btn btn-primary">Simpan Perubahan</button>
                </div>
            </form>
        </div>
    </div>
@endsection
@push('scripts')
    <script src="{{ asset('assets/employee/plugins/custom/ckeditor/ckeditor-classic.bundle.js') }}"></script>
    <script>
        ClassicEditor.create(document.querySelector('#kt_docs_ckeditor_classic'))
    </script>
@endpush
