-- ═══════════════════════════════════════════════════
-- QAFYS — 005 Seed Data
-- Default admin account + school configuration
-- ═══════════════════════════════════════════════════
-- NOTE: The password hash below is for 'admin123' using bcrypt (12 rounds).
-- In production, change this immediately after first login.
-- Generate a new hash: node -e "require('bcryptjs').hash('YOUR_NEW_PASSWORD', 12).then(h => console.log(h))"

-- ────────────────────────────────────────
-- Default Super Admin Account
-- ────────────────────────────────────────
INSERT INTO `users` (`id`, `username`, `password_hash`, `role`, `first_name`, `last_name`, `gender`, `status`)
VALUES (
  'SA-2024-0001',
  'admin',
  '$2a$12$goYnexMZe7RNZk0kX21qVOO/pmnlktDHL.nva94RRKKt.e4hIUmDO',
  'superadmin',
  'System',
  'Admin',
  '—',
  'active'
) ON DUPLICATE KEY UPDATE `password_hash` = VALUES(`password_hash`);

INSERT INTO `staff_details` (`user_id`, `qafys_email`, `employment`, `salary_type`, `payment_method`)
VALUES (
  'SA-2024-0001',
  'admin@qafys.edu',
  'full',
  'monthly',
  'direct'
) ON DUPLICATE KEY UPDATE `user_id` = `user_id`;


-- ────────────────────────────────────────
-- School Year Configuration
-- ────────────────────────────────────────
INSERT INTO `school_config` (`config_key`, `config_value`) VALUES
  ('school_year',             '2024–2025'),
  ('year_start',              '2024-09-03'),
  ('year_end',                '2025-06-20'),
  ('student_on_time_before',  '08:00'),
  ('student_day_over',        '15:30'),
  ('ft_clock_in',             '07:30'),
  ('ft_late_after',           '07:45'),
  ('ft_clock_out',            '15:30'),
  ('quarters',                '[{"q":"Q1","start":"2024-09-03","end":"2024-11-08"},{"q":"Q2","start":"2024-11-12","end":"2025-01-24"},{"q":"Q3","start":"2025-01-27","end":"2025-04-04"},{"q":"Q4","start":"2025-04-07","end":"2025-06-20"}]')
ON DUPLICATE KEY UPDATE `config_value` = VALUES(`config_value`);
