2026-10-27 09:42:15 +07:00
{% extends 'base.html' %}
2026-10-27 11:13:13 +07:00
{% block page_title %}Consumable Item{% endblock %}
2026-10-27 09:42:15 +07:00
{% block page_title_guide %}Panduan Modul Consumable Item{% endblock %}
{% block page_guide_content %}
< div class = "space-y-4" >
< p > Modul < b > Consumable Item</ b > dirancang khusus untuk mengelola logistik barang habis pakai yang digunakan oleh tim IT Network & Security serta Technical Support PT. Kerinci Hydropower.</ p >
< div class = "p-3 bg-emerald-50 border border-emerald-200 rounded-xl" >
< h4 class = "font-bold text-emerald-800 text-xs uppercase tracking-wider mb-1" > Prinsip Audit & Integritas Stok</ h4 >
< p class = "text-xs text-emerald-700" > Saldo stok tidak dapat diedit sembarangan. Setiap perubahan stok dicatat secara mutlak melalui transaksi atomik: < b > Barang Masuk</ b > , < b > Barang Keluar</ b > , atau < b > Stock Opname</ b > pada buku besar transaksi (stock ledger).</ p >
</ div >
< ul class = "list-disc pl-5 space-y-1 text-xs text-gray-600" >
2026-10-27 11:13:13 +07:00
< li >< b > Barang Masuk:</ b > Penambahan stok dari pengadaan/pembelian, transfer, atau retur sisa teknisi.</ li >
< li >< b > Barang Keluar:</ b > Konsumsi material oleh teknisi dengan keterkaitan ke tiket support, work order, atau unit aset.</ li >
2026-10-27 09:42:15 +07:00
< li >< b > Stock Opname:</ b > Penyesuaian fisik berkala dengan alasan audit yang wajib diisi.</ li >
</ ul >
</ div >
{% endblock %}
{% block content %}
2026-10-27 11:13:13 +07:00
< div class = "mb-8 flex flex-col sm:flex-row sm:justify-between sm:items-center space-y-4 sm:space-y-0" >
2026-10-27 09:42:15 +07:00
< div >
2026-10-27 11:13:13 +07:00
< p class = "text-xs font-bold text-kerinci uppercase tracking-widest mb-1" > Manajemen Aset</ p >
2026-10-27 09:42:15 +07:00
< div class = "flex items-center space-x-3" >
< h2 class = "text-3xl font-extrabold text-gray-900" > Consumable Item</ h2 >
2026-10-27 11:13:13 +07:00
< 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 >
2026-10-27 09:42:15 +07:00
</ div >
</ div >
2026-10-27 11:13:13 +07:00
<!-- Header Actions -->
< div class = "flex items-center space-x-3 w-full sm:w-auto" >
<!-- Ekspor Dropdown -->
< div class = "relative inline-block w-full sm:w-auto flex-1 sm:flex-none" >
< button onclick = "var d = document.getElementById('exportMenuConsumable'); 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 Consumable</ 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 = "exportMenuConsumable" 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 'consumable_export_pdf' %}?q={{ search_query }}&category={{ category_filter }}&status={{ status_filter }}" 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 'consumable_export_excel' %}?q={{ search_query }}&category={{ category_filter }}&status={{ status_filter }}" 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 >
2026-10-27 09:42:15 +07:00
{% if not is_read_only %}
2026-10-27 11:13:13 +07:00
<!-- Transaksi Stok Dropdown -->
< div class = "relative inline-block w-full sm:w-auto flex-1 sm:flex-none" >
< button onclick = "var d = document.getElementById('trxMenuConsumable'); d.style.display = d.style.display === 'block' ? 'none' : 'block'; event.stopPropagation();" class = "w-full border border-gray-300 bg-white text-gray-700 rounded-xl px-4 py-2 text-sm font-bold hover:bg-gray-50 transition-colors flex items-center space-x-2 justify-center shadow-sm" >
< svg class = "w-4 h-4 text-blue-600" fill = "none" stroke = "currentColor" viewBox = "0 0 24 24" >< path stroke-linecap = "round" stroke-linejoin = "round" stroke-width = "2" d = "M8 7h12m0 0l-4-4m4 4l-4 4m0 6H4m0 0l4 4m-4-4l4-4" ></ path ></ svg >
< span > Transaksi Stok</ 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 = "trxMenuConsumable" style = "display: none;" class = "absolute right-0 mt-2 w-52 bg-white rounded-xl shadow-[0_8px_30px_rgb(0,0,0,0.12)] border border-gray-100 z-50 py-1" >
< button onclick = "document.getElementById('trxMenuConsumable').style.display='none'; openModalBarangMasuk();" class = "w-full flex items-center px-4 py-2.5 text-sm text-gray-700 hover:bg-blue-50 hover:text-blue-700 font-bold transition-colors text-left" >
< svg class = "w-4 h-4 mr-2.5 text-blue-600" fill = "none" stroke = "currentColor" viewBox = "0 0 24 24" >< path stroke-linecap = "round" stroke-linejoin = "round" stroke-width = "2" d = "M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-8l-4-4m0 0L8 8m4-4v12" ></ path ></ svg >
Barang Masuk
</ button >
< button onclick = "document.getElementById('trxMenuConsumable').style.display='none'; openModalBarangKeluar();" class = "w-full flex items-center px-4 py-2.5 text-sm text-gray-700 hover:bg-amber-50 hover:text-amber-700 font-bold transition-colors text-left" >
< svg class = "w-4 h-4 mr-2.5 text-amber-600" fill = "none" stroke = "currentColor" viewBox = "0 0 24 24" >< path stroke-linecap = "round" stroke-linejoin = "round" stroke-width = "2" d = "M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4" ></ path ></ svg >
Barang Keluar
</ button >
< div class = "h-px bg-gray-100 mx-2" ></ div >
< button onclick = "document.getElementById('trxMenuConsumable').style.display='none'; openModalOpname();" class = "w-full flex items-center px-4 py-2.5 text-sm text-gray-700 hover:bg-purple-50 hover:text-purple-700 font-bold transition-colors text-left" >
< svg class = "w-4 h-4 mr-2.5 text-purple-600" 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 2m-6 9l2 2 4-4" ></ path ></ svg >
Stock Opname
</ button >
</ div >
</ div >
<!-- Tambah Item Button -->
< button onclick = "openCreateItemModal()" class = "bg-kerinci text-white border border-kerinci rounded-xl shadow-sm px-4 py-2 text-sm font-bold hover:bg-kerinci/90 transition-colors flex items-center space-x-2 justify-center w-full sm:w-auto flex-1 sm:flex-none" >
2026-10-27 09:42:15 +07:00
< 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 4v16m8-8H4" ></ path ></ svg >
2026-10-27 11:13:13 +07:00
< span > Tambah Item</ span >
2026-10-27 09:42:15 +07:00
</ button >
{% endif %}
</ div >
</ div >
2026-10-27 11:13:13 +07:00
<!-- Category Tabs -->
< div class = "flex space-x-2 mb-6 border-b border-gray-200 overflow-x-auto whitespace-nowrap scrollbar-hide" >
2026-10-27 09:42:15 +07:00
< a href = "?status={% if search_query %}&q={{ search_query }}{% endif %}{% if category_filter %}&category={{ category_filter }}{% endif %}{% if location_filter %}&location={{ location_filter }}{% endif %}" class = "px-5 py-3 text-sm font-bold border-b-2 transition-colors flex items-center {% if not status_filter %}border-kerinci text-kerinci{% else %}border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300{% endif %}" >
Semua Item
< span class = "ml-2 {% if not status_filter %}bg-kerinci/10 text-kerinci{% else %}bg-gray-100 text-gray-500{% endif %} text-[10px] px-2 py-0.5 rounded-full font-extrabold" > {{ counts.total }}</ span >
</ a >
< a href = "?status=available{% if search_query %}&q={{ search_query }}{% endif %}{% if category_filter %}&category={{ category_filter }}{% endif %}{% if location_filter %}&location={{ location_filter }}{% endif %}" class = "px-5 py-3 text-sm font-bold border-b-2 transition-colors flex items-center {% if status_filter == 'available' %}border-kerinci text-kerinci{% else %}border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300{% endif %}" >
Stok Aman
< span class = "ml-2 {% if status_filter == 'available' %}bg-kerinci/10 text-kerinci{% else %}bg-gray-100 text-gray-500{% endif %} text-[10px] px-2 py-0.5 rounded-full font-extrabold" > {{ counts.available }}</ span >
</ a >
2026-10-27 11:13:13 +07:00
< a href = "?status=low_stock{% if search_query %}&q={{ search_query }}{% endif %}{% if category_filter %}&category={{ category_filter }}{% endif %}{% if location_filter %}&location={{ location_filter }}{% endif %}" class = "px-5 py-3 text-sm font-bold border-b-2 transition-colors flex items-center {% if status_filter == 'low_stock' %}border-kerinci text-kerinci{% else %}border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300{% endif %}" >
2026-10-27 09:42:15 +07:00
Stok Menipis
< span class = "ml-2 {% if status_filter == 'low_stock' %}bg-amber-100 text-amber-700{% else %}bg-gray-100 text-gray-500{% endif %} text-[10px] px-2 py-0.5 rounded-full font-extrabold" > {{ counts.low_stock }}</ span >
</ a >
2026-10-27 11:13:13 +07:00
< a href = "?status=out_of_stock{% if search_query %}&q={{ search_query }}{% endif %}{% if category_filter %}&category={{ category_filter }}{% endif %}{% if location_filter %}&location={{ location_filter }}{% endif %}" class = "px-5 py-3 text-sm font-bold border-b-2 transition-colors flex items-center {% if status_filter == 'out_of_stock' %}border-kerinci text-kerinci{% else %}border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300{% endif %}" >
2026-10-27 09:42:15 +07:00
Stok Habis
< span class = "ml-2 {% if status_filter == 'out_of_stock' %}bg-red-100 text-red-700{% else %}bg-gray-100 text-gray-500{% endif %} text-[10px] px-2 py-0.5 rounded-full font-extrabold" > {{ counts.out_of_stock }}</ span >
</ a >
</ div >
2026-10-27 11:13:13 +07:00
<!-- Filters & Search -->
< div class = "mb-4 flex flex-col sm:flex-row sm:items-center sm:justify-between space-y-3 sm:space-y-0" >
< form id = "searchForm" method = "GET" class = "relative w-full sm:w-96" >
2026-10-27 09:42:15 +07:00
< input type = "hidden" name = "status" value = "{{ status_filter }}" >
2026-10-27 11:13:13 +07:00
{% if category_filter %}< input type = "hidden" name = "category" value = "{{ category_filter }}" > {% endif %}
{% if location_filter %}< input type = "hidden" name = "location" value = "{{ location_filter }}" > {% endif %}
< input type = "text" id = "searchInput" name = "q" value = "{{ search_query }}" placeholder = "Cari kode barang, nama, merek, atau spesifikasi..." class = "w-full pl-10 pr-4 py-2.5 rounded-xl border border-gray-200 text-sm focus:outline-none focus:border-kerinci focus:ring-1 focus:ring-kerinci bg-white shadow-sm placeholder-gray-400" >
< svg class = "w-5 h-5 text-gray-400 absolute left-3 top-2.5" fill = "none" stroke = "currentColor" viewBox = "0 0 24 24" >< path stroke-linecap = "round" stroke-linejoin = "round" stroke-width = "2" d = "M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z" ></ path ></ svg >
</ form >
2026-10-27 09:42:15 +07:00
2026-10-27 11:13:13 +07:00
< div class = "flex items-center space-x-2 w-full sm:w-auto" >
< select onchange = "location = this.value;" class = "px-3 py-2 rounded-xl border border-gray-200 text-xs font-semibold focus:outline-none focus:border-kerinci focus:ring-1 focus:ring-kerinci bg-white text-gray-700 shadow-sm" >
< option value = "?status={{ status_filter }}&q={{ search_query }}{% if location_filter %}&location={{ location_filter }}{% endif %}" > Semua Kategori</ option >
2026-10-27 09:42:15 +07:00
{% for cat_val, cat_label in categories %}
2026-10-27 11:13:13 +07:00
< option value = "?status={{ status_filter }}&category={{ cat_val }}&q={{ search_query }}{% if location_filter %}&location={{ location_filter }}{% endif %}" {% if category_filter = = cat_val %} selected {% endif %} > {{ cat_label }}</ option >
2026-10-27 09:42:15 +07:00
{% endfor %}
</ select >
2026-10-27 11:13:13 +07:00
< select onchange = "location = this.value;" class = "px-3 py-2 rounded-xl border border-gray-200 text-xs font-semibold focus:outline-none focus:border-kerinci focus:ring-1 focus:ring-kerinci bg-white text-gray-700 shadow-sm" >
< option value = "?status={{ status_filter }}&category={{ category_filter }}&q={{ search_query }}" > Semua Lokasi</ option >
2026-10-27 09:42:15 +07:00
{% for loc in locations %}
2026-10-27 11:13:13 +07:00
< option value = "?status={{ status_filter }}&category={{ category_filter }}&location={{ loc }}&q={{ search_query }}" {% if location_filter = = loc %} selected {% endif %} > {{ loc }}</ option >
2026-10-27 09:42:15 +07:00
{% endfor %}
</ select >
{% if search_query or category_filter or location_filter or status_filter %}
2026-10-27 11:13:13 +07:00
< a href = "{% url 'consumable_list' %}" class = "px-3 py-2 text-xs font-bold text-gray-500 hover:text-red-600 border border-gray-200 hover:border-red-200 rounded-xl bg-white transition-colors shadow-sm" title = "Reset Filter" >
2026-10-27 09:42:15 +07:00
Reset
</ a >
{% endif %}
2026-10-27 11:13:13 +07:00
</ div >
2026-10-27 09:42:15 +07:00
</ div >
2026-10-27 11:13:13 +07:00
<!-- Main Data Table -->
< div class = "bg-white rounded-none sm:rounded-2xl shadow-sm border border-gray-100 overflow-hidden w-full" id = "tableContainer" >
2026-10-27 09:42:15 +07:00
< div class = "overflow-x-auto" >
2026-10-27 11:13:13 +07:00
< table class = "w-full text-left border-collapse" >
2026-10-27 09:42:15 +07:00
< thead >
2026-10-27 11:13:13 +07:00
< tr class = "bg-[#002060] text-white text-[11px] uppercase tracking-widest" >
< th class = "p-4 font-bold text-center w-16" > No</ th >
< th class = "p-4 font-bold w-36" > Kode Item</ th >
< th class = "p-4 font-bold min-w-[200px]" > Nama Barang & Merek</ th >
< th class = "p-4 font-bold" > Kategori</ th >
< th class = "p-4 font-bold min-w-[160px]" > Spesifikasi</ th >
< th class = "p-4 font-bold text-center" > Satuan</ th >
< th class = "p-4 font-bold text-center" > Stok</ th >
< th class = "p-4 font-bold" > Lokasi</ th >
< th class = "p-4 font-bold text-center" > Status</ th >
< th class = "p-4 font-bold text-center w-28" > Aksi</ th >
2026-10-27 09:42:15 +07:00
</ tr >
</ thead >
2026-10-27 11:13:13 +07:00
< tbody class = "text-sm divide-y divide-gray-200" >
2026-10-27 09:42:15 +07:00
{% for item in page_obj %}
2026-10-27 11:13:13 +07:00
< tr class = "hover:bg-gray-50 transition-colors" >
< td class = "p-4 text-center text-gray-500" > {{ forloop.counter }}</ td >
< td class = "p-4 font-bold text-gray-700 font-mono text-xs" >
< a href = "{% url 'consumable_detail' item.id %}" class = "hover:text-kerinci transition-colors" >
2026-10-27 09:42:15 +07:00
{{ item.item_code }}
</ a >
</ td >
2026-10-27 11:13:13 +07:00
< td class = "p-4" >
< a href = "{% url 'consumable_detail' item.id %}" class = "font-bold text-gray-900 hover:text-kerinci transition-colors block" >
{{ item.name }}
</ a >
2026-10-27 09:42:15 +07:00
{% if item.brand %}
2026-10-27 11:13:13 +07:00
< p class = "text-xs text-gray-500 font-normal mt-0.5" > Merek: {{ item.brand }}</ p >
2026-10-27 09:42:15 +07:00
{% endif %}
</ td >
2026-10-27 11:13:13 +07:00
< td class = "p-4 text-gray-600 font-medium text-xs" >
{{ item.get_category_display }}
2026-10-27 09:42:15 +07:00
</ td >
2026-10-27 11:13:13 +07:00
< td class = "p-4 text-xs text-gray-500 max-w-[220px]" >
2026-10-27 09:42:15 +07:00
< span class = "line-clamp-2" title = "{{ item.specification }}" > {{ item.specification|default:"-" }}</ span >
</ td >
2026-10-27 11:13:13 +07:00
< td class = "p-4 text-center text-gray-700 font-semibold text-xs" >
{{ item.base_unit }}
2026-10-27 09:42:15 +07:00
</ td >
2026-10-27 11:13:13 +07:00
< td class = "p-4 text-center" >
< span class = "font-extrabold {% if item.stock_status == 'out_of_stock' %}text-red-600{% elif item.stock_status == 'low_stock' %}text-amber-600{% else %}text-emerald-600{% endif %}" > {{ item.formatted_stock }}</ span >
< span class = "text-gray-300 mx-1" > /</ span >
< span class = "text-gray-400 text-xs" title = "Batas Minimum Stok" > {{ item.minimum_stock|floatformat:0 }}</ span >
2026-10-27 09:42:15 +07:00
</ td >
2026-10-27 11:13:13 +07:00
< td class = "p-4 text-gray-600 text-xs font-medium" >
{{ item.location }}
2026-10-27 09:42:15 +07:00
</ td >
2026-10-27 11:13:13 +07:00
< td class = "p-4 text-center" >
2026-10-27 09:42:15 +07:00
{% if item.stock_status == 'out_of_stock' %}
2026-10-27 11:13:13 +07:00
< span class = "inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-bold bg-red-50 text-red-700 border border-red-200" > Habis</ span >
2026-10-27 09:42:15 +07:00
{% elif item.stock_status == 'low_stock' %}
2026-10-27 11:13:13 +07:00
< span class = "inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-bold bg-amber-50 text-amber-700 border border-amber-200" > Menipis</ span >
2026-10-27 09:42:15 +07:00
{% else %}
2026-10-27 11:13:13 +07:00
< span class = "inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-bold bg-emerald-50 text-emerald-700 border border-emerald-200" > Aman</ span >
2026-10-27 09:42:15 +07:00
{% endif %}
</ td >
2026-10-27 11:13:13 +07:00
< td class = "p-4 text-center" >
2026-10-27 09:42:15 +07:00
< div class = "flex items-center justify-center space-x-1.5" >
2026-10-27 11:13:13 +07:00
< a href = "{% url 'consumable_detail' item.id %}" class = "p-2 bg-gray-50 text-gray-600 hover:bg-gray-100 rounded-lg transition-colors border border-gray-200" title = "Buku Besar & Detail" >
2026-10-27 09:42:15 +07:00
< 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 = "M15 12a3 3 0 11-6 0 3 3 0 016 0z" ></ path >< path stroke-linecap = "round" stroke-linejoin = "round" stroke-width = "2" d = "M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z" ></ path ></ svg >
</ a >
{% if not is_read_only %}
2026-10-27 11:13:13 +07:00
< button onclick = "openEditModal('{{ item.id }}', '{{ item.item_code }}', '{{ item.name|escapejs }}', '{{ item.category }}', '{{ item.brand|default:''|escapejs }}', '{{ item.specification|default:''|escapejs }}', '{{ item.base_unit|escapejs }}', '{{ item.purchase_unit|default:''|escapejs }}', '{{ item.conversion_rate|default:1 }}', '{{ item.minimum_stock|default:0 }}', '{{ item.unit_price|default:0 }}', '{{ item.location|escapejs }}')" class = "p-2 bg-amber-50 text-amber-600 hover:bg-amber-100 rounded-lg transition-colors border border-amber-100" title = "Edit Item" >
< 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 = "M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z" ></ path ></ svg >
2026-10-27 09:42:15 +07:00
</ button >
{% endif %}
</ div >
</ td >
</ tr >
{% empty %}
< tr >
2026-10-27 11:13:13 +07:00
< td colspan = "10" class = "p-8 text-center text-gray-400 text-sm" >
Belum ada data Consumable Item untuk kategori ini.
2026-10-27 09:42:15 +07:00
</ td >
</ tr >
{% endfor %}
</ tbody >
</ table >
</ div >
{% include 'components/pagination.html' %}
</ div >
<!-- MODAL 1: Tambah Consumable Item Baru -->
<!-- ========================================================================= -->
< div id = "modalCreateItem" class = "fixed inset-0 z-50 hidden overflow-y-auto bg-gray-900/50 backdrop-blur-sm flex items-center justify-center p-4" >
< div class = "bg-white rounded-2xl shadow-xl max-w-2xl w-full max-h-[90vh] flex flex-col overflow-hidden animate-in fade-in zoom-in-95 duration-200" >
< div class = "px-6 py-4 border-b border-gray-100 flex items-center justify-between bg-gray-50/50" >
< div class = "flex items-center space-x-2.5" >
< div class = "w-8 h-8 rounded-lg bg-emerald-50 text-kerinci flex items-center justify-center" >
< 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 4v16m8-8H4" ></ path ></ svg >
</ div >
< div >
< h3 class = "font-extrabold text-gray-900 text-base" > Tambah Consumable Item Baru</ h3 >
< p class = "text-xs text-gray-500" > Daftarkan jenis barang habis pakai ke katalog master persediaan.</ p >
</ div >
</ div >
< button onclick = "closeCreateItemModal()" class = "text-gray-400 hover:text-gray-600 p-1.5 rounded-lg transition-colors" >
< 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 = "M6 18L18 6M6 6l12 12" ></ path ></ svg >
</ button >
</ div >
< form action = "{% url 'consumable_create' %}" method = "POST" class = "flex-1 overflow-y-auto p-6 space-y-4" >
{% csrf_token %}
< div class = "grid grid-cols-1 sm:grid-cols-2 gap-4" >
<!-- Kode Barang -->
< div >
< label class = "block text-xs font-bold text-gray-700 uppercase tracking-wider mb-1" >
Kode Barang < span class = "text-gray-400 font-normal text-[10px]" > (Opsional - auto-generated)</ span >
</ label >
< input type = "text" name = "item_code" placeholder = "Misal: CNS-CAB-001" class = "w-full px-3.5 py-2.5 rounded-xl border border-gray-200 text-sm focus:outline-none focus:border-kerinci focus:ring-1 focus:ring-kerinci uppercase font-mono" >
</ div >
<!-- Kategori -->
< div >
< label class = "block text-xs font-bold text-gray-700 uppercase tracking-wider mb-1" >
Kategori < span class = "text-red-500" > *</ span >
</ label >
< select name = "category" required class = "w-full px-3.5 py-2.5 rounded-xl border border-gray-200 text-sm focus:outline-none focus:border-kerinci focus:ring-1 focus:ring-kerinci bg-white" >
{% for cat_val, cat_label in categories %}
< option value = "{{ cat_val }}" > {{ cat_label }}</ option >
{% endfor %}
</ select >
</ div >
</ div >
<!-- Nama Barang & Merek -->
< div class = "grid grid-cols-1 sm:grid-cols-2 gap-4" >
< div >
< label class = "block text-xs font-bold text-gray-700 uppercase tracking-wider mb-1" >
Nama Barang < span class = "text-red-500" > *</ span >
</ label >
< input type = "text" name = "name" required placeholder = "Contoh: Kabel UTP Cat6, Konektor RJ45" class = "w-full px-3.5 py-2.5 rounded-xl border border-gray-200 text-sm focus:outline-none focus:border-kerinci focus:ring-1 focus:ring-kerinci" >
</ div >
< div >
< label class = "block text-xs font-bold text-gray-700 uppercase tracking-wider mb-1" >
Merek / Brand
</ label >
< input type = "text" name = "brand" placeholder = "Contoh: Belden, CommScope, Arctic, 3M" class = "w-full px-3.5 py-2.5 rounded-xl border border-gray-200 text-sm focus:outline-none focus:border-kerinci focus:ring-1 focus:ring-kerinci" >
</ div >
</ div >
<!-- Spesifikasi Teknis -->
< div >
< label class = "block text-xs font-bold text-gray-700 uppercase tracking-wider mb-1" >
Spesifikasi Teknis
</ label >
< input type = "text" name = "specification" placeholder = "Contoh: UTP Cat6 24AWG Solid Copper, Thermal Paste 5g 8.5W/mK" class = "w-full px-3.5 py-2.5 rounded-xl border border-gray-200 text-sm focus:outline-none focus:border-kerinci focus:ring-1 focus:ring-kerinci" >
</ div >
<!-- Satuan & Konversi -->
< div class = "p-3.5 bg-gray-50/80 rounded-xl border border-gray-200 space-y-3" >
< p class = "text-xs font-bold text-gray-700 uppercase tracking-wider" > Satuan Kuantitas & Konversi</ p >
< div class = "grid grid-cols-1 sm:grid-cols-3 gap-3" >
< div >
< label class = "block text-[11px] font-semibold text-gray-600 mb-1" >
Satuan Dasar (UoM) < span class = "text-red-500" > *</ span >
</ label >
< input type = "text" name = "base_unit" required placeholder = "pcs, meter, tube, roll" class = "w-full px-3 py-2 rounded-lg border border-gray-200 text-sm focus:outline-none focus:border-kerinci bg-white" >
< span class = "text-[10px] text-gray-400" > Satuan terkecil pemakaian</ span >
</ div >
< div >
< label class = "block text-[11px] font-semibold text-gray-600 mb-1" >
Satuan Pembelian
</ label >
< input type = "text" name = "purchase_unit" placeholder = "roll, box, pack, tube" class = "w-full px-3 py-2 rounded-lg border border-gray-200 text-sm focus:outline-none focus:border-kerinci bg-white" >
< span class = "text-[10px] text-gray-400" > Satuan saat order/beli</ span >
</ div >
< div >
< label class = "block text-[11px] font-semibold text-gray-600 mb-1" >
Faktor Konversi
</ label >
< input type = "number" step = "0.01" min = "0.01" name = "conversion_rate" value = "1.00" class = "w-full px-3 py-2 rounded-lg border border-gray-200 text-sm focus:outline-none focus:border-kerinci bg-white font-mono" >
< span class = "text-[10px] text-gray-400" > 1 Beli = X Satuan Dasar</ span >
</ div >
</ div >
</ div >
<!-- Stok & Lokasi -->
< div class = "grid grid-cols-1 sm:grid-cols-3 gap-3" >
< div >
< label class = "block text-xs font-bold text-gray-700 uppercase tracking-wider mb-1" >
Stok Awal Fisik
</ label >
< input type = "number" step = "0.01" min = "0" name = "initial_stock" value = "0" class = "w-full px-3.5 py-2.5 rounded-xl border border-gray-200 text-sm focus:outline-none focus:border-kerinci font-mono" >
< span class = "text-[10px] text-gray-400" > Dicatat terotorisasi ke buku besar</ span >
</ div >
< div >
< label class = "block text-xs font-bold text-gray-700 uppercase tracking-wider mb-1" >
Batas Stok Minimum
</ label >
< input type = "number" step = "0.01" min = "0" name = "minimum_stock" value = "10" class = "w-full px-3.5 py-2.5 rounded-xl border border-gray-200 text-sm focus:outline-none focus:border-kerinci font-mono" >
< span class = "text-[10px] text-gray-400" > Ambang batas peringatan</ span >
</ div >
< div >
< label class = "block text-xs font-bold text-gray-700 uppercase tracking-wider mb-1" >
Lokasi Penyimpanan
</ label >
< select name = "location" class = "w-full px-3.5 py-2.5 rounded-xl border border-gray-200 text-sm focus:outline-none focus:border-kerinci bg-white" >
{% for loc in locations %}
< option value = "{{ loc }}" {% if loc = = ' Gudang Induk ( GI )' %} selected {% endif %} > {{ loc }}</ option >
{% endfor %}
</ select >
</ div >
</ div >
<!-- Estimasi Harga Beli & Catatan -->
< div class = "grid grid-cols-1 sm:grid-cols-2 gap-4" >
< div >
< label class = "block text-xs font-bold text-gray-700 uppercase tracking-wider mb-1" >
Estimasi Harga Beli Satuan (Rp)
</ label >
< input type = "number" step = "100" min = "0" name = "last_purchase_price" value = "0" class = "w-full px-3.5 py-2.5 rounded-xl border border-gray-200 text-sm focus:outline-none focus:border-kerinci font-mono" >
</ div >
< div >
< label class = "block text-xs font-bold text-gray-700 uppercase tracking-wider mb-1" >
Catatan Tambahan
</ label >
< input type = "text" name = "notes" placeholder = "Keterangan peruntukan, rak, vendor langganan" class = "w-full px-3.5 py-2.5 rounded-xl border border-gray-200 text-sm focus:outline-none focus:border-kerinci" >
</ div >
</ div >
< div class = "pt-4 border-t border-gray-100 flex items-center justify-end space-x-3" >
< button type = "button" onclick = "closeCreateItemModal()" class = "px-5 py-2.5 rounded-xl border border-gray-200 text-sm font-bold text-gray-600 hover:bg-gray-50 transition-colors" >
Batal
</ button >
< button type = "submit" class = "px-6 py-2.5 rounded-xl bg-kerinci text-white text-sm font-bold shadow-sm shadow-kerinci/30 hover:bg-kerinci/90 transition-colors" >
Simpan Master Item
</ button >
</ div >
</ form >
</ div >
</ div >
<!-- ========================================================================= -->
<!-- MODAL 2: Transaksi Barang Masuk -->
<!-- ========================================================================= -->
< div id = "modalBarangMasuk" class = "fixed inset-0 z-50 hidden overflow-y-auto bg-gray-900/50 backdrop-blur-sm flex items-center justify-center p-4" >
< div class = "bg-white rounded-2xl shadow-xl max-w-xl w-full max-h-[90vh] flex flex-col overflow-hidden animate-in fade-in zoom-in-95 duration-200" >
< div class = "px-6 py-4 border-b border-gray-100 flex items-center justify-between bg-blue-50/50" >
< div class = "flex items-center space-x-2.5" >
< div class = "w-8 h-8 rounded-lg bg-blue-100 text-blue-700 flex items-center justify-center" >
< 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 = "M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-8l-4-4m0 0L8 8m4-4v12" ></ path ></ svg >
</ div >
< div >
< h3 class = "font-extrabold text-gray-900 text-base" > Penerimaan Barang Masuk</ h3 >
< p class = "text-xs text-gray-500" > Mencatat penambahan stok dari pengadaan, restock, atau retur.</ p >
</ div >
</ div >
< button onclick = "closeModalBarangMasuk()" class = "text-gray-400 hover:text-gray-600 p-1.5 rounded-lg transition-colors" >
< 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 = "M6 18L18 6M6 6l12 12" ></ path ></ svg >
</ button >
</ div >
< form action = "{% url 'consumable_in' %}" method = "POST" class = "flex-1 overflow-y-auto p-6 space-y-4" >
{% csrf_token %}
<!-- Pilih Item -->
< div >
< label class = "block text-xs font-bold text-gray-700 uppercase tracking-wider mb-1" >
Pilih Item Consumable < span class = "text-red-500" > *</ span >
</ label >
< select id = "in_item_select" name = "item_id" required class = "w-full px-3.5 py-2.5 rounded-xl border border-gray-200 text-sm focus:outline-none focus:border-blue-600 bg-white" >
< option value = "" > -- Pilih Barang --</ option >
{% for itm in selectable_items %}
< option value = "{{ itm.id }}" data-base = "{{ itm.base_unit }}" data-purchase = "{{ itm.purchase_unit|default:'' }}" data-conv = "{{ itm.conversion_rate }}" >
{{ itm.item_code }} - {{ itm.name }} (Stok saat ini: {{ itm.formatted_stock }})
</ option >
{% endfor %}
</ select >
</ div >
<!-- Jumlah & Pilihan Satuan -->
< div class = "grid grid-cols-1 sm:grid-cols-2 gap-4" >
< div >
< label class = "block text-xs font-bold text-gray-700 uppercase tracking-wider mb-1" >
Jumlah Masuk < span class = "text-red-500" > *</ span >
</ label >
< input type = "number" step = "0.01" min = "0.01" name = "quantity" required placeholder = "0.00" class = "w-full px-3.5 py-2.5 rounded-xl border border-gray-200 text-sm focus:outline-none focus:border-blue-600 font-mono font-bold" >
</ div >
< div >
< label class = "block text-xs font-bold text-gray-700 uppercase tracking-wider mb-1" >
Satuan Transaksi
</ label >
< select id = "in_unit_type" name = "unit_type" class = "w-full px-3.5 py-2.5 rounded-xl border border-gray-200 text-sm focus:outline-none focus:border-blue-600 bg-white" >
< option value = "base" > Satuan Dasar</ option >
< option value = "purchase" > Satuan Pembelian (Jika ada)</ option >
</ select >
</ div >
</ div >
<!-- Sumber & Tanggal -->
< div class = "grid grid-cols-1 sm:grid-cols-2 gap-4" >
< div >
< label class = "block text-xs font-bold text-gray-700 uppercase tracking-wider mb-1" >
Sumber Barang
</ label >
< select name = "source_destination" class = "w-full px-3.5 py-2.5 rounded-xl border border-gray-200 text-sm focus:outline-none focus:border-blue-600 bg-white" >
< option value = "Pembelian / Pengadaan Baru" > Pembelian / Pengadaan Baru</ option >
< option value = "Pengembalian Sisa Proyek" > Pengembalian Sisa Proyek / Teknisi</ option >
< option value = "Transfer Antar Gudang" > Transfer Antar Gudang</ option >
< option value = "Hibah / Suplai Kantor Pusat" > Hibah / Suplai Kantor Pusat</ option >
</ select >
</ div >
< div >
< label class = "block text-xs font-bold text-gray-700 uppercase tracking-wider mb-1" >
Tanggal Penerimaan < span class = "text-red-500" > *</ span >
</ label >
< input type = "date" name = "transaction_date" value = "{{ today_date }}" required class = "w-full px-3.5 py-2.5 rounded-xl border border-gray-200 text-sm focus:outline-none focus:border-blue-600 bg-white" >
</ div >
</ div >
<!-- Supplier & Referensi -->
< div class = "grid grid-cols-1 sm:grid-cols-2 gap-4" >
< div >
< label class = "block text-xs font-bold text-gray-700 uppercase tracking-wider mb-1" >
Vendor / Supplier
</ label >
< input type = "text" name = "supplier" placeholder = "Nama toko / distributor" class = "w-full px-3.5 py-2.5 rounded-xl border border-gray-200 text-sm focus:outline-none focus:border-blue-600" >
</ div >
< div >
< label class = "block text-xs font-bold text-gray-700 uppercase tracking-wider mb-1" >
No. Referensi / PO / Faktur
</ label >
< input type = "text" name = "reference_no" placeholder = "PO-2026-..., BAST-..." class = "w-full px-3.5 py-2.5 rounded-xl border border-gray-200 text-sm focus:outline-none focus:border-blue-600" >
</ div >
</ div >
<!-- Batch / Lot & Expiry Date -->
< div class = "grid grid-cols-1 sm:grid-cols-2 gap-4" >
< div >
< label class = "block text-xs font-bold text-gray-700 uppercase tracking-wider mb-1" >
Nomor Batch / Lot
</ label >
< input type = "text" name = "batch_lot" placeholder = "Opsional" class = "w-full px-3.5 py-2.5 rounded-xl border border-gray-200 text-sm focus:outline-none focus:border-blue-600" >
</ div >
< div >
< label class = "block text-xs font-bold text-gray-700 uppercase tracking-wider mb-1" >
Tanggal Kedaluwarsa
</ label >
< input type = "date" name = "expiry_date" class = "w-full px-3.5 py-2.5 rounded-xl border border-gray-200 text-sm focus:outline-none focus:border-blue-600 bg-white" >
</ div >
</ div >
< div >
< label class = "block text-xs font-bold text-gray-700 uppercase tracking-wider mb-1" >
Catatan
</ label >
< textarea name = "notes" rows = "2" placeholder = "Keterangan tambahan barang masuk..." class = "w-full px-3.5 py-2 rounded-xl border border-gray-200 text-sm focus:outline-none focus:border-blue-600" ></ textarea >
</ div >
< div class = "pt-4 border-t border-gray-100 flex items-center justify-end space-x-3" >
< button type = "button" onclick = "closeModalBarangMasuk()" class = "px-5 py-2.5 rounded-xl border border-gray-200 text-sm font-bold text-gray-600 hover:bg-gray-50 transition-colors" >
Batal
</ button >
< button type = "submit" class = "px-6 py-2.5 rounded-xl bg-blue-600 text-white text-sm font-bold shadow-sm shadow-blue-500/20 hover:bg-blue-700 transition-colors" >
Posting Barang Masuk
</ button >
</ div >
</ form >
</ div >
</ div >
<!-- ========================================================================= -->
<!-- MODAL 3: Transaksi Barang Keluar (Pemakaian Teknisi) -->
<!-- ========================================================================= -->
< div id = "modalBarangKeluar" class = "fixed inset-0 z-50 hidden overflow-y-auto bg-gray-900/50 backdrop-blur-sm flex items-center justify-center p-4" >
< div class = "bg-white rounded-2xl shadow-xl max-w-xl w-full max-h-[90vh] flex flex-col overflow-hidden animate-in fade-in zoom-in-95 duration-200" >
< div class = "px-6 py-4 border-b border-gray-100 flex items-center justify-between bg-amber-50/50" >
< div class = "flex items-center space-x-2.5" >
< div class = "w-8 h-8 rounded-lg bg-amber-100 text-amber-700 flex items-center justify-center" >
< 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 = "M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4" ></ path ></ svg >
</ div >
< div >
< h3 class = "font-extrabold text-gray-900 text-base" > Pengeluaran Barang (Pemakaian)</ h3 >
< p class = "text-xs text-gray-500" > Mencatat konsumsi material untuk pekerjaan teknis IT.</ p >
</ div >
</ div >
< button onclick = "closeModalBarangKeluar()" class = "text-gray-400 hover:text-gray-600 p-1.5 rounded-lg transition-colors" >
< 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 = "M6 18L18 6M6 6l12 12" ></ path ></ svg >
</ button >
</ div >
< form action = "{% url 'consumable_out' %}" method = "POST" class = "flex-1 overflow-y-auto p-6 space-y-4" >
{% csrf_token %}
<!-- Pilih Item -->
< div >
< label class = "block text-xs font-bold text-gray-700 uppercase tracking-wider mb-1" >
Pilih Item Consumable < span class = "text-red-500" > *</ span >
</ label >
< select id = "out_item_select" name = "item_id" required class = "w-full px-3.5 py-2.5 rounded-xl border border-gray-200 text-sm focus:outline-none focus:border-amber-600 bg-white" >
< option value = "" > -- Pilih Barang --</ option >
{% for itm in selectable_items %}
< option value = "{{ itm.id }}" data-stock = "{{ itm.stock_available }}" data-base = "{{ itm.base_unit }}" >
{{ itm.item_code }} - {{ itm.name }} (Stok: {{ itm.formatted_stock }})
</ option >
{% endfor %}
</ select >
</ div >
<!-- Jumlah & Satuan -->
< div class = "grid grid-cols-1 sm:grid-cols-2 gap-4" >
< div >
< label class = "block text-xs font-bold text-gray-700 uppercase tracking-wider mb-1" >
Jumlah Dikeluarkan < span class = "text-red-500" > *</ span >
</ label >
< input type = "number" step = "0.01" min = "0.01" name = "quantity" required placeholder = "0.00" class = "w-full px-3.5 py-2.5 rounded-xl border border-gray-200 text-sm focus:outline-none focus:border-amber-600 font-mono font-bold" >
</ div >
< div >
< label class = "block text-xs font-bold text-gray-700 uppercase tracking-wider mb-1" >
Satuan Pemakaian
</ label >
< select name = "unit_type" class = "w-full px-3.5 py-2.5 rounded-xl border border-gray-200 text-sm focus:outline-none focus:border-amber-600 bg-white" >
< option value = "base" > Satuan Dasar</ option >
< option value = "purchase" > Satuan Pembelian</ option >
</ select >
</ div >
</ div >
<!-- Teknisi Penerima & Tanggal -->
< div class = "grid grid-cols-1 sm:grid-cols-2 gap-4" >
< div >
< label class = "block text-xs font-bold text-gray-700 uppercase tracking-wider mb-1" >
Teknisi / Karyawan Penerima < span class = "text-red-500" > *</ span >
</ label >
< select name = "recipient_employee" required class = "w-full px-3.5 py-2.5 rounded-xl border border-gray-200 text-sm focus:outline-none focus:border-amber-600 bg-white" >
< option value = "" > -- Pilih Teknisi --</ option >
{% for emp in employees %}
< option value = "{{ emp.id }}" > {{ emp.nik }} - {{ emp.name }} ({{ emp.position|default:"Staff" }})</ option >
{% endfor %}
</ select >
</ div >
< div >
< label class = "block text-xs font-bold text-gray-700 uppercase tracking-wider mb-1" >
Tanggal Pemakaian < span class = "text-red-500" > *</ span >
</ label >
< input type = "date" name = "transaction_date" value = "{{ today_date }}" required class = "w-full px-3.5 py-2.5 rounded-xl border border-gray-200 text-sm focus:outline-none focus:border-amber-600 bg-white" >
</ div >
</ div >
<!-- Tiket & Unit Aset Terkait -->
< div class = "grid grid-cols-1 sm:grid-cols-2 gap-4" >
< div >
< label class = "block text-xs font-bold text-gray-700 uppercase tracking-wider mb-1" >
No. Tiket Support / Work Order
</ label >
< input type = "text" name = "ticket_number" placeholder = "WO-2026-..., TIKET-IT-..." class = "w-full px-3.5 py-2.5 rounded-xl border border-gray-200 text-sm focus:outline-none focus:border-amber-600" >
</ div >
< div >
< label class = "block text-xs font-bold text-gray-700 uppercase tracking-wider mb-1" >
Unit Aset Terkait < span class = "text-gray-400 font-normal text-[10px]" > (Jika maintenance aset)</ span >
</ label >
< select name = "related_unit" class = "w-full px-3.5 py-2.5 rounded-xl border border-gray-200 text-sm focus:outline-none focus:border-amber-600 bg-white" >
< option value = "" > -- Tidak Terikat Unit Tertentu --</ option >
{% for unt in units %}
< option value = "{{ unt.id }}" > {{ unt.unit_code }} - {{ unt.asset.name }}</ option >
{% endfor %}
</ select >
</ div >
</ div >
<!-- Peruntukan / Area Pekerjaan -->
< div >
< label class = "block text-xs font-bold text-gray-700 uppercase tracking-wider mb-1" >
Tujuan / Area Penggunaan < span class = "text-red-500" > *</ span >
</ label >
< input type = "text" name = "source_destination" required placeholder = "Contoh: Instalasi Titik LAN Adit 1, Repasting Server DB, Terminasi Patch Cord" class = "w-full px-3.5 py-2.5 rounded-xl border border-gray-200 text-sm focus:outline-none focus:border-amber-600" >
</ div >
< div >
< label class = "block text-xs font-bold text-gray-700 uppercase tracking-wider mb-1" >
Catatan
</ label >
< textarea name = "notes" rows = "2" placeholder = "Keterangan tambahan penggunaan..." class = "w-full px-3.5 py-2 rounded-xl border border-gray-200 text-sm focus:outline-none focus:border-amber-600" ></ textarea >
</ div >
< div class = "pt-4 border-t border-gray-100 flex items-center justify-end space-x-3" >
< button type = "button" onclick = "closeModalBarangKeluar()" class = "px-5 py-2.5 rounded-xl border border-gray-200 text-sm font-bold text-gray-600 hover:bg-gray-50 transition-colors" >
Batal
</ button >
< button type = "submit" class = "px-6 py-2.5 rounded-xl bg-amber-600 text-white text-sm font-bold shadow-sm shadow-amber-500/20 hover:bg-amber-700 transition-colors" >
Posting Barang Keluar
</ button >
</ div >
</ form >
</ div >
</ div >
<!-- ========================================================================= -->
<!-- MODAL 4: Stock Opname / Penyesuaian Fisik -->
<!-- ========================================================================= -->
< div id = "modalOpname" class = "fixed inset-0 z-50 hidden overflow-y-auto bg-gray-900/50 backdrop-blur-sm flex items-center justify-center p-4" >
< div class = "bg-white rounded-2xl shadow-xl max-w-lg w-full max-h-[90vh] flex flex-col overflow-hidden animate-in fade-in zoom-in-95 duration-200" >
< div class = "px-6 py-4 border-b border-gray-100 flex items-center justify-between bg-purple-50/50" >
< div class = "flex items-center space-x-2.5" >
< div class = "w-8 h-8 rounded-lg bg-purple-100 text-purple-700 flex items-center justify-center" >
< 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 2m-6 9l2 2 4-4" ></ path ></ svg >
</ div >
< div >
< h3 class = "font-extrabold text-gray-900 text-base" > Stock Opname & Penyesuaian</ h3 >
< p class = "text-xs text-gray-500" > Sesuaikan saldo sistem dengan perhitungan fisik aktual di gudang.</ p >
</ div >
</ div >
< button onclick = "closeModalOpname()" class = "text-gray-400 hover:text-gray-600 p-1.5 rounded-lg transition-colors" >
< 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 = "M6 18L18 6M6 6l12 12" ></ path ></ svg >
</ button >
</ div >
< form action = "{% url 'consumable_adjust' %}" method = "POST" class = "flex-1 overflow-y-auto p-6 space-y-4" >
{% csrf_token %}
< div >
< label class = "block text-xs font-bold text-gray-700 uppercase tracking-wider mb-1" >
Pilih Item Consumable < span class = "text-red-500" > *</ span >
</ label >
< select id = "opname_item_select" name = "item_id" required onchange = "updateOpnameSystemStock(this)" class = "w-full px-3.5 py-2.5 rounded-xl border border-gray-200 text-sm focus:outline-none focus:border-purple-600 bg-white" >
< option value = "" > -- Pilih Barang --</ option >
{% for itm in selectable_items %}
< option value = "{{ itm.id }}" data-stock = "{{ itm.stock_available }}" data-base = "{{ itm.base_unit }}" >
{{ itm.item_code }} - {{ itm.name }} (Stok Sistem: {{ itm.formatted_stock }})
</ option >
{% endfor %}
</ select >
</ div >
<!-- Panel Selisih Real-time -->
< div class = "grid grid-cols-2 gap-3 p-3 bg-gray-50 rounded-xl border border-gray-200" >
< div >
< p class = "text-[10px] font-bold text-gray-400 uppercase" > Stok Sistem Saat Ini</ p >
< p id = "opname_sys_stock" class = "text-lg font-black text-gray-800" > 0</ p >
</ div >
< div >
< p class = "text-[10px] font-bold text-gray-400 uppercase" > Selisih (+/-)</ p >
< p id = "opname_diff_display" class = "text-lg font-black text-gray-500" > 0</ p >
</ div >
</ div >
< div class = "grid grid-cols-1 sm:grid-cols-2 gap-4" >
< div >
< label class = "block text-xs font-bold text-gray-700 uppercase tracking-wider mb-1" >
Stok Fisik Aktual < span class = "text-red-500" > *</ span >
</ label >
< input type = "number" id = "opname_actual_input" step = "0.01" min = "0" name = "actual_stock" required oninput = "calculateOpnameDiff()" placeholder = "0.00" class = "w-full px-3.5 py-2.5 rounded-xl border border-gray-200 text-sm focus:outline-none focus:border-purple-600 font-mono font-bold" >
</ div >
< div >
< label class = "block text-xs font-bold text-gray-700 uppercase tracking-wider mb-1" >
Tanggal Opname < span class = "text-red-500" > *</ span >
</ label >
< input type = "date" name = "transaction_date" value = "{{ today_date }}" required class = "w-full px-3.5 py-2.5 rounded-xl border border-gray-200 text-sm focus:outline-none focus:border-purple-600 bg-white" >
</ div >
</ div >
< div >
< label class = "block text-xs font-bold text-gray-700 uppercase tracking-wider mb-1" >
Alasan Penyesuaian < span class = "text-red-500" > *</ span >
</ label >
< textarea name = "reason" rows = "3" required placeholder = "Contoh: Hasil audit opname fisik akhir bulan; 2 pcs konektor rusak pecah dipisahkan..." class = "w-full px-3.5 py-2 rounded-xl border border-gray-200 text-sm focus:outline-none focus:border-purple-600" ></ textarea >
</ div >
< div class = "pt-4 border-t border-gray-100 flex items-center justify-end space-x-3" >
< button type = "button" onclick = "closeModalOpname()" class = "px-5 py-2.5 rounded-xl border border-gray-200 text-sm font-bold text-gray-600 hover:bg-gray-50 transition-colors" >
Batal
</ button >
< button type = "submit" class = "px-6 py-2.5 rounded-xl bg-purple-600 text-white text-sm font-bold shadow-sm shadow-purple-500/20 hover:bg-purple-700 transition-colors" >
Posting Penyesuaian
</ button >
</ div >
</ form >
</ div >
</ div >
<!-- ========================================================================= -->
<!-- JAVASCRIPT MODAL HANDLERS -->
<!-- ========================================================================= -->
< script >
// Create Modal
function openCreateItemModal () {
document . getElementById ( 'modalCreateItem' ). classList . remove ( 'hidden' );
}
function closeCreateItemModal () {
document . getElementById ( 'modalCreateItem' ). classList . add ( 'hidden' );
}
// In Modal
function openModalBarangMasuk () {
document . getElementById ( 'modalBarangMasuk' ). classList . remove ( 'hidden' );
}
function closeModalBarangMasuk () {
document . getElementById ( 'modalBarangMasuk' ). classList . add ( 'hidden' );
}
function openModalBarangMasukItem ( id , name , base , purchase ) {
openModalBarangMasuk ();
const select = document . getElementById ( 'in_item_select' );
select . value = id ;
}
// Out Modal
function openModalBarangKeluar () {
document . getElementById ( 'modalBarangKeluar' ). classList . remove ( 'hidden' );
}
function closeModalBarangKeluar () {
document . getElementById ( 'modalBarangKeluar' ). classList . add ( 'hidden' );
}
function openModalBarangKeluarItem ( id , name , base , stock ) {
openModalBarangKeluar ();
const select = document . getElementById ( 'out_item_select' );
select . value = id ;
}
// Opname Modal
function openModalOpname () {
document . getElementById ( 'modalOpname' ). classList . remove ( 'hidden' );
}
function closeModalOpname () {
document . getElementById ( 'modalOpname' ). classList . add ( 'hidden' );
}
let currentOpnameStock = 0 ;
function updateOpnameSystemStock ( select ) {
const option = select . options [ select . selectedIndex ];
if ( option && option . dataset . stock ) {
currentOpnameStock = parseFloat ( option . dataset . stock ) || 0 ;
const baseUnit = option . dataset . base || '' ;
document . getElementById ( 'opname_sys_stock' ). textContent = currentOpnameStock + ' ' + baseUnit ;
calculateOpnameDiff ();
} else {
currentOpnameStock = 0 ;
document . getElementById ( 'opname_sys_stock' ). textContent = '0' ;
document . getElementById ( 'opname_diff_display' ). textContent = '0' ;
}
}
function calculateOpnameDiff () {
const actualInput = document . getElementById ( 'opname_actual_input' );
const diffDisplay = document . getElementById ( 'opname_diff_display' );
const actual = parseFloat ( actualInput . value );
if ( ! isNaN ( actual )) {
const diff = actual - currentOpnameStock ;
if ( diff > 0 ) {
diffDisplay . textContent = '+' + diff ;
diffDisplay . className = 'text-lg font-black text-emerald-600' ;
} else if ( diff < 0 ) {
diffDisplay . textContent = diff ;
diffDisplay . className = 'text-lg font-black text-red-600' ;
} else {
diffDisplay . textContent = '0' ;
diffDisplay . className = 'text-lg font-black text-gray-500' ;
}
} else {
diffDisplay . textContent = '0' ;
diffDisplay . className = 'text-lg font-black text-gray-500' ;
}
}
2026-10-27 11:13:13 +07:00
// Close dropdowns when clicking outside
window . addEventListener ( 'click' , function ( e ) {
const exportMenu = document . getElementById ( 'exportMenuConsumable' );
if ( exportMenu && ! e . target . closest ( '#exportMenuConsumable' ) && ! e . target . closest ( 'button' )) {
exportMenu . style . display = 'none' ;
}
const trxMenu = document . getElementById ( 'trxMenuConsumable' );
if ( trxMenu && ! e . target . closest ( '#trxMenuConsumable' ) && ! e . target . closest ( 'button' )) {
trxMenu . style . display = 'none' ;
}
});
2026-10-27 09:42:15 +07:00
</ script >
{% endblock %}