241 lines
17 KiB
PHP
241 lines
17 KiB
PHP
@extends('layouts.app')
|
|
|
|
@section('content')
|
|
<link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css" rel="stylesheet" />
|
|
<script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
|
|
<script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"></script>
|
|
|
|
<style>
|
|
/* Styling Select2 Single (Materi/SOP) untuk Tailwind */
|
|
.select2-container .select2-selection--single { height: 42px; border-radius: 0.75rem; border-color: #e2e8f0; background-color: #f8fafc; }
|
|
.select2-container--default .select2-selection--single .select2-selection__rendered { line-height: 42px; font-size: 0.875rem; color: #334155; padding-left: 0.75rem; }
|
|
.select2-container--default .select2-selection--single .select2-selection__arrow { height: 40px; right: 10px; }
|
|
|
|
/* Styling Select2 Multiple (Pilih Karyawan Bulk) untuk Tailwind */
|
|
.select2-container--default .select2-selection--multiple { min-height: 44px; border-radius: 0.75rem; border-color: #e2e8f0; background-color: #f8fafc; padding: 4px 8px; }
|
|
.select2-container--default.select2-container--focus .select2-selection--multiple { border-color: #2563eb; ring: 2px; --tw-ring-color: rgba(37, 99, 235, 0.2); }
|
|
.select2-container--default .select2-selection--multiple .select2-selection__choice { bg-color: #eff6ff; border: 1px solid #bfdbfe; color: #1e40af; font-weight: 700; font-size: 0.75rem; border-radius: 0.5rem; padding: 2px 8px; margin-top: 4px; }
|
|
.select2-container--default .select2-selection--multiple .select2-selection__choice__remove { color: #3b82f6; margin-right: 6px; font-weight: bold; }
|
|
.select2-container--default .select2-selection--multiple .select2-selection__choice__remove:hover { color: #1d4ed8; }
|
|
|
|
/* Global Dropdown Search Field */
|
|
.select2-container--default .select2-search--dropdown .select2-search__field { border-radius: 0.5rem; border-color: #cbd5e1; outline: none; padding: 0.5rem; }
|
|
</style>
|
|
|
|
<div class="max-w-6xl mx-auto px-4 py-8"
|
|
x-data="{
|
|
trainingType: 'matrix_plant',
|
|
sops: [{ id: Date.now() }], // State untuk Dynamic Array
|
|
|
|
addSop() {
|
|
this.sops.push({ id: Date.now() });
|
|
// Panggil ulang Select2 untuk elemen yang baru dirender
|
|
setTimeout(() => { initDynamicSelect2(); }, 50);
|
|
},
|
|
removeSop(id) {
|
|
if(this.sops.length > 1) {
|
|
this.sops = this.sops.filter(sop => sop.id !== id);
|
|
}
|
|
}
|
|
}">
|
|
|
|
<div class="flex items-center space-x-3 mb-6">
|
|
<a href="{{ route('admin.exams.index') }}" class="text-slate-400 hover:text-blue-600 transition-colors">
|
|
<svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 19l-7-7m0 0l7-7m-7 7h18"></path></svg>
|
|
</a>
|
|
<div>
|
|
<h2 class="text-2xl font-bold text-slate-800 tracking-tight">Assign Training & Ujian Baru</h2>
|
|
<p class="text-sm text-slate-500">Tugaskan modul SOP ke dalam sesi Ujian (CBT).</p>
|
|
</div>
|
|
</div>
|
|
|
|
@if(session('info'))
|
|
<div class="mb-6 p-4 bg-blue-50 text-blue-700 rounded-xl border border-blue-100 text-sm font-bold flex items-center">
|
|
<svg class="w-5 h-5 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path></svg>
|
|
{{ session('info') }}
|
|
</div>
|
|
@endif
|
|
|
|
<form action="{{ route('admin.exams.store') }}" method="POST">
|
|
@csrf
|
|
|
|
<div class="bg-white p-6 rounded-2xl shadow-sm border border-slate-200 mb-6">
|
|
<label class="block text-base font-bold text-slate-800 mb-4">1. Pilih Jenis Training <span class="text-red-500">*</span></label>
|
|
<div class="grid grid-cols-1 md:grid-cols-3 gap-4">
|
|
<label class="flex items-center p-4 bg-slate-50 border rounded-xl cursor-pointer transition-all hover:bg-blue-50"
|
|
:class="trainingType === 'matrix_plant' ? 'border-blue-500 ring-2 ring-blue-500/20' : 'border-slate-200'">
|
|
<input type="radio" x-model="trainingType" name="training_type" value="matrix_plant" class="w-5 h-5 text-blue-600 focus:ring-blue-500">
|
|
<div class="ml-3">
|
|
<span class="block text-sm font-bold text-slate-800">Training Matrix (Plant)</span>
|
|
<span class="block text-xs text-slate-500 mt-0.5">SOP & Prosedur Teknis Pabrik</span>
|
|
</div>
|
|
</label>
|
|
|
|
<label class="flex items-center p-4 bg-slate-50 border rounded-xl cursor-pointer transition-all hover:bg-purple-50"
|
|
:class="trainingType === 'general' ? 'border-purple-500 ring-2 ring-purple-500/20' : 'border-slate-200'">
|
|
<input type="radio" x-model="trainingType" name="training_type" value="general" class="w-5 h-5 text-purple-600 focus:ring-purple-500">
|
|
<div class="ml-3">
|
|
<span class="block text-sm font-bold text-slate-800">General (Non-Plant / Produk)</span>
|
|
<span class="block text-xs text-slate-500 mt-0.5">Marketing, Sales, & Modul Umum</span>
|
|
</div>
|
|
</label>
|
|
|
|
<label class="flex items-center p-4 bg-slate-50 border rounded-xl cursor-pointer transition-all hover:bg-emerald-50"
|
|
:class="trainingType === 'external' ? 'border-emerald-500 ring-2 ring-emerald-500/20' : 'border-slate-200'">
|
|
<input type="radio" x-model="trainingType" name="training_type" value="external" class="w-5 h-5 text-emerald-600 focus:ring-emerald-500">
|
|
<div class="ml-3">
|
|
<span class="block text-sm font-bold text-slate-800">External Training</span>
|
|
<span class="block text-xs text-slate-500 mt-0.5">Pelatihan via Vendor / HR</span>
|
|
</div>
|
|
</label>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="bg-white p-6 rounded-2xl shadow-sm border border-slate-200 mb-6" x-show="trainingType !== 'external'">
|
|
<div class="flex flex-col sm:flex-row sm:justify-between sm:items-center mb-6">
|
|
<div>
|
|
<label class="block text-base font-bold text-slate-800">2. Konfigurasi Modul & Aturan CBT</label>
|
|
<p class="text-sm text-slate-500">Anda dapat menugaskan banyak SOP sekaligus dalam satu kali simpan.</p>
|
|
</div>
|
|
<button type="button" @click="addSop()" class="mt-3 sm:mt-0 px-4 py-2 bg-indigo-50 text-indigo-700 font-bold rounded-xl border border-indigo-100 hover:bg-indigo-100 transition-colors flex items-center shadow-sm">
|
|
<svg class="w-4 h-4 mr-1.5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4"></path></svg>
|
|
Tambah Modul SOP
|
|
</button>
|
|
</div>
|
|
|
|
<div class="space-y-5">
|
|
<template x-for="(sop, index) in sops" :key="sop.id">
|
|
<div class="p-5 bg-slate-50 border border-slate-200 rounded-xl relative hover:border-blue-300 transition-colors">
|
|
|
|
<button type="button" x-show="sops.length > 1" @click="removeSop(sop.id)" class="absolute top-4 right-4 p-1.5 text-slate-400 hover:text-red-500 hover:bg-red-50 rounded-lg transition-colors" title="Hapus Modul">
|
|
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"></path></svg>
|
|
</button>
|
|
|
|
<div class="flex items-center space-x-2 mb-4">
|
|
<span class="flex items-center justify-center w-6 h-6 rounded-full bg-slate-200 text-slate-600 text-xs font-bold" x-text="index + 1"></span>
|
|
<h4 class="text-sm font-bold text-slate-700" x-text="trainingType === 'matrix_plant' ? 'Dokumen SOP' : 'Subject / Modul'"></h4>
|
|
</div>
|
|
|
|
<div class="grid grid-cols-1 md:grid-cols-12 gap-5">
|
|
|
|
<div class="md:col-span-5">
|
|
<label class="block text-[11px] font-bold text-slate-500 uppercase tracking-wide mb-1.5">Pilih Materi <span class="text-red-500">*</span></label>
|
|
<select :name="'exams['+index+'][subject_id]'" required class="select2-dynamic w-full">
|
|
<option value="">-- Ketik untuk mencari materi/SOP --</option>
|
|
@foreach($subjects as $subject)
|
|
<option value="{{ $subject->id }}">{{ $subject->name }}</option>
|
|
@endforeach
|
|
</select>
|
|
</div>
|
|
|
|
<div class="md:col-span-7 md:pr-8">
|
|
<label class="block text-[11px] font-bold text-slate-500 uppercase tracking-wide mb-1.5">Nama Quiz Khusus (Opsional)</label>
|
|
<input type="text" :name="'exams['+index+'][title]'" class="w-full px-3 py-2 bg-white border border-slate-200 rounded-lg text-sm focus:ring-2 focus:ring-blue-500/20 focus:border-blue-500 transition-all" placeholder="Kosongkan jika ingin mengikuti nama materi...">
|
|
</div>
|
|
|
|
<div class="md:col-span-3">
|
|
<label class="block text-[11px] font-bold text-slate-500 uppercase tracking-wide mb-1.5">Durasi (Menit) <span class="text-red-500">*</span></label>
|
|
<input type="number" :name="'exams['+index+'][duration_minutes]'" value="60" min="1" required class="w-full px-3 py-2 bg-white border border-slate-200 rounded-lg text-sm focus:ring-2 focus:ring-blue-500/20 focus:border-blue-500 transition-all">
|
|
</div>
|
|
|
|
<div class="md:col-span-3">
|
|
<label class="block text-[11px] font-bold text-slate-500 uppercase tracking-wide mb-1.5">Nilai KKM <span class="text-red-500">*</span></label>
|
|
<div class="relative">
|
|
<input type="number" :name="'exams['+index+'][passing_grade]'" value="80" min="1" max="100" required class="w-full px-3 py-2 bg-white border border-slate-200 rounded-lg text-sm focus:ring-2 focus:ring-blue-500/20 focus:border-blue-500 transition-all">
|
|
<span class="absolute right-3 top-2.5 text-slate-400 text-xs font-bold">/ 100</span>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="md:col-span-6 md:pr-8">
|
|
<label class="block text-[11px] font-bold text-slate-500 uppercase tracking-wide mb-1.5">Jatah Remedial <span class="text-red-500">*</span></label>
|
|
<div class="flex items-center space-x-3">
|
|
<input type="number" :name="'exams['+index+'][max_retakes]'" value="1" min="0" required class="w-24 px-3 py-2 bg-white border border-slate-200 rounded-lg text-sm focus:ring-2 focus:ring-blue-500/20 focus:border-blue-500 transition-all">
|
|
<p class="text-[11px] leading-tight text-slate-500 font-medium">Kali. Jika melebihi jatah, <span class="text-red-500 font-bold">Ujian terkunci (Offline)</span>.</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
</div>
|
|
|
|
<div class="mt-6 pt-5 border-t border-slate-200">
|
|
<label class="flex items-center cursor-pointer p-3 bg-indigo-50/50 border border-indigo-100 rounded-xl hover:bg-indigo-50 transition-colors w-max">
|
|
<input type="checkbox" name="is_random_order" value="1" checked class="w-5 h-5 text-indigo-600 border-slate-300 rounded focus:ring-indigo-500">
|
|
<span class="ml-3 text-sm font-bold text-indigo-900">Acak Urutan Soal (Terapkan ke seluruh modul di atas)</span>
|
|
</label>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="bg-white p-6 rounded-2xl shadow-sm border border-slate-200 mb-6" x-show="trainingType !== 'external'">
|
|
<div class="mb-4 border-b border-slate-100 pb-4">
|
|
<label class="block text-base font-bold text-slate-800">3. Pilih Peserta & Deadline Pelatihan</label>
|
|
<p class="text-sm text-slate-500">Karyawan yang dipilih akan langsung menerima seluruh modul di atas pada dashboard mereka.</p>
|
|
</div>
|
|
|
|
<div class="grid grid-cols-1 md:grid-cols-3 gap-6">
|
|
<div class="md:col-span-2">
|
|
<label class="block text-[11px] font-bold text-slate-500 uppercase tracking-wide mb-2">Pilih Karyawan Pelatihan (Bisa Bulk / Banyak) <span class="text-red-500">*</span></label>
|
|
<select name="employee_ids[]" id="employeeSelect" multiple="multiple" class="w-full" required>
|
|
@foreach($employees as $emp)
|
|
<option value="{{ $emp->id }}">
|
|
{{ $emp->first_name }} {{ $emp->last_name }} - {{ $emp->nik ?? 'No NIK' }} ({{ $emp->position->name ?? '-' }})
|
|
</option>
|
|
@endforeach
|
|
</select>
|
|
</div>
|
|
|
|
<div>
|
|
<label class="block text-[11px] font-bold text-slate-500 uppercase tracking-wide mb-2">Batas Akhir Penyelesaian (Deadline) <span class="text-red-500">*</span></label>
|
|
<input type="datetime-local" name="deadline_date" required class="w-full px-4 py-2 bg-white border border-slate-200 rounded-xl text-sm focus:ring-2 focus:ring-blue-500/20 focus:border-blue-500 transition-all" style="height: 44px;">
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div x-show="trainingType === 'external'" x-cloak class="bg-white p-10 rounded-2xl shadow-sm border border-slate-200 mb-6 text-center">
|
|
<div class="w-20 h-20 bg-emerald-50 rounded-full flex items-center justify-center mx-auto mb-4 border border-emerald-100">
|
|
<svg class="w-10 h-10 text-emerald-500" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 21V5a2 2 0 00-2-2H7a2 2 0 00-2 2v16m14 0h2m-2 0h-5m-9 0H3m2 0h5M9 7h1m-1 4h1m4-4h1m-1 4h1m-5 10v-5a1 1 0 011-1h2a1 1 0 011 1v5m-4 0h4"></path></svg>
|
|
</div>
|
|
<h3 class="text-xl font-bold text-slate-800 mb-2">Modul External Training Segera Hadir</h3>
|
|
<p class="text-slate-500 max-w-lg mx-auto">Sistem sedang menyiapkan integrasi dengan Database Vendor Pelatihan dari HRD (Mencakup Nama Vendor, Kategori Kompetensi, Sertifikat, dan JPL).</p>
|
|
</div>
|
|
|
|
<div class="flex justify-end space-x-3">
|
|
<a href="{{ route('admin.exams.index') }}" class="px-6 py-3 text-sm font-bold text-slate-600 hover:bg-slate-200 bg-slate-100 rounded-xl transition-colors">Batal</a>
|
|
<button type="submit" class="px-8 py-3 text-sm font-bold text-white bg-blue-600 hover:bg-blue-700 rounded-xl shadow-md transition-all transform hover:-translate-y-0.5">
|
|
Simpan & Distribusikan Training
|
|
</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
|
|
<script>
|
|
function initDynamicSelect2() {
|
|
$('.select2-dynamic').each(function() {
|
|
if ($(this).hasClass("select2-hidden-accessible")) {
|
|
$(this).select2('destroy');
|
|
}
|
|
});
|
|
|
|
$('.select2-dynamic').select2({
|
|
placeholder: "-- Ketik untuk mencari materi/SOP --",
|
|
width: '100%',
|
|
allowClear: true
|
|
});
|
|
}
|
|
|
|
$(document).ready(function() {
|
|
// Inisialisasi awal dropdown dinamis SOP
|
|
initDynamicSelect2();
|
|
|
|
// Inisialisasi dropdown multiple karyawan bulk
|
|
$('#employeeSelect').select2({
|
|
placeholder: "Ketik nama atau NIK karyawan...",
|
|
allowClear: true,
|
|
width: '100%',
|
|
language: {
|
|
noResults: function() { return "Karyawan tidak ditemukan"; }
|
|
}
|
|
});
|
|
});
|
|
</script>
|
|
@endsection |