<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta content="width=device-width, initial-scale=1.0" name="viewport">

    <title>Form J-Classify Tracer Study MIF</title>
    <meta content="" name="description">
    <meta content="" name="keywords">

    <!-- Favicons -->
    <link href="{{ asset('assets/img/favicon.png') }}" rel="icon">
    <link href="{{ asset('assets/img/apple-touch-icon.png') }}" rel="apple-touch-icon">

    <!-- Google Fonts -->
    <link href="https://fonts.gstatic.com" rel="preconnect">
    <link
        href="https://fonts.googleapis.com/css?family=Open+Sans:300,300i,400,400i,600,600i,700,700i|Nunito:300,300i,400,400i,600,600i,700,700i|Poppins:300,300i,400,400i,500,500i,600,600i,700,700i"
        rel="stylesheet">

    <!-- Tambahkan ini di bagian <head> atau sebelum penutup </body> -->
    <script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>

    <!-- Vendor CSS Files -->
    <link href="{{ asset('assets/vendor/bootstrap/css/bootstrap.min.css') }}" rel="stylesheet">
    <link href="{{ asset('assets/vendor/bootstrap-icons/bootstrap-icons.css') }}" rel="stylesheet">
    <link href="{{ asset('assets/vendor/boxicons/css/boxicons.min.css') }}" rel="stylesheet">
    <link href="{{ asset('assets/vendor/quill/quill.snow.css') }}" rel="stylesheet">
    <link href="{{ asset('assets/vendor/quill/quill.bubble.css') }}" rel="stylesheet">
    <link href="{{ asset('assets/vendor/remixicon/remixicon.css') }}" rel="stylesheet">
    <link href="{{ asset('assets/vendor/simple-datatables/style.css') }}" rel="stylesheet">

    <!-- Template Main CSS File -->
    <link href="{{ asset('assets/css/style.css') }}" rel="stylesheet">
</head>

<body>

    <!-- ======= Header ======= -->
    @include('header')
    <!-- ======= Sidebar ======= -->
    @include('sidebar')

    <main id="main" class="main">
        <div class="pagetitle">
            <h1>Form Alumni</h1>
            <nav>
                <ol class="breadcrumb">
                    <li class="breadcrumb-item"><a href="index.html">Home</a></li>
                    <li class="breadcrumb-item">Form Alumni</li>
                </ol>
            </nav>
        </div><!-- End Page Title -->

        <section class="section">
            <div class="row">
                <div class="col-lg-12">
                    <div class="card">
                        <div class="card-body">
                            <h5 class="card-title">Data Alumni</h5>

                            <!-- Alerts for success or error messages -->
                            @if(session('success'))
                            <div class="alert alert-success alert-dismissible fade show" role="alert">
                                {{ session('success') }}
                                <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
                            </div>
                            @endif

                            @if(session('error'))
                            <div class="alert alert-danger alert-dismissible fade show" role="alert">
                                {{ session('error') }}
                                <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
                            </div>
                            @endif

                            <!-- Form Start -->
                            @if($dataAlumni)
                                <form action="{{ route('formalumni.update', $dataAlumni->id_alumni) }}" method="POST">
                                @csrf
                                @method('PUT')
                            @else
                                <form action="{{ route('form_alumni.store') }}" method="POST">
                                @csrf
                            @endif
                                <div class="row">
                                    <!-- Kolom Kiri -->
                                    <div class="col-md-6">
                                        <div class="mb-3">
                                            <label for="nama" class="form-label">Nama</label>
                                            <input type="text" class="form-control" id="nama" name="nama"
                                                value="{{ session('name') }}" readonly required>
                                        </div>
                                        <div class="mb-3">
                                            <label for="nim" class="form-label">NIM</label>
                                            <input type="text" class="form-control" id="nim" name="nim"
                                                value="{{ session('username') }}" readonly required>
                                        </div>

                                        <div class="mb-3">
                                            <label for="angkatan" class="form-label">Angkatan</label>
                                            @if(isset($dataAlumni))
                                            <input type="hidden" name="angkatan" value="{{ $dataAlumni->angkatan }}">
                                            <select class="form-select" disabled>
                                                @foreach ($angkatans as $angkatan)
                                                    <option value="{{ $angkatan->id_angkatan }}" {{ $dataAlumni->angkatan == $angkatan->id_angkatan ? 'selected' : '' }}>
                                                        {{ $angkatan->tahun }}
                                                    </option>
                                                @endforeach
                                            </select>
                                            @else
                                            <select class="form-select" id="angkatan" name="angkatan" required>
                                                <option value="" disabled selected>Pilih Angkatan</option>
                                                @foreach ($angkatans as $angkatan)
                                                    <option value="{{ $angkatan->id_angkatan }}">{{ $angkatan->tahun }}</option>
                                                @endforeach
                                            </select>
                                            @endif
                                        </div>

                                        <div class="mb-3">
                                            <label for="masa_tunggu" class="form-label">Masa Tunggu (bulan)</label>
                                            <input type="number" class="form-control" id="masa_tunggu"
                                                name="masa_tunggu" value="{{ $dataAlumni->masa_tunggu ?? '' }}">
                                        </div>
                                        <div class="mb-3">
                                            <label for="pekerjaan" class="form-label">Pekerjaan</label>
                                            <input type="text" class="form-control" id="pekerjaan"
                                                name="pekerjaan" value="{{ $dataAlumni->pekerjaan ?? '' }}">
                                        </div>
                                        <div class="mb-3">
                                            <label for="instansi" class="form-label">Instansi</label>
                                            <input type="text" class="form-control" id="instansi"
                                                name="instansi" value="{{ $dataAlumni->instansi ?? '' }}">
                                        </div>
                                    </div>

                                    <!-- Kolom Kanan -->
                                    <div class="col-md-6">
                                        <div class="mb-3">
                                            <label for="link_linkedin" class="form-label">Link LinkedIn</label>
                                            <input type="text" class="form-control" id="link_linkedin"
                                                name="link_linkedin" value="{{ $dataAlumni->link_linkedin ?? '' }}">
                                        </div>
                                        <div class="mb-3">
                                            <label for="Jenis_profesi" class="form-label">Profesi Inforkom</label>
                                            <select class="form-select" id="Jenis_profesi" name="Jenis_profesi" required>
                                                <option value="" disabled selected>Pilih Profesi</option>
                                                @foreach (['Programmer', 'Data Analyst', 'Wirausaha', 'Non IT', 'Tidak diketahui', 'Tidak bekerja', 'Pelajar', 'Wirausaha IT', 'Infokom'] as $profesi)
                                                    <option value="{{ $profesi }}" {{ (isset($dataAlumni) && $dataAlumni->Jenis_profesi == $profesi) ? 'selected' : '' }}>
                                                        {{ $profesi }}
                                                    </option>
                                                @endforeach
                                            </select>
                                        </div>
                                        <div class="mb-3">
                                            <label for="lingkup_pekerjaan" class="form-label">Lingkup Pekerjaan</label>
                                            <select class="form-select" id="lingkup_pekerjaan" name="lingkup_pekerjaan" required>
                                                <option value="" disabled selected>Pilih Lingkup Pekerjaan</option>
                                                @foreach (['Nasional', 'Internasional', 'Wirausaha'] as $lingkup)
                                                    <option value="{{ $lingkup }}" {{ (isset($dataAlumni) && $dataAlumni->lingkup_pekerjaan == $lingkup) ? 'selected' : '' }}>
                                                        {{ $lingkup }}
                                                    </option>
                                                @endforeach
                                            </select>
                                        </div>
                                        {{-- ubah --}}
                                        <div class="mb-3">
                                            <label for="kualifikasi_bidang_kerja" class="form-label">Kualifikasi Bidang Kerja</label>
                                            <select class="form-select" id="kualifikasi_bidang_kerja"
                                                name="kualifikasi_bidang_kerja" required>
                                                <option value="" selected disabled>Pilih Kualifikasi</option>
                                                @foreach ($kualifikasis as $kualifikasi)
                                                    <option value="{{ $kualifikasi->id_kualifikasi }}"
                                                        {{ (isset($dataAlumni) && $dataAlumni->kualifikasi_bidang_kerja == $kualifikasi->id_kualifikasi) ? 'selected' : '' }}>
                                                        {{ $kualifikasi->kualifikasi_bidang }}
                                                    </option>
                                                @endforeach
                                            </select>
                                        </div>
                                        {{-- ubah --}}
                                        <div class="mb-3">
                                            <label for="id_kategori" class="form-label">Kelompok Jabatan</label>
                                            <select class="form-select" id="id_kategori" name="jabatan" required>
                                                <option value="" selected disabled>Pilih Jabatan</option>
                                                @foreach ($jabatans as $jabatan)
                                                    <option value="{{ $jabatan->id_kategori }}"
                                                        {{ (isset($dataAlumni) && $dataAlumni->jabatan == $jabatan->id_kategori) ? 'selected' : '' }}>
                                                        {{ $jabatan->Kategori_bidang_kerja }}
                                                    </option>
                                                @endforeach
                                            </select>
                                        </div>
                                    </div>
                                </div>

                                <div class="mt-4 d-flex justify-content-end">
                                    <button type="submit" class="btn btn-primary">
                                        {{ isset($dataAlumni) ? 'Perbarui Data' : 'Simpan Data' }}
                                    </button>
                                </div>
                            </form>
                            <!-- Form End -->

                        </div>
                    </div>
                </div>
            </div>
        </section>


    </main><!-- End #main -->


    <!-- ======= Footer ======= -->
    @include('footer')

    <a href="#" class="back-to-top d-flex align-items-center justify-content-center"><i
            class="bi bi-arrow-up-short"></i></a>

    <!-- Vendor JS Files -->
    <script src="{{ asset('assets/vendor/apexcharts/apexcharts.min.js') }}"></script>
    <script src="{{ asset('assets/vendor/bootstrap/js/bootstrap.bundle.min.js') }}"></script>
    <script src="{{ asset('assets/vendor/chart.js/chart.umd.js') }}"></script>
    <script src="{{ asset('assets/vendor/echarts/echarts.min.js') }}"></script>
    <script src="{{ asset('assets/vendor/quill/quill.js') }}"></script>
    <script src="{{ asset('assets/vendor/simple-datatables/simple-datatables.js') }}"></script>
    <script src="{{ asset('assets/vendor/tinymce/tinymce.min.js') }}"></script>
    <script src="{{ asset('assets/vendor/php-email-form/validate.js') }}"></script>
    <!-- Template Main JS File -->
    <script src="{{ asset('assets/js/main.js') }}"></script>

    <!-- Display success/error messages with SweetAlert -->
    @if(session('success'))
    <script>
        Swal.fire({
            icon: 'success',
            title: 'Berhasil!',
            text: "{{ session('success') }}",
            showConfirmButton: true
        });
    </script>
    @endif

    @if(session('error'))
    <script>
        Swal.fire({
            icon: 'error',
            title: 'Error!',
            text: "{{ session('error') }}",
            showConfirmButton: true
        });
    </script>
    @endif
</body>

</html>
