feat(auth): set default employee password to 123456 and sync employee profile in super admin

This commit is contained in:
Ray1111-aa
2026-10-22 09:28:19 +07:00
parent 8e23cffed8
commit ceea61048c
7 changed files with 226 additions and 18 deletions
+107 -1
View File
@@ -218,7 +218,13 @@
@endif
<div>
<p class="font-bold text-slate-900 text-xs">{{ $user->name }}</p>
<p class="text-[11px] text-slate-400 font-mono">@<span>{{ $user->username }}</span></p>
<div class="flex items-center gap-1.5 text-[11px] text-slate-400">
<span class="font-mono">@<span>{{ $user->username }}</span></span>
@if($user->employee && ($user->employee->position || $user->employee->unit_kerja))
<span>&bull;</span>
<span class="text-slate-500 font-medium">{{ $user->employee->position ?: $user->employee->unit_kerja }}</span>
@endif
</div>
</div>
</div>
</td>
@@ -349,6 +355,51 @@
</select>
</div>
<!-- Section: Data Profil Karyawan & Penugasan (Selaras Master HSE) -->
<div class="pt-3 border-t border-slate-100 space-y-3">
<div class="flex items-center justify-between">
<label class="text-xs font-bold text-slate-700 flex items-center gap-1.5">
<i class="fa-solid fa-id-badge text-indigo-600"></i>
<span>Data Profil Karyawan & Penugasan</span>
</label>
<span class="text-[10px] text-slate-400 font-medium">(Opsional)</span>
</div>
<div class="grid grid-cols-2 gap-3">
<div>
<label class="block text-[11px] font-semibold text-slate-600 mb-1">Unit Kerja</label>
<select name="unit_kerja" class="w-full px-3 py-2 bg-slate-50 border border-slate-200 rounded-xl text-xs focus:ring-2 focus:ring-indigo-500 focus:bg-white text-slate-700">
<option value="">-- Pilih Unit Kerja --</option>
<option value="Pembangkit">Pembangkit</option>
<option value="Bendungan">Bendungan</option>
<option value="Teknik">Teknik</option>
<option value="Umum">Umum</option>
<option value="Logistik">Logistik</option>
<option value="HSE">HSE</option>
<option value="QMA">QMA</option>
</select>
</div>
<div>
<label class="block text-[11px] font-semibold text-slate-600 mb-1">Divisi</label>
<input type="text" name="division" class="w-full px-3 py-2 bg-slate-50 border border-slate-200 rounded-xl text-xs focus:ring-2 focus:ring-indigo-500 focus:bg-white text-slate-700" placeholder="Contoh: Operasi / Keuangan">
</div>
</div>
<div class="grid grid-cols-2 gap-3">
<div>
<label class="block text-[11px] font-semibold text-slate-600 mb-1">Posisi / Jabatan</label>
<input type="text" name="position" class="w-full px-3 py-2 bg-slate-50 border border-slate-200 rounded-xl text-xs focus:ring-2 focus:ring-indigo-500 focus:bg-white text-slate-700" placeholder="Contoh: Driver / Staff Finance">
</div>
<div>
<label class="block text-[11px] font-semibold text-slate-600 mb-1">Operator / Driver</label>
<select name="is_operator" class="w-full px-3 py-2 bg-slate-50 border border-slate-200 rounded-xl text-xs focus:ring-2 focus:ring-indigo-500 focus:bg-white text-slate-700">
<option value="0">TIDAK (Bukan Driver)</option>
<option value="1">YA (Aktif Mengemudi)</option>
</select>
</div>
</div>
</div>
<div class="pt-4 border-t border-slate-100 flex items-center justify-end gap-2.5">
<button type="button" onclick="closeCreateUserModal()" class="px-4 py-2 bg-slate-100 hover:bg-slate-200 text-slate-600 rounded-xl text-xs font-bold transition">
Batal
@@ -430,6 +481,51 @@
</select>
</div>
<!-- Section: Data Profil Karyawan & Penugasan (Selaras Master HSE) -->
<div class="pt-3 border-t border-slate-100 space-y-3">
<div class="flex items-center justify-between">
<label class="text-xs font-bold text-slate-700 flex items-center gap-1.5">
<i class="fa-solid fa-id-badge text-indigo-600"></i>
<span>Data Profil Karyawan & Penugasan</span>
</label>
<span class="text-[10px] text-slate-400 font-medium">(Opsional)</span>
</div>
<div class="grid grid-cols-2 gap-3">
<div>
<label class="block text-[11px] font-semibold text-slate-600 mb-1">Unit Kerja</label>
<select id="edit_unit_kerja" name="unit_kerja" class="w-full px-3 py-2 bg-slate-50 border border-slate-200 rounded-xl text-xs focus:ring-2 focus:ring-indigo-500 focus:bg-white text-slate-700">
<option value="">-- Pilih Unit Kerja --</option>
<option value="Pembangkit">Pembangkit</option>
<option value="Bendungan">Bendungan</option>
<option value="Teknik">Teknik</option>
<option value="Umum">Umum</option>
<option value="Logistik">Logistik</option>
<option value="HSE">HSE</option>
<option value="QMA">QMA</option>
</select>
</div>
<div>
<label class="block text-[11px] font-semibold text-slate-600 mb-1">Divisi</label>
<input type="text" id="edit_division" name="division" class="w-full px-3 py-2 bg-slate-50 border border-slate-200 rounded-xl text-xs focus:ring-2 focus:ring-indigo-500 focus:bg-white text-slate-700" placeholder="Contoh: Operasi / Keuangan">
</div>
</div>
<div class="grid grid-cols-2 gap-3">
<div>
<label class="block text-[11px] font-semibold text-slate-600 mb-1">Posisi / Jabatan</label>
<input type="text" id="edit_position" name="position" class="w-full px-3 py-2 bg-slate-50 border border-slate-200 rounded-xl text-xs focus:ring-2 focus:ring-indigo-500 focus:bg-white text-slate-700" placeholder="Contoh: Driver / Staff Finance">
</div>
<div>
<label class="block text-[11px] font-semibold text-slate-600 mb-1">Operator / Driver</label>
<select id="edit_is_operator" name="is_operator" class="w-full px-3 py-2 bg-slate-50 border border-slate-200 rounded-xl text-xs focus:ring-2 focus:ring-indigo-500 focus:bg-white text-slate-700">
<option value="0">TIDAK (Bukan Driver)</option>
<option value="1">YA (Aktif Mengemudi)</option>
</select>
</div>
</div>
</div>
<!-- Accordion: Izin Tambahan Khusus (Direct Permissions) -->
<div class="border border-slate-200 rounded-xl overflow-hidden bg-slate-50/50">
<button type="button"
@@ -674,6 +770,16 @@
const editGateEl = document.getElementById('edit_gate_id');
if (editGateEl) editGateEl.value = user.gate_id || '';
const emp = user.employee || {};
const editUnitKerja = document.getElementById('edit_unit_kerja');
if (editUnitKerja) editUnitKerja.value = emp.unit_kerja || '';
const editDivision = document.getElementById('edit_division');
if (editDivision) editDivision.value = emp.division || '';
const editPosition = document.getElementById('edit_position');
if (editPosition) editPosition.value = emp.position || '';
const editIsOperator = document.getElementById('edit_is_operator');
if (editIsOperator) editIsOperator.value = (emp.is_operator ? '1' : '0');
const editPhotoPreview = document.getElementById('editUserPhotoPreview');
const editPhotoPlaceholder = document.getElementById('editUserPhotoPlaceholder');
const editPhotoInput = document.getElementById('editUserPhotoInput');
@@ -287,6 +287,13 @@
<form action="{{ route('hse.employees.store') }}" method="POST" enctype="multipart/form-data" class="mt-5 space-y-4">
@csrf
<div class="p-3 rounded-2xl bg-emerald-50/70 border border-emerald-100 flex items-start gap-2.5">
<i class="fa-solid fa-circle-info text-emerald-600 text-xs mt-0.5"></i>
<div class="text-[11px] text-emerald-900 leading-relaxed">
Akun login karyawan otomatis dibuatkan dengan <strong>Username NIK</strong> dan <strong>Password default: 123456</strong> (Role: Karyawan).
</div>
</div>
<div>
<label class="block text-xs font-bold text-slate-800 mb-1.5">Foto Profil Karyawan (Opsional)</label>
<div class="flex items-center space-x-3.5 p-3 rounded-2xl border border-slate-200 bg-slate-50/50">
@@ -408,6 +415,13 @@
</a>
</div>
<div class="mt-3.5 p-3 rounded-2xl bg-slate-50 border border-slate-100 flex items-start gap-2.5">
<i class="fa-solid fa-shield-halved text-emerald-600 text-xs mt-0.5"></i>
<div class="text-[11px] text-slate-600 leading-relaxed">
Setiap data karyawan yang diimpor otomatis dibuatkan akun login sistem dengan <strong>Username NIK</strong>, <strong>Role Karyawan</strong>, dan <strong>Password default: 123456</strong>.
</div>
</div>
<form action="{{ route('hse.employees.import') }}" method="POST" enctype="multipart/form-data" class="mt-4 space-y-4">
@csrf