-- ============================================================
-- Restaurant Time Clock - Seed Data
-- Run AFTER schema.sql
-- ============================================================

-- Default admin:  admin@restaurant.local / Admin1234!
-- Employees PIN:  1001 / 1002 / 1003


-- Admin user  (password: Admin1234!)
INSERT INTO `users` (`name`, `email`, `password_hash`, `role`) VALUES
('Admin User',   'admin@restaurant.local',   '$2y$12$XKJBHfRzfcH4.4ySSSLOAe9Qkd0tq8vCkD/Ja7gH2WrXfmCo9OQHC', 'admin'),
('Jane Manager', 'manager@restaurant.local', '$2y$12$XKJBHfRzfcH4.4ySSSLOAe9Qkd0tq8vCkD/Ja7gH2WrXfmCo9OQHC', 'manager');
-- Both passwords hash to "Admin1234!" — change immediately after install

-- Location
INSERT INTO `locations` (`name`, `address`) VALUES
('Main Street Grill', '123 Main St, Springfield, IL 62701');

-- Employees (PINs hashed with password_hash)
-- PIN 1001 → employee Maria
-- PIN 1002 → employee Carlos
-- PIN 1003 → employee Sam
INSERT INTO `employees` (`location_id`, `first_name`, `last_name`, `email`, `position`, `hourly_rate`, `pin_hash`) VALUES
(1, 'Maria',  'Garcia',   'maria@example.com',  'Server',       14.50, '$2y$12$tIDlm8bwcSwi4SvZByFTdeyvHy/YPD/pvQXRbfioS6cBh3FKgWp9K'),
(1, 'Carlos', 'Reyes',    'carlos@example.com', 'Line Cook',    16.00, '$2y$12$pqRnGz0T1.hNc6PX/5FWXuV0qpQyJ8dOMR3vFHkNaGelLOXJOcNfG'),
(1, 'Sam',    'Johnson',  'sam@example.com',    'Host',         13.25, '$2y$12$nDQ7bUG3dVIR.r0VWGBNIeAL5Q9zO2TnB8lDo1yswCq9YG0IhTqkC');
-- PIN 1001 hash for Maria, 1002 for Carlos, 1003 for Sam

-- QR Stations
INSERT INTO `qr_stations` (`location_id`, `name`, `token`) VALUES
(1, 'Front Entrance Kiosk', 'station_front_a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1d2e3f4a5b6c7d8'),
(1, 'Back-of-House Station', 'station_back_z9y8x7w6v5u4t3s2r1q0p9o8n7m6l5k4j3i2h1g0f9e8d7c6b5a4');

-- Sample punches for yesterday (replace date dynamically if needed)
-- We use a stored procedure to make dates relative
SET @yesterday = DATE_SUB(CURDATE(), INTERVAL 1 DAY);
SET @two_days  = DATE_SUB(CURDATE(), INTERVAL 2 DAY);

INSERT INTO `punches` (`employee_id`, `station_id`, `punch_type`, `punched_at`) VALUES
-- Maria yesterday: full shift
(1, 1, 'clock_in',    CONCAT(@yesterday, ' 09:00:00')),
(1, 1, 'break_start', CONCAT(@yesterday, ' 12:00:00')),
(1, 1, 'break_end',   CONCAT(@yesterday, ' 12:30:00')),
(1, 1, 'clock_out',   CONCAT(@yesterday, ' 17:00:00')),
-- Carlos yesterday
(2, 2, 'clock_in',    CONCAT(@yesterday, ' 10:00:00')),
(2, 2, 'break_start', CONCAT(@yesterday, ' 13:00:00')),
(2, 2, 'break_end',   CONCAT(@yesterday, ' 13:20:00')),
(2, 2, 'clock_out',   CONCAT(@yesterday, ' 18:30:00')),
-- Sam yesterday
(3, 1, 'clock_in',    CONCAT(@yesterday, ' 11:00:00')),
(3, 1, 'clock_out',   CONCAT(@yesterday, ' 15:00:00')),
-- Maria two days ago
(1, 1, 'clock_in',    CONCAT(@two_days, ' 08:45:00')),
(1, 1, 'break_start', CONCAT(@two_days, ' 12:15:00')),
(1, 1, 'break_end',   CONCAT(@two_days, ' 12:45:00')),
(1, 1, 'clock_out',   CONCAT(@two_days, ' 16:45:00'));

-- Sample audit log entry
INSERT INTO `audit_logs` (`user_id`, `action`, `entity`, `entity_id`, `ip_address`) VALUES
(1, 'seed_data_loaded', 'system', NULL, '127.0.0.1');
