-- seed2.sql
-- 1. ROLES & CATEGORIES
INSERT INTO roles (id, name, description) VALUES
(1, 'admin', 'Administrator with full access'),
(2, 'manager', 'Manager for verification and approval'),
(3, 'user', 'Regular user (student)');
INSERT INTO categories (id, name, slug, description) VALUES
(1, 'Pakaian', 'pakaian', 'Baju, celana, jaket, dll'),
(2, 'Alat Makan', 'alat-makan', 'Botol, tupperware, dll'),
(3, 'Aksesoris', 'aksesoris', 'Jam tangan, kacamata, perhiasan'),
(4, 'Elektronik', 'elektronik', 'HP, laptop, charger, dll'),
(5, 'Alat Tulis', 'alat-tulis', 'Pulpen, buku, pensil, dll'),
(6, 'Lainnya', 'lainnya', 'Barang lain yang tidak masuk kategori');
-- 2. USERS (Explicit IDs 1-10)
INSERT INTO users (id, name, email, password, nrp, phone, role_id, status, last_login) VALUES
(1, 'Admin', 'admin@lostandfound.com', '$2a$10$zhRlU9e1v6T2x4/bPwOZNOAqSktHjj6QFgXV3i2/0pITlKasUpv4G', '0001', '081234567890', 1, 'active', NULL),
(2, 'Pak Budi', 'manager1@lostandfound.com', '$2a$10$zhRlU9e1v6T2x4/bPwOZNOAqSktHjj6QFgXV3i2/0pITlKasUpv4G', '2234567890', '081234567891', 2, 'active', NULL),
(3, 'Bu Siti', 'manager2@lostandfound.com', '$2a$10$zhRlU9e1v6T2x4/bPwOZNOAqSktHjj6QFgXV3i2/0pITlKasUpv4G', '2234567891', '081234567892', 2, 'active', NULL),
(4, 'Ahmad Rizki', 'ahmad@student.com', '$2a$10$zhRlU9e1v6T2x4/bPwOZNOAqSktHjj6QFgXV3i2/0pITlKasUpv4G', '5025211004', '081234567893', 3, 'active', '2024-02-12 09:15:00'),
(5, 'Siti Nurhaliza', 'siti@student.com', '$2a$10$zhRlU9e1v6T2x4/bPwOZNOAqSktHjj6QFgXV3i2/0pITlKasUpv4G', '5025211005', '081234567894', 3, 'active', '2024-02-11 14:20:00'),
(6, 'Budi Santoso', 'budi@student.com', '$2a$10$zhRlU9e1v6T2x4/bPwOZNOAqSktHjj6QFgXV3i2/0pITlKasUpv4G', '5025211008', '081234567895', 3, 'active', '2024-02-08 16:30:00'),
(7, 'Dewi Lestari', 'dewi@student.com', '$2a$10$zhRlU9e1v6T2x4/bPwOZNOAqSktHjj6QFgXV3i2/0pITlKasUpv4G', '5025211009', '081234567896', 3, 'active', '2024-01-15 11:00:00'),
(8, 'Pak Joko', 'manager3@lostandfound.com', '$2a$10$zhRlU9e1v6T2x4/bPwOZNOAqSktHjj6QFgXV3i2/0pITlKasUpv4G', '2234567892', '081234567898', 2, 'active', '2024-02-11 08:30:00'),
(9, 'Rina Melati', 'rina@student.com', '$2a$10$zhRlU9e1v6T2x4/bPwOZNOAqSktHjj6QFgXV3i2/0pITlKasUpv4G', '5025211006', '081234567899', 3, 'active', '2024-02-10 13:20:00'),
(10, 'Fajar Ramadhan', 'fajar@student.com', '$2a$10$zhRlU9e1v6T2x4/bPwOZNOAqSktHjj6QFgXV3i2/0pITlKasUpv4G', '5025211007', '081234567800', 3, 'active', '2024-02-09 10:45:00');
-- 1. Insert Permissions
INSERT INTO permissions (id, slug, name, description) VALUES
(1, 'item:read', 'View Items', 'Melihat daftar barang (public/dashboard)'),
(2, 'item:create', 'Create Item', 'Melaporkan barang temuan/hilang'),
(3, 'item:update', 'Update Item', 'Mengedit data barang'),
(4, 'item:delete', 'Delete Item', 'Menghapus data barang'),
(5, 'item:verify', 'Verify Item', 'Verifikasi detail barang (lihat detail rahasia)'),
(6, 'claim:read', 'View Claims', 'Melihat daftar klaim'),
(7, 'claim:create', 'Create Claim', 'Mengajukan klaim barang'),
(8, 'claim:approve', 'Approve Claim', 'Menyetujui klaim (verifikasi fisik)'),
(9, 'claim:reject', 'Reject Claim', 'Menolak klaim'),
(10, 'user:read', 'View Users', 'Melihat daftar pengguna'),
(11, 'user:update', 'Update User Role', 'Mengubah role pengguna'),
(12, 'user:block', 'Block/Unblock User', 'Memblokir atau membuka blokir user'),
(13, 'report:export', 'Export Report', 'Export laporan ke PDF/Excel'),
(14, 'audit:read', 'View Audit Log', 'Melihat log aktivitas sistem'),
(15, 'category:manage', 'Manage Categories', 'Membuat, edit, hapus kategori');
-- 2. Assign Permissions to Roles
-- Role ID 1: Admin (All Permissions)
-- A. ADMIN (Role ID: 1) - Punya SEMUA (1-15)
INSERT INTO role_permissions (role_id, permission_id)
SELECT 1, id FROM permissions;
-- B. MANAGER (Role ID: 2) - Operasional
INSERT INTO role_permissions (role_id, permission_id) VALUES
(2, 1), (2, 3), (2, 5), (2, 6), (2, 8), (2, 9), (2, 10), (2, 13);
-- C. USER (Role ID: 3) - Dasar
INSERT INTO role_permissions (role_id, permission_id) VALUES
(3, 1), (3, 2), (3, 6), (3, 7);

-- 1. Tambahkan permission baru khusus untuk Laporan Kehilangan (Lost Item)
-- Melanjutkan ID terakhir dari seed2.sql (ID 15)
INSERT INTO permissions (id, slug, name, description) VALUES
(16, 'lost_item:update', 'Update Lost Item', 'Mengedit laporan kehilangan (Admin/Manager)'),
(17, 'lost_item:delete', 'Delete Lost Item', 'Menghapus laporan kehilangan (Admin/Manager)');

-- 2. Berikan akses ke ADMIN (Role ID: 1)
-- Admin harus punya semua akses
INSERT INTO role_permissions (role_id, permission_id) VALUES
(1, 16),
(1, 17);

-- 3. Berikan akses ke MANAGER (Role ID: 2)
-- Sesuai permintaan: akses edit dan hapus laporan barang hilang
INSERT INTO role_permissions (role_id, permission_id) VALUES
(2, 16), -- Akses Edit Lost Item
(2, 17); -- Akses Hapus Lost Item