@extends('layouts.pengguna')
@section('title', 'SPK Penerimaan karyawan ')
@section('topbar', 'Pengajuan Lamaran')
@section('css')
<link href="{{ asset('vendor/datatables/dataTables.bootstrap4.min.css') }}" rel="stylesheet">
<style>
    .form-section {
        margin-bottom: 30px;
    }
    .section-title {
        border-bottom: 2px solid #4e73df;
        padding-bottom: 10px;
        margin-bottom: 20px;
        color: #4e73df;
    }
</style>
@stop
@section('content')

<div class="container-fluid">
    <div class="card shadow mb-4">
        <div class="card-header py-3">
            <h6 class="m-0 font-weight-bold text-primary">Form Pengajuan Lamaran</h6>
        </div>
        <div class="card-body">
            @if (Session::has('msg'))
            <div class="alert alert-info alert-dismissible fade show" role="alert">
                <strong>Info</strong> {{ Session::get('msg') }}
                <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            @endif

            <form action="{{ route('alternatif.store') }}" method="post" enctype="multipart/form-data">
                @csrf
                
                <!-- Data Pribadi -->
                <div class="form-section">
                    <h5 class="section-title">Data Pribadi</h5>
                    <div class="row">
                        <div class="col-md-6">
                            <div class="form-group">
                                <label for="nama_alternatif">Nama Lengkap <span class="text-danger">*</span></label>
                                <input type="text" class="form-control @error('nama_alternatif') is-invalid @enderror" 
                                    name="nama_alternatif" value="{{ old('nama_alternatif') }}">
                                @error('nama_alternatif')
                                    <div class="invalid-feedback">{{ $message }}</div>
                                @enderror
                            </div>

                            <div class="form-group">
                                <label for="usia">Usia <span class="text-danger">*</span></label>
                                <input type="number" class="form-control @error('usia') is-invalid @enderror" 
                                    name="usia" value="{{ old('usia') }}">
                                @error('usia')
                                    <div class="invalid-feedback">{{ $message }}</div>
                                @enderror
                            </div>
                        </div>
                    </div>
                </div>

                <!-- Pendidikan -->
                <div class="form-section">
                    <h5 class="section-title">Pendidikan</h5>
                    <div class="row">
                        <div class="col-md-6">
                            <div class="form-group">
                                <label for="pendidikan">Pendidikan Terakhir <span class="text-danger">*</span></label>
                                <select name="pendidikan" class="form-control @error('pendidikan') is-invalid @enderror">
                                    <option value="">-- Pilih Pendidikan --</option>
                                    <option value="D3" {{ old('pendidikan') == 'D3' ? 'selected' : '' }}>D3</option>
                                    <option value="S1" {{ old('pendidikan') == 'S1' ? 'selected' : '' }}>S1</option>
                                </select>
                                @error('pendidikan')
                                    <div class="invalid-feedback">{{ $message }}</div>
                                @enderror
                            </div>

                            <div class="form-group">
                                <label for="ipk">IPK <span class="text-danger">*</span></label>
                                <input type="number" step="0.01" name="ipk" 
                                    class="form-control @error('ipk') is-invalid @enderror" 
                                    value="{{ old('ipk') }}">
                                @error('ipk')
                                    <div class="invalid-feedback">{{ $message }}</div>
                                @enderror
                            </div>

                            <div class="form-group">
                                <label for="jurusan">Jurusan <span class="text-danger">*</span></label>
                                <input type="text" name="jurusan" 
                                    class="form-control @error('jurusan') is-invalid @enderror" 
                                    value="{{ old('jurusan') }}">
                                @error('jurusan')
                                    <div class="invalid-feedback">{{ $message }}</div>
                                @enderror
                            </div>

                            <div class="form-group">
                                <label for="lama_studi">Lama Studi (tahun) <span class="text-danger">*</span></label>
                                <input type="number" name="lama_studi" min="0" max="10" step="1"
                                    class="form-control @error('lama_studi') is-invalid @enderror" 
                                    value="{{ old('lama_studi') }}">
                                @error('lama_studi')
                                    <div class="invalid-feedback">{{ $message }}</div>
                                @enderror
                            </div>
                        </div>
                    </div>
                </div>

                <!-- Pengalaman & Sertifikasi -->
                <div class="form-section">
                    <h5 class="section-title">Pengalaman & Upload Sertifikat Kompetensi</h5>
                    <div class="row">
                        <div class="col-md-6">
                            <div class="form-group">
                                <label for="pengalaman">Pengalaman Kerja (tahun) <span class="text-danger">*</span></label>
                                <input type="number" name="pengalaman" 
                                    class="form-control @error('pengalaman') is-invalid @enderror" 
                                    value="{{ old('pengalaman') }}">
                                @error('pengalaman')
                                    <div class="invalid-feedback">{{ $message }}</div>
                                @enderror
                            </div>

                            <div class="form-group">
                                <label for="serkom">Sertifikasi Kompetensi <span class="text-danger">*</span></label>
                                <select name="serkom" class="form-control @error('serkom') is-invalid @enderror">
                                    <option value="">-- Pilih --</option>
                                    <option value="1" {{ old('serkom') == '1' ? 'selected' : '' }}>Punya</option>
                                    <option value="0" {{ old('serkom') == '0' ? 'selected' : '' }}>Tidak Punya</option>
                                </select>
                                @error('serkom')
                                    <div class="invalid-feedback">{{ $message }}</div>
                                @enderror
                            </div>

                            <!-- Upload Dokumen -->
                            <div class="form-section">
                                <h5 class="section-title">Upload Dokumen</h5>
                                <div class="row">
                                    <div class="col-md-6">
                                        <div class="form-group">
                                            <label for="cv">Upload CV (PDF/DOC) <span class="text-danger">*</span></label>
                                            <input type="file" name="cv" accept=".pdf,.doc,.docx"
                                                class="form-control-file @error('cv') is-invalid @enderror">
                                            @error('cv')
                                                <div class="invalid-feedback d-block">{{ $message }}</div>
                                            @enderror
                                        </div>

                                        <div class="form-group">
                                            <label for="dokumen_pendukung">Dokumen Pendukung Lainnya (Opsional)</label>
                                            <input type="file" name="dokumen_pendukung[]" accept=".pdf,.doc,.docx,.jpg,.png"
                                                multiple class="form-control-file @error('dokumen_pendukung') is-invalid @enderror">
                                            @error('dokumen_pendukung')
                                                <div class="invalid-feedback d-block">{{ $message }}</div>
                                            @enderror
                                        </div>
                                    </div>
                                </div>
                            </div>

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

                <div class="form-group">
                    <button type="submit" class="btn btn-primary btn-block">
                        <i class="fas fa-paper-plane mr-2"></i>Submit Lamaran
                    </button>
                </div>
            </form>
        </div>
    </div>
</div>

@stop
@section('js')
<script src="{{ asset('vendor/datatables/jquery.dataTables.min.js') }}"></script>
<script src="{{ asset('vendor/datatables/dataTables.bootstrap4.min.js') }}"></script>
<script src="{{ asset('js/sweetalert.js')}}"></script>
@stop