-- 120_users.sql — user awal & penugasan departemen (WP-1A)
-- Password dev untuk semua akun non-admin: Sanggra#2026 ; admin: Admin#2026 (bcrypt)
-- fb_user (id 6) ditambahkan WP-9D (Kontrak Sprint 9 §8): akun dept_user FB satu-satunya
-- diperlukan agar RBAC tulis /driver/cover (admin + dept_user FB) punya akun uji non-admin —
-- sebelum WP-9D belum ada user FB sama sekali di seed manapun. Password sama (Sanggra#2026).
-- sm_user (id 7) ditambahkan WP-11B (ADR-014): akun dept_user SM (Sales & Marketing)
-- satu-satunya — sebelum WP-11B belum ada akun S&M sama sekali di seed manapun. Diperlukan
-- agar S&M punya akses tulis Statistik Kamar/Rate ADR Target/Room Revenue (config_json
-- ROOMREV_OWNER.write_depts, seed 180_roomrev_owner.sql). Password sama (Sanggra#2026).

INSERT INTO app_user (id, username, password_hash, display_name, role, is_active) VALUES
(1, 'admin', '$2y$10$odcpOHGKOwWqYr85OklRuuoUWC1Yb9uqQCWc9f1GkEOMv/Tx8ZLdm', 'Administrator', 'admin', 1),
(2, 'gm_viewer', '$2y$10$lHLpcXj8ctBCFvNxtSCBTuZXCDpgwD.KzG87gVPLcL1E44p8KGWdO', 'GM Viewer', 'viewer', 1),
(3, 'fo_user', '$2y$10$lHLpcXj8ctBCFvNxtSCBTuZXCDpgwD.KzG87gVPLcL1E44p8KGWdO', 'Front Office User', 'dept_user', 1),
(4, 'hk_user', '$2y$10$lHLpcXj8ctBCFvNxtSCBTuZXCDpgwD.KzG87gVPLcL1E44p8KGWdO', 'Housekeeping User', 'dept_user', 1),
(5, 'hc_user', '$2y$10$lHLpcXj8ctBCFvNxtSCBTuZXCDpgwD.KzG87gVPLcL1E44p8KGWdO', 'Human Capital User', 'hc_user', 1),
(6, 'fb_user', '$2y$10$lHLpcXj8ctBCFvNxtSCBTuZXCDpgwD.KzG87gVPLcL1E44p8KGWdO', 'Food & Beverage User', 'dept_user', 1),
(7, 'sm_user', '$2y$10$lHLpcXj8ctBCFvNxtSCBTuZXCDpgwD.KzG87gVPLcL1E44p8KGWdO', 'Sales & Marketing User', 'dept_user', 1)
ON DUPLICATE KEY UPDATE
    password_hash = VALUES(password_hash),
    display_name = VALUES(display_name),
    role = VALUES(role),
    is_active = VALUES(is_active);

-- Penugasan departemen: fo_user->FO(1), hk_user->HK(2), hc_user->HC(8), fb_user->FB(3),
-- sm_user->SM(9)
INSERT INTO user_department (id, user_id, department_id, can_edit) VALUES
(1, 3, 1, 1),
(2, 4, 2, 1),
(3, 5, 8, 1),
(4, 6, 3, 1),
(5, 7, 9, 1)
ON DUPLICATE KEY UPDATE can_edit = VALUES(can_edit);
