Sync SOP ke e-doc Plant & Add Subject dan penyempurnaan bagian matrix training karyawan

This commit is contained in:
Iwit
2026-06-04 19:01:17 +07:00
parent 91c0a8147f
commit 1089f60a3d
26 changed files with 1241 additions and 155 deletions
@@ -20,6 +20,16 @@
<h2 class="text-2xl font-bold text-slate-800 tracking-tight">Edit Data Karyawan</h2>
</div>
@if ($errors->any())
<div class="mb-6 p-4 bg-red-50 text-red-700 rounded-xl border border-red-100 text-sm font-bold">
<ul class="list-disc pl-5">
@foreach ($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
</div>
@endif
<div class="bg-white rounded-2xl shadow-sm border border-slate-200 overflow-hidden">
<form action="{{ route('admin.employees.update', $employee->id) }}" method="POST" enctype="multipart/form-data" class="p-6 sm:p-8 space-y-6">
@csrf
@@ -85,7 +95,7 @@
<label class="block text-sm font-bold text-slate-700 mb-2">Posisi / Jabatan <span class="text-red-500">*</span></label>
<select name="position_id" id="posSelect" class="select2 w-full text-sm" required>
<option value="">-- Pilih Jabatan --</option>
</select>
</select>
</div>
<div class="bg-slate-50 p-4 border border-slate-200 rounded-xl">
@@ -114,13 +124,82 @@
</div>
<div class="border-t border-slate-100 pt-6 mt-6">
<label class="block text-sm font-bold text-slate-700 mb-2">Modul SOP Training (Marketing)</label>
<select name="training_matrix_id" class="select2 w-full text-sm">
<option value="">-- Kosongkan jika bukan marketing --</option>
@foreach($trainingMatrices as $matrix)
<option value="{{ $matrix->id }}" {{ old('training_matrix_id', $employee->training_matrix_id) == $matrix->id ? 'selected' : '' }}>{{ $matrix->title ?? $matrix->name }}</option>
@endforeach
</select>
<h3 class="text-sm font-bold text-slate-700 mb-1">Materi SOP / Training Matrix</h3>
<p class="text-xs text-slate-500 mb-4">Perbarui materi dan status pelatihan untuk karyawan ini.</p>
<div class="bg-slate-50 border border-slate-200 rounded-xl p-4 max-h-[400px] overflow-y-auto">
<table class="w-full text-left text-sm text-slate-600">
<thead class="border-b border-slate-200 text-slate-500 uppercase text-xs sticky top-0 bg-slate-50">
<tr>
<th class="py-2 w-12 text-center">Pilih</th>
<th class="py-2">Nama Materi / Dokumen SOP</th>
<th class="py-2 w-48 text-center">Status Training</th>
</tr>
</thead>
<tbody class="divide-y divide-slate-200">
@foreach($subjects as $subject)
@php
$hasTraining = $employee->trainings->contains('id', $subject->id);
$currentStatus = $hasTraining ? $employee->trainings->find($subject->id)->pivot->status : 'belum_training';
@endphp
<tr class="hover:bg-white transition-colors">
<td class="py-3 text-center">
<input type="checkbox" name="trainings[{{ $subject->id }}][selected]" value="1"
{{ $hasTraining ? 'checked' : '' }}
class="w-5 h-5 text-blue-600 rounded border-slate-300 focus:ring-blue-500 cursor-pointer">
</td>
<td class="py-3 font-bold text-slate-700">{{ $subject->name }}</td>
<td class="py-3">
<select name="trainings[{{ $subject->id }}][status]" class="w-full px-3 py-1.5 bg-white border border-slate-300 rounded-lg text-xs font-bold focus:ring-blue-500">
<option value="belum_training" class="text-amber-600" {{ $currentStatus == 'belum_training' ? 'selected' : '' }}>Belum Training</option>
<option value="passed" class="text-emerald-600" {{ $currentStatus == 'passed' ? 'selected' : '' }}>Lulus (Passed)</option>
</select>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
<div class="mt-8 pt-6 border-t border-slate-200">
<h3 class="text-lg font-bold text-slate-800 mb-2">Training Matrix & Kompetensi</h3>
<p class="text-sm text-slate-500 mb-4">Pilih materi/SOP wajib untuk karyawan ini dan perbarui status pelatihannya.</p>
<div class="bg-slate-50 border border-slate-200 rounded-xl p-4 max-h-[400px] overflow-y-auto">
<table class="w-full text-left text-sm text-slate-600">
<thead class="border-b border-slate-200 text-slate-500 uppercase text-xs sticky top-0 bg-slate-50">
<tr>
<th class="py-2 w-12 text-center">Pilih</th>
<th class="py-2">Nama Materi / Dokumen SOP</th>
<th class="py-2 w-48 text-center">Status Training</th>
</tr>
</thead>
<tbody class="divide-y divide-slate-200">
@foreach($subjects as $subject)
@php
// Mengecek apakah relasi dengan pivot sudah ada di database
$hasTraining = $employee->trainings->contains('id', $subject->id);
$currentStatus = $hasTraining ? $employee->trainings->find($subject->id)->pivot->status : 'belum_training';
@endphp
<tr class="hover:bg-white transition-colors">
<td class="py-3 text-center">
<input type="checkbox" name="trainings[{{ $subject->id }}][selected]" value="1"
{{ $hasTraining ? 'checked' : '' }}
class="w-5 h-5 text-blue-600 rounded border-slate-300 focus:ring-blue-500 cursor-pointer">
</td>
<td class="py-3 font-bold text-slate-700">{{ $subject->name }}</td>
<td class="py-3">
<select name="trainings[{{ $subject->id }}][status]" class="w-full px-3 py-1.5 bg-white border border-slate-300 rounded-lg text-xs font-bold focus:ring-blue-500">
<option value="belum_training" class="text-amber-600" {{ $currentStatus == 'belum_training' ? 'selected' : '' }}>Belum Training</option>
<option value="passed" class="text-emerald-600" {{ $currentStatus == 'passed' ? 'selected' : '' }}>Lulus (Passed)</option>
</select>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
<div class="border-t border-slate-100 pt-6 mt-6">
@@ -140,7 +219,6 @@
$(document).ready(function() {
$('.select2').select2({ width: '100%' });
// Logika Dropdown Bertingkat untuk Edit (Sama dengan Create)
const mapping = @json($deptPosMapping ?? []);
const posSelect = $('#posSelect');
const deptSelect = $('#deptSelect');