-- Roller Central v1.1 Seed Data
-- Creates Admin User, District, Branch 29, and Default Rooms

-- Ensure district & branch exist
INSERT IGNORE INTO districts (district_id, district_name)
VALUES (1, 'North Arkansas');

INSERT IGNORE INTO branches (
    branch_id, district_id, branch_name, branch_number, phone, fax, email,
    physical_address1, physical_city, physical_state, physical_postal,
    has_prep_room, has_refrigeration, arrangement_rooms, chapels, state_rooms, selection_room
) VALUES (
    29, 1, 'Roller-Christeson Funeral Home', 29,
    '(870) 741-3113', '(870) 741-3115', 'info@rollerfuneralhomes.com',
    '519 N. Spring St', 'Harrison', 'Arkansas', '72601',
    1, 1, 2, 1, 3, 1
);

-- State rooms / parlors
INSERT IGNORE INTO branch_rooms (branch_id, room_name, room_type, display_order)
VALUES
(29, 'Lilac Room', 'stateroom', 1),
(29, 'White Room', 'stateroom', 2),
(29, 'Blue Room', 'stateroom', 3),
(29, 'Chapel', 'chapel', 4),
(29, 'Prep Room', 'prep', 5),
(29, 'Refrigeration', 'refrigeration', 6);

-- Default admin login
-- password = ChangeMe123
INSERT IGNORE INTO admin_users (username, password_hash, role, active, branch_id, district_id, email)
VALUES (
    'admin',
    '$2y$10$K/HwG7zT8GBpR3Q.Nq5b3uxN5iBdGW3cQJZlMLUax4gT8QL/epTnC', -- bcrypt hash of ChangeMe123
    'admin',
    1,
    29,
    1,
    'admin@rollerfuneralhomes.com'
);

-- Admin has management access to branch 29
INSERT IGNORE INTO user_branch_access (user_id, branch_id, access_level)
SELECT user_id, 29, 'manage' FROM admin_users WHERE username='admin';

-- Verify
SELECT * FROM branches WHERE branch_id=29;
SELECT * FROM admin_users WHERE username='admin';
SELECT * FROM branch_rooms WHERE branch_id=29;
