Files

297 lines
22 KiB
HTML

{% extends 'base.html' %}
{% block page_title %}Detail Karyawan{% endblock %}
{% block content %}
<div class="mb-6 flex flex-col sm:flex-row sm:justify-between sm:items-center items-start space-y-4 sm:space-y-0">
<div>
<p class="text-xs font-bold text-kerinci uppercase tracking-widest mb-1">Detail Karyawan</p>
<div class="flex items-center space-x-3">
<h2 class="text-3xl font-extrabold text-gray-900">{{ employee.name }}</h2>
<button onclick="openGuideModal()" class="w-5 h-5 rounded-full bg-gray-200 text-gray-600 hover:bg-kerinci hover:text-white flex items-center justify-center text-xs font-extrabold transition-colors shadow-sm shrink-0" title="Panduan Halaman">!</button>
</div>
<p class="text-gray-500 mt-1 font-medium">NIK: {{ employee.nik }} <span class="mx-2">&bull;</span> Jabatan: {{ employee.position|default:"-" }}</p>
</div>
<div class="flex flex-wrap sm:flex-nowrap items-center gap-3 w-full sm:w-auto">
<a href="{% url 'employee_list' %}" class="bg-white border border-gray-200 rounded-xl shadow-sm px-4 py-2 text-sm font-bold text-gray-700 hover:bg-gray-50 hover:text-kerinci transition-colors flex items-center space-x-2 justify-center text-center w-full sm:w-auto flex-1 sm:flex-none">
<svg class="w-4 h-4 text-gray-500" 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>
<span>Kembali</span>
</a>
<div class="relative inline-block w-full sm:w-auto flex-1 sm:flex-none">
<button onclick="var d = document.getElementById('exportMenuEmployeeDetail'); d.style.display = d.style.display === 'block' ? 'none' : 'block'; event.stopPropagation();" class="w-full border border-kerinci text-kerinci rounded-xl px-4 py-2 text-sm font-bold hover:bg-kerinci/10 transition-colors flex items-center space-x-2 justify-center">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 10v6m0 0l-3-3m3 3l3-3m2 8H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"></path></svg>
<span>Ekspor Data</span>
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7"></path></svg>
</button>
<div id="exportMenuEmployeeDetail" style="display: none;" class="absolute right-0 mt-2 w-48 bg-white rounded-xl shadow-[0_8px_30px_rgb(0,0,0,0.12)] border border-gray-100 z-50">
<a href="{% url 'employee_detail_export_pdf' employee.id %}" target="_blank" class="flex items-center px-4 py-3 text-sm text-gray-700 hover:bg-gray-50 hover:text-kerinci rounded-t-xl font-bold transition-colors">
<svg class="w-4 h-4 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg>
Format PDF
</a>
<div class="h-px bg-gray-100 mx-2"></div>
<a href="{% url 'employee_detail_export_excel' employee.id %}" class="flex items-center px-4 py-3 text-sm text-green-600 hover:bg-green-50 rounded-b-xl font-bold transition-colors">
<svg class="w-4 h-4 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 17v-2m3 2v-4m3 4v-6m2 10H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"></path></svg>
Format Excel (.xlsx)
</a>
</div>
</div>
</div>
</div>
<div class="bg-white rounded-none sm:rounded-2xl shadow-sm border border-gray-100 overflow-hidden">
<div class="p-5 border-b border-gray-100 bg-gray-50/50 flex justify-between items-center">
<h3 class="font-bold text-gray-800">Aset Yang Digunakan Saat Ini</h3>
<span class="bg-kerinci text-white px-3 py-1 rounded-full text-xs font-bold shadow-sm">{{ units|length }} Aset</span>
</div>
<div class="overflow-x-auto">
<table class="w-full text-left border-collapse">
<thead>
<tr class="bg-[#002060] text-white text-[11px] uppercase tracking-widest border-b border-[#002060]">
<th class="p-4 font-bold text-center w-16">No</th>
<th class="p-4 font-bold w-40">Kode Unit</th>
<th class="p-4 font-bold">Nama Aset</th>
<th class="p-4 font-bold text-center w-32">Status</th>
<th class="p-4 font-bold text-center w-40">Riwayat Unit</th>
</tr>
</thead>
<tbody class="text-sm divide-y divide-gray-50">
{% for unit in units %}
<tr class="hover:bg-gray-50/50 transition-colors">
<td class="p-4 text-center text-gray-500">{{ forloop.counter }}</td>
<td class="p-4">
<a href="{% url 'unit_history' unit.id %}" class="font-bold text-gray-900 hover:text-kerinci transition-colors inline-block w-max">{{ unit.unit_code }}</a>
</td>
<td class="p-4">
<a href="{% url 'asset_units' unit.asset.id %}" class="block group w-max">
<p class="font-bold text-gray-800 transition-colors group-hover:text-kerinci">{{ unit.asset.name }}</p>
</a>
</td>
<td class="p-4 text-center">
<button onclick="openStatusModal('{{ unit.id }}', '{{ unit.unit_code }}', '{{ unit.status }}', '{% if unit.assigned_to %}{{ unit.assigned_to.name|escapejs }}{% endif %}', '{{ unit.asset.category.name|escapejs }}', '{{ unit.area|default_if_none:""|escapejs }}', '{{ unit.location|default_if_none:""|escapejs }}')" class="hover:opacity-80 transition-opacity focus:outline-none focus:ring-2 focus:ring-kerinci focus:ring-offset-1 rounded-md" title="Klik untuk ubah status">
{% if unit.status == 'tersedia' %}
<span style="display:inline-flex;align-items:center;gap:4px;" class="bg-emerald-50 border border-emerald-200 text-emerald-700 hover:bg-emerald-100 transition-colors px-2.5 py-1 rounded-md text-[10px] font-extrabold uppercase tracking-wider">Tersedia <svg width="10" height="10" fill="none" stroke="currentColor" viewBox="0 0 24 24" style="opacity:0.7;flex-shrink:0;"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15.232 5.232l3.536 3.536m-2.036-5.036a2.5 2.5 0 113.536 3.536L6.5 21.036H3v-3.572L16.732 3.732z"></path></svg></span>
{% elif unit.status == 'digunakan' %}
<span style="display:inline-flex;align-items:center;gap:4px;" class="bg-blue-50 border border-blue-200 text-blue-700 hover:bg-blue-100 transition-colors px-2.5 py-1 rounded-md text-[10px] font-extrabold uppercase tracking-wider">Digunakan <svg width="10" height="10" fill="none" stroke="currentColor" viewBox="0 0 24 24" style="opacity:0.7;flex-shrink:0;"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15.232 5.232l3.536 3.536m-2.036-5.036a2.5 2.5 0 113.536 3.536L6.5 21.036H3v-3.572L16.732 3.732z"></path></svg></span>
{% elif unit.status == 'rusak' %}
<span style="display:inline-flex;align-items:center;gap:4px;" class="bg-red-50 border border-red-200 text-red-700 hover:bg-red-100 transition-colors px-2.5 py-1 rounded-md text-[10px] font-extrabold uppercase tracking-wider">Maintenance <svg width="10" height="10" fill="none" stroke="currentColor" viewBox="0 0 24 24" style="opacity:0.7;flex-shrink:0;"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15.232 5.232l3.536 3.536m-2.036-5.036a2.5 2.5 0 113.536 3.536L6.5 21.036H3v-3.572L16.732 3.732z"></path></svg></span>
{% else %}
<span style="display:inline-flex;align-items:center;gap:4px;" class="bg-gray-50 border border-gray-200 text-gray-600 hover:bg-gray-100 transition-colors px-2.5 py-1 rounded-md text-[10px] font-extrabold uppercase tracking-wider">{{ unit.get_status_display }} <svg width="10" height="10" fill="none" stroke="currentColor" viewBox="0 0 24 24" style="opacity:0.7;flex-shrink:0;"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15.232 5.232l3.536 3.536m-2.036-5.036a2.5 2.5 0 113.536 3.536L6.5 21.036H3v-3.572L16.732 3.732z"></path></svg></span>
{% endif %}
</button>
</td>
<td class="p-4 text-center">
<a href="{% url 'unit_history' unit.id %}" class="inline-flex items-center justify-center p-2 text-kerinci hover:bg-kerinci-light rounded-xl transition-colors" title="Riwayat Unit">
<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="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"></path></svg>
</a>
</td>
</tr>
{% empty %}
<tr>
<td colspan="5" class="p-12 text-center text-gray-400">
<div class="flex flex-col items-center justify-center space-y-3">
<svg class="w-12 h-12 text-gray-200" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M20 7l-8-4-8 4m16 0l-8 4m8-4v10l-8 4m0-10L4 7m8 4v10M4 7v10l8 4"></path></svg>
<p class="text-sm font-medium">Karyawan ini tidak memegang aset apapun saat ini.</p>
</div>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
<div id="statusUnitModal" class="fixed inset-0 z-50 hidden flex items-center justify-center">
<div class="absolute inset-0 bg-gray-900/40 backdrop-blur-sm" onclick="closeStatusUnitModal()"></div>
<div class="bg-white rounded-2xl shadow-2xl w-11/12 max-w-md relative mx-auto z-10 p-6">
<h3 class="text-xl font-bold text-gray-900 mb-4">Update Status Unit</h3>
<p class="text-sm text-gray-500 mb-1">Kode Unit: <strong id="su_code" class="text-gray-900"></strong></p>
<p id="su_assigned_info" class="text-sm text-gray-500 mb-4 hidden">Dipegang Oleh: <strong id="su_assigned_name" class="text-gray-900"></strong></p>
<form id="statusUnitForm" method="POST" class="space-y-4">
{% csrf_token %}
<div>
<label class="block text-sm font-bold text-gray-700 mb-1">Status Baru</label>
<select id="su_status" name="status" class="w-full px-4 py-2 rounded-lg border border-gray-200 text-sm focus:outline-none focus:border-kerinci focus:ring-1 focus:ring-kerinci bg-gray-50">
<option value="tersedia" id="opt_su_tersedia">Tersedia</option>
<option value="digunakan" id="opt_su_digunakan" class="hidden" disabled>Digunakan</option>
<option value="rusak">Diperbaiki (Rusak / Maintenance)</option>
</select>
<p id="su_bast_warning" class="text-xs text-amber-600 mt-1 hidden font-bold">* Aset sedang digunakan. Pengembalian atau Mutasi harus melalui menu Distribusi Aset.</p>
</div>
<div id="su_notes_container" class="hidden">
<label class="block text-sm font-bold text-gray-700 mb-1">Catatan Kejadian <span class="text-red-500">*</span></label>
<textarea id="su_notes" name="notes" rows="2" class="w-full px-4 py-2 rounded-lg border border-gray-200 text-sm focus:outline-none focus:border-kerinci focus:ring-1 focus:ring-kerinci bg-gray-50" placeholder="Jelaskan alasan perbaikan / keluhan kerusakan..."></textarea>
</div>
<div id="su_network_fields" class="hidden space-y-4 pt-4 border-t border-gray-100 mt-4">
<p class="text-xs font-bold text-gray-500 uppercase">Detail Lokasi Pemasangan</p>
<div>
<label class="block text-sm font-bold text-gray-700 mb-1">Area <span class="text-red-500">*</span></label>
<select id="su_area" name="area" class="w-full px-4 py-2 rounded-lg border border-gray-200 text-sm focus:outline-none focus:border-kerinci focus:ring-1 focus:ring-kerinci bg-gray-50">
<option value="">-- Pilih Area --</option>
<option value="Regulating Weir (RW)">Regulating Weir (RW)</option>
<option value="Jakon">Jakon</option>
<option value="Beringin Tunggal (BT)">Beringin Tunggal (BT)</option>
<option value="DAM">DAM</option>
<option value="Adit 1">Adit 1</option>
<option value="Adit 2">Adit 2</option>
<option value="Adit 3">Adit 3</option>
<option value="Gudang Induk (GI)">Gudang Induk (GI)</option>
<option value="Vertical Shaft (VS)">Vertical Shaft (VS)</option>
<option value="Power House (PH)">Power House (PH)</option>
<option value="Lain-lainnya">Lain-lainnya</option>
</select>
</div>
<div>
<label class="block text-sm font-bold text-gray-700 mb-1">Lokasi Spesifik <span class="text-red-500">*</span></label>
<input type="text" id="su_location" name="location" class="w-full px-4 py-2 rounded-lg border border-gray-200 text-sm focus:outline-none focus:border-kerinci focus:ring-1 focus:ring-kerinci bg-gray-50" placeholder="Misal: Dinding server room barat...">
</div>
</div>
<div class="mt-6 flex justify-end space-x-3 pt-4 border-t border-gray-100">
<button type="button" onclick="closeStatusUnitModal()" class="px-4 py-2 border border-gray-300 text-gray-700 font-bold rounded-lg text-sm hover:bg-gray-50 transition-colors">Batal</button>
<button type="submit" class="px-4 py-2 bg-kerinci text-white font-bold rounded-lg text-sm shadow-sm hover:bg-kerinci/90 transition-colors">
Simpan Status
</button>
</div>
</form>
</div>
</div>
<script>
function openStatusModal(id, fullCode, status, assignedTo, categoryName, area, location) {
document.getElementById('statusUnitForm').action = '/unit/' + id + '/status/';
document.getElementById('su_code').innerText = fullCode;
const assignedInfo = document.getElementById('su_assigned_info');
const assignedName = document.getElementById('su_assigned_name');
if (assignedTo && assignedTo !== 'None' && assignedTo !== '' && assignedTo !== 'true') {
assignedName.innerText = assignedTo;
assignedInfo.classList.remove('hidden');
} else {
assignedInfo.classList.add('hidden');
}
const statSelect = document.getElementById('su_status');
const optTersedia = document.getElementById('opt_su_tersedia');
const optDigunakan = document.getElementById('opt_su_digunakan');
const warnText = document.getElementById('su_bast_warning');
const netFields = document.getElementById('su_network_fields');
const areaInput = document.getElementById('su_area');
const locInput = document.getElementById('su_location');
netFields.classList.add('hidden');
areaInput.required = false;
locInput.required = false;
areaInput.value = area && area !== 'None' ? area : '';
locInput.value = location && location !== 'None' ? location : '';
const isNetwork = categoryName && categoryName.includes('Network');
if (assignedTo && assignedTo !== 'None' && assignedTo !== '') {
optDigunakan.disabled = false;
optDigunakan.classList.remove('hidden');
optTersedia.disabled = true;
optTersedia.classList.add('hidden');
warnText.classList.remove('hidden');
let empName = assignedTo === 'true' ? 'karyawan' : assignedTo;
warnText.innerHTML = '* Aset sedang digunakan oleh <strong class="font-extrabold underline">' + empName + '</strong>. Pengembalian harus melalui menu Distribusi Aset.';
} else if (isNetwork) {
optDigunakan.disabled = false;
optDigunakan.classList.remove('hidden');
optTersedia.disabled = false;
optTersedia.classList.remove('hidden');
warnText.classList.add('hidden');
} else {
optDigunakan.disabled = true;
optDigunakan.classList.add('hidden');
optTersedia.disabled = false;
optTersedia.classList.remove('hidden');
warnText.classList.add('hidden');
}
statSelect.value = status;
statSelect.onchange = function() {
const notesContainer = document.getElementById('su_notes_container');
const notesInput = document.getElementById('su_notes');
if (this.value === 'rusak') {
notesContainer.classList.remove('hidden');
notesInput.required = true;
} else {
notesContainer.classList.add('hidden');
notesInput.required = false;
}
if ((this.value === 'digunakan' || this.value === 'rusak') && isNetwork) {
netFields.classList.remove('hidden');
areaInput.required = true;
locInput.required = true;
} else {
netFields.classList.add('hidden');
areaInput.required = false;
locInput.required = false;
}
};
statSelect.onchange();
document.getElementById('statusUnitModal').classList.remove('hidden');
}
function closeStatusUnitModal() {
document.getElementById('statusUnitModal').classList.add('hidden');
}
</script>
{% endblock %}
{% block page_title_guide %}Profil & Aset Karyawan{% endblock %}
{% block page_guide_content %}
<div class="space-y-4">
<p>Halaman <strong>Detail Karyawan</strong> adalah profil personal tiap karyawan yang merangkum segala perangkat IT yang saat ini sedang menjadi tanggung jawab mereka. Di halaman ini Anda dapat:</p>
<div class="space-y-3">
<div class="flex items-start space-x-3 bg-gray-50 p-4 rounded-xl border border-gray-100">
<div class="mt-0.5 text-kerinci bg-kerinci-light rounded p-1 shrink-0">
<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="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg>
</div>
<div>
<h4 class="font-bold text-gray-900 mb-1">Mengecek Aset yang Ditahan</h4>
<p>Tabel menampilkan secara spesifik unit aset apa saja (beserta kodenya) yang statusnya sedang <strong>Digunakan</strong> oleh karyawan bersangkutan saat ini.</p>
</div>
</div>
<div class="flex items-start space-x-3 bg-gray-50 p-4 rounded-xl border border-gray-100">
<div class="mt-0.5 text-amber-500 bg-amber-50 rounded p-1 shrink-0">
<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="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path></svg>
</div>
<div>
<h4 class="font-bold text-gray-900 mb-1">Informasi Penarikan / Pengembalian</h4>
<p>Apabila Anda ingin menarik perangkat dari karyawan ini (misal karena mereka resign atau ganti perangkat), Anda harus melakukannya melalui menu <strong>Distribusi Aset &gt; Tambah Baru &gt; Pilih Pengembalian</strong>. Anda tidak dapat langsung menghapusnya dari sini demi menjaga integritas rekaman jejak (log).</p>
</div>
</div>
<div class="flex items-start space-x-3 bg-gray-50 p-4 rounded-xl border border-gray-100">
<div class="mt-0.5 text-blue-500 bg-blue-50 rounded p-1 shrink-0">
<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="M12 10v6m0 0l-3-3m3 3l3-3m2 8H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"></path></svg>
</div>
<div>
<h4 class="font-bold text-gray-900 mb-1">Ekspor Laporan Peminjaman</h4>
<p>Klik tombol <strong>Ekspor PDF</strong> di bagian atas untuk mencetak dokumen daftar inventaris resmi atas nama karyawan bersangkutan.</p>
</div>
</div>
</div>
</div>
{% endblock %}
<script>
document.addEventListener('click', function() {
var menu = document.getElementById('exportMenuEmployeeDetail');
if (menu) menu.style.display = 'none';
});
</script>