Compare commits
13
Commits
614fe1cf0a
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cd6a1e6034 | ||
|
|
4d09fe29bd | ||
|
|
2713e89543 | ||
|
|
d3dfe4be3c | ||
|
|
78161aed01 | ||
|
|
5593bd9ccc | ||
|
|
1b645deff7 | ||
|
|
4bfeb96c4c | ||
|
|
08fecbc437 | ||
|
|
10a4c83f3b | ||
|
|
fc7abb013f | ||
|
|
9a5079e5f6 | ||
|
|
4b5c9f506d |
@@ -0,0 +1,519 @@
|
||||
from django.core.management.base import BaseCommand
|
||||
from django.contrib.auth.models import User
|
||||
from assets.models import ConfigurationItem, CIHistory, AssetUnit, Employee
|
||||
from datetime import date, timedelta
|
||||
from decimal import Decimal
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
help = 'Mengisi sampel data dummy Configuration Item (CI) dan riwayatnya untuk IT Asset Management'
|
||||
|
||||
def handle(self, *args, **options):
|
||||
self.stdout.write(self.style.NOTICE("Memeriksa dan mengisi data dummy Configuration Item (CI)..."))
|
||||
|
||||
admin_user = User.objects.filter(is_superuser=True).first()
|
||||
today = date.today()
|
||||
|
||||
# Dapatkan referensi unit dan karyawan yang ada di sistem
|
||||
unit_thinkpad = AssetUnit.objects.filter(unit_code='LNV-GEN12-001').first()
|
||||
unit_router = AssetUnit.objects.filter(unit_code='TPL-01-001').first()
|
||||
unit_acer2 = AssetUnit.objects.filter(unit_code='ACR-GEN11-002').first()
|
||||
unit_acer3 = AssetUnit.objects.filter(unit_code='ACR-GEN11-003').first()
|
||||
|
||||
emp_rayyan = Employee.objects.filter(name__icontains='Rayyan').first()
|
||||
emp_budi = Employee.objects.filter(name__icontains='Budi').first()
|
||||
emp_fallback = Employee.objects.first()
|
||||
|
||||
sample_cis = [
|
||||
# 1. STORAGE
|
||||
{
|
||||
'ci_code': 'CI-SSD-001',
|
||||
'name': 'Samsung SSD 980 PRO 1TB NVMe M.2 PCIe 4.0',
|
||||
'category': 'storage',
|
||||
'brand': 'Samsung',
|
||||
'model_series': '980 PRO 1TB (MZ-V8P1T0BW)',
|
||||
'serial_number': 'S6B1NF0R102938A',
|
||||
'specifications': 'Read up to 7,000 MB/s, Write up to 5,000 MB/s, V-NAND 3-bit MLC, PCIe Gen 4.0 x4',
|
||||
'status': 'in_use',
|
||||
'condition': 'good',
|
||||
'installed_on': unit_thinkpad,
|
||||
'assigned_to': None,
|
||||
'location': 'Terpasang di Laptop Rayyan Adam',
|
||||
'purchase_date': today - timedelta(days=240),
|
||||
'warranty_expiry': today + timedelta(days=850),
|
||||
'price': Decimal('2150000.00'),
|
||||
'notes': 'Upgrade storage utama workstation dev.',
|
||||
'history_action': 'installed',
|
||||
'history_notes': 'Dipasang sebagai upgrade SSD internal ThinkPad LNV-GEN12-001.'
|
||||
},
|
||||
{
|
||||
'ci_code': 'CI-SSD-002',
|
||||
'name': 'Kingston NV2 SSD 500GB NVMe PCIe 4.0 M.2',
|
||||
'category': 'storage',
|
||||
'brand': 'Kingston',
|
||||
'model_series': 'NV2 500G (SNV2S/500G)',
|
||||
'serial_number': '50026B7685930211',
|
||||
'specifications': 'Read 3,500 MB/s, Write 2,100 MB/s, Form Factor M.2 2280',
|
||||
'status': 'available',
|
||||
'condition': 'new',
|
||||
'installed_on': None,
|
||||
'assigned_to': None,
|
||||
'location': 'Gudang IT - Lemari Sparepart Rak 2',
|
||||
'purchase_date': today - timedelta(days=45),
|
||||
'warranty_expiry': today + timedelta(days=1050),
|
||||
'price': Decimal('620000.00'),
|
||||
'notes': 'Stok cadangan untuk penggantian darurat laptop operasional.',
|
||||
'history_action': 'created',
|
||||
'history_notes': 'Penerimaan barang pengadaan sparepart Q4.'
|
||||
},
|
||||
{
|
||||
'ci_code': 'CI-HDD-001',
|
||||
'name': 'Seagate IronWolf 4TB NAS Internal Hard Drive 3.5"',
|
||||
'category': 'storage',
|
||||
'brand': 'Seagate',
|
||||
'model_series': 'IronWolf ST4000VN006',
|
||||
'serial_number': 'WSD389102377',
|
||||
'specifications': '5400 RPM, 256MB Cache, SATA 6.0Gb/s 3.5", AgileArray Technology',
|
||||
'status': 'available',
|
||||
'condition': 'good',
|
||||
'installed_on': None,
|
||||
'assigned_to': None,
|
||||
'location': 'Ruang Server - Rak Storage Backup',
|
||||
'purchase_date': today - timedelta(days=180),
|
||||
'warranty_expiry': today + timedelta(days=550),
|
||||
'price': Decimal('1750000.00'),
|
||||
'notes': 'HDD spare untuk array Synology NAS Ruang Server.',
|
||||
'history_action': 'created',
|
||||
'history_notes': 'Penyimpanan cadangan cold spare NAS server.'
|
||||
},
|
||||
{
|
||||
'ci_code': 'CI-SSD-003',
|
||||
'name': 'Western Digital Blue 2.5" SATA SSD 500GB',
|
||||
'category': 'storage',
|
||||
'brand': 'Western Digital',
|
||||
'model_series': 'WD Blue SA510',
|
||||
'serial_number': 'WD-WCC4N728190',
|
||||
'specifications': 'SATA III 6 Gb/s 2.5 Inch 7mm, Read up to 560 MB/s',
|
||||
'status': 'under_inspection',
|
||||
'condition': 'fair',
|
||||
'installed_on': None,
|
||||
'assigned_to': None,
|
||||
'location': 'Workshop IT - Meja Diagnostic',
|
||||
'purchase_date': today - timedelta(days=400),
|
||||
'warranty_expiry': today + timedelta(days=300),
|
||||
'price': Decimal('750000.00'),
|
||||
'notes': 'Dilepas dari PC Administrasi karena ada laporan I/O error sporadis.',
|
||||
'history_action': 'status_change',
|
||||
'history_notes': 'Sedang dilakukan health test SMART diagnostic sektor.'
|
||||
},
|
||||
{
|
||||
'ci_code': 'CI-HDD-002',
|
||||
'name': 'WD Black 1TB 2.5" HDD SATA 7200 RPM',
|
||||
'category': 'storage',
|
||||
'brand': 'Western Digital',
|
||||
'model_series': 'WD10SPSX',
|
||||
'serial_number': 'WX31A6729012',
|
||||
'specifications': '7200 RPM, 64MB Cache, SATA 6Gb/s',
|
||||
'status': 'retired',
|
||||
'condition': 'damaged',
|
||||
'installed_on': None,
|
||||
'assigned_to': None,
|
||||
'location': 'Gudang Limbah IT - Kotak Scrap',
|
||||
'purchase_date': today - timedelta(days=1200),
|
||||
'warranty_expiry': today - timedelta(days=100),
|
||||
'price': Decimal('950000.00'),
|
||||
'notes': 'Mengalami bad sector parah dan unrecoverable read error. Selesai diaudit scrap.',
|
||||
'history_action': 'retired',
|
||||
'history_notes': 'Dipensiunkan dan didekripsikan untuk dimusnahkan sesuai SOP IT security.'
|
||||
},
|
||||
|
||||
# 2. MEMORY (RAM)
|
||||
{
|
||||
'ci_code': 'CI-RAM-001',
|
||||
'name': 'Corsair Vengeance SODIMM DDR4 16GB 3200MHz',
|
||||
'category': 'memory',
|
||||
'brand': 'Corsair',
|
||||
'model_series': 'CMSX16GX4M1A3200C22',
|
||||
'serial_number': 'CRS-16GB-829103',
|
||||
'specifications': '16GB DDR4 SODIMM 3200MHz CL22 1.2V Non-ECC',
|
||||
'status': 'in_use',
|
||||
'condition': 'good',
|
||||
'installed_on': unit_acer2,
|
||||
'assigned_to': None,
|
||||
'location': 'Terpasang di Laptop Acer Legion ACR-GEN11-002',
|
||||
'purchase_date': today - timedelta(days=190),
|
||||
'warranty_expiry': today + timedelta(days=900),
|
||||
'price': Decimal('750000.00'),
|
||||
'notes': 'Penambahan RAM laptop grafis Rayyan Adam.',
|
||||
'history_action': 'installed',
|
||||
'history_notes': 'Pemasangan ekspansi RAM di slot kedua laptop.'
|
||||
},
|
||||
{
|
||||
'ci_code': 'CI-RAM-002',
|
||||
'name': 'Kingston Fury Beast DDR4 16GB (2x8GB) 3200MHz',
|
||||
'category': 'memory',
|
||||
'brand': 'Kingston',
|
||||
'model_series': 'KF432C16BBK2/16',
|
||||
'serial_number': 'KF-DDR4-992101',
|
||||
'specifications': 'Dual Channel Kit 2x8GB DDR4-3200 CL16-18-18 1.35V Black Heatsink',
|
||||
'status': 'available',
|
||||
'condition': 'new',
|
||||
'installed_on': None,
|
||||
'assigned_to': None,
|
||||
'location': 'Gudang IT - Laci RAM & Storage',
|
||||
'purchase_date': today - timedelta(days=30),
|
||||
'warranty_expiry': today + timedelta(days=1400),
|
||||
'price': Decimal('890000.00'),
|
||||
'notes': 'Stok cadangan untuk PC engineering GIS.',
|
||||
'history_action': 'created',
|
||||
'history_notes': 'Registrasi item komponen baru di gudang.'
|
||||
},
|
||||
{
|
||||
'ci_code': 'CI-RAM-003',
|
||||
'name': 'Samsung DDR4 8GB 2666MHz SODIMM Original',
|
||||
'category': 'memory',
|
||||
'brand': 'Samsung',
|
||||
'model_series': 'M471A1K43CB1-CTD',
|
||||
'serial_number': 'SAM-D4-738192',
|
||||
'specifications': '8GB DDR4 2666V SODIMM 1Rx8 CL19 1.2V',
|
||||
'status': 'available',
|
||||
'condition': 'fair',
|
||||
'installed_on': None,
|
||||
'assigned_to': None,
|
||||
'location': 'Gudang IT - Laci RAM Bekas Pakai',
|
||||
'purchase_date': today - timedelta(days=500),
|
||||
'warranty_expiry': today + timedelta(days=200),
|
||||
'price': Decimal('420000.00'),
|
||||
'notes': 'RAM copotan laptop Lenovo lama, kondisi normal 100% lulus MemTest86.',
|
||||
'history_action': 'returned',
|
||||
'history_notes': 'Dikembalikan ke inventaris gudang setelah laptop donor diganti.'
|
||||
},
|
||||
|
||||
# 3. PROCESSOR & MOTHERBOARD
|
||||
{
|
||||
'ci_code': 'CI-CPU-001',
|
||||
'name': 'Intel Core i7-12700K Processor 25M Cache up to 5.00 GHz',
|
||||
'category': 'processor',
|
||||
'brand': 'Intel',
|
||||
'model_series': 'Core i7 12th Gen (BX8071512700K)',
|
||||
'serial_number': 'V219B82918231',
|
||||
'specifications': '12 Cores (8P + 4E), 20 Threads, LGA1700, Intel UHD Graphics 770',
|
||||
'status': 'available',
|
||||
'condition': 'good',
|
||||
'installed_on': None,
|
||||
'assigned_to': None,
|
||||
'location': 'Ruang Server - Brankas Sparepart IT',
|
||||
'purchase_date': today - timedelta(days=150),
|
||||
'warranty_expiry': today + timedelta(days=950),
|
||||
'price': Decimal('5200000.00'),
|
||||
'notes': 'CPU cadangan workstation server SCADA monitoring.',
|
||||
'history_action': 'created',
|
||||
'history_notes': 'Barang pengadaan darurat server SCADA.'
|
||||
},
|
||||
{
|
||||
'ci_code': 'CI-MBD-001',
|
||||
'name': 'ASUS TUF GAMING B660M-PLUS WIFI D4',
|
||||
'category': 'motherboard',
|
||||
'brand': 'ASUS',
|
||||
'model_series': 'TUF B660M-PLUS D4',
|
||||
'serial_number': 'M5N0CX1928371',
|
||||
'specifications': 'LGA 1700, 4x DDR4, 2x M.2 PCIe 4.0, Realtek 2.5Gb LAN, Intel WiFi 6',
|
||||
'status': 'available',
|
||||
'condition': 'good',
|
||||
'installed_on': None,
|
||||
'assigned_to': None,
|
||||
'location': 'Gudang IT - Rak Motherboard',
|
||||
'purchase_date': today - timedelta(days=150),
|
||||
'warranty_expiry': today + timedelta(days=950),
|
||||
'price': Decimal('2650000.00'),
|
||||
'notes': 'Pasangan sparepart motherboard untuk workstation SCADA.',
|
||||
'history_action': 'created',
|
||||
'history_notes': 'Disimpan sebagai unit hot-swap motherboard.'
|
||||
},
|
||||
|
||||
# 4. GPU & GRAPHIC CARD
|
||||
{
|
||||
'ci_code': 'CI-GPU-001',
|
||||
'name': 'ASUS Dual GeForce RTX 3060 V2 OC Edition 12GB GDDR6',
|
||||
'category': 'gpu',
|
||||
'brand': 'ASUS',
|
||||
'model_series': 'DUAL-RTX3060-O12G-V2',
|
||||
'serial_number': '21098471029381',
|
||||
'specifications': '12GB GDDR6, 192-bit, PCIe 4.0, 3x DisplayPort 1.4a, 1x HDMI 2.1',
|
||||
'status': 'available',
|
||||
'condition': 'good',
|
||||
'installed_on': None,
|
||||
'assigned_to': None,
|
||||
'location': 'Ruang Server - Rak Sparepart Hardware',
|
||||
'purchase_date': today - timedelta(days=220),
|
||||
'warranty_expiry': today + timedelta(days=500),
|
||||
'price': Decimal('4850000.00'),
|
||||
'notes': 'GPU untuk kebutuhan rendering 3D model DAM & Turbin Hydro.',
|
||||
'history_action': 'created',
|
||||
'history_notes': 'Disiapkan untuk workstation sipil engineering.'
|
||||
},
|
||||
|
||||
# 5. PERIPHERALS (Monitor, Keyboard, Mouse, Scanner, etc.)
|
||||
{
|
||||
'ci_code': 'CI-PER-001',
|
||||
'name': 'Monitor Dell 24" P2422H FHD IPS Ultra-Thin Bezel',
|
||||
'category': 'peripheral',
|
||||
'brand': 'Dell',
|
||||
'model_series': 'P2422H',
|
||||
'serial_number': 'CN-08W91-72872-91A',
|
||||
'specifications': '23.8" IPS 1920x1080 @60Hz, Pivot/Tilt/Swivel Height-Adjustable, VGA, HDMI, DP, USB Hub',
|
||||
'status': 'in_use',
|
||||
'condition': 'good',
|
||||
'installed_on': None,
|
||||
'assigned_to': emp_rayyan or emp_fallback,
|
||||
'location': 'Ruang IT Development / Workstation Rayyan',
|
||||
'purchase_date': today - timedelta(days=320),
|
||||
'warranty_expiry': today + timedelta(days=750),
|
||||
'price': Decimal('2850000.00'),
|
||||
'notes': 'Monitor sekunder dual-display untuk pemantauan sistem dan coding.',
|
||||
'history_action': 'assigned',
|
||||
'history_notes': 'Dialokasikan langsung ke Rayyan Adam sebagai monitor sekunder.'
|
||||
},
|
||||
{
|
||||
'ci_code': 'CI-PER-002',
|
||||
'name': 'Logitech MK270 Wireless Keyboard & Mouse Combo',
|
||||
'category': 'peripheral',
|
||||
'brand': 'Logitech',
|
||||
'model_series': 'MK270 Wireless Combo',
|
||||
'serial_number': '2142LZ028190',
|
||||
'specifications': '2.4GHz Wireless with Nano USB Receiver, Spill-resistant keyboard, 3-button optical mouse',
|
||||
'status': 'in_use',
|
||||
'condition': 'good',
|
||||
'installed_on': None,
|
||||
'assigned_to': emp_budi or emp_fallback,
|
||||
'location': 'Ruang Finance & Accounting',
|
||||
'purchase_date': today - timedelta(days=120),
|
||||
'warranty_expiry': today + timedelta(days=240),
|
||||
'price': Decimal('325000.00'),
|
||||
'notes': 'Perangkat input wireless operasional.',
|
||||
'history_action': 'assigned',
|
||||
'history_notes': 'Dialokasikan kepada Budi Santoso untuk laptop kerja.'
|
||||
},
|
||||
{
|
||||
'ci_code': 'CI-PER-003',
|
||||
'name': 'Monitor LG 27" UltraGear 27GP850-B Nano IPS QHD 165Hz',
|
||||
'category': 'peripheral',
|
||||
'brand': 'LG',
|
||||
'model_series': '27GP850-B',
|
||||
'serial_number': '208NTPW928173',
|
||||
'specifications': '27" Nano IPS 2560x1440 165Hz (O/C 180Hz) 1ms GtG, HDR400, G-Sync Compatible',
|
||||
'status': 'available',
|
||||
'condition': 'new',
|
||||
'installed_on': None,
|
||||
'assigned_to': None,
|
||||
'location': 'Gudang IT - Rak Monitor Box Original',
|
||||
'purchase_date': today - timedelta(days=14),
|
||||
'warranty_expiry': today + timedelta(days=1080),
|
||||
'price': Decimal('5400000.00'),
|
||||
'notes': 'Monitor baru untuk workstation simulator dispatch PLTA Kerinci.',
|
||||
'history_action': 'created',
|
||||
'history_notes': 'Penerimaan unit monitor baru dari vendor LG.'
|
||||
},
|
||||
{
|
||||
'ci_code': 'CI-PER-004',
|
||||
'name': 'Headset Jabra Evolve 20 Stereo USB & 3.5mm Noise Cancelling',
|
||||
'category': 'peripheral',
|
||||
'brand': 'Jabra',
|
||||
'model_series': 'Evolve 20 MS Stereo',
|
||||
'serial_number': 'JBR-EV20-19284',
|
||||
'specifications': 'Noise-cancelling microphone, USB-A and 3.5mm jack connectivity, In-line call controller',
|
||||
'status': 'available',
|
||||
'condition': 'new',
|
||||
'installed_on': None,
|
||||
'assigned_to': None,
|
||||
'location': 'Gudang IT - Lemari Aksesori & Audio',
|
||||
'purchase_date': today - timedelta(days=40),
|
||||
'warranty_expiry': today + timedelta(days=690),
|
||||
'price': Decimal('680000.00'),
|
||||
'notes': 'Headset standar untuk video conference manajemen.',
|
||||
'history_action': 'created',
|
||||
'history_notes': 'Stok baru pengadaan fasilitas meeting online.'
|
||||
},
|
||||
{
|
||||
'ci_code': 'CI-PER-005',
|
||||
'name': 'Honeywell Voyager 1472g Wireless 2D Barcode Scanner',
|
||||
'category': 'peripheral',
|
||||
'brand': 'Honeywell',
|
||||
'model_series': 'Voyager 1472g 2D',
|
||||
'serial_number': '21289B00192',
|
||||
'specifications': 'Area Image 2D (QR Code & Barcode), Bluetooth Range up to 30m, Cradle USB Base',
|
||||
'status': 'under_inspection',
|
||||
'condition': 'good',
|
||||
'installed_on': None,
|
||||
'assigned_to': None,
|
||||
'location': 'Workshop IT - Meja Service',
|
||||
'purchase_date': today - timedelta(days=360),
|
||||
'warranty_expiry': today + timedelta(days=370),
|
||||
'price': Decimal('3200000.00'),
|
||||
'notes': 'Scanner barcode gudang logistik, sedang diuji sinkronisasi Bluetooth dan daya baterai.',
|
||||
'history_action': 'status_change',
|
||||
'history_notes': 'Pemeriksaan performa baterai dan pembacaan barcode damaged.'
|
||||
},
|
||||
|
||||
# 6. NETWORK COMPONENTS (SFP, NIC, Adapter)
|
||||
{
|
||||
'ci_code': 'CI-NET-001',
|
||||
'name': 'Cisco 10GBASE-SR SFP+ Transceiver Module',
|
||||
'category': 'network',
|
||||
'brand': 'Cisco',
|
||||
'model_series': 'SFP-10G-SR',
|
||||
'serial_number': 'FNS22190A2B',
|
||||
'specifications': '10GBASE-SR 850nm Multimode Fiber LC Duplex up to 300m DOM support',
|
||||
'status': 'available',
|
||||
'condition': 'new',
|
||||
'installed_on': None,
|
||||
'assigned_to': None,
|
||||
'location': 'Ruang Server - Laci Fiber Transceiver',
|
||||
'purchase_date': today - timedelta(days=90),
|
||||
'warranty_expiry': today + timedelta(days=1000),
|
||||
'price': Decimal('1450000.00'),
|
||||
'notes': 'Modul SFP+ 10Gbps untuk interkoneksi switch core Cisco Catalyst.',
|
||||
'history_action': 'created',
|
||||
'history_notes': 'Stok modul optik cadangan link switch backbone.'
|
||||
},
|
||||
{
|
||||
'ci_code': 'CI-NET-002',
|
||||
'name': 'TP-Link UE300 USB 3.0 to Gigabit Ethernet Adapter',
|
||||
'category': 'network',
|
||||
'brand': 'TP-Link',
|
||||
'model_series': 'UE300 Foldable',
|
||||
'serial_number': '221B8910293',
|
||||
'specifications': 'USB 3.0 to RJ45 Gigabit Ethernet 10/100/1000Mbps, Plug and Play Windows/macOS',
|
||||
'status': 'available',
|
||||
'condition': 'good',
|
||||
'installed_on': None,
|
||||
'assigned_to': None,
|
||||
'location': 'Gudang IT - Laci Adapter & Converter',
|
||||
'purchase_date': today - timedelta(days=60),
|
||||
'warranty_expiry': today + timedelta(days=300),
|
||||
'price': Decimal('165000.00'),
|
||||
'notes': 'Adapter LAN eksternal untuk laptop tipis yang tidak memiliki port RJ45 bawaan.',
|
||||
'history_action': 'created',
|
||||
'history_notes': 'Penerimaan inventaris toolkit teknisi.'
|
||||
},
|
||||
{
|
||||
'ci_code': 'CI-NET-003',
|
||||
'name': 'MikroTik S-85DLC05D SFP Transceiver 1.25G 850nm MultiMode',
|
||||
'category': 'network',
|
||||
'brand': 'MikroTik',
|
||||
'model_series': 'S-85DLC05D',
|
||||
'serial_number': 'MT-SFP-091823',
|
||||
'specifications': '1.25G SFP, 850nm Dual LC connector, up to 550m, DDM',
|
||||
'status': 'in_use',
|
||||
'condition': 'good',
|
||||
'installed_on': unit_router,
|
||||
'assigned_to': None,
|
||||
'location': 'Terpasang pada Router TPL-01-001',
|
||||
'purchase_date': today - timedelta(days=210),
|
||||
'warranty_expiry': today + timedelta(days=155),
|
||||
'price': Decimal('320000.00'),
|
||||
'notes': 'Modul uplink fiber optik menuju switch intake.',
|
||||
'history_action': 'installed',
|
||||
'history_notes': 'Dipasang pada port SFP router jaringan.'
|
||||
},
|
||||
|
||||
# 7. POWER & UPS
|
||||
{
|
||||
'ci_code': 'CI-PWR-001',
|
||||
'name': 'UPS APC Back-UPS Pro BR1500GI 1500VA / 865W AVR LCD',
|
||||
'category': 'power',
|
||||
'brand': 'APC / Schneider Electric',
|
||||
'model_series': 'BR1500GI',
|
||||
'serial_number': '3B1928X01928',
|
||||
'specifications': '1500VA/865Watts, Line Interactive, AVR, LCD Interface, 6x IEC Battery Backup, Data line surge protection',
|
||||
'status': 'in_use',
|
||||
'condition': 'good',
|
||||
'installed_on': None,
|
||||
'assigned_to': emp_rayyan or emp_fallback,
|
||||
'location': 'Ruang Control Room & SCADA IT',
|
||||
'purchase_date': today - timedelta(days=300),
|
||||
'warranty_expiry': today + timedelta(days=430),
|
||||
'price': Decimal('5650000.00'),
|
||||
'notes': 'Pencatu daya darurat workstation monitor utama PLTA.',
|
||||
'history_action': 'assigned',
|
||||
'history_notes': 'Ditempatkan di workstation SCADA untuk backup listrik darurat.'
|
||||
},
|
||||
{
|
||||
'ci_code': 'CI-PWR-002',
|
||||
'name': 'Corsair RM750e 750W 80 Plus Gold Fully Modular Power Supply',
|
||||
'category': 'power',
|
||||
'brand': 'Corsair',
|
||||
'model_series': 'CP-9020262-NA (RMe Series)',
|
||||
'serial_number': 'CRS-PSU-750E-9102',
|
||||
'specifications': '750 Watt, 80 PLUS Gold Certified, ATX 3.0 & PCIe 5.0 Ready, Zero RPM Fan Mode, 105°C Capacitors',
|
||||
'status': 'available',
|
||||
'condition': 'new',
|
||||
'installed_on': None,
|
||||
'assigned_to': None,
|
||||
'location': 'Gudang IT - Rak Power Supply',
|
||||
'purchase_date': today - timedelta(days=50),
|
||||
'warranty_expiry': today + timedelta(days=1770),
|
||||
'price': Decimal('1850000.00'),
|
||||
'notes': 'PSU cadangan untuk PC rendering teknik dan PC server lokal.',
|
||||
'history_action': 'created',
|
||||
'history_notes': 'Penerimaan stok unit PSU high-efficiency.'
|
||||
},
|
||||
{
|
||||
'ci_code': 'CI-PWR-003',
|
||||
'name': 'APC Replacement Battery Cartridge RBC17 12V 9Ah',
|
||||
'category': 'power',
|
||||
'brand': 'APC',
|
||||
'model_series': 'APCRBC17',
|
||||
'serial_number': 'RBC17-202610-098',
|
||||
'specifications': '12V 9Ah VRLA Maintenance-Free Sealed Lead-Acid battery with suspended electrolyte',
|
||||
'status': 'under_repair',
|
||||
'condition': 'fair',
|
||||
'installed_on': None,
|
||||
'assigned_to': None,
|
||||
'location': 'Workshop IT - Lemari Charger & Baterai',
|
||||
'purchase_date': today - timedelta(days=420),
|
||||
'warranty_expiry': today - timedelta(days=55),
|
||||
'price': Decimal('650000.00'),
|
||||
'notes': 'Sedang dilakukan conditioning & re-charging cycle sebelum dipasang kembali.',
|
||||
'history_action': 'repair_in',
|
||||
'history_notes': 'Baterai mengalami penurunan kapasitas retensi daya; dalam perbaikan uji voltase.'
|
||||
},
|
||||
]
|
||||
|
||||
created_count = 0
|
||||
updated_count = 0
|
||||
|
||||
for item_data in sample_cis:
|
||||
history_action = item_data.pop('history_action')
|
||||
history_notes = item_data.pop('history_notes')
|
||||
|
||||
ci, created = ConfigurationItem.objects.get_or_create(
|
||||
ci_code=item_data['ci_code'],
|
||||
defaults=item_data
|
||||
)
|
||||
|
||||
if not created:
|
||||
# Perbarui data jika sudah ada agar tetap up-to-date
|
||||
for key, val in item_data.items():
|
||||
setattr(ci, key, val)
|
||||
ci.save()
|
||||
updated_count += 1
|
||||
self.stdout.write(f"[DIPERBARUI] CI: {ci.ci_code} - {ci.name}")
|
||||
else:
|
||||
created_count += 1
|
||||
self.stdout.write(self.style.SUCCESS(f"[BARU] CI: {ci.ci_code} - {ci.name}"))
|
||||
|
||||
# Buat entri riwayat jika belum ada riwayat untuk aksi ini
|
||||
if not ci.history.filter(action=history_action).exists():
|
||||
CIHistory.objects.create(
|
||||
ci=ci,
|
||||
action=history_action,
|
||||
related_unit=ci.installed_on,
|
||||
related_employee=ci.assigned_to,
|
||||
performed_by=admin_user,
|
||||
notes=history_notes
|
||||
)
|
||||
|
||||
self.stdout.write(self.style.SUCCESS(
|
||||
f"\nSelesai! Berhasil memproses Configuration Items: {created_count} baru, {updated_count} diperbarui."
|
||||
))
|
||||
@@ -1,7 +1,8 @@
|
||||
from django.core.management.base import BaseCommand
|
||||
from django.contrib.auth.models import User
|
||||
from assets.models import ConsumableItem, ConsumableTransaction
|
||||
from assets.models import ConsumableItem, ConsumableTransaction, Employee, AssetUnit
|
||||
from datetime import date
|
||||
from decimal import Decimal
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
@@ -22,11 +23,11 @@ class Command(BaseCommand):
|
||||
'description': 'Kabel jaringan utama untuk instalasi backbone dan drop point lokal.',
|
||||
'base_unit': 'meter',
|
||||
'purchase_unit': 'roll',
|
||||
'conversion_rate': 305.00,
|
||||
'initial_stock': 610.00, # 2 roll
|
||||
'minimum_stock': 100.00,
|
||||
'conversion_rate': Decimal('305.00'),
|
||||
'initial_stock': Decimal('610.00'), # 2 roll
|
||||
'minimum_stock': Decimal('100.00'),
|
||||
'location': 'Gudang Induk (GI)',
|
||||
'last_purchase_price': 1850000,
|
||||
'last_purchase_price': Decimal('1850000.00'),
|
||||
'notes': 'Stok pengadaan proyek Q3'
|
||||
},
|
||||
{
|
||||
@@ -38,11 +39,11 @@ class Command(BaseCommand):
|
||||
'description': 'Kabel fiber optik outdoor untuk interkoneksi bangunan dan intake.',
|
||||
'base_unit': 'meter',
|
||||
'purchase_unit': 'roll',
|
||||
'conversion_rate': 1000.00,
|
||||
'initial_stock': 1000.00, # 1 roll
|
||||
'minimum_stock': 200.00,
|
||||
'conversion_rate': Decimal('1000.00'),
|
||||
'initial_stock': Decimal('1000.00'), # 1 roll
|
||||
'minimum_stock': Decimal('200.00'),
|
||||
'location': 'Gudang Induk (GI)',
|
||||
'last_purchase_price': 1200000,
|
||||
'last_purchase_price': Decimal('1200000.00'),
|
||||
'notes': 'Jalur fiber optik area DAM & Power House'
|
||||
},
|
||||
{
|
||||
@@ -54,11 +55,11 @@ class Command(BaseCommand):
|
||||
'description': 'Konektor RJ45 crimping untuk terminasi kabel LAN.',
|
||||
'base_unit': 'pcs',
|
||||
'purchase_unit': 'box',
|
||||
'conversion_rate': 100.00,
|
||||
'initial_stock': 150.00,
|
||||
'minimum_stock': 30.00,
|
||||
'conversion_rate': Decimal('100.00'),
|
||||
'initial_stock': Decimal('150.00'),
|
||||
'minimum_stock': Decimal('30.00'),
|
||||
'location': 'Ruang Server / IT',
|
||||
'last_purchase_price': 250000,
|
||||
'last_purchase_price': Decimal('250000.00'),
|
||||
'notes': 'Sering digunakan teknisi lapangan'
|
||||
},
|
||||
{
|
||||
@@ -70,11 +71,11 @@ class Command(BaseCommand):
|
||||
'description': 'Konektor cepat fiber optik tanpa splicing fusion.',
|
||||
'base_unit': 'pcs',
|
||||
'purchase_unit': 'pack',
|
||||
'conversion_rate': 50.00,
|
||||
'initial_stock': 50.00,
|
||||
'minimum_stock': 15.00,
|
||||
'conversion_rate': Decimal('50.00'),
|
||||
'initial_stock': Decimal('50.00'),
|
||||
'minimum_stock': Decimal('15.00'),
|
||||
'location': 'Ruang Server / IT',
|
||||
'last_purchase_price': 175000,
|
||||
'last_purchase_price': Decimal('175000.00'),
|
||||
'notes': 'Untuk terminasi kabel drop optik'
|
||||
},
|
||||
{
|
||||
@@ -86,11 +87,11 @@ class Command(BaseCommand):
|
||||
'description': 'Pasta pendingin CPU/GPU server, PC workstation, dan laptop.',
|
||||
'base_unit': 'tube',
|
||||
'purchase_unit': None,
|
||||
'conversion_rate': 1.00,
|
||||
'initial_stock': 8.00,
|
||||
'minimum_stock': 2.00,
|
||||
'conversion_rate': Decimal('1.00'),
|
||||
'initial_stock': Decimal('8.00'),
|
||||
'minimum_stock': Decimal('2.00'),
|
||||
'location': 'Workshop IT',
|
||||
'last_purchase_price': 115000,
|
||||
'last_purchase_price': Decimal('115000.00'),
|
||||
'notes': 'Pemakaian preventive maintenance PC berkala'
|
||||
},
|
||||
{
|
||||
@@ -102,11 +103,11 @@ class Command(BaseCommand):
|
||||
'description': 'Pengikat kabel manajemen pada rak server dan jalur kabel tray.',
|
||||
'base_unit': 'pcs',
|
||||
'purchase_unit': 'pack',
|
||||
'conversion_rate': 100.00,
|
||||
'initial_stock': 400.00, # 4 pack
|
||||
'minimum_stock': 100.00,
|
||||
'conversion_rate': Decimal('100.00'),
|
||||
'initial_stock': Decimal('400.00'), # 4 pack
|
||||
'minimum_stock': Decimal('100.00'),
|
||||
'location': 'Ruang Server / IT',
|
||||
'last_purchase_price': 35000,
|
||||
'last_purchase_price': Decimal('35000.00'),
|
||||
'notes': 'Manajemen kabel rak & instalasi'
|
||||
},
|
||||
{
|
||||
@@ -118,11 +119,11 @@ class Command(BaseCommand):
|
||||
'description': 'Baut pemasangan switch, router, server, dan patch panel pada rak 19 inci.',
|
||||
'base_unit': 'set',
|
||||
'purchase_unit': 'pack',
|
||||
'conversion_rate': 50.00,
|
||||
'initial_stock': 100.00, # 2 pack
|
||||
'minimum_stock': 20.00,
|
||||
'conversion_rate': Decimal('50.00'),
|
||||
'initial_stock': Decimal('100.00'), # 2 pack
|
||||
'minimum_stock': Decimal('20.00'),
|
||||
'location': 'Ruang Server / IT',
|
||||
'last_purchase_price': 90000,
|
||||
'last_purchase_price': Decimal('90000.00'),
|
||||
'notes': 'Mounting rack unit'
|
||||
},
|
||||
{
|
||||
@@ -134,11 +135,11 @@ class Command(BaseCommand):
|
||||
'description': 'Isolasi listrik tahan panas dan cuaca untuk penyambungan kabel.',
|
||||
'base_unit': 'roll',
|
||||
'purchase_unit': None,
|
||||
'conversion_rate': 1.00,
|
||||
'initial_stock': 12.00,
|
||||
'minimum_stock': 3.00,
|
||||
'conversion_rate': Decimal('1.00'),
|
||||
'initial_stock': Decimal('12.00'),
|
||||
'minimum_stock': Decimal('3.00'),
|
||||
'location': 'Workshop IT',
|
||||
'last_purchase_price': 45000,
|
||||
'last_purchase_price': Decimal('45000.00'),
|
||||
'notes': 'Keperluan isolasi kabel listrik dan jaringan outdoor'
|
||||
},
|
||||
{
|
||||
@@ -150,11 +151,11 @@ class Command(BaseCommand):
|
||||
'description': 'Kabel patch cord pabrikan untuk koneksi dari patch panel ke switch.',
|
||||
'base_unit': 'pcs',
|
||||
'purchase_unit': None,
|
||||
'conversion_rate': 1.00,
|
||||
'initial_stock': 25.00,
|
||||
'minimum_stock': 10.00,
|
||||
'conversion_rate': Decimal('1.00'),
|
||||
'initial_stock': Decimal('25.00'),
|
||||
'minimum_stock': Decimal('10.00'),
|
||||
'location': 'Ruang Server / IT',
|
||||
'last_purchase_price': 35000,
|
||||
'last_purchase_price': Decimal('35000.00'),
|
||||
'notes': 'Kabel patching rak distribusi'
|
||||
},
|
||||
{
|
||||
@@ -166,11 +167,11 @@ class Command(BaseCommand):
|
||||
'description': 'Kabel display HDMI untuk ruang meeting, CCTV monitor, dan presentasi.',
|
||||
'base_unit': 'pcs',
|
||||
'purchase_unit': None,
|
||||
'conversion_rate': 1.00,
|
||||
'initial_stock': 6.00,
|
||||
'minimum_stock': 2.00,
|
||||
'conversion_rate': Decimal('1.00'),
|
||||
'initial_stock': Decimal('6.00'),
|
||||
'minimum_stock': Decimal('2.00'),
|
||||
'location': 'Ruang Server / IT',
|
||||
'last_purchase_price': 85000,
|
||||
'last_purchase_price': Decimal('85000.00'),
|
||||
'notes': 'Kabel display operasional kantor & meeting'
|
||||
},
|
||||
{
|
||||
@@ -182,13 +183,79 @@ class Command(BaseCommand):
|
||||
'description': 'Pembersih kontak soket RAM, PCIe, port switch, dan PCB.',
|
||||
'base_unit': 'can',
|
||||
'purchase_unit': None,
|
||||
'conversion_rate': 1.00,
|
||||
'initial_stock': 4.00,
|
||||
'minimum_stock': 2.00,
|
||||
'conversion_rate': Decimal('1.00'),
|
||||
'initial_stock': Decimal('4.00'),
|
||||
'minimum_stock': Decimal('2.00'),
|
||||
'location': 'Workshop IT',
|
||||
'last_purchase_price': 95000,
|
||||
'last_purchase_price': Decimal('95000.00'),
|
||||
'notes': 'Kimia pembersih maintenance hardware'
|
||||
},
|
||||
# Item Stok Menipis (Low Stock)
|
||||
{
|
||||
'item_code': 'CNS-CAB-005',
|
||||
'name': 'Kabel Power AC C13 Heavy Duty 1.8m 3x1.5mm',
|
||||
'category': 'cable',
|
||||
'brand': 'APC / Schneider',
|
||||
'specification': 'AC Power Cord C13 to Schuko Plug 250V 16A 1.8 Meter',
|
||||
'description': 'Kabel power standar untuk server, switch, PDU, dan monitor kerja.',
|
||||
'base_unit': 'pcs',
|
||||
'purchase_unit': None,
|
||||
'conversion_rate': Decimal('1.00'),
|
||||
'initial_stock': Decimal('2.00'),
|
||||
'minimum_stock': Decimal('5.00'),
|
||||
'location': 'Ruang Server / IT',
|
||||
'last_purchase_price': Decimal('45000.00'),
|
||||
'notes': 'Stok menipis, perlu pengadaan ulang untuk rak server.'
|
||||
},
|
||||
{
|
||||
'item_code': 'CNS-BAT-001',
|
||||
'name': 'Baterai Kancing CMOS CR2032 3V Lithium Coin',
|
||||
'category': 'tools_acc',
|
||||
'brand': 'Panasonic',
|
||||
'specification': 'Lithium Coin Cell 3V CR2032 DL2032 225mAh',
|
||||
'description': 'Baterai backup BIOS/CMOS motherboard PC, laptop, dan kontroler PLC.',
|
||||
'base_unit': 'pcs',
|
||||
'purchase_unit': 'strip',
|
||||
'conversion_rate': Decimal('5.00'),
|
||||
'initial_stock': Decimal('3.00'),
|
||||
'minimum_stock': Decimal('10.00'),
|
||||
'location': 'Workshop IT - Laci Baterai',
|
||||
'last_purchase_price': Decimal('15000.00'),
|
||||
'notes': 'Sering digunakan untuk pergantian baterai motherboard lama.'
|
||||
},
|
||||
# Item Stok Habis (Out of Stock)
|
||||
{
|
||||
'item_code': 'CNS-CON-003',
|
||||
'name': 'RJ45 Modular Inline Coupler Barrel Female-to-Female Cat6',
|
||||
'category': 'connector',
|
||||
'brand': 'D-Link / Vention',
|
||||
'specification': 'Cat6 Shielded RJ45 Female to Female Keystone Coupler Adapter',
|
||||
'description': 'Penyambung barrel darurat untuk ekstensi kabel LAN tanpa crimping ulang.',
|
||||
'base_unit': 'pcs',
|
||||
'purchase_unit': 'pack',
|
||||
'conversion_rate': Decimal('10.00'),
|
||||
'initial_stock': Decimal('0.00'),
|
||||
'minimum_stock': Decimal('5.00'),
|
||||
'location': 'Workshop IT',
|
||||
'last_purchase_price': Decimal('25000.00'),
|
||||
'notes': 'Stok habis total, sedang diajukan pembelian ke vendor.'
|
||||
},
|
||||
{
|
||||
'item_code': 'CNS-CLN-002',
|
||||
'name': 'Compressed Air Duster Cleaner Can 400ml',
|
||||
'category': 'cleaning',
|
||||
'brand': 'Falcon Dust-Off',
|
||||
'specification': 'Gas aerosol pembersih debu bertekanan tinggi 400ml non-CFC',
|
||||
'description': 'Pembersih debu kipas heatsink, power supply, dan kisi-kisi radiator server.',
|
||||
'base_unit': 'can',
|
||||
'purchase_unit': None,
|
||||
'conversion_rate': Decimal('1.00'),
|
||||
'initial_stock': Decimal('0.00'),
|
||||
'minimum_stock': Decimal('4.00'),
|
||||
'location': 'Workshop IT',
|
||||
'last_purchase_price': Decimal('75000.00'),
|
||||
'notes': 'Stok habis, pending approval pengadaan logistik.'
|
||||
},
|
||||
]
|
||||
|
||||
created_count = 0
|
||||
@@ -222,9 +289,9 @@ class Command(BaseCommand):
|
||||
item=item,
|
||||
quantity=data['initial_stock'],
|
||||
unit=data['base_unit'],
|
||||
conversion_rate=1.00,
|
||||
conversion_rate=Decimal('1.00'),
|
||||
quantity_base=data['initial_stock'],
|
||||
stock_before=0.00,
|
||||
stock_before=Decimal('0.00'),
|
||||
stock_after=data['initial_stock'],
|
||||
source_destination='Stok Awal Terotorisasi',
|
||||
performed_by=admin_user,
|
||||
@@ -235,4 +302,93 @@ class Command(BaseCommand):
|
||||
else:
|
||||
self.stdout.write(f"[ADA] Consumable Item: {item.item_code} - {item.name}")
|
||||
|
||||
# Tambahkan transaksi mutasi keluar (pemakaian teknisi) sebagai sampel realistis
|
||||
emp_rayyan = Employee.objects.filter(name__icontains='Rayyan').first()
|
||||
unit_thinkpad = AssetUnit.objects.filter(unit_code='LNV-GEN12-001').first()
|
||||
|
||||
# 1. Transaksi keluar Kabel Belden
|
||||
item_kabel = ConsumableItem.objects.filter(item_code='CNS-CAB-001').first()
|
||||
if item_kabel and not ConsumableTransaction.objects.filter(transaction_code='TRX-OUT-CNS-CAB-001-DEMO').exists():
|
||||
qty_out = Decimal('35.00')
|
||||
stock_before = item_kabel.stock_available
|
||||
stock_after = max(Decimal('0.00'), stock_before - qty_out)
|
||||
item_kabel.stock_available = stock_after
|
||||
item_kabel.save()
|
||||
|
||||
ConsumableTransaction.objects.create(
|
||||
transaction_code='TRX-OUT-CNS-CAB-001-DEMO',
|
||||
transaction_type='out',
|
||||
item=item_kabel,
|
||||
quantity=qty_out,
|
||||
unit=item_kabel.base_unit,
|
||||
conversion_rate=Decimal('1.00'),
|
||||
quantity_base=qty_out,
|
||||
stock_before=stock_before,
|
||||
stock_after=stock_after,
|
||||
source_destination='Lantai 2 Kantor Administrasi & Finance',
|
||||
recipient_employee=emp_rayyan,
|
||||
ticket_number='WO-NET-202610-014',
|
||||
performed_by=admin_user,
|
||||
transaction_date=date.today(),
|
||||
notes='Penarikan kabel LAN drop point baru ruang meeting dan finance.'
|
||||
)
|
||||
self.stdout.write(self.style.SUCCESS("[BARU] Transaksi Keluar: 35 meter Kabel Cat6 Belden."))
|
||||
|
||||
# 2. Transaksi keluar Konektor RJ45
|
||||
item_rj45 = ConsumableItem.objects.filter(item_code='CNS-CON-001').first()
|
||||
if item_rj45 and not ConsumableTransaction.objects.filter(transaction_code='TRX-OUT-CNS-CON-001-DEMO').exists():
|
||||
qty_out = Decimal('12.00')
|
||||
stock_before = item_rj45.stock_available
|
||||
stock_after = max(Decimal('0.00'), stock_before - qty_out)
|
||||
item_rj45.stock_available = stock_after
|
||||
item_rj45.save()
|
||||
|
||||
ConsumableTransaction.objects.create(
|
||||
transaction_code='TRX-OUT-CNS-CON-001-DEMO',
|
||||
transaction_type='out',
|
||||
item=item_rj45,
|
||||
quantity=qty_out,
|
||||
unit=item_rj45.base_unit,
|
||||
conversion_rate=Decimal('1.00'),
|
||||
quantity_base=qty_out,
|
||||
stock_before=stock_before,
|
||||
stock_after=stock_after,
|
||||
source_destination='Workshop IT - Crimping Patch Cable',
|
||||
recipient_employee=emp_rayyan,
|
||||
ticket_number='WO-NET-202610-015',
|
||||
performed_by=admin_user,
|
||||
transaction_date=date.today(),
|
||||
notes='Crimping 6 buah patch cord custom untuk rack distribution switch.'
|
||||
)
|
||||
self.stdout.write(self.style.SUCCESS("[BARU] Transaksi Keluar: 12 pcs RJ45 Cat6."))
|
||||
|
||||
# 3. Transaksi keluar Thermal Paste
|
||||
item_pasta = ConsumableItem.objects.filter(item_code='CNS-MNT-001').first()
|
||||
if item_pasta and not ConsumableTransaction.objects.filter(transaction_code='TRX-OUT-CNS-MNT-001-DEMO').exists():
|
||||
qty_out = Decimal('1.00')
|
||||
stock_before = item_pasta.stock_available
|
||||
stock_after = max(Decimal('0.00'), stock_before - qty_out)
|
||||
item_pasta.stock_available = stock_after
|
||||
item_pasta.save()
|
||||
|
||||
ConsumableTransaction.objects.create(
|
||||
transaction_code='TRX-OUT-CNS-MNT-001-DEMO',
|
||||
transaction_type='out',
|
||||
item=item_pasta,
|
||||
quantity=qty_out,
|
||||
unit=item_pasta.base_unit,
|
||||
conversion_rate=Decimal('1.00'),
|
||||
quantity_base=qty_out,
|
||||
stock_before=stock_before,
|
||||
stock_after=stock_after,
|
||||
source_destination='Maintenance Laptop Karyawan',
|
||||
recipient_employee=emp_rayyan,
|
||||
related_unit=unit_thinkpad,
|
||||
ticket_number='WO-HW-202610-008',
|
||||
performed_by=admin_user,
|
||||
transaction_date=date.today(),
|
||||
notes='Repasting CPU dan GPU laptop operasional ThinkPad T14.'
|
||||
)
|
||||
self.stdout.write(self.style.SUCCESS("[BARU] Transaksi Keluar: 1 tube Thermal Paste MX-4."))
|
||||
|
||||
self.stdout.write(self.style.SUCCESS(f"Selesai! Berhasil menambahkan {created_count} item consumable baru."))
|
||||
|
||||
@@ -66,6 +66,8 @@ from .ci_views import (
|
||||
ci_remove,
|
||||
ci_replace,
|
||||
ci_report_damage,
|
||||
ci_export_excel,
|
||||
ci_export_pdf,
|
||||
)
|
||||
|
||||
# Consumable Item (Barang Habis Pakai)
|
||||
@@ -159,6 +161,8 @@ __all__ = [
|
||||
'ci_remove',
|
||||
'ci_replace',
|
||||
'ci_report_damage',
|
||||
'ci_export_excel',
|
||||
'ci_export_pdf',
|
||||
# Consumable Items
|
||||
'consumable_list',
|
||||
'consumable_detail',
|
||||
|
||||
+393
-1
@@ -3,7 +3,7 @@ from datetime import datetime
|
||||
from django.shortcuts import render, redirect, get_object_or_404
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from django.contrib import messages
|
||||
from django.http import JsonResponse
|
||||
from django.http import HttpResponse, JsonResponse
|
||||
from django.db import transaction
|
||||
from django.db.models import Count, Q
|
||||
from django.core.paginator import Paginator
|
||||
@@ -496,3 +496,395 @@ def ci_report_damage(request, ci_id):
|
||||
messages.success(request, f'Komponen {ci.ci_code} selesai diperbaiki dan siap digunakan.')
|
||||
|
||||
return redirect(request.META.get('HTTP_REFERER', 'ci_list'))
|
||||
|
||||
|
||||
@login_required
|
||||
def ci_export_excel(request):
|
||||
"""Menghasilkan laporan Excel profesional untuk katalog Configuration Item."""
|
||||
from openpyxl import Workbook
|
||||
from openpyxl.styles import Font, Alignment, PatternFill, Border, Side
|
||||
|
||||
search_query = request.GET.get('q', '').strip()
|
||||
status_filter = request.GET.get('status', '').strip()
|
||||
category_filter = request.GET.get('category', '').strip()
|
||||
condition_filter = request.GET.get('condition', '').strip()
|
||||
|
||||
ci_qs = ConfigurationItem.objects.select_related(
|
||||
'installed_on', 'installed_on__asset', 'installed_on__assigned_to', 'assigned_to'
|
||||
).order_by('category', 'ci_code')
|
||||
|
||||
if status_filter:
|
||||
if status_filter == 'repair':
|
||||
ci_qs = ci_qs.filter(status__in=['under_inspection', 'under_repair'])
|
||||
else:
|
||||
ci_qs = ci_qs.filter(status=status_filter)
|
||||
|
||||
if category_filter:
|
||||
ci_qs = ci_qs.filter(category=category_filter)
|
||||
|
||||
if condition_filter:
|
||||
ci_qs = ci_qs.filter(condition=condition_filter)
|
||||
|
||||
if search_query:
|
||||
ci_qs = ci_qs.filter(
|
||||
Q(ci_code__icontains=search_query) |
|
||||
Q(name__icontains=search_query) |
|
||||
Q(brand__icontains=search_query) |
|
||||
Q(model_series__icontains=search_query) |
|
||||
Q(serial_number__icontains=search_query) |
|
||||
Q(specifications__icontains=search_query) |
|
||||
Q(installed_on__unit_code__icontains=search_query) |
|
||||
Q(assigned_to__name__icontains=search_query)
|
||||
)
|
||||
|
||||
wb = Workbook()
|
||||
ws = wb.active
|
||||
ws.title = "Katalog CI"
|
||||
|
||||
title_font = Font(size=14, bold=True, color="002060")
|
||||
subtitle_font = Font(size=10, italic=True, color="555555")
|
||||
header_font = Font(bold=True, color="FFFFFF")
|
||||
header_fill = PatternFill(start_color="002060", end_color="002060", fill_type="solid")
|
||||
center_align = Alignment(horizontal="center", vertical="center")
|
||||
left_align = Alignment(horizontal="left", vertical="center")
|
||||
thin_border = Border(
|
||||
left=Side(style='thin', color='CCCCCC'),
|
||||
right=Side(style='thin', color='CCCCCC'),
|
||||
top=Side(style='thin', color='CCCCCC'),
|
||||
bottom=Side(style='thin', color='CCCCCC')
|
||||
)
|
||||
|
||||
ws.merge_cells('A1:J1')
|
||||
ws['A1'] = "LAPORAN CONFIGURATION ITEM (CI) - PT. KERINCI HYDROPOWER"
|
||||
ws['A1'].font = title_font
|
||||
ws['A1'].alignment = left_align
|
||||
|
||||
ws.merge_cells('A2:J2')
|
||||
ws['A2'] = f"Tanggal Ekspor: {datetime.now().strftime('%d %B %Y %H:%M')} WIB | Dicetak oleh: {request.user.get_full_name() or request.user.username}"
|
||||
ws['A2'].font = subtitle_font
|
||||
ws['A2'].alignment = left_align
|
||||
|
||||
headers = [
|
||||
"No", "Kode CI", "Nama Komponen", "Kategori", "Merek & Model",
|
||||
"Nomor Seri (S/N)", "Status", "Kondisi", "Perangkat Terpasang", "PIC / Pengguna"
|
||||
]
|
||||
ws.append([])
|
||||
ws.append(headers)
|
||||
|
||||
for col_idx in range(1, len(headers) + 1):
|
||||
cell = ws.cell(row=4, column=col_idx)
|
||||
cell.font = header_font
|
||||
cell.fill = header_fill
|
||||
cell.alignment = center_align
|
||||
|
||||
for idx, ci in enumerate(ci_qs, 1):
|
||||
installed = f"{ci.installed_on.unit_code} ({ci.installed_on.asset.name})" if ci.installed_on else "-"
|
||||
pic = ci.assigned_to.name if ci.assigned_to else (ci.installed_on.assigned_to.name if ci.installed_on and ci.installed_on.assigned_to else "-")
|
||||
row = [
|
||||
idx,
|
||||
ci.ci_code,
|
||||
ci.name,
|
||||
ci.get_category_display(),
|
||||
f"{ci.brand or ''} {ci.model_series or ''}".strip() or "-",
|
||||
ci.serial_number or "-",
|
||||
ci.get_status_display(),
|
||||
ci.get_condition_display(),
|
||||
installed,
|
||||
pic
|
||||
]
|
||||
ws.append(row)
|
||||
curr_row = ws.max_row
|
||||
for col_idx in range(1, len(headers) + 1):
|
||||
c = ws.cell(row=curr_row, column=col_idx)
|
||||
c.border = thin_border
|
||||
if col_idx in [1, 2, 7, 8]:
|
||||
c.alignment = center_align
|
||||
else:
|
||||
c.alignment = left_align
|
||||
|
||||
col_widths = {'A': 6, 'B': 18, 'C': 26, 'D': 16, 'E': 20, 'F': 20, 'G': 16, 'H': 14, 'I': 24, 'J': 22}
|
||||
for col, width in col_widths.items():
|
||||
ws.column_dimensions[col].width = width
|
||||
|
||||
response = HttpResponse(content_type='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet')
|
||||
filename = f"laporan_configuration_item_{datetime.now().strftime('%Y%m%d_%H%M%S')}.xlsx"
|
||||
response['Content-Disposition'] = f'attachment; filename="{filename}"'
|
||||
wb.save(response)
|
||||
return response
|
||||
|
||||
|
||||
@login_required
|
||||
def ci_export_pdf(request):
|
||||
"""Menghasilkan laporan PDF resmi untuk Configuration Item yang seragam dengan modul lainnya."""
|
||||
import os
|
||||
import datetime
|
||||
from io import BytesIO
|
||||
from PIL import Image
|
||||
|
||||
from django.conf import settings
|
||||
from django.http import HttpResponse
|
||||
from django.db.models import Q
|
||||
|
||||
from reportlab.lib.pagesizes import A4, landscape
|
||||
from reportlab.lib.units import mm, cm
|
||||
from reportlab.lib.colors import HexColor, white
|
||||
from reportlab.platypus import SimpleDocTemplate, Table, TableStyle, Paragraph, Spacer
|
||||
from reportlab.platypus.flowables import HRFlowable
|
||||
from reportlab.platypus import Image as RLImage
|
||||
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
|
||||
from reportlab.lib.enums import TA_CENTER, TA_LEFT, TA_RIGHT
|
||||
|
||||
search_query = request.GET.get('q', '').strip()
|
||||
status_filter = request.GET.get('status', '').strip()
|
||||
category_filter = request.GET.get('category', '').strip()
|
||||
condition_filter = request.GET.get('condition', '').strip()
|
||||
|
||||
ci_qs = ConfigurationItem.objects.select_related(
|
||||
'installed_on', 'installed_on__asset', 'installed_on__assigned_to', 'assigned_to'
|
||||
).order_by('category', 'ci_code')
|
||||
|
||||
status_labels = {
|
||||
'available': 'Tersedia',
|
||||
'in_use': 'Sedang Digunakan',
|
||||
'repair': 'Maintenance',
|
||||
'under_repair': 'Maintenance',
|
||||
'under_inspection': 'Maintenance',
|
||||
'retired': 'Pensiun / Bricked',
|
||||
}
|
||||
status_label = status_labels.get(status_filter, 'Semua Status')
|
||||
|
||||
if status_filter:
|
||||
if status_filter == 'repair':
|
||||
ci_qs = ci_qs.filter(status__in=['under_inspection', 'under_repair'])
|
||||
else:
|
||||
ci_qs = ci_qs.filter(status=status_filter)
|
||||
|
||||
cat_dict = dict(ConfigurationItem.CATEGORY_CHOICES)
|
||||
cat_label = cat_dict.get(category_filter, 'Semua Kategori') if category_filter else 'Semua Kategori'
|
||||
if category_filter:
|
||||
ci_qs = ci_qs.filter(category=category_filter)
|
||||
|
||||
cond_dict = dict(ConfigurationItem.CONDITION_CHOICES)
|
||||
cond_label = cond_dict.get(condition_filter, '') if condition_filter else ''
|
||||
if condition_filter:
|
||||
ci_qs = ci_qs.filter(condition=condition_filter)
|
||||
|
||||
if search_query:
|
||||
ci_qs = ci_qs.filter(
|
||||
Q(ci_code__icontains=search_query) |
|
||||
Q(name__icontains=search_query) |
|
||||
Q(brand__icontains=search_query) |
|
||||
Q(model_series__icontains=search_query) |
|
||||
Q(serial_number__icontains=search_query) |
|
||||
Q(specifications__icontains=search_query) |
|
||||
Q(installed_on__unit_code__icontains=search_query) |
|
||||
Q(assigned_to__name__icontains=search_query)
|
||||
)
|
||||
|
||||
navy = HexColor('#002060')
|
||||
alt_row = HexColor('#F8F9FC')
|
||||
border_color = HexColor('#D0D5DD')
|
||||
|
||||
buffer = BytesIO()
|
||||
doc = SimpleDocTemplate(
|
||||
buffer,
|
||||
pagesize=landscape(A4),
|
||||
leftMargin=1.5 * cm,
|
||||
rightMargin=1.5 * cm,
|
||||
topMargin=1.5 * cm,
|
||||
bottomMargin=2 * cm
|
||||
)
|
||||
page_width = landscape(A4)[0] - 3 * cm
|
||||
|
||||
styles = getSampleStyleSheet()
|
||||
title_style = ParagraphStyle('CustomTitle', parent=styles['Normal'], fontName='Helvetica-Bold', fontSize=16, textColor=white, leading=20)
|
||||
subtitle_style = ParagraphStyle('CustomSubtitle', parent=styles['Normal'], fontName='Helvetica', fontSize=10, textColor=HexColor('#B0C4DE'), leading=14)
|
||||
company_style = ParagraphStyle('CompanyName', parent=styles['Normal'], fontName='Helvetica-Bold', fontSize=11, textColor=white, alignment=TA_RIGHT, leading=14)
|
||||
company_sub_style = ParagraphStyle('CompanySub', parent=styles['Normal'], fontName='Helvetica', fontSize=8, textColor=HexColor('#B0C4DE'), alignment=TA_RIGHT, leading=11)
|
||||
|
||||
cell_style = ParagraphStyle('CellStyle', parent=styles['Normal'], fontName='Helvetica', fontSize=8.5, leading=11)
|
||||
cell_bold_style = ParagraphStyle('CellBoldStyle', parent=styles['Normal'], fontName='Helvetica-Bold', fontSize=8.5, leading=11)
|
||||
cell_small = ParagraphStyle('CellSmall', parent=styles['Normal'], fontName='Helvetica', fontSize=7.5, textColor=HexColor('#666666'), leading=9)
|
||||
header_cell = ParagraphStyle('HeaderCell', parent=styles['Normal'], fontName='Helvetica-Bold', fontSize=8, textColor=white, alignment=TA_CENTER, leading=11)
|
||||
cell_center = ParagraphStyle('CellCenter', parent=styles['Normal'], fontName='Helvetica', fontSize=8.5, alignment=TA_CENTER)
|
||||
info_style = ParagraphStyle('InfoStyle', parent=styles['Normal'], fontName='Helvetica', fontSize=9, textColor=HexColor('#555555'))
|
||||
info_bold = ParagraphStyle('InfoBold', parent=styles['Normal'], fontName='Helvetica-Bold', fontSize=9, textColor=HexColor('#333333'))
|
||||
|
||||
elements = []
|
||||
now = datetime.datetime.now()
|
||||
bulan_indo = {
|
||||
1: 'Januari', 2: 'Februari', 3: 'Maret', 4: 'April',
|
||||
5: 'Mei', 6: 'Juni', 7: 'Juli', 8: 'Agustus',
|
||||
9: 'September', 10: 'Oktober', 11: 'November', 12: 'Desember'
|
||||
}
|
||||
tanggal_str = f"{now.day} {bulan_indo[now.month]} {now.year}"
|
||||
|
||||
# Top Logos
|
||||
try:
|
||||
it_logo_path = os.path.join(settings.BASE_DIR, 'static', 'img', 'it_all_role_logo.png')
|
||||
kerinci_logo_path = os.path.join(settings.BASE_DIR, 'static', 'img', 'kerinci_logo.png')
|
||||
desired_height = 1.3 * cm
|
||||
it_img = Image.open(it_logo_path)
|
||||
it_rl_img = RLImage(it_logo_path, width=desired_height * (it_img.width / float(it_img.height)), height=desired_height)
|
||||
ker_img = Image.open(kerinci_logo_path)
|
||||
ker_rl_img = RLImage(kerinci_logo_path, width=desired_height * (ker_img.width / float(ker_img.height)), height=desired_height)
|
||||
logo_table = Table([[ker_rl_img, it_rl_img]], colWidths=[page_width/2, page_width/2])
|
||||
logo_table.setStyle(TableStyle([
|
||||
('ALIGN', (0, 0), (0, 0), 'LEFT'),
|
||||
('ALIGN', (1, 0), (1, 0), 'RIGHT'),
|
||||
('VALIGN', (0, 0), (-1, -1), 'MIDDLE'),
|
||||
('BOTTOMPADDING', (0, 0), (-1, -1), 10),
|
||||
('TOPPADDING', (0, 0), (-1, -1), 0)
|
||||
]))
|
||||
elements.append(logo_table)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
category_label = f"Status: {status_label} - Kategori: {cat_label}"
|
||||
|
||||
# Navy Header Banner
|
||||
header_data = [[
|
||||
[Paragraph('Laporan Configuration Item', title_style), Paragraph(f'{category_label} - {tanggal_str}', subtitle_style)],
|
||||
[Paragraph('SISTEM MANAJEMEN ASET IT', company_style), Paragraph('Dicetak otomatis dari sistem', company_sub_style)]
|
||||
]]
|
||||
header_table = Table(header_data, colWidths=[page_width * 0.65, page_width * 0.35])
|
||||
header_table.setStyle(TableStyle([
|
||||
('BACKGROUND', (0, 0), (-1, -1), navy),
|
||||
('VALIGN', (0, 0), (-1, -1), 'MIDDLE'),
|
||||
('LEFTPADDING', (0, 0), (0, 0), 20),
|
||||
('RIGHTPADDING', (-1, -1), (-1, -1), 20),
|
||||
('TOPPADDING', (0, 0), (-1, -1), 14),
|
||||
('BOTTOMPADDING', (0, 0), (-1, -1), 14),
|
||||
('ROUNDEDCORNERS', [6, 6, 0, 0]),
|
||||
]))
|
||||
elements.append(header_table)
|
||||
elements.append(Spacer(1, 8 * mm))
|
||||
|
||||
# Metadata Grid
|
||||
total_data = ci_qs.count()
|
||||
info_data = [
|
||||
[Paragraph('Kategori', info_style), Paragraph(f': {category_label}', info_bold), Paragraph('Total Data', info_style), Paragraph(f': {total_data} komponen', info_bold)]
|
||||
]
|
||||
row_2 = [Paragraph('Tanggal Cetak', info_style), Paragraph(f': {tanggal_str}, {now.strftime("%H:%M")} WIB', info_bold)]
|
||||
filters_desc = []
|
||||
if cond_label: filters_desc.append(f"Kondisi: {cond_label}")
|
||||
if search_query: filters_desc.append(f"Cari: '{search_query}'")
|
||||
if filters_desc:
|
||||
row_2.extend([Paragraph('Filter', info_style), Paragraph(f': {", ".join(filters_desc)}', info_bold)])
|
||||
else:
|
||||
row_2.extend(['', ''])
|
||||
info_data.append(row_2)
|
||||
|
||||
info_table = Table(info_data, colWidths=[page_width * 0.12, page_width * 0.38, page_width * 0.12, page_width * 0.38])
|
||||
info_table.setStyle(TableStyle([
|
||||
('VALIGN', (0, 0), (-1, -1), 'TOP'),
|
||||
('TOPPADDING', (0, 0), (-1, -1), 2),
|
||||
('BOTTOMPADDING', (0, 0), (-1, -1), 2),
|
||||
('LEFTPADDING', (0, 0), (-1, -1), 0)
|
||||
]))
|
||||
elements.append(info_table)
|
||||
elements.append(Spacer(1, 6 * mm))
|
||||
elements.append(HRFlowable(width="100%", thickness=1, color=border_color, spaceAfter=4 * mm))
|
||||
|
||||
# Table Header & Data
|
||||
table_header = [
|
||||
Paragraph('NO', header_cell),
|
||||
Paragraph('KODE ITEM', header_cell),
|
||||
Paragraph('NAMA & KOMPONEN', header_cell),
|
||||
Paragraph('KATEGORI', header_cell),
|
||||
Paragraph('NOMOR SERI (S/N)', header_cell),
|
||||
Paragraph('PERANGKAT / PENGGUNA', header_cell),
|
||||
Paragraph('KONDISI', header_cell),
|
||||
Paragraph('STATUS', header_cell)
|
||||
]
|
||||
col_widths = [
|
||||
page_width * 0.05,
|
||||
page_width * 0.14,
|
||||
page_width * 0.23,
|
||||
page_width * 0.12,
|
||||
page_width * 0.13,
|
||||
page_width * 0.17,
|
||||
page_width * 0.08,
|
||||
page_width * 0.08
|
||||
]
|
||||
table_data = [table_header]
|
||||
|
||||
for idx, ci in enumerate(ci_qs, 1):
|
||||
brand_model = f"{ci.brand or ''} {ci.model_series or ''}".strip()
|
||||
comp_info = [Paragraph(ci.name, cell_bold_style)]
|
||||
if brand_model:
|
||||
comp_info.append(Paragraph(brand_model, cell_small))
|
||||
|
||||
if ci.installed_on:
|
||||
pic_name = ci.installed_on.assigned_to.name if ci.installed_on.assigned_to else "Gudang"
|
||||
holder_info = [
|
||||
Paragraph(ci.installed_on.unit_code, cell_bold_style),
|
||||
Paragraph(f"{ci.installed_on.asset.name} (PIC: {pic_name})", cell_small)
|
||||
]
|
||||
elif ci.assigned_to:
|
||||
holder_info = [
|
||||
Paragraph(ci.assigned_to.name, cell_bold_style),
|
||||
Paragraph("Pegang Langsung", cell_small)
|
||||
]
|
||||
else:
|
||||
holder_info = Paragraph("Gudang / Workshop", cell_style)
|
||||
|
||||
row = [
|
||||
Paragraph(str(idx), cell_center),
|
||||
Paragraph(ci.ci_code, cell_bold_style),
|
||||
comp_info,
|
||||
Paragraph(ci.get_category_display(), cell_center),
|
||||
Paragraph(ci.serial_number or "-", cell_center),
|
||||
holder_info,
|
||||
Paragraph(ci.get_condition_display(), cell_center),
|
||||
Paragraph(ci.get_status_display(), cell_center)
|
||||
]
|
||||
table_data.append(row)
|
||||
|
||||
if total_data == 0:
|
||||
table_data.append([
|
||||
Paragraph("Belum ada data Configuration Item yang cocok dengan kriteria laporan.", cell_center),
|
||||
"", "", "", "", "", "", ""
|
||||
])
|
||||
|
||||
data_table = Table(table_data, colWidths=col_widths, repeatRows=1)
|
||||
table_style = [
|
||||
('BACKGROUND', (0, 0), (-1, 0), navy),
|
||||
('TEXTCOLOR', (0, 0), (-1, 0), white),
|
||||
('TOPPADDING', (0, 0), (-1, 0), 8),
|
||||
('BOTTOMPADDING', (0, 0), (-1, 0), 8),
|
||||
('ALIGN', (0, 0), (-1, 0), 'CENTER'),
|
||||
('VALIGN', (0, 0), (-1, -1), 'MIDDLE'),
|
||||
('TOPPADDING', (0, 1), (-1, -1), 6),
|
||||
('BOTTOMPADDING', (0, 1), (-1, -1), 6),
|
||||
('LEFTPADDING', (0, 0), (-1, -1), 5),
|
||||
('RIGHTPADDING', (0, 0), (-1, -1), 5),
|
||||
('LINEBELOW', (0, 0), (-1, 0), 1, navy),
|
||||
('LINEBELOW', (0, 1), (-1, -2), 0.5, HexColor('#E5E7EB')),
|
||||
('LINEBELOW', (0, -1), (-1, -1), 1, border_color),
|
||||
]
|
||||
if total_data == 0:
|
||||
table_style.append(('SPAN', (0, 1), (-1, 1)))
|
||||
table_style.append(('ALIGN', (0, 1), (-1, 1), 'CENTER'))
|
||||
table_style.append(('TOPPADDING', (0, 1), (-1, 1), 16))
|
||||
table_style.append(('BOTTOMPADDING', (0, 1), (-1, 1), 16))
|
||||
else:
|
||||
for i in range(1, len(table_data)):
|
||||
if i % 2 == 0:
|
||||
table_style.append(('BACKGROUND', (0, i), (-1, i), alt_row))
|
||||
|
||||
data_table.setStyle(TableStyle(table_style))
|
||||
elements.append(data_table)
|
||||
|
||||
elements.append(Spacer(1, 5 * mm))
|
||||
elements.append(Paragraph(
|
||||
f"Menampilkan {total_data} komponen — Dokumen ini digenerate secara otomatis oleh Sistem Manajemen Aset IT pada {tanggal_str}.",
|
||||
ParagraphStyle('F', parent=styles['Normal'], fontName='Helvetica', fontSize=8, textColor=HexColor('#999999'))
|
||||
))
|
||||
|
||||
doc.build(elements)
|
||||
buffer.seek(0)
|
||||
response = HttpResponse(buffer.getvalue(), content_type='application/pdf')
|
||||
filename = f"Laporan_Configuration_Item_{now.strftime('%Y%m%d')}.pdf"
|
||||
response['Content-Disposition'] = f'inline; filename="{filename}"'
|
||||
return response
|
||||
@@ -876,21 +876,39 @@ def consumable_export_excel(request):
|
||||
|
||||
@login_required
|
||||
def consumable_export_pdf(request):
|
||||
"""Menghasilkan laporan PDF ringkasan status persediaan consumable."""
|
||||
"""Menghasilkan laporan PDF resmi untuk Consumable Item yang seragam dengan modul lainnya."""
|
||||
import os
|
||||
import datetime
|
||||
from io import BytesIO
|
||||
from PIL import Image
|
||||
|
||||
from django.conf import settings
|
||||
from django.http import HttpResponse
|
||||
from django.db.models import Q, F
|
||||
|
||||
from reportlab.lib.pagesizes import A4, landscape
|
||||
from reportlab.lib.units import mm
|
||||
from reportlab.lib.colors import HexColor, white, black
|
||||
from reportlab.lib.units import mm, cm
|
||||
from reportlab.lib.colors import HexColor, white
|
||||
from reportlab.platypus import SimpleDocTemplate, Table, TableStyle, Paragraph, Spacer
|
||||
from reportlab.platypus.flowables import HRFlowable
|
||||
from reportlab.platypus import Image as RLImage
|
||||
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
|
||||
from reportlab.lib.enums import TA_CENTER, TA_LEFT, TA_RIGHT
|
||||
from io import BytesIO
|
||||
|
||||
search_query = request.GET.get('q', '').strip()
|
||||
category_filter = request.GET.get('category', '').strip()
|
||||
status_filter = request.GET.get('status', '').strip()
|
||||
location_filter = request.GET.get('location', '').strip()
|
||||
|
||||
items_qs = ConsumableItem.objects.all().order_by('category', 'name')
|
||||
|
||||
status_labels = {
|
||||
'available': 'Stok Aman',
|
||||
'low_stock': 'Stok Menipis',
|
||||
'out_of_stock': 'Stok Habis',
|
||||
}
|
||||
status_label = status_labels.get(status_filter, 'Semua Status')
|
||||
|
||||
if status_filter == 'available':
|
||||
items_qs = items_qs.filter(stock_available__gt=F('minimum_stock'))
|
||||
elif status_filter == 'low_stock':
|
||||
@@ -898,9 +916,14 @@ def consumable_export_pdf(request):
|
||||
elif status_filter == 'out_of_stock':
|
||||
items_qs = items_qs.filter(stock_available__lte=0)
|
||||
|
||||
cat_dict = dict(ConsumableItem.CATEGORY_CHOICES)
|
||||
cat_label = cat_dict.get(category_filter, 'Semua Kategori') if category_filter else 'Semua Kategori'
|
||||
if category_filter:
|
||||
items_qs = items_qs.filter(category=category_filter)
|
||||
|
||||
if location_filter:
|
||||
items_qs = items_qs.filter(location=location_filter)
|
||||
|
||||
if search_query:
|
||||
items_qs = items_qs.filter(
|
||||
Q(item_code__icontains=search_query) |
|
||||
@@ -909,116 +932,200 @@ def consumable_export_pdf(request):
|
||||
Q(specification__icontains=search_query)
|
||||
)
|
||||
|
||||
navy = HexColor('#002060')
|
||||
alt_row = HexColor('#F8F9FC')
|
||||
border_color = HexColor('#D0D5DD')
|
||||
|
||||
buffer = BytesIO()
|
||||
doc = SimpleDocTemplate(
|
||||
buffer,
|
||||
pagesize=landscape(A4),
|
||||
rightMargin=12 * mm,
|
||||
leftMargin=12 * mm,
|
||||
topMargin=12 * mm,
|
||||
bottomMargin=12 * mm
|
||||
leftMargin=1.5 * cm,
|
||||
rightMargin=1.5 * cm,
|
||||
topMargin=1.5 * cm,
|
||||
bottomMargin=2 * cm
|
||||
)
|
||||
page_width = landscape(A4)[0] - 3 * cm
|
||||
|
||||
styles = getSampleStyleSheet()
|
||||
title_style = ParagraphStyle(
|
||||
'DocTitle',
|
||||
parent=styles['Heading1'],
|
||||
fontName='Helvetica-Bold',
|
||||
fontSize=15,
|
||||
leading=18,
|
||||
textColor=HexColor('#1b5e20'),
|
||||
alignment=TA_LEFT
|
||||
)
|
||||
meta_style = ParagraphStyle(
|
||||
'DocMeta',
|
||||
parent=styles['Normal'],
|
||||
fontName='Helvetica',
|
||||
fontSize=8,
|
||||
leading=11,
|
||||
textColor=HexColor('#555555'),
|
||||
alignment=TA_LEFT
|
||||
)
|
||||
cell_style = ParagraphStyle(
|
||||
'CellText',
|
||||
parent=styles['Normal'],
|
||||
fontName='Helvetica',
|
||||
fontSize=8,
|
||||
leading=10,
|
||||
alignment=TA_LEFT
|
||||
)
|
||||
cell_center = ParagraphStyle(
|
||||
'CellCenter',
|
||||
parent=styles['Normal'],
|
||||
fontName='Helvetica',
|
||||
fontSize=8,
|
||||
leading=10,
|
||||
alignment=TA_CENTER
|
||||
)
|
||||
header_style = ParagraphStyle(
|
||||
'HeaderCell',
|
||||
parent=styles['Normal'],
|
||||
fontName='Helvetica-Bold',
|
||||
fontSize=8,
|
||||
leading=10,
|
||||
textColor=white,
|
||||
alignment=TA_CENTER
|
||||
)
|
||||
title_style = ParagraphStyle('CustomTitle', parent=styles['Normal'], fontName='Helvetica-Bold', fontSize=16, textColor=white, leading=20)
|
||||
subtitle_style = ParagraphStyle('CustomSubtitle', parent=styles['Normal'], fontName='Helvetica', fontSize=10, textColor=HexColor('#B0C4DE'), leading=14)
|
||||
company_style = ParagraphStyle('CompanyName', parent=styles['Normal'], fontName='Helvetica-Bold', fontSize=11, textColor=white, alignment=TA_RIGHT, leading=14)
|
||||
company_sub_style = ParagraphStyle('CompanySub', parent=styles['Normal'], fontName='Helvetica', fontSize=8, textColor=HexColor('#B0C4DE'), alignment=TA_RIGHT, leading=11)
|
||||
|
||||
story = []
|
||||
story.append(Paragraph("LAPORAN PERSEDIAAN CONSUMABLE ITEM - PT. KERINCI HYDROPOWER", title_style))
|
||||
story.append(Spacer(1, 2 * mm))
|
||||
story.append(Paragraph(
|
||||
f"Dicetak: {datetime.now().strftime('%d/%m/%Y %H:%M')} WIB | Oleh: {request.user.get_full_name() or request.user.username} | Total: {items_qs.count()} item",
|
||||
meta_style
|
||||
))
|
||||
story.append(Spacer(1, 5 * mm))
|
||||
cell_style = ParagraphStyle('CellStyle', parent=styles['Normal'], fontName='Helvetica', fontSize=8.5, leading=11)
|
||||
cell_bold_style = ParagraphStyle('CellBoldStyle', parent=styles['Normal'], fontName='Helvetica-Bold', fontSize=8.5, leading=11)
|
||||
cell_small = ParagraphStyle('CellSmall', parent=styles['Normal'], fontName='Helvetica', fontSize=7.5, textColor=HexColor('#666666'), leading=9)
|
||||
header_cell = ParagraphStyle('HeaderCell', parent=styles['Normal'], fontName='Helvetica-Bold', fontSize=8, textColor=white, alignment=TA_CENTER, leading=11)
|
||||
cell_center = ParagraphStyle('CellCenter', parent=styles['Normal'], fontName='Helvetica', fontSize=8.5, alignment=TA_CENTER)
|
||||
info_style = ParagraphStyle('InfoStyle', parent=styles['Normal'], fontName='Helvetica', fontSize=9, textColor=HexColor('#555555'))
|
||||
info_bold = ParagraphStyle('InfoBold', parent=styles['Normal'], fontName='Helvetica-Bold', fontSize=9, textColor=HexColor('#333333'))
|
||||
|
||||
table_data = [[
|
||||
Paragraph("No", header_style),
|
||||
Paragraph("Kode", header_style),
|
||||
Paragraph("Nama Barang", header_style),
|
||||
Paragraph("Kategori", header_style),
|
||||
Paragraph("Merek & Spesifikasi", header_style),
|
||||
Paragraph("Satuan", header_style),
|
||||
Paragraph("Stok", header_style),
|
||||
Paragraph("Min", header_style),
|
||||
Paragraph("Status", header_style),
|
||||
Paragraph("Lokasi", header_style),
|
||||
elements = []
|
||||
now = datetime.datetime.now()
|
||||
bulan_indo = {
|
||||
1: 'Januari', 2: 'Februari', 3: 'Maret', 4: 'April',
|
||||
5: 'Mei', 6: 'Juni', 7: 'Juli', 8: 'Agustus',
|
||||
9: 'September', 10: 'Oktober', 11: 'November', 12: 'Desember'
|
||||
}
|
||||
tanggal_str = f"{now.day} {bulan_indo[now.month]} {now.year}"
|
||||
|
||||
# Top Logos
|
||||
try:
|
||||
it_logo_path = os.path.join(settings.BASE_DIR, 'static', 'img', 'it_all_role_logo.png')
|
||||
kerinci_logo_path = os.path.join(settings.BASE_DIR, 'static', 'img', 'kerinci_logo.png')
|
||||
desired_height = 1.3 * cm
|
||||
it_img = Image.open(it_logo_path)
|
||||
it_rl_img = RLImage(it_logo_path, width=desired_height * (it_img.width / float(it_img.height)), height=desired_height)
|
||||
ker_img = Image.open(kerinci_logo_path)
|
||||
ker_rl_img = RLImage(kerinci_logo_path, width=desired_height * (ker_img.width / float(ker_img.height)), height=desired_height)
|
||||
logo_table = Table([[ker_rl_img, it_rl_img]], colWidths=[page_width/2, page_width/2])
|
||||
logo_table.setStyle(TableStyle([
|
||||
('ALIGN', (0, 0), (0, 0), 'LEFT'),
|
||||
('ALIGN', (1, 0), (1, 0), 'RIGHT'),
|
||||
('VALIGN', (0, 0), (-1, -1), 'MIDDLE'),
|
||||
('BOTTOMPADDING', (0, 0), (-1, -1), 10),
|
||||
('TOPPADDING', (0, 0), (-1, -1), 0)
|
||||
]))
|
||||
elements.append(logo_table)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
category_label = f"Status: {status_label} - Kategori: {cat_label}"
|
||||
|
||||
# Navy Header Banner
|
||||
header_data = [[
|
||||
[Paragraph('Laporan Consumable Item', title_style), Paragraph(f'{category_label} - {tanggal_str}', subtitle_style)],
|
||||
[Paragraph('SISTEM MANAJEMEN ASET IT', company_style), Paragraph('Dicetak otomatis dari sistem', company_sub_style)]
|
||||
]]
|
||||
header_table = Table(header_data, colWidths=[page_width * 0.65, page_width * 0.35])
|
||||
header_table.setStyle(TableStyle([
|
||||
('BACKGROUND', (0, 0), (-1, -1), navy),
|
||||
('VALIGN', (0, 0), (-1, -1), 'MIDDLE'),
|
||||
('LEFTPADDING', (0, 0), (0, 0), 20),
|
||||
('RIGHTPADDING', (-1, -1), (-1, -1), 20),
|
||||
('TOPPADDING', (0, 0), (-1, -1), 14),
|
||||
('BOTTOMPADDING', (0, 0), (-1, -1), 14),
|
||||
('ROUNDEDCORNERS', [6, 6, 0, 0]),
|
||||
]))
|
||||
elements.append(header_table)
|
||||
elements.append(Spacer(1, 8 * mm))
|
||||
|
||||
# Metadata Grid
|
||||
total_data = items_qs.count()
|
||||
info_data = [
|
||||
[Paragraph('Kategori', info_style), Paragraph(f': {category_label}', info_bold), Paragraph('Total Data', info_style), Paragraph(f': {total_data} item', info_bold)]
|
||||
]
|
||||
row_2 = [Paragraph('Tanggal Cetak', info_style), Paragraph(f': {tanggal_str}, {now.strftime("%H:%M")} WIB', info_bold)]
|
||||
filters_desc = []
|
||||
if location_filter: filters_desc.append(f"Lokasi: {location_filter}")
|
||||
if search_query: filters_desc.append(f"Cari: '{search_query}'")
|
||||
if filters_desc:
|
||||
row_2.extend([Paragraph('Filter', info_style), Paragraph(f': {", ".join(filters_desc)}', info_bold)])
|
||||
else:
|
||||
row_2.extend(['', ''])
|
||||
info_data.append(row_2)
|
||||
|
||||
info_table = Table(info_data, colWidths=[page_width * 0.12, page_width * 0.38, page_width * 0.12, page_width * 0.38])
|
||||
info_table.setStyle(TableStyle([
|
||||
('VALIGN', (0, 0), (-1, -1), 'TOP'),
|
||||
('TOPPADDING', (0, 0), (-1, -1), 2),
|
||||
('BOTTOMPADDING', (0, 0), (-1, -1), 2),
|
||||
('LEFTPADDING', (0, 0), (-1, -1), 0)
|
||||
]))
|
||||
elements.append(info_table)
|
||||
elements.append(Spacer(1, 6 * mm))
|
||||
elements.append(HRFlowable(width="100%", thickness=1, color=border_color, spaceAfter=4 * mm))
|
||||
|
||||
# Table Header & Data
|
||||
table_header = [
|
||||
Paragraph('NO', header_cell),
|
||||
Paragraph('KODE ITEM', header_cell),
|
||||
Paragraph('NAMA BARANG & MEREK', header_cell),
|
||||
Paragraph('KATEGORI', header_cell),
|
||||
Paragraph('SPESIFIKASI', header_cell),
|
||||
Paragraph('SATUAN', header_cell),
|
||||
Paragraph('STOK', header_cell),
|
||||
Paragraph('STATUS', header_cell),
|
||||
Paragraph('LOKASI', header_cell)
|
||||
]
|
||||
col_widths = [
|
||||
page_width * 0.05,
|
||||
page_width * 0.13,
|
||||
page_width * 0.24,
|
||||
page_width * 0.12,
|
||||
page_width * 0.18,
|
||||
page_width * 0.06,
|
||||
page_width * 0.07,
|
||||
page_width * 0.07,
|
||||
page_width * 0.08
|
||||
]
|
||||
table_data = [table_header]
|
||||
|
||||
for idx, itm in enumerate(items_qs, 1):
|
||||
status_text = itm.stock_status_display
|
||||
status_color = "#1b5e20" if itm.stock_status == 'available' else ("#e65100" if itm.stock_status == 'low_stock' else "#c62828")
|
||||
status_cell = f"<font color='{status_color}'><b>{status_text}</b></font>"
|
||||
item_info = [Paragraph(itm.name, cell_bold_style)]
|
||||
if itm.brand:
|
||||
item_info.append(Paragraph(f"Merek: {itm.brand}", cell_small))
|
||||
|
||||
table_data.append([
|
||||
status_text = "Aman" if itm.stock_status == 'available' else ("Menipis" if itm.stock_status == 'low_stock' else "Habis")
|
||||
|
||||
row = [
|
||||
Paragraph(str(idx), cell_center),
|
||||
Paragraph(itm.item_code, cell_center),
|
||||
Paragraph(itm.name, cell_style),
|
||||
Paragraph(itm.get_category_display().split('(')[0].strip(), cell_style),
|
||||
Paragraph(f"{itm.brand or '-'} / {itm.specification or '-'}", cell_style),
|
||||
Paragraph(itm.item_code, cell_bold_style),
|
||||
item_info,
|
||||
Paragraph(itm.get_category_display().split('(')[0].strip(), cell_center),
|
||||
Paragraph(itm.specification or "-", cell_small),
|
||||
Paragraph(itm.base_unit, cell_center),
|
||||
Paragraph(f"<b>{itm.stock_available}</b>", cell_center),
|
||||
Paragraph(str(itm.minimum_stock), cell_center),
|
||||
Paragraph(status_cell, cell_center),
|
||||
Paragraph(itm.location, cell_style),
|
||||
Paragraph(f"<b>{itm.formatted_stock}</b>", cell_center),
|
||||
Paragraph(status_text, cell_center),
|
||||
Paragraph(itm.location or "-", cell_center)
|
||||
]
|
||||
table_data.append(row)
|
||||
|
||||
if total_data == 0:
|
||||
table_data.append([
|
||||
Paragraph("Belum ada data Consumable Item yang cocok dengan kriteria laporan.", cell_center),
|
||||
"", "", "", "", "", "", "", ""
|
||||
])
|
||||
|
||||
col_widths = [10 * mm, 25 * mm, 50 * mm, 38 * mm, 50 * mm, 16 * mm, 18 * mm, 16 * mm, 22 * mm, 28 * mm]
|
||||
t = Table(table_data, colWidths=col_widths, repeatRows=1)
|
||||
t.setStyle(TableStyle([
|
||||
('BACKGROUND', (0, 0), (-1, 0), HexColor('#1b5e20')),
|
||||
('ALIGN', (0, 0), (-1, -1), 'CENTER'),
|
||||
data_table = Table(table_data, colWidths=col_widths, repeatRows=1)
|
||||
table_style = [
|
||||
('BACKGROUND', (0, 0), (-1, 0), navy),
|
||||
('TEXTCOLOR', (0, 0), (-1, 0), white),
|
||||
('TOPPADDING', (0, 0), (-1, 0), 8),
|
||||
('BOTTOMPADDING', (0, 0), (-1, 0), 8),
|
||||
('ALIGN', (0, 0), (-1, 0), 'CENTER'),
|
||||
('VALIGN', (0, 0), (-1, -1), 'MIDDLE'),
|
||||
('GRID', (0, 0), (-1, -1), 0.5, HexColor('#e0e0e0')),
|
||||
('TOPPADDING', (0, 0), (-1, -1), 3),
|
||||
('BOTTOMPADDING', (0, 0), (-1, -1), 3),
|
||||
]))
|
||||
story.append(t)
|
||||
('TOPPADDING', (0, 1), (-1, -1), 6),
|
||||
('BOTTOMPADDING', (0, 1), (-1, -1), 6),
|
||||
('LEFTPADDING', (0, 0), (-1, -1), 5),
|
||||
('RIGHTPADDING', (0, 0), (-1, -1), 5),
|
||||
('LINEBELOW', (0, 0), (-1, 0), 1, navy),
|
||||
('LINEBELOW', (0, 1), (-1, -2), 0.5, HexColor('#E5E7EB')),
|
||||
('LINEBELOW', (0, -1), (-1, -1), 1, border_color),
|
||||
]
|
||||
if total_data == 0:
|
||||
table_style.append(('SPAN', (0, 1), (-1, 1)))
|
||||
table_style.append(('ALIGN', (0, 1), (-1, 1), 'CENTER'))
|
||||
table_style.append(('TOPPADDING', (0, 1), (-1, 1), 16))
|
||||
table_style.append(('BOTTOMPADDING', (0, 1), (-1, 1), 16))
|
||||
else:
|
||||
for i in range(1, len(table_data)):
|
||||
if i % 2 == 0:
|
||||
table_style.append(('BACKGROUND', (0, i), (-1, i), alt_row))
|
||||
|
||||
doc.build(story)
|
||||
data_table.setStyle(TableStyle(table_style))
|
||||
elements.append(data_table)
|
||||
|
||||
elements.append(Spacer(1, 5 * mm))
|
||||
elements.append(Paragraph(
|
||||
f"Menampilkan {total_data} item — Dokumen ini digenerate secara otomatis oleh Sistem Manajemen Aset IT pada {tanggal_str}.",
|
||||
ParagraphStyle('F', parent=styles['Normal'], fontName='Helvetica', fontSize=8, textColor=HexColor('#999999'))
|
||||
))
|
||||
|
||||
doc.build(elements)
|
||||
buffer.seek(0)
|
||||
response = HttpResponse(buffer.getvalue(), content_type='application/pdf')
|
||||
filename = f"Laporan_Consumable_PTKMH_{datetime.now().strftime('%Y%m%d_%H%M')}.pdf"
|
||||
filename = f"Laporan_Consumable_Item_{now.strftime('%Y%m%d')}.pdf"
|
||||
response['Content-Disposition'] = f'inline; filename="{filename}"'
|
||||
return response
|
||||
return response
|
||||
@@ -11,6 +11,7 @@ from assets.views import (
|
||||
employee_list, employee_export_pdf, employee_detail, employee_detail_export_pdf,
|
||||
employee_create, employee_edit, employee_delete, employee_activate,
|
||||
ci_list, ci_detail, ci_create, ci_edit, ci_assign, ci_remove, ci_replace, ci_report_damage,
|
||||
ci_export_excel, ci_export_pdf,
|
||||
asset_export_pdf, asset_export_excel, backup_database_view, asset_units_export_excel,
|
||||
unit_history_export_excel, status_aset_export_excel, distribusi_export_excel,
|
||||
employee_export_excel, employee_detail_export_excel,
|
||||
@@ -72,6 +73,8 @@ urlpatterns = [
|
||||
path('karyawan/<int:emp_id>/activate/', employee_activate, name='employee_activate'),
|
||||
# Configuration Items (CI / CMDB)
|
||||
path('ci/', ci_list, name='ci_list'),
|
||||
path('ci/export/', ci_export_pdf, name='ci_export_pdf'),
|
||||
path('ci/export-excel/', ci_export_excel, name='ci_export_excel'),
|
||||
path('ci/create/', ci_create, name='ci_create'),
|
||||
path('ci/<int:ci_id>/', ci_detail, name='ci_detail'),
|
||||
path('ci/<int:ci_id>/edit/', ci_edit, name='ci_edit'),
|
||||
|
||||
@@ -65,7 +65,7 @@ echo [2] Jalankan Automated Test Suite (python manage.py test assets)
|
||||
echo [3] Jalankan Test dengan Output Terperinci (Verbose -v 2)
|
||||
echo [4] Jalankan Migrasi Database (python manage.py migrate)
|
||||
echo [5] Buat Migrasi Baru (python manage.py makemigrations)
|
||||
echo [6] Seed Data Awal ('Aset Karyawan', 'Aset Network', & Consumables)
|
||||
echo [6] Seed Data Awal (Aset, Consumables, & Configuration Items)
|
||||
echo [7] Setup Akun Superuser Administrator (setup_superuser)
|
||||
echo [8] Build Aset Frontend / TailwindCSS (npm run build)
|
||||
echo [9] Install / Update Dependensi Python (pip install -r requirements.txt)
|
||||
@@ -224,6 +224,7 @@ echo ===========================================================================
|
||||
echo.
|
||||
python manage.py seed_initial_data
|
||||
python manage.py seed_consumables
|
||||
python manage.py seed_cis
|
||||
echo.
|
||||
pause
|
||||
goto main_menu
|
||||
|
||||
+28
-24
@@ -13,33 +13,37 @@
|
||||
<p class="text-sm text-gray-500 mt-1">Kode: <strong>{{ asset.asset_code }}</strong> · Total: <strong>{{ asset.qty }} {{ asset.uom }}</strong></p>
|
||||
</div>
|
||||
<div class="flex flex-wrap sm:flex-nowrap items-center gap-3 w-full sm:w-auto">
|
||||
<a href="{% url 'asset_list' %}" class="order-1 sm:order-1 bg-white border border-gray-200 rounded-xl shadow-sm px-4 py-2.5 text-sm font-bold text-gray-700 hover:bg-gray-50 transition-colors flex-1 sm:flex-none text-center">
|
||||
Kembali
|
||||
</a>
|
||||
<!-- 1. Fitur Ekspor: Mobile baris atas kiri (flex-1), Desktop tengah (sm:order-2 sm:flex-none) -->
|
||||
<div class="order-1 sm:order-2 relative inline-block flex-1 sm:flex-none w-auto">
|
||||
<button onclick="var d = document.getElementById('exportMenuUnits'); d.style.display = d.style.display === 'block' ? 'none' : 'block'; event.stopPropagation();" class="w-full border border-kerinci text-kerinci rounded-xl px-3.5 sm:px-4 py-2 text-xs sm:text-sm font-bold hover:bg-kerinci/10 transition-colors flex items-center space-x-1.5 sm:space-x-2 justify-center whitespace-nowrap shadow-sm">
|
||||
<svg class="w-4 h-4 shrink-0" 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 shrink-0" 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="exportMenuUnits" 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 'asset_units_export_pdf' asset.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 'asset_units_export_excel' asset.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 class="relative inline-block w-full sm:w-auto flex-1 sm:flex-none">
|
||||
<button onclick="var d = document.getElementById('exportMenuUnits'); 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="exportMenuUnits" 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 'asset_units_export_pdf' asset.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 'asset_units_export_excel' asset.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>
|
||||
|
||||
<button onclick="openAddUnitModal()" class="order-2 sm:order-3 bg-kerinci text-white border border-kerinci rounded-xl shadow-sm px-4 py-2.5 text-sm font-bold hover:bg-kerinci/90 transition-colors flex items-center justify-center space-x-2 flex-1 sm:flex-none">
|
||||
<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>
|
||||
<!-- 2. Tombol Tambah Unit: Mobile baris atas kanan (flex-1), Desktop paling kanan (sm:order-3 sm:flex-none) -->
|
||||
<button onclick="openAddUnitModal()" class="order-2 sm:order-3 bg-kerinci text-white border border-kerinci rounded-xl shadow-sm px-3.5 sm:px-4 py-2 text-xs sm:text-sm font-bold hover:bg-kerinci/90 transition-colors flex items-center justify-center space-x-1.5 sm:space-x-2 flex-1 sm:flex-none whitespace-nowrap">
|
||||
<svg class="w-5 h-5 shrink-0" 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>
|
||||
<span>Tambah Unit</span>
|
||||
</button>
|
||||
|
||||
<!-- 3. Tombol Kembali: Mobile baris bawah (w-full), Desktop paling kiri (sm:order-1 sm:w-auto) -->
|
||||
<a href="{% url 'asset_list' %}" class="order-3 sm:order-1 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-none">
|
||||
<svg class="w-4 h-4 text-gray-500 shrink-0" 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>
|
||||
</div>
|
||||
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@
|
||||
<title>Manajemen Aset IT - Kerinci Hydropower</title>
|
||||
|
||||
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap" rel="stylesheet">
|
||||
<link rel="stylesheet" href="{% static 'dist/style.css' %}?v=2.1">
|
||||
<link rel="stylesheet" href="{% static 'dist/style.css' %}?v=2.4">
|
||||
|
||||
<style>
|
||||
body { background-color: #F8F9FA; }
|
||||
|
||||
@@ -28,8 +28,9 @@
|
||||
|
||||
<!-- Header Actions -->
|
||||
<div class="flex items-center space-x-2">
|
||||
<a href="{% url 'ci_list' %}" class="px-4 py-2 border border-gray-200 rounded-xl text-sm font-bold text-gray-600 hover:bg-gray-50 transition-colors">
|
||||
← Kembali
|
||||
<a href="{% url 'ci_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">
|
||||
<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>
|
||||
{% if not is_read_only %}
|
||||
<button onclick="openEditModal()" class="px-4 py-2 bg-amber-50 text-amber-700 hover:bg-amber-100 border border-amber-200 rounded-xl text-sm font-bold transition-colors flex items-center space-x-1.5">
|
||||
|
||||
+158
-158
@@ -1,240 +1,236 @@
|
||||
{% extends 'base.html' %}
|
||||
|
||||
{% block page_title %}Configuration Item (CI / CMDB){% endblock %}
|
||||
{% block page_title %}Configuration Item{% endblock %}
|
||||
|
||||
{% block page_title_guide %}Panduan Configuration Item (CMDB){% endblock %}
|
||||
{% block page_guide_content %}
|
||||
<div class="space-y-4">
|
||||
<p>Modul <b>Configuration Item (CI)</b> digunakan untuk melacak dan mengelola komponen hardware modular, peripheral, dan modul pendukung perangkat IT (misalnya: RAM, SSD/HDD, kartu grafis, adaptor, monitor eksternal, mouse, keyboard).</p>
|
||||
<div class="p-3 bg-blue-50 border border-blue-200 rounded-xl">
|
||||
<h4 class="font-bold text-blue-800 text-xs uppercase tracking-wider mb-1">Hubungan Perangkat & Karyawan</h4>
|
||||
<p class="text-xs text-blue-700">Setiap CI dapat berdiri sendiri di gudang (Tersedia), terpasang pada Unit Aset induk (misal: SSD di dalam laptop ACR-GEN11-001), atau dipegang langsung oleh PIC Karyawan.</p>
|
||||
</div>
|
||||
<ul class="list-disc pl-5 space-y-1 text-xs text-gray-600">
|
||||
<li><b>Tersedia:</b> Komponen berada di gudang/workshop IT dan siap dialokasikan.</li>
|
||||
<li><b>Digunakan:</b> Terpasang pada unit perangkat aktif atau dipegang karyawan.</li>
|
||||
<li><b>Maintenance:</b> Sedang dalam proses pengecekan atau servis teknis.</li>
|
||||
<li><b>Pensiun / Bricked:</b> Komponen telah rusak total atau tidak dapat digunakan kembali.</li>
|
||||
</ul>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="mb-6 flex flex-col sm:flex-row sm:justify-between sm:items-end space-y-4 sm:space-y-0">
|
||||
<div class="mb-8 flex flex-col sm:flex-row sm:justify-between sm:items-center space-y-4 sm:space-y-0">
|
||||
<div>
|
||||
<p class="text-xs font-bold text-kerinci uppercase tracking-widest mb-1">Manajemen Aset • CMDB</p>
|
||||
<p class="text-xs font-bold text-kerinci uppercase tracking-widest mb-1">Manajemen Aset</p>
|
||||
<div class="flex items-center space-x-3">
|
||||
<h2 class="text-3xl font-extrabold text-gray-900">Configuration Item (CI)</h2>
|
||||
<span class="px-2.5 py-0.5 rounded-full text-xs font-extrabold bg-blue-50 text-blue-700 border border-blue-200">
|
||||
CMDB & Komponen
|
||||
</span>
|
||||
<h2 class="text-3xl font-extrabold text-gray-900">Configuration Item</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-xs text-gray-500 mt-1">Pelacakan komponen internal, peripheral, dan modul pendukung perangkat IT.</p>
|
||||
</div>
|
||||
<div class="flex items-center space-x-3 w-full sm:w-auto">
|
||||
<div class="relative inline-block w-full sm:w-auto flex-1 sm:flex-none">
|
||||
<button onclick="var d = document.getElementById('exportMenuCI'); 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 CI</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="exportMenuCI" 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 'ci_export_pdf' %}?status={{ status_filter }}&category={{ category_filter }}&condition={{ condition_filter }}&q={{ search_query }}" 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 'ci_export_excel' %}?status={{ status_filter }}&category={{ category_filter }}&condition={{ condition_filter }}&q={{ search_query }}" 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>
|
||||
{% if not is_read_only %}
|
||||
<button onclick="openCreateCIModal()" class="bg-kerinci text-white px-5 py-2.5 rounded-xl text-sm font-bold shadow-sm shadow-kerinci/30 hover:bg-kerinci/90 transition-colors flex items-center space-x-2 justify-center w-full sm:w-auto">
|
||||
<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>
|
||||
<span>Tambah CI Baru</span>
|
||||
<button onclick="openCreateCIModal()" 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">
|
||||
<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>
|
||||
<span>Tambah CI</span>
|
||||
</button>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- KPI Summary Cards -->
|
||||
<div class="grid grid-cols-2 lg:grid-cols-4 gap-4 mb-6">
|
||||
<div class="bg-white p-5 rounded-2xl border border-gray-100 shadow-sm flex items-center justify-between">
|
||||
<div>
|
||||
<p class="text-xs font-bold text-gray-400 uppercase tracking-wider mb-1">Total Komponen</p>
|
||||
<h3 class="text-2xl font-black text-gray-900">{{ counts.total }}</h3>
|
||||
<p class="text-[11px] text-gray-400 mt-1">Terdaftar di CMDB</p>
|
||||
</div>
|
||||
<div class="w-12 h-12 bg-blue-50 text-kerinci rounded-xl flex items-center justify-center font-bold">
|
||||
<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="M9 3v2m6-2v2M9 19v2m6-2v2M5 9H3m2 6H3m18-6h-2m2 6h-2M7 19h10a2 2 0 002-2V7a2 2 0 00-2-2H7a2 2 0 00-2 2v10a2 2 0 002 2zM9 9h6v6H9V9z"></path></svg>
|
||||
</div>
|
||||
</div>
|
||||
<div class="bg-white p-5 rounded-2xl border border-gray-100 shadow-sm flex items-center justify-between">
|
||||
<div>
|
||||
<p class="text-xs font-bold text-blue-600 uppercase tracking-wider mb-1">Sedang Digunakan</p>
|
||||
<h3 class="text-2xl font-black text-blue-900">{{ counts.in_use }}</h3>
|
||||
<p class="text-[11px] text-blue-500 mt-1">Terpasang / Dipegang</p>
|
||||
</div>
|
||||
<div class="w-12 h-12 bg-blue-50 text-blue-600 rounded-xl flex items-center justify-center font-bold">
|
||||
<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="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"></path></svg>
|
||||
</div>
|
||||
</div>
|
||||
<div class="bg-white p-5 rounded-2xl border border-gray-100 shadow-sm flex items-center justify-between">
|
||||
<div>
|
||||
<p class="text-xs font-bold text-emerald-600 uppercase tracking-wider mb-1">Tersedia (Gudang)</p>
|
||||
<h3 class="text-2xl font-black text-emerald-900">{{ counts.available }}</h3>
|
||||
<p class="text-[11px] text-emerald-500 mt-1">Siap dialokasikan</p>
|
||||
</div>
|
||||
<div class="w-12 h-12 bg-emerald-50 text-emerald-600 rounded-xl flex items-center justify-center font-bold">
|
||||
<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="M20 7l-8-4-8 4m16 0l-8 4m8-4v10l-8 4m0-10L4 7m8 4v10M4 7v10l8 4"></path></svg>
|
||||
</div>
|
||||
</div>
|
||||
<div class="bg-white p-5 rounded-2xl border border-gray-100 shadow-sm flex items-center justify-between">
|
||||
<div>
|
||||
<p class="text-xs font-bold text-amber-600 uppercase tracking-wider mb-1">Dalam Perbaikan</p>
|
||||
<h3 class="text-2xl font-black text-amber-900">{{ counts.under_repair }}</h3>
|
||||
<p class="text-[11px] text-amber-500 mt-1">Inspeksi / Maintenance</p>
|
||||
</div>
|
||||
<div class="w-12 h-12 bg-amber-50 text-amber-600 rounded-xl flex items-center justify-center font-bold">
|
||||
<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="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>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Status Tabs -->
|
||||
<div class="flex space-x-2 mb-4 border-b border-gray-200 overflow-x-auto whitespace-nowrap scrollbar-hide">
|
||||
<a href="?status={% if search_query %}&q={{ search_query }}{% endif %}{% if category_filter %}&category={{ category_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 %}">
|
||||
<!-- Category Tabs -->
|
||||
<div class="flex space-x-2 mb-6 border-b border-gray-200 overflow-x-auto whitespace-nowrap scrollbar-hide">
|
||||
<a href="?status={% if search_query %}&q={{ search_query }}{% endif %}{% if category_filter %}&category={{ category_filter }}{% endif %}{% if condition_filter %}&condition={{ condition_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 Komponen
|
||||
<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 %}" 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 %}">
|
||||
Tersedia (Gudang)
|
||||
<a href="?status=available{% if search_query %}&q={{ search_query }}{% endif %}{% if category_filter %}&category={{ category_filter }}{% endif %}{% if condition_filter %}&condition={{ condition_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 %}">
|
||||
Tersedia
|
||||
<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>
|
||||
<a href="?status=in_use{% if search_query %}&q={{ search_query }}{% endif %}{% if category_filter %}&category={{ category_filter }}{% endif %}" class="px-5 py-3 text-sm font-bold border-b-2 transition-colors flex items-center {% if status_filter == 'in_use' %}border-kerinci text-kerinci{% else %}border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300{% endif %}">
|
||||
<a href="?status=in_use{% if search_query %}&q={{ search_query }}{% endif %}{% if category_filter %}&category={{ category_filter }}{% endif %}{% if condition_filter %}&condition={{ condition_filter }}{% endif %}" class="px-5 py-3 text-sm font-bold border-b-2 transition-colors flex items-center {% if status_filter == 'in_use' %}border-kerinci text-kerinci{% else %}border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300{% endif %}">
|
||||
Sedang Digunakan
|
||||
<span class="ml-2 {% if status_filter == 'in_use' %}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.in_use }}</span>
|
||||
</a>
|
||||
<a href="?status=repair{% if search_query %}&q={{ search_query }}{% endif %}{% if category_filter %}&category={{ category_filter }}{% endif %}" class="px-5 py-3 text-sm font-bold border-b-2 transition-colors flex items-center {% if status_filter == 'repair' %}border-kerinci text-kerinci{% else %}border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300{% endif %}">
|
||||
Perbaikan / Rusak
|
||||
<a href="?status=repair{% if search_query %}&q={{ search_query }}{% endif %}{% if category_filter %}&category={{ category_filter }}{% endif %}{% if condition_filter %}&condition={{ condition_filter }}{% endif %}" class="px-5 py-3 text-sm font-bold border-b-2 transition-colors flex items-center {% if status_filter == 'repair' %}border-kerinci text-kerinci{% else %}border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300{% endif %}">
|
||||
Maintenance
|
||||
<span class="ml-2 {% if status_filter == 'repair' %}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.under_repair }}</span>
|
||||
</a>
|
||||
<a href="?status=retired{% if search_query %}&q={{ search_query }}{% endif %}{% if category_filter %}&category={{ category_filter }}{% endif %}" class="px-5 py-3 text-sm font-bold border-b-2 transition-colors flex items-center {% if status_filter == 'retired' %}border-kerinci text-kerinci{% else %}border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300{% endif %}">
|
||||
Bricked
|
||||
<a href="?status=retired{% if search_query %}&q={{ search_query }}{% endif %}{% if category_filter %}&category={{ category_filter }}{% endif %}{% if condition_filter %}&condition={{ condition_filter }}{% endif %}" class="px-5 py-3 text-sm font-bold border-b-2 transition-colors flex items-center {% if status_filter == 'retired' %}border-kerinci text-kerinci{% else %}border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300{% endif %}">
|
||||
Pensiun / Bricked
|
||||
<span class="ml-2 {% if status_filter == 'retired' %}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.retired }}</span>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<!-- Filters & Search -->
|
||||
<div class="mb-4 flex flex-col md:flex-row md:items-center justify-between gap-3">
|
||||
<form id="searchForm" method="GET" class="flex flex-wrap items-center gap-2 w-full">
|
||||
<div class="mb-4 flex flex-col md:flex-row md:items-center md:justify-between gap-3">
|
||||
<form id="searchForm" method="GET" class="relative w-full md:w-96 min-w-0">
|
||||
<input type="hidden" name="status" value="{{ status_filter }}">
|
||||
<div class="relative flex-1 min-w-[240px]">
|
||||
<input type="text" id="searchInput" name="q" value="{{ search_query }}" placeholder="Cari Kode Item, nama, S/N, perangkat, atau PIC..." 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>
|
||||
{% if category_filter %}<input type="hidden" name="category" value="{{ category_filter }}">{% endif %}
|
||||
{% if condition_filter %}<input type="hidden" name="condition" value="{{ condition_filter }}">{% endif %}
|
||||
<input type="text" id="searchInput" name="q" value="{{ search_query }}" placeholder="Cari kode item, nama, S/N, atau PIC..." 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>
|
||||
|
||||
<div class="flex items-center gap-2 w-full md:w-auto min-w-0">
|
||||
<div class="grid grid-cols-2 gap-2 flex-1 md:flex-none w-full md:w-auto min-w-0">
|
||||
<div class="min-w-0">
|
||||
<select onchange="location = this.value;" class="w-full md:w-48 truncate 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 cursor-pointer" style="min-width: 0; max-width: 100%;">
|
||||
<option value="?status={{ status_filter }}&q={{ search_query }}{% if condition_filter %}&condition={{ condition_filter }}{% endif %}">Semua Kategori</option>
|
||||
{% for cat_val, cat_label in categories %}
|
||||
<option value="?status={{ status_filter }}&category={{ cat_val }}&q={{ search_query }}{% if condition_filter %}&condition={{ condition_filter }}{% endif %}" {% if category_filter == cat_val %}selected{% endif %}>{{ cat_label }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="min-w-0">
|
||||
<select onchange="location = this.value;" class="w-full md:w-44 truncate 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 cursor-pointer" style="min-width: 0; max-width: 100%;">
|
||||
<option value="?status={{ status_filter }}&category={{ category_filter }}&q={{ search_query }}">Semua Kondisi</option>
|
||||
{% for cond_val, cond_label in condition_choices %}
|
||||
<option value="?status={{ status_filter }}&category={{ category_filter }}&condition={{ cond_val }}&q={{ search_query }}" {% if condition_filter == cond_val %}selected{% endif %}>{{ cond_label }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<select name="category" onchange="this.form.submit()" class="px-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 text-gray-700 shadow-sm">
|
||||
<option value="">Semua Kategori</option>
|
||||
{% for cat_val, cat_label in categories %}
|
||||
<option value="{{ cat_val }}" {% if category_filter == cat_val %}selected{% endif %}>{{ cat_label }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
|
||||
<select name="condition" onchange="this.form.submit()" class="px-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 text-gray-700 shadow-sm">
|
||||
<option value="">Semua Kondisi</option>
|
||||
{% for cond_val, cond_label in condition_choices %}
|
||||
<option value="{{ cond_val }}" {% if condition_filter == cond_val %}selected{% endif %}>{{ cond_label }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
|
||||
{% if search_query or category_filter or condition_filter or status_filter %}
|
||||
<a href="{% url 'ci_list' %}" class="px-3.5 py-2.5 text-xs font-bold text-gray-500 hover:text-red-500 border border-gray-200 hover:border-red-200 rounded-xl bg-white transition-colors" title="Reset Filter">
|
||||
<a href="{% url 'ci_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 shrink-0 whitespace-nowrap" title="Reset Filter">
|
||||
Reset
|
||||
</a>
|
||||
{% endif %}
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Main Data Table -->
|
||||
<div class="bg-white rounded-none sm:rounded-2xl shadow-sm border border-gray-100 overflow-hidden w-full">
|
||||
<div class="bg-white rounded-none sm:rounded-2xl shadow-sm border border-gray-100 overflow-hidden w-full" id="tableContainer">
|
||||
<div class="overflow-x-auto">
|
||||
<table class="w-full text-left border-collapse">
|
||||
<table class="w-full text-left border-collapse min-w-[1050px]">
|
||||
<thead>
|
||||
<tr class="bg-[#002060] text-white text-[11px] uppercase tracking-widest">
|
||||
<th class="p-4 font-bold text-center w-12">No</th>
|
||||
<th class="p-4 font-bold min-w-[130px]">Kode Item</th>
|
||||
<th class="p-4 font-bold min-w-[220px]">Nama & Komponen</th>
|
||||
<th class="p-4 font-bold">Kategori</th>
|
||||
<th class="p-4 font-bold min-w-[140px]">Nomor Seri (S/N)</th>
|
||||
<th class="p-4 font-bold min-w-[200px]">Perangkat / Pengguna</th>
|
||||
<th class="p-4 font-bold text-center">Kondisi</th>
|
||||
<th class="p-4 font-bold text-center">Status</th>
|
||||
<th class="p-4 font-bold text-center min-w-[140px]">Aksi</th>
|
||||
<tr class="bg-[#002060] text-white text-[11px] uppercase tracking-wider">
|
||||
<th class="p-4 font-bold text-center w-14 whitespace-nowrap">No</th>
|
||||
<th class="p-4 font-bold whitespace-nowrap">Kode Item</th>
|
||||
<th class="p-4 font-bold min-w-[200px]">Nama & Komponen</th>
|
||||
<th class="p-4 font-bold whitespace-nowrap">Kategori</th>
|
||||
<th class="p-4 font-bold whitespace-nowrap">Nomor Seri (S/N)</th>
|
||||
<th class="p-4 font-bold min-w-[180px]">Perangkat / Pengguna</th>
|
||||
<th class="p-4 font-bold text-center whitespace-nowrap">Kondisi</th>
|
||||
<th class="p-4 font-bold text-center whitespace-nowrap">Status</th>
|
||||
<th class="p-4 font-bold text-left w-28 whitespace-nowrap">Aksi</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="text-sm divide-y divide-gray-50">
|
||||
<tbody class="text-sm divide-y divide-gray-200">
|
||||
{% for item in items %}
|
||||
<tr class="hover:bg-gray-50/50 transition-colors">
|
||||
<td class="p-4 text-gray-400 font-medium text-center text-xs">{{ forloop.counter }}</td>
|
||||
<td class="p-4">
|
||||
<a href="{% url 'ci_detail' item.id %}" class="block group">
|
||||
<span class="font-extrabold text-gray-900 group-hover:text-kerinci transition-colors font-mono text-xs">{{ item.ci_code }}</span>
|
||||
<tr class="hover:bg-gray-50 transition-colors">
|
||||
<td class="p-4 text-center text-gray-500 whitespace-nowrap">{{ forloop.counter }}</td>
|
||||
<td class="p-4 font-bold text-gray-700 font-mono text-xs whitespace-nowrap">
|
||||
<a href="{% url 'ci_detail' item.id %}" class="hover:text-kerinci transition-colors">
|
||||
{{ item.ci_code }}
|
||||
</a>
|
||||
</td>
|
||||
<td class="p-4">
|
||||
<a href="{% url 'ci_detail' item.id %}" class="block group">
|
||||
<span class="font-bold text-gray-900 group-hover:text-kerinci transition-colors">{{ item.name }}</span>
|
||||
<td class="p-4 min-w-[200px]">
|
||||
<a href="{% url 'ci_detail' item.id %}" class="font-bold text-gray-900 hover:text-kerinci transition-colors block">
|
||||
{{ item.name }}
|
||||
</a>
|
||||
<p class="text-xs text-gray-500 mt-0.5">{{ item.brand|default:"-" }}{% if item.model_series %} • {{ item.model_series }}{% endif %}</p>
|
||||
{% if item.brand or item.model_series %}
|
||||
<p class="text-xs text-gray-500 font-normal mt-0.5">{{ item.brand|default:"" }} {{ item.model_series|default:"" }}</p>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td class="p-4">
|
||||
<span class="text-xs font-semibold text-gray-700 bg-gray-100 px-2 py-1 rounded-md">
|
||||
{{ item.get_category_display }}
|
||||
</span>
|
||||
<td class="p-4 text-gray-600 font-medium text-xs whitespace-nowrap">
|
||||
{% if item.category == 'storage' %}Storage
|
||||
{% elif item.category == 'memory' %}Memory (RAM)
|
||||
{% elif item.category == 'processor' %}Processor (CPU)
|
||||
{% elif item.category == 'motherboard' %}Motherboard
|
||||
{% elif item.category == 'gpu' %}GPU / VGA
|
||||
{% elif item.category == 'peripheral' %}Peripheral
|
||||
{% elif item.category == 'network' %}Network Component
|
||||
{% elif item.category == 'power' %}Power Supply & UPS
|
||||
{% else %}{{ item.get_category_display }}
|
||||
{% endif %}
|
||||
</td>
|
||||
<td class="p-4">
|
||||
<span class="font-mono text-xs text-gray-700">{{ item.serial_number|default:"-" }}</span>
|
||||
<td class="p-4 text-gray-600 font-mono text-xs whitespace-nowrap">
|
||||
{{ item.serial_number|default:"-" }}
|
||||
</td>
|
||||
<td class="p-4">
|
||||
<td class="p-4 min-w-[180px]">
|
||||
{% if item.installed_on %}
|
||||
<div class="flex items-center space-x-1.5">
|
||||
<span class="w-2 h-2 rounded-full bg-blue-500"></span>
|
||||
<div>
|
||||
<span class="font-bold text-xs text-blue-700">Terpasang: {{ item.installed_on.unit_code }}</span>
|
||||
{% if item.installed_on.assigned_to %}
|
||||
<p class="text-[11px] text-gray-500">PIC: {{ item.installed_on.assigned_to.name }}</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="flex items-center space-x-1.5 text-xs text-gray-800">
|
||||
<span class="font-bold text-blue-700 font-mono whitespace-nowrap">{{ item.installed_on.unit_code }}</span>
|
||||
</div>
|
||||
<p class="text-[11px] text-gray-500 truncate max-w-[200px]" title="{{ item.installed_on.asset.name }}">{{ item.installed_on.asset.name }}</p>
|
||||
{% if item.installed_on.assigned_to %}
|
||||
<p class="text-[10px] text-gray-400 font-medium whitespace-nowrap">PIC: {{ item.installed_on.assigned_to.name }}</p>
|
||||
{% endif %}
|
||||
{% elif item.assigned_to %}
|
||||
<div class="flex items-center space-x-1.5">
|
||||
<span class="w-2 h-2 rounded-full bg-purple-500"></span>
|
||||
<div>
|
||||
<span class="font-bold text-xs text-purple-700">Dipegang: {{ item.assigned_to.name }}</span>
|
||||
<p class="text-[11px] text-gray-400">NIK: {{ item.assigned_to.nik }}</p>
|
||||
</div>
|
||||
</div>
|
||||
{% elif item.status == 'available' %}
|
||||
<span class="text-xs text-emerald-700 font-medium bg-emerald-50 px-2 py-0.5 rounded border border-emerald-100">
|
||||
{{ item.location|default:"Gudang IT" }}
|
||||
</span>
|
||||
<p class="font-bold text-xs text-gray-800 whitespace-nowrap">{{ item.assigned_to.name }}</p>
|
||||
<p class="text-[11px] text-gray-500 whitespace-nowrap">Pegang Langsung</p>
|
||||
{% else %}
|
||||
<span class="text-xs text-gray-400 italic">-</span>
|
||||
<span class="text-xs text-gray-400 italic whitespace-nowrap">Gudang / Tidak terpasang</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td class="p-4 text-center">
|
||||
<td class="p-4 text-center whitespace-nowrap">
|
||||
{% if item.condition == 'new' %}
|
||||
<span class="px-2.5 py-0.5 rounded-full text-[11px] font-bold bg-blue-50 text-blue-700 border border-blue-200">Baru</span>
|
||||
<span class="inline-flex items-center px-2.5 py-1 rounded-full text-xs font-bold bg-emerald-50 text-emerald-700 border border-emerald-200 whitespace-nowrap">Baru</span>
|
||||
{% elif item.condition == 'good' %}
|
||||
<span class="px-2.5 py-0.5 rounded-full text-[11px] font-bold bg-emerald-50 text-emerald-700 border border-emerald-200">Bagus</span>
|
||||
<span class="inline-flex items-center px-2.5 py-1 rounded-full text-xs font-bold bg-emerald-50 text-emerald-700 border border-emerald-200 whitespace-nowrap">Bagus / Normal</span>
|
||||
{% elif item.condition == 'fair' %}
|
||||
<span class="px-2.5 py-0.5 rounded-full text-[11px] font-bold bg-amber-50 text-amber-700 border border-amber-200">Bekas</span>
|
||||
<span class="inline-flex items-center px-2.5 py-1 rounded-full text-xs font-bold bg-blue-50 text-blue-700 border border-blue-200 whitespace-nowrap">Cukup / Bekas</span>
|
||||
{% elif item.condition == 'damaged' %}
|
||||
<span class="inline-flex items-center px-2.5 py-1 rounded-full text-xs font-bold bg-red-50 text-red-700 border border-red-200 whitespace-nowrap">Rusak</span>
|
||||
{% else %}
|
||||
<span class="px-2.5 py-0.5 rounded-full text-[11px] font-bold bg-red-50 text-red-700 border border-red-200">Rusak</span>
|
||||
<span class="inline-flex items-center px-2.5 py-1 rounded-full text-xs font-bold bg-gray-50 text-gray-700 border border-gray-200 whitespace-nowrap">{{ item.get_condition_display }}</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td class="p-4 text-center">
|
||||
<td class="p-4 text-center whitespace-nowrap">
|
||||
{% if item.status == 'available' %}
|
||||
<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">Tersedia</span>
|
||||
<span class="inline-flex items-center px-2.5 py-1 rounded-full text-xs font-bold bg-emerald-50 text-emerald-700 border border-emerald-200 whitespace-nowrap">Tersedia</span>
|
||||
{% elif item.status == 'in_use' %}
|
||||
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-bold bg-blue-50 text-blue-700 border border-blue-200">Digunakan</span>
|
||||
<span class="inline-flex items-center px-2.5 py-1 rounded-full text-xs font-bold bg-blue-50 text-blue-700 border border-blue-200 whitespace-nowrap">Digunakan</span>
|
||||
{% elif item.status == 'under_repair' or item.status == 'under_inspection' %}
|
||||
<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">Perbaikan</span>
|
||||
<span class="inline-flex items-center px-2.5 py-1 rounded-full text-xs font-bold bg-amber-50 text-amber-700 border border-amber-200 whitespace-nowrap">Maintenance</span>
|
||||
{% else %}
|
||||
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-bold bg-gray-100 text-gray-500 border border-gray-200">Pensiun</span>
|
||||
<span class="inline-flex items-center px-2.5 py-1 rounded-full text-xs font-bold bg-gray-100 text-gray-500 border border-gray-200 whitespace-nowrap">Pensiun</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td class="p-4 text-center">
|
||||
<div class="flex items-center justify-center space-x-1.5">
|
||||
<a href="{% url 'ci_detail' item.id %}" class="p-1.5 text-gray-500 hover:text-kerinci hover:bg-gray-100 rounded-lg transition-colors" title="Lihat Detail & Riwayat">
|
||||
<td class="p-4 text-left whitespace-nowrap">
|
||||
<div class="flex items-center justify-start space-x-1.5">
|
||||
<a href="{% url 'ci_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="Detail & Riwayat">
|
||||
<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 %}
|
||||
{% if item.status == 'available' %}
|
||||
<button onclick="openAssignModal('{{ item.id }}', '{{ item.ci_code }}', '{{ item.name|escapejs }}')" class="p-1.5 text-emerald-600 hover:bg-emerald-50 rounded-lg transition-colors" title="Gunakan Untuk (Pasang/Alokasi)">
|
||||
<button onclick="openAssignModal('{{ item.id }}', '{{ item.ci_code }}', '{{ item.name|escapejs }}')" class="p-2 bg-emerald-50 text-emerald-600 hover:bg-emerald-100 rounded-lg transition-colors border border-emerald-100" title="Pasang / Alokasikan">
|
||||
<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>
|
||||
</button>
|
||||
{% elif item.status == 'in_use' %}
|
||||
{% if item.installed_on %}
|
||||
<button onclick="openReplaceModal('{{ item.id }}', '{{ item.ci_code }}', '{{ item.name|escapejs }}', '{{ item.installed_on.unit_code }}')" class="p-1.5 text-blue-600 hover:bg-blue-50 rounded-lg transition-colors" title="Ganti / Upgrade Komponen">
|
||||
<button onclick="openReplaceModal('{{ item.id }}', '{{ item.ci_code }}', '{{ item.name|escapejs }}', '{{ item.installed_on.unit_code }}')" class="p-2 bg-blue-50 text-blue-600 hover:bg-blue-100 rounded-lg transition-colors border border-blue-100" title="Ganti / Upgrade Komponen">
|
||||
<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="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"></path></svg>
|
||||
</button>
|
||||
{% endif %}
|
||||
<button onclick="openRemoveModal('{{ item.id }}', '{{ item.ci_code }}', '{{ item.name|escapejs }}')" class="p-1.5 text-amber-600 hover:bg-amber-50 rounded-lg transition-colors" title="Lepas dari Perangkat/Pengguna">
|
||||
<button onclick="openRemoveModal('{{ item.id }}', '{{ item.ci_code }}', '{{ item.name|escapejs }}')" class="p-2 bg-amber-50 text-amber-600 hover:bg-amber-100 rounded-lg transition-colors border border-amber-100" title="Lepas Komponen">
|
||||
<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="M17 16l4-4m0 0l-4-4m4 4H7m6 4v1a3 3 0 01-3 3H6a3 3 0 01-3-3V7a3 3 0 013-3h4a3 3 0 013 3v1"></path></svg>
|
||||
</button>
|
||||
{% endif %}
|
||||
|
||||
<button onclick="openDamageModal('{{ item.id }}', '{{ item.ci_code }}', '{{ item.name|escapejs }}')" class="p-1.5 text-red-500 hover:bg-red-50 rounded-lg transition-colors" title="Laporkan Kerusakan / Perbaikan">
|
||||
<button onclick="openDamageModal('{{ item.id }}', '{{ item.ci_code }}', '{{ item.name|escapejs }}')" class="p-2 bg-red-50 text-red-600 hover:bg-red-100 rounded-lg transition-colors border border-red-100" title="Lapor Kerusakan">
|
||||
<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 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"></path></svg>
|
||||
</button>
|
||||
{% endif %}
|
||||
@@ -243,11 +239,8 @@
|
||||
</tr>
|
||||
{% empty %}
|
||||
<tr>
|
||||
<td colspan="9" class="p-12 text-center text-gray-400 text-sm">
|
||||
<div class="flex flex-col items-center justify-center space-y-3">
|
||||
<svg class="w-12 h-12 text-gray-300" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 3v2m6-2v2M9 19v2m6-2v2M5 9H3m2 6H3m18-6h-2m2 6h-2M7 19h10a2 2 0 002-2V7a2 2 0 00-2-2H7a2 2 0 00-2 2v10a2 2 0 002 2zM9 9h6v6H9V9z"></path></svg>
|
||||
<p class="font-medium text-gray-500">Belum ada Configuration Item yang cocok dengan kriteria pencarian.</p>
|
||||
</div>
|
||||
<td colspan="9" class="p-8 text-center text-gray-400 text-sm">
|
||||
Belum ada data Configuration Item untuk kategori ini.
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
@@ -257,7 +250,6 @@
|
||||
{% include 'components/pagination.html' %}
|
||||
</div>
|
||||
|
||||
<!-- ============================================================== -->
|
||||
<!-- MODAL: Tambah Configuration Item Baru -->
|
||||
<!-- ============================================================== -->
|
||||
<div id="createCIModal" class="fixed inset-0 z-50 hidden flex items-center justify-center">
|
||||
@@ -600,5 +592,13 @@
|
||||
function closeDamageModal() {
|
||||
document.getElementById('damageModal').classList.add('hidden');
|
||||
}
|
||||
|
||||
// Close export dropdown when clicking outside
|
||||
window.addEventListener('click', function(e) {
|
||||
const exportMenu = document.getElementById('exportMenuCI');
|
||||
if (exportMenu && !e.target.closest('#exportMenuCI') && !e.target.closest('button')) {
|
||||
exportMenu.style.display = 'none';
|
||||
}
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{% extends 'base.html' %}
|
||||
|
||||
{% block page_title %}{{ item.item_code }} - {{ item.name }}{% endblock %}
|
||||
{% block page_title %}{{ item.item_code }}{% endblock %}
|
||||
|
||||
{% block page_title_guide %}Buku Besar & Riwayat Stok Consumable{% endblock %}
|
||||
{% block page_guide_content %}
|
||||
@@ -15,59 +15,73 @@
|
||||
|
||||
{% block content %}
|
||||
<!-- Header Navigation & Actions -->
|
||||
<div class="mb-6 flex flex-col sm:flex-row sm:justify-between sm:items-end space-y-4 sm:space-y-0">
|
||||
<div>
|
||||
<div class="flex items-center space-x-2 text-xs font-bold text-gray-400 mb-1">
|
||||
<a href="{% url 'consumable_list' %}" class="hover:text-kerinci transition-colors">Consumable Item</a>
|
||||
<span>•</span>
|
||||
<span class="text-kerinci font-mono">{{ item.item_code }}</span>
|
||||
<div class="mb-6 flex flex-col md:flex-row md:justify-between md:items-start gap-4">
|
||||
<!-- Kiri: Breadcrumb, Judul, Badges & Spesifikasi -->
|
||||
<div class="min-w-0 flex-1">
|
||||
<div class="flex items-center space-x-2 text-xs font-bold text-kerinci uppercase tracking-widest mb-1.5">
|
||||
<a href="{% url 'consumable_list' %}" class="hover:underline flex items-center gap-1">
|
||||
<span>Consumable Item</span>
|
||||
</a>
|
||||
<span class="text-gray-300">•</span>
|
||||
<span class="font-mono text-gray-500 font-semibold">{{ item.item_code }}</span>
|
||||
</div>
|
||||
<div class="flex flex-wrap items-center gap-3">
|
||||
<h2 class="text-2xl sm:text-3xl font-extrabold text-gray-900">{{ item.name }}</h2>
|
||||
<!-- Status Badge -->
|
||||
{% if item.stock_status == 'out_of_stock' %}
|
||||
<span class="px-3 py-1 rounded-full text-xs font-bold bg-red-100 text-red-700 border border-red-200 flex items-center gap-1.5">
|
||||
<span class="w-2 h-2 rounded-full bg-red-500"></span>
|
||||
Stok Habis
|
||||
</span>
|
||||
{% elif item.stock_status == 'low_stock' %}
|
||||
<span class="px-3 py-1 rounded-full text-xs font-bold bg-amber-100 text-amber-800 border border-amber-200 flex items-center gap-1.5">
|
||||
<span class="w-2 h-2 rounded-full bg-amber-500"></span>
|
||||
Stok Menipis
|
||||
</span>
|
||||
{% else %}
|
||||
<span class="px-3 py-1 rounded-full text-xs font-bold bg-emerald-100 text-emerald-800 border border-emerald-200 flex items-center gap-1.5">
|
||||
<span class="w-2 h-2 rounded-full bg-emerald-500"></span>
|
||||
Stok Tersedia
|
||||
</span>
|
||||
|
||||
<h2 class="text-2xl sm:text-3xl font-extrabold text-gray-900 tracking-tight leading-tight">{{ item.name }}</h2>
|
||||
|
||||
<p class="text-xs text-gray-500 mt-2 flex flex-wrap items-center gap-x-2 gap-y-1">
|
||||
<span class="font-semibold text-gray-700">{{ item.brand|default:"Tanpa Merek" }}</span>
|
||||
{% if item.specification %}
|
||||
<span class="text-gray-300">•</span>
|
||||
<span>{{ item.specification }}</span>
|
||||
{% endif %}
|
||||
<span class="px-2.5 py-1 rounded-full text-xs font-medium bg-gray-100 text-gray-700">
|
||||
{{ item.get_category_display }}
|
||||
</span>
|
||||
</div>
|
||||
<p class="text-xs text-gray-500 mt-1">{{ item.brand|default:"Tanpa Merek" }} • {{ item.specification|default:"Tidak ada spesifikasi khusus" }}</p>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<!-- Action Buttons -->
|
||||
<div class="flex flex-wrap items-center gap-2 w-full sm:w-auto">
|
||||
<a href="{% url 'consumable_list' %}" class="px-3.5 py-2 rounded-xl border border-gray-200 text-xs font-bold text-gray-600 hover:bg-gray-50 transition-colors flex items-center space-x-1.5 bg-white shadow-sm">
|
||||
<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="M10 19l-7-7m0 0l7-7m-7 7h18"></path></svg>
|
||||
<span>Katalog</span>
|
||||
</a>
|
||||
<!-- Kanan: Action Buttons Rapih & Teratur (Tidak Menumpuk) -->
|
||||
<div class="flex flex-wrap sm:flex-nowrap items-center gap-3 w-full sm:w-auto shrink-0 self-start">
|
||||
{% if not is_read_only %}
|
||||
<button onclick="openModalBarangMasuk()" class="bg-blue-600 text-white px-3.5 py-2 rounded-xl text-xs font-bold shadow-sm shadow-blue-500/20 hover:bg-blue-700 transition-colors flex items-center space-x-1.5">
|
||||
<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="M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-8l-4-4m0 0L8 8m4-4v12"></path></svg>
|
||||
<span>+ Barang Masuk</span>
|
||||
</button>
|
||||
<button onclick="openModalBarangKeluar()" class="bg-amber-600 text-white px-3.5 py-2 rounded-xl text-xs font-bold shadow-sm shadow-amber-500/20 hover:bg-amber-700 transition-colors flex items-center space-x-1.5">
|
||||
<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="M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4"></path></svg>
|
||||
<span>- Barang Keluar</span>
|
||||
</button>
|
||||
<button onclick="openModalEditItem()" class="px-3.5 py-2 rounded-xl border border-gray-200 text-xs font-bold text-gray-700 hover:bg-gray-50 transition-colors flex items-center space-x-1.5 bg-white shadow-sm">
|
||||
<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>
|
||||
<span>Edit Master</span>
|
||||
<!-- 1. Tombol Edit Item: Mobile baris atas kiri (flex-1), Desktop tengah (sm:order-2 sm:flex-none) -->
|
||||
<button onclick="openModalEditItem()" class="order-1 sm:order-2 bg-white border border-gray-200 rounded-xl shadow-sm px-3.5 sm:px-4 py-2 text-xs sm:text-sm font-bold text-gray-700 hover:bg-gray-50 transition-colors flex items-center space-x-1.5 sm:space-x-2 justify-center flex-1 sm:flex-none whitespace-nowrap">
|
||||
<svg class="w-4 h-4 text-amber-500 shrink-0" 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>
|
||||
<span>Edit Item</span>
|
||||
</button>
|
||||
|
||||
<!-- 2. Dropdown Transaksi Stok: Mobile baris atas kanan (flex-1), Desktop kanan (sm:order-3 sm:flex-none) -->
|
||||
<div class="order-2 sm:order-3 relative inline-block flex-1 sm:flex-none w-auto" id="trxDropdownContainer">
|
||||
<button onclick="var d = document.getElementById('trxActionDropdown'); d.style.display = d.style.display === 'block' ? 'none' : 'block'; event.stopPropagation();" class="w-full bg-kerinci hover:bg-kerinci/90 text-white rounded-xl shadow-sm px-3.5 sm:px-4 py-2 text-xs sm:text-sm font-bold transition-all flex items-center space-x-1.5 sm:space-x-2 justify-center whitespace-nowrap">
|
||||
<svg class="w-4 h-4 shrink-0" 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 shrink-0" 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="trxActionDropdown" style="display: none;" class="absolute right-0 mt-2 w-56 bg-white rounded-2xl shadow-[0_10px_35px_rgba(0,0,0,0.15)] border border-gray-100 p-1.5 z-50">
|
||||
<button onclick="openModalBarangMasuk(); document.getElementById('trxActionDropdown').style.display='none';" class="w-full text-left px-3.5 py-2.5 rounded-xl hover:bg-blue-50 text-blue-700 font-bold text-xs flex items-center space-x-2.5 transition-colors">
|
||||
<div class="w-7 h-7 rounded-lg bg-blue-100 flex items-center justify-center text-blue-600 shrink-0">
|
||||
<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="M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-8l-4-4m0 0L8 8m4-4v12"></path></svg>
|
||||
</div>
|
||||
<div>
|
||||
<div class="font-extrabold">+ Barang Masuk</div>
|
||||
<div class="text-[10px] text-gray-500 font-normal">Penerimaan / Pengadaan</div>
|
||||
</div>
|
||||
</button>
|
||||
<div class="h-px bg-gray-100 my-1"></div>
|
||||
<button onclick="openModalBarangKeluar(); document.getElementById('trxActionDropdown').style.display='none';" class="w-full text-left px-3.5 py-2.5 rounded-xl hover:bg-amber-50 text-amber-700 font-bold text-xs flex items-center space-x-2.5 transition-colors">
|
||||
<div class="w-7 h-7 rounded-lg bg-amber-100 flex items-center justify-center text-amber-600 shrink-0">
|
||||
<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="M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4"></path></svg>
|
||||
</div>
|
||||
<div>
|
||||
<div class="font-extrabold">- Barang Keluar</div>
|
||||
<div class="text-[10px] text-gray-500 font-normal">Pemakaian Teknisi / Unit</div>
|
||||
</div>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<!-- 3. Tombol Kembali: Mobile baris bawah (w-full), Desktop paling kiri (sm:order-1 sm:w-auto) -->
|
||||
<a href="{% url 'consumable_list' %}" class="order-3 sm:order-1 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 w-full sm:w-auto flex-none">
|
||||
<svg class="w-4 h-4 text-gray-500 shrink-0" 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>
|
||||
</div>
|
||||
|
||||
@@ -120,18 +134,31 @@
|
||||
|
||||
<!-- Stock Ledger Table (Buku Besar Mutasi) -->
|
||||
<div class="bg-white rounded-2xl shadow-sm border border-gray-200 overflow-hidden mb-6">
|
||||
<div class="p-4 border-b border-gray-100 flex items-center justify-between bg-gray-50/50">
|
||||
<div class="p-4 border-b border-gray-100 flex flex-col sm:flex-row sm:items-center justify-between gap-3 bg-gray-50/50">
|
||||
<div class="flex items-center space-x-2">
|
||||
<svg class="w-5 h-5 text-kerinci" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12h6m-6 4h6m2 5H7a2 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>
|
||||
<h3 class="font-extrabold text-gray-900 text-sm">Buku Besar Persediaan (Stock Ledger)</h3>
|
||||
</div>
|
||||
{% if not is_read_only %}
|
||||
<div class="flex items-center space-x-2 self-start sm:self-auto">
|
||||
<button onclick="openModalBarangMasuk()" class="text-xs font-bold text-blue-700 bg-blue-50 hover:bg-blue-100 border border-blue-200 px-3 py-1.5 rounded-lg transition-colors flex items-center space-x-1 shadow-xs">
|
||||
<svg class="w-3.5 h-3.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>
|
||||
<span>+ Barang Masuk</span>
|
||||
</button>
|
||||
<button onclick="openModalBarangKeluar()" class="text-xs font-bold text-amber-700 bg-amber-50 hover:bg-amber-100 border border-amber-200 px-3 py-1.5 rounded-lg transition-colors flex items-center space-x-1 shadow-xs">
|
||||
<svg class="w-3.5 h-3.5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M20 12H4"></path></svg>
|
||||
<span>- Barang Keluar</span>
|
||||
</button>
|
||||
</div>
|
||||
{% else %}
|
||||
<span class="text-xs text-gray-500 font-medium">Audit Trail Mutasi Stok</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<div class="overflow-x-auto">
|
||||
<table class="w-full text-left border-collapse min-w-[1000px]">
|
||||
<thead>
|
||||
<tr class="bg-gray-50/75 border-b border-gray-200 text-[11px] font-bold text-gray-500 uppercase tracking-wider">
|
||||
<thead class="bg-[#002060] text-white">
|
||||
<tr class="text-[11px] font-bold uppercase tracking-wider">
|
||||
<th class="py-3 px-4">Tanggal & Ref</th>
|
||||
<th class="py-3 px-4 text-center">Tipe Transaksi</th>
|
||||
<th class="py-3 px-4 text-right">Kuantitas Transaksi</th>
|
||||
@@ -654,5 +681,13 @@
|
||||
function closeModalReversal() {
|
||||
document.getElementById('modalReversal').classList.add('hidden');
|
||||
}
|
||||
|
||||
// Tutup dropdown saat klik di luar
|
||||
window.addEventListener('click', function(e) {
|
||||
var trxDropdown = document.getElementById('trxActionDropdown');
|
||||
if (trxDropdown && !trxDropdown.contains(e.target)) {
|
||||
trxDropdown.style.display = 'none';
|
||||
}
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
||||
+160
-233
@@ -1,6 +1,6 @@
|
||||
{% extends 'base.html' %}
|
||||
|
||||
{% block page_title %}Consumable Item & Persediaan IT{% endblock %}
|
||||
{% block page_title %}Consumable Item{% endblock %}
|
||||
|
||||
{% block page_title_guide %}Panduan Modul Consumable Item{% endblock %}
|
||||
{% block page_guide_content %}
|
||||
@@ -11,128 +11,81 @@
|
||||
<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">
|
||||
<li><b>Barang Masuk:</b> Mencatat penambahan stok dari pengadaan/pembelian, transfer, atau retur sisa teknisi.</li>
|
||||
<li><b>Barang Keluar:</b> Mencatat konsumsi material oleh teknisi dengan keterkaitan ke tiket support, work order, atau unit aset terkait.</li>
|
||||
<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>
|
||||
<li><b>Stock Opname:</b> Penyesuaian fisik berkala dengan alasan audit yang wajib diisi.</li>
|
||||
</ul>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<!-- Top Header & Action Buttons -->
|
||||
<div class="mb-6 flex flex-col sm:flex-row sm:justify-between sm:items-end space-y-4 sm:space-y-0">
|
||||
<div class="mb-8 flex flex-col sm:flex-row sm:justify-between sm:items-center space-y-4 sm:space-y-0">
|
||||
<div>
|
||||
<p class="text-xs font-bold text-kerinci uppercase tracking-widest mb-1">Manajemen Aset • Logistik Habis Pakai</p>
|
||||
<p class="text-xs font-bold text-kerinci uppercase tracking-widest mb-1">Manajemen Aset</p>
|
||||
<div class="flex items-center space-x-3">
|
||||
<h2 class="text-3xl font-extrabold text-gray-900">Consumable Item</h2>
|
||||
<span class="px-2.5 py-0.5 rounded-full text-xs font-extrabold bg-emerald-50 text-emerald-700 border border-emerald-200">
|
||||
Network & Support
|
||||
</span>
|
||||
<button onclick="openGuideModal()" class="text-gray-400 hover:text-kerinci p-1 rounded-lg hover:bg-gray-100 transition-colors" title="Buka Panduan 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="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path></svg>
|
||||
</button>
|
||||
<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-xs text-gray-500 mt-1">Pengelolaan persediaan kabel, konektor RJ45, thermal paste, cable ties, fastener, dan perlengkapan teknisi IT.</p>
|
||||
</div>
|
||||
|
||||
<!-- Quick Action Buttons -->
|
||||
<div class="flex flex-wrap items-center gap-2 w-full sm:w-auto">
|
||||
<!-- Header Actions -->
|
||||
<div class="flex flex-wrap sm:flex-nowrap items-center gap-3 w-full sm:w-auto">
|
||||
<!-- Ekspor Dropdown -->
|
||||
<div class="relative inline-block flex-1 sm:flex-none w-auto">
|
||||
<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 whitespace-nowrap shadow-sm">
|
||||
<svg class="w-4 h-4 shrink-0" 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 shrink-0" 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 py-1">
|
||||
<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>
|
||||
|
||||
{% if not is_read_only %}
|
||||
<button onclick="openModalBarangMasuk()" class="bg-blue-600 text-white px-3.5 py-2.5 rounded-xl text-xs font-bold shadow-sm shadow-blue-500/20 hover:bg-blue-700 transition-colors flex items-center space-x-1.5">
|
||||
<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="M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-8l-4-4m0 0L8 8m4-4v12"></path></svg>
|
||||
<span>Barang Masuk</span>
|
||||
</button>
|
||||
<button onclick="openModalBarangKeluar()" class="bg-amber-600 text-white px-3.5 py-2.5 rounded-xl text-xs font-bold shadow-sm shadow-amber-500/20 hover:bg-amber-700 transition-colors flex items-center space-x-1.5">
|
||||
<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="M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4"></path></svg>
|
||||
<span>Barang Keluar</span>
|
||||
</button>
|
||||
<button onclick="openModalOpname()" class="bg-purple-600 text-white px-3.5 py-2.5 rounded-xl text-xs font-bold shadow-sm shadow-purple-500/20 hover:bg-purple-700 transition-colors flex items-center space-x-1.5">
|
||||
<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="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>
|
||||
<span>Stock Opname</span>
|
||||
</button>
|
||||
<button onclick="openCreateItemModal()" class="bg-kerinci text-white px-4 py-2.5 rounded-xl text-xs font-bold shadow-sm shadow-kerinci/30 hover:bg-kerinci/90 transition-colors flex items-center space-x-1.5">
|
||||
<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>
|
||||
<span>+ Tambah Item</span>
|
||||
<!-- Transaksi Stok Dropdown -->
|
||||
<div class="relative inline-block flex-1 sm:flex-none w-auto">
|
||||
<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 whitespace-nowrap">
|
||||
<svg class="w-4 h-4 text-blue-600 shrink-0" 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 shrink-0" 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 sm:flex-none whitespace-nowrap">
|
||||
<svg class="w-4 h-4 shrink-0" 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>
|
||||
<span>Tambah Item</span>
|
||||
</button>
|
||||
{% endif %}
|
||||
|
||||
<!-- Export Dropdown / Buttons -->
|
||||
<div class="flex items-center space-x-1 pl-1">
|
||||
<a href="{% url 'consumable_export_excel' %}?q={{ search_query }}&category={{ category_filter }}&status={{ status_filter }}" class="p-2.5 rounded-xl border border-gray-200 bg-white hover:bg-gray-50 text-emerald-700 transition-colors shadow-sm" title="Ekspor Excel">
|
||||
<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>
|
||||
</a>
|
||||
<a href="{% url 'consumable_export_pdf' %}?q={{ search_query }}&category={{ category_filter }}&status={{ status_filter }}" target="_blank" class="p-2.5 rounded-xl border border-gray-200 bg-white hover:bg-gray-50 text-red-600 transition-colors shadow-sm" title="Ekspor PDF">
|
||||
<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="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>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- KPI Summary Cards -->
|
||||
<div class="grid grid-cols-2 lg:grid-cols-5 gap-3.5 mb-6">
|
||||
<!-- Total Jenis Item -->
|
||||
<div class="bg-white p-4 rounded-2xl border border-gray-100 shadow-sm flex items-center justify-between">
|
||||
<div>
|
||||
<p class="text-[11px] font-bold text-gray-400 uppercase tracking-wider mb-0.5">Total Jenis</p>
|
||||
<h3 class="text-2xl font-black text-gray-900">{{ counts.total }}</h3>
|
||||
<p class="text-[10px] text-gray-400">Item Terdaftar</p>
|
||||
</div>
|
||||
<div class="w-10 h-10 bg-emerald-50 text-kerinci rounded-xl flex items-center justify-center font-bold">
|
||||
<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="M20 7l-8-4-8 4m16 0l-8 4m8-4v10l-8 4m0-10L4 7m8 4v10M4 7v10l8 4"></path></svg>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Akumulasi Stok Fisik -->
|
||||
<div class="bg-white p-4 rounded-2xl border border-gray-100 shadow-sm flex items-center justify-between">
|
||||
<div>
|
||||
<p class="text-[11px] font-bold text-blue-600 uppercase tracking-wider mb-0.5" title="Jumlah agregat kuantitas seluruh item">Akumulasi Stok</p>
|
||||
<h3 class="text-2xl font-black text-blue-900">{{ counts.total_qty|floatformat:0 }}</h3>
|
||||
<p class="text-[10px] text-blue-500" title="Agregat lintas satuan (pcs, meter, roll, dsb)">*Agregat kuantitas</p>
|
||||
</div>
|
||||
<div class="w-10 h-10 bg-blue-50 text-blue-600 rounded-xl flex items-center justify-center font-bold">
|
||||
<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="M7 12l3-3 3 3 4-4M8 21l4-4 4 4M3 4h18M4 4h16v12a1 1 0 01-1 1H5a1 1 0 01-1-1V4z"></path></svg>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Stok Tersedia Aman -->
|
||||
<div class="bg-white p-4 rounded-2xl border border-gray-100 shadow-sm flex items-center justify-between">
|
||||
<div>
|
||||
<p class="text-[11px] font-bold text-emerald-600 uppercase tracking-wider mb-0.5">Stok Normal</p>
|
||||
<h3 class="text-2xl font-black text-emerald-900">{{ counts.available }}</h3>
|
||||
<p class="text-[10px] text-emerald-500">Di atas batas min</p>
|
||||
</div>
|
||||
<div class="w-10 h-10 bg-emerald-50 text-emerald-600 rounded-xl flex items-center justify-center font-bold">
|
||||
<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 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"></path></svg>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Stok Menipis -->
|
||||
<div class="bg-white p-4 rounded-2xl border border-gray-100 shadow-sm flex items-center justify-between">
|
||||
<div>
|
||||
<p class="text-[11px] font-bold text-amber-600 uppercase tracking-wider mb-0.5">Stok Menipis</p>
|
||||
<h3 class="text-2xl font-black text-amber-900">{{ counts.low_stock }}</h3>
|
||||
<p class="text-[10px] text-amber-500">Perlu reorder</p>
|
||||
</div>
|
||||
<div class="w-10 h-10 bg-amber-50 text-amber-600 rounded-xl flex items-center justify-center font-bold">
|
||||
<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 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"></path></svg>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Stok Habis -->
|
||||
<div class="bg-white p-4 rounded-2xl border border-gray-100 shadow-sm flex items-center justify-between col-span-2 lg:col-span-1">
|
||||
<div>
|
||||
<p class="text-[11px] font-bold text-red-600 uppercase tracking-wider mb-0.5">Stok Habis</p>
|
||||
<h3 class="text-2xl font-black text-red-900">{{ counts.out_of_stock }}</h3>
|
||||
<p class="text-[10px] text-red-500">Saldo 0</p>
|
||||
</div>
|
||||
<div class="w-10 h-10 bg-red-50 text-red-600 rounded-xl flex items-center justify-center font-bold">
|
||||
<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="M18.364 18.364A9 9 0 005.636 5.636m12.728 12.728A9 9 0 015.636 5.636m12.728 12.728L5.636 5.636"></path></svg>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Status Tabs -->
|
||||
<div class="flex space-x-2 mb-4 border-b border-gray-200 overflow-x-auto whitespace-nowrap scrollbar-hide">
|
||||
<!-- Category Tabs -->
|
||||
<div class="flex space-x-2 mb-6 border-b border-gray-200 overflow-x-auto whitespace-nowrap scrollbar-hide">
|
||||
<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>
|
||||
@@ -141,161 +94,138 @@
|
||||
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>
|
||||
<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-amber-600 text-amber-600{% else %}border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300{% endif %}">
|
||||
<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 %}">
|
||||
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>
|
||||
<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-red-600 text-red-600{% else %}border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300{% endif %}">
|
||||
<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 %}">
|
||||
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>
|
||||
|
||||
<!-- Filters & Search Bar -->
|
||||
<div class="mb-5 flex flex-col md:flex-row md:items-center justify-between gap-3">
|
||||
<form id="filterForm" method="GET" class="flex flex-wrap items-center gap-2 w-full">
|
||||
<!-- Filters & Search -->
|
||||
<div class="mb-4 flex flex-col md:flex-row md:items-center md:justify-between gap-3">
|
||||
<form id="searchForm" method="GET" class="relative w-full md:w-96 min-w-0">
|
||||
<input type="hidden" name="status" value="{{ status_filter }}">
|
||||
<div class="relative flex-1 min-w-[240px]">
|
||||
<input type="text" name="q" value="{{ search_query }}" placeholder="Cari kode barang, nama, merek, spesifikasi, lokasi..." 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>
|
||||
{% 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>
|
||||
|
||||
<div class="flex items-center gap-2 w-full md:w-auto min-w-0">
|
||||
<div class="grid grid-cols-2 gap-2 flex-1 md:flex-none w-full md:w-auto min-w-0">
|
||||
<div class="min-w-0">
|
||||
<select onchange="location = this.value;" class="w-full md:w-48 truncate 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 cursor-pointer" style="min-width: 0; max-width: 100%;">
|
||||
<option value="?status={{ status_filter }}&q={{ search_query }}{% if location_filter %}&location={{ location_filter }}{% endif %}">Semua Kategori</option>
|
||||
{% for cat_val, cat_label in categories %}
|
||||
<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>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="min-w-0">
|
||||
<select onchange="location = this.value;" class="w-full md:w-44 truncate 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 cursor-pointer" style="min-width: 0; max-width: 100%;">
|
||||
<option value="?status={{ status_filter }}&category={{ category_filter }}&q={{ search_query }}">Semua Lokasi</option>
|
||||
{% for loc in locations %}
|
||||
<option value="?status={{ status_filter }}&category={{ category_filter }}&location={{ loc }}&q={{ search_query }}" {% if location_filter == loc %}selected{% endif %}>{{ loc }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<select name="category" onchange="this.form.submit()" class="px-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 text-gray-700 shadow-sm">
|
||||
<option value="">Semua Kategori</option>
|
||||
{% for cat_val, cat_label in categories %}
|
||||
<option value="{{ cat_val }}" {% if category_filter == cat_val %}selected{% endif %}>{{ cat_label }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
|
||||
<select name="location" onchange="this.form.submit()" class="px-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 text-gray-700 shadow-sm">
|
||||
<option value="">Semua Lokasi</option>
|
||||
{% for loc in locations %}
|
||||
<option value="{{ loc }}" {% if location_filter == loc %}selected{% endif %}>{{ loc }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
|
||||
{% if search_query or category_filter or location_filter or status_filter %}
|
||||
<a href="{% url 'consumable_list' %}" class="px-3.5 py-2.5 text-xs font-bold text-gray-500 hover:text-red-500 border border-gray-200 hover:border-red-200 rounded-xl bg-white transition-colors" title="Reset Semua Filter">
|
||||
<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 shrink-0 whitespace-nowrap" title="Reset Filter">
|
||||
Reset
|
||||
</a>
|
||||
{% endif %}
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Consumable Item Table Card -->
|
||||
<div class="bg-white rounded-2xl shadow-sm border border-gray-200 overflow-hidden">
|
||||
<!-- Main Data Table -->
|
||||
<div class="bg-white rounded-none sm:rounded-2xl shadow-sm border border-gray-100 overflow-hidden w-full" id="tableContainer">
|
||||
<div class="overflow-x-auto">
|
||||
<table class="w-full text-left border-collapse min-w-[900px]">
|
||||
<table class="w-full text-left border-collapse min-w-[1100px]">
|
||||
<thead>
|
||||
<tr class="bg-gray-50/75 border-b border-gray-200 text-[11px] font-bold text-gray-500 uppercase tracking-wider">
|
||||
<th class="py-3.5 px-4">Kode Item</th>
|
||||
<th class="py-3.5 px-4">Nama Barang & Merek</th>
|
||||
<th class="py-3.5 px-4">Kategori</th>
|
||||
<th class="py-3.5 px-4">Spesifikasi</th>
|
||||
<th class="py-3.5 px-4 text-center">Satuan</th>
|
||||
<th class="py-3.5 px-4 text-right">Stok Tersedia</th>
|
||||
<th class="py-3.5 px-4 text-right">Stok Min</th>
|
||||
<th class="py-3.5 px-4">Lokasi</th>
|
||||
<th class="py-3.5 px-4 text-center">Status</th>
|
||||
<th class="py-3.5 px-4 text-center">Aksi</th>
|
||||
<tr class="bg-[#002060] text-white text-[11px] uppercase tracking-wider">
|
||||
<th class="p-4 font-bold text-center w-14 whitespace-nowrap">No</th>
|
||||
<th class="p-4 font-bold whitespace-nowrap">Kode Item</th>
|
||||
<th class="p-4 font-bold min-w-[200px]">Nama Barang & Merek</th>
|
||||
<th class="p-4 font-bold whitespace-nowrap">Kategori</th>
|
||||
<th class="p-4 font-bold min-w-[160px]">Spesifikasi</th>
|
||||
<th class="p-4 font-bold text-center whitespace-nowrap">Satuan</th>
|
||||
<th class="p-4 font-bold text-center whitespace-nowrap min-w-[120px]">Stok</th>
|
||||
<th class="p-4 font-bold whitespace-nowrap min-w-[160px]">Lokasi</th>
|
||||
<th class="p-4 font-bold text-center whitespace-nowrap">Status</th>
|
||||
<th class="p-4 font-bold text-center w-28 whitespace-nowrap">Aksi</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="divide-y divide-gray-100 text-sm">
|
||||
<tbody class="text-sm divide-y divide-gray-200">
|
||||
{% for item in page_obj %}
|
||||
<tr class="hover:bg-gray-50/80 transition-colors">
|
||||
<!-- Kode Item -->
|
||||
<td class="py-3.5 px-4 whitespace-nowrap">
|
||||
<a href="{% url 'consumable_detail' item.id %}" class="font-mono text-xs font-bold text-kerinci hover:underline">
|
||||
<tr class="hover:bg-gray-50 transition-colors">
|
||||
<td class="p-4 text-center text-gray-500 whitespace-nowrap">{{ forloop.counter }}</td>
|
||||
<td class="p-4 font-bold text-gray-700 font-mono text-xs whitespace-nowrap">
|
||||
<a href="{% url 'consumable_detail' item.id %}" class="hover:text-kerinci transition-colors">
|
||||
{{ item.item_code }}
|
||||
</a>
|
||||
</td>
|
||||
|
||||
<!-- Nama Barang & Merek -->
|
||||
<td class="py-3.5 px-4">
|
||||
<div class="font-bold text-gray-900 leading-snug">
|
||||
<a href="{% url 'consumable_detail' item.id %}" class="hover:text-kerinci">
|
||||
{{ item.name }}
|
||||
</a>
|
||||
</div>
|
||||
<td class="p-4 min-w-[200px]">
|
||||
<a href="{% url 'consumable_detail' item.id %}" class="font-bold text-gray-900 hover:text-kerinci transition-colors block">
|
||||
{{ item.name }}
|
||||
</a>
|
||||
{% if item.brand %}
|
||||
<div class="text-[11px] text-gray-400 font-medium">Merek: {{ item.brand }}</div>
|
||||
<p class="text-xs text-gray-500 font-normal mt-0.5">Merek: {{ item.brand }}</p>
|
||||
{% endif %}
|
||||
</td>
|
||||
|
||||
<!-- Kategori -->
|
||||
<td class="py-3.5 px-4 whitespace-nowrap">
|
||||
<span class="inline-flex items-center px-2 py-0.5 rounded-lg text-xs font-medium bg-gray-100 text-gray-700">
|
||||
{{ item.get_category_display|truncatewords:2 }}
|
||||
</span>
|
||||
<td class="p-4 text-gray-600 font-medium text-xs whitespace-nowrap">
|
||||
{% if item.category == 'cable' %}Kabel (UTP & FO)
|
||||
{% elif item.category == 'connector' %}Konektor & Barrel
|
||||
{% elif item.category == 'maintenance' %}Bahan Perawatan
|
||||
{% elif item.category == 'fastener' %}Baut, Mur & Ties
|
||||
{% elif item.category == 'electrical' %}Kelistrikan & Isolasi
|
||||
{% elif item.category == 'cleaning' %}Cleaning Supplies
|
||||
{% elif item.category == 'tools_acc' %}Aksesori & Tools
|
||||
{% else %}{{ item.get_category_display }}
|
||||
{% endif %}
|
||||
</td>
|
||||
|
||||
<!-- Spesifikasi -->
|
||||
<td class="py-3.5 px-4 text-xs text-gray-600 max-w-[220px]">
|
||||
<td class="p-4 text-xs text-gray-500 max-w-[220px]">
|
||||
<span class="line-clamp-2" title="{{ item.specification }}">{{ item.specification|default:"-" }}</span>
|
||||
</td>
|
||||
|
||||
<!-- Satuan & Konversi -->
|
||||
<td class="py-3.5 px-4 text-center whitespace-nowrap">
|
||||
<span class="font-semibold text-gray-700 text-xs">{{ item.base_unit }}</span>
|
||||
{% if item.purchase_unit %}
|
||||
<div class="text-[10px] text-gray-400" title="1 {{ item.purchase_unit }} = {{ item.conversion_rate }} {{ item.base_unit }}">
|
||||
1 {{ item.purchase_unit }} = {{ item.conversion_rate|floatformat:0 }} {{ item.base_unit }}
|
||||
</div>
|
||||
{% endif %}
|
||||
<td class="p-4 text-center text-gray-700 font-semibold text-xs whitespace-nowrap">
|
||||
{{ item.base_unit }}
|
||||
</td>
|
||||
|
||||
<!-- Stok Tersedia -->
|
||||
<td class="py-3.5 px-4 text-right whitespace-nowrap">
|
||||
<span class="text-base font-extrabold {% if item.stock_status == 'out_of_stock' %}text-red-600{% elif item.stock_status == 'low_stock' %}text-amber-600{% else %}text-emerald-700{% endif %}">
|
||||
<td class="p-4 text-center whitespace-nowrap">
|
||||
<div class="font-black text-sm {% 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>
|
||||
</div>
|
||||
<div class="text-[11px] text-gray-400 font-medium">
|
||||
Min: {{ item.minimum_stock|floatformat:0 }} {{ item.base_unit }}
|
||||
</div>
|
||||
</td>
|
||||
|
||||
<!-- Stok Minimum -->
|
||||
<td class="py-3.5 px-4 text-right whitespace-nowrap text-xs text-gray-500 font-medium">
|
||||
{{ item.formatted_minimum_stock }}
|
||||
<td class="p-4 text-gray-700 text-xs font-medium whitespace-nowrap min-w-[160px]">
|
||||
<div class="flex items-center space-x-1.5">
|
||||
<svg class="w-3.5 h-3.5 text-gray-400 shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M17.657 16.657L13.414 20.9a1.998 1.998 0 01-2.827 0l-4.244-4.243a8 8 0 1111.314 0z"></path><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 11a3 3 0 11-6 0 3 3 0 016 0z"></path></svg>
|
||||
<span>{{ item.location }}</span>
|
||||
</div>
|
||||
</td>
|
||||
|
||||
<!-- Lokasi -->
|
||||
<td class="py-3.5 px-4 whitespace-nowrap text-xs text-gray-600">
|
||||
<span class="inline-flex items-center gap-1">
|
||||
<svg class="w-3.5 h-3.5 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M17.657 16.657L13.414 20.9a1.998 1.998 0 01-2.827 0l-4.244-4.243a8 8 0 1111.314 0z"></path></svg>
|
||||
{{ item.location }}
|
||||
</span>
|
||||
</td>
|
||||
|
||||
<!-- Status Stok Badge -->
|
||||
<td class="py-3.5 px-4 text-center whitespace-nowrap">
|
||||
<td class="p-4 text-center whitespace-nowrap">
|
||||
{% if item.stock_status == 'out_of_stock' %}
|
||||
<span class="inline-flex items-center px-2.5 py-1 rounded-full text-xs font-bold bg-red-100 text-red-700 border border-red-200">
|
||||
<span class="w-1.5 h-1.5 rounded-full bg-red-500 mr-1.5"></span>
|
||||
Habis
|
||||
</span>
|
||||
<span class="inline-flex items-center px-2.5 py-1 rounded-full text-xs font-bold bg-red-50 text-red-700 border border-red-200 whitespace-nowrap">Habis</span>
|
||||
{% elif item.stock_status == 'low_stock' %}
|
||||
<span class="inline-flex items-center px-2.5 py-1 rounded-full text-xs font-bold bg-amber-100 text-amber-800 border border-amber-200">
|
||||
<span class="w-1.5 h-1.5 rounded-full bg-amber-500 mr-1.5"></span>
|
||||
Menipis
|
||||
</span>
|
||||
<span class="inline-flex items-center px-2.5 py-1 rounded-full text-xs font-bold bg-amber-50 text-amber-700 border border-amber-200 whitespace-nowrap">Menipis</span>
|
||||
{% else %}
|
||||
<span class="inline-flex items-center px-2.5 py-1 rounded-full text-xs font-bold bg-emerald-100 text-emerald-800 border border-emerald-200">
|
||||
<span class="w-1.5 h-1.5 rounded-full bg-emerald-500 mr-1.5"></span>
|
||||
Tersedia
|
||||
</span>
|
||||
<span class="inline-flex items-center px-2.5 py-1 rounded-full text-xs font-bold bg-emerald-50 text-emerald-700 border border-emerald-200 whitespace-nowrap">Aman</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
|
||||
<!-- Aksi -->
|
||||
<td class="py-3.5 px-4 text-center whitespace-nowrap">
|
||||
<td class="p-4 text-center whitespace-nowrap">
|
||||
<div class="flex items-center justify-center space-x-1.5">
|
||||
<a href="{% url 'consumable_detail' item.id %}" class="p-1.5 text-gray-500 hover:text-kerinci hover:bg-gray-100 rounded-lg transition-colors" title="Buku Besar & Riwayat Lengkap">
|
||||
<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">
|
||||
<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 %}
|
||||
<button onclick="openModalBarangMasukItem('{{ item.id }}', '{{ item.name|escapejs }}', '{{ item.base_unit }}', '{{ item.purchase_unit|default:'' }}')" class="p-1.5 text-blue-600 hover:text-blue-800 hover:bg-blue-50 rounded-lg transition-colors" title="Tambah Stok (Barang Masuk)">
|
||||
<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>
|
||||
</button>
|
||||
<button onclick="openModalBarangKeluarItem('{{ item.id }}', '{{ item.name|escapejs }}', '{{ item.base_unit }}', '{{ item.stock_available }}')" class="p-1.5 text-amber-600 hover:text-amber-800 hover:bg-amber-50 rounded-lg transition-colors" title="Gunakan / Keluarkan Barang">
|
||||
<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="M20 12H4"></path></svg>
|
||||
<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>
|
||||
</button>
|
||||
{% endif %}
|
||||
</div>
|
||||
@@ -303,32 +233,17 @@
|
||||
</tr>
|
||||
{% empty %}
|
||||
<tr>
|
||||
<td colspan="10" class="py-12 text-center text-gray-500">
|
||||
<div class="flex flex-col items-center justify-center">
|
||||
<div class="w-16 h-16 bg-gray-100 rounded-full flex items-center justify-center text-gray-400 mb-3">
|
||||
<svg class="w-8 h-8" 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>
|
||||
</div>
|
||||
<h4 class="text-base font-bold text-gray-800">Tidak ada consumable item ditemukan</h4>
|
||||
<p class="text-xs text-gray-400 mt-1 max-w-sm">
|
||||
{% if search_query or category_filter or location_filter or status_filter %}
|
||||
Tidak ada data yang cocok dengan kriteria pencarian atau filter yang diterapkan.
|
||||
{% else %}
|
||||
Belum ada data barang habis pakai. Klik tombol "+ Tambah Item" di atas untuk mendaftarkan barang baru.
|
||||
{% endif %}
|
||||
</p>
|
||||
</div>
|
||||
<td colspan="10" class="p-8 text-center text-gray-400 text-sm">
|
||||
Belum ada data Consumable Item untuk kategori ini.
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<!-- Paginasi -->
|
||||
{% 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">
|
||||
@@ -901,5 +816,17 @@
|
||||
diffDisplay.className = 'text-lg font-black text-gray-500';
|
||||
}
|
||||
}
|
||||
|
||||
// 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';
|
||||
}
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
||||
@@ -12,28 +12,30 @@
|
||||
</div>
|
||||
<p class="text-gray-500 mt-1 font-medium">NIK: {{ employee.nik }} <span class="mx-2">•</span> Jabatan: {{ employee.position|default:"-" }}</p>
|
||||
</div>
|
||||
<div class="flex items-center space-x-3 w-full sm:w-auto">
|
||||
<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>
|
||||
<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 transition-colors flex items-center space-x-2 justify-center text-center w-full sm:w-auto flex-1 sm:flex-none">
|
||||
<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>
|
||||
|
||||
|
||||
+22
-20
@@ -11,28 +11,30 @@
|
||||
Dari Aset: <a href="{% url 'asset_units' unit.asset.id %}" class="font-bold text-blue-600 hover:underline">{{ unit.asset.name }}</a>
|
||||
</p>
|
||||
</div>
|
||||
<div class="flex items-center space-x-3 w-full sm:w-auto">
|
||||
<div class="relative inline-block w-full sm:w-auto flex-1 sm:flex-none">
|
||||
<button onclick="var d = document.getElementById('exportMenuHistory'); 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 Riwayat</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="exportMenuHistory" 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 'unit_history_export_pdf' unit.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 'unit_history_export_excel' unit.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>
|
||||
<a href="{% url 'asset_units' unit.asset.id %}" 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 transition-colors flex items-center space-x-2 justify-center text-center w-full sm:w-auto flex-1 sm:flex-none">
|
||||
<div class="flex flex-wrap sm:flex-nowrap items-center gap-3 w-full sm:w-auto">
|
||||
<a href="{% url 'asset_units' unit.asset.id %}" 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('exportMenuHistory'); 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 Riwayat</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="exportMenuHistory" 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 'unit_history_export_pdf' unit.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 'unit_history_export_excel' unit.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>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user