-- Insert demo users
-- Passwords:
--   demo123: d3ad9315b7be5dd53b31a273b3b3aba5defe700808305aa16a3062b76658a791
--   tootmine: a1026b7bd143f7190248bc79901e9a357a408e208f2d8e4d38fccf184754f35f
-- Users:
--   kasutaja (tootmine): regular user - can edit problems only
--   aknaproff (demo123): admin - full access
--   admin (demo123): super admin - full access (same as admin)
INSERT OR IGNORE INTO users (username, password_hash, full_name, role) VALUES 
  ('kasutaja', 'a1026b7bd143f7190248bc79901e9a357a408e208f2d8e4d38fccf184754f35f', 'Kasutaja', 'user'),
  ('aknaproff', 'd3ad9315b7be5dd53b31a273b3b3aba5defe700808305aa16a3062b76658a791', 'AKNAPROFF', 'admin'),
  ('admin', 'd3ad9315b7be5dd53b31a273b3b3aba5defe700808305aa16a3062b76658a791', 'Administrator', 'admin');

-- Insert test production records for January 2025
INSERT OR IGNORE INTO production_records (id, month, year, client_name, offer_number, work_number, quantity, price, installer) VALUES 
  (1, 1, 2025, 'AS Okna Service', 'P-2025-001', 'T-2025-001', 12, 2500.00, 'Jüri Tamm'),
  (2, 1, 2025, 'OÜ Aken ja Uks', 'P-2025-002', 'T-2025-002', 8, 1800.00, 'Mari Lepik'),
  (3, 1, 2025, 'Kodutehnika OÜ', 'P-2025-003', 'T-2025-003', 15, 3200.00, 'Peeter Kask'),
  (4, 1, 2025, 'Ehitus ja Remont AS', 'P-2025-004', 'T-2025-004', 6, 1200.00, 'Jüri Tamm'),
  (5, 1, 2025, 'Akende Maailm OÜ', 'P-2025-005', 'T-2025-005', 20, 4500.00, 'Mari Lepik');

-- Insert test production records for December 2024
INSERT OR IGNORE INTO production_records (id, month, year, client_name, offer_number, work_number, quantity, price, installer) VALUES 
  (6, 12, 2024, 'Vana Klient OÜ', 'P-2024-099', 'T-2024-099', 10, 2200.00, 'Peeter Kask'),
  (7, 12, 2024, 'Teine Ettevõte AS', 'P-2024-100', 'T-2024-100', 5, 1000.00, 'Mari Lepik');

-- Insert status checkboxes for the test records
INSERT OR IGNORE INTO status_checkboxes (
  record_id, material_date, material2_date, package_date, worksheets_date, worksheets_confirmed,
  cutting_date, glazing_date, ready_date, issued_date
) VALUES 
  -- Record 1: All stages completed
  (1, '2025-01-08', '2025-11-11', '2025-01-09', '2025-11-26', 1, '2025-01-10', '2025-01-12', '2025-01-14', '2025-01-15'),
  
  -- Record 2: Partial completion with worksheets error
  (2, '2025-01-07', NULL, '2025-01-07', NULL, 0, '2025-01-08', '2025-01-10', NULL, NULL),
  
  -- Record 3: Early stage with material confirmed
  (3, '2025-01-05', '2025-01-06', NULL, NULL, 0, NULL, NULL, NULL, NULL),
  
  -- Record 4: Mid stage
  (4, '2025-01-06', '2025-01-07', '2025-01-08', '2025-01-09', 1, '2025-01-10', NULL, NULL, NULL),
  
  -- Record 5: Just started
  (5, '2025-01-07', NULL, NULL, NULL, 0, NULL, NULL, NULL, NULL),
  
  -- Record 6: December - completed
  (6, '2024-12-10', '2024-12-11', '2024-12-12', '2024-12-13', 1, '2024-12-14', '2024-12-15', '2024-12-16', '2024-12-17'),
  
  -- Record 7: December - partial
  (7, '2024-12-08', NULL, '2024-12-09', NULL, 0, '2024-12-10', NULL, NULL, NULL);

-- Update record 2 to have worksheets error flag set
UPDATE status_checkboxes SET worksheets_error = 1 WHERE record_id = 2;

-- Update record 2 to have glazing error flag set
UPDATE status_checkboxes SET glazing_error = 1 WHERE record_id = 2;
