-- Minimal local-dev fixture data: one login per role, plus enough
-- group/schedule/lesson/payment data to click through each role's dashboard.
-- All accounts share the password "password123".


-- ── Dictionaries ──────────────────────────────────────────────────────────────

INSERT INTO classes (id, name) VALUES (1, '10'), (2, '11');
INSERT INTO languages (id, name) VALUES (1, 'Русский');
INSERT INTO learning_types (id, name, abbreviation) VALUES (1, 'Отдел А', 'А');
INSERT INTO disciplines (id, name, abbreviation) VALUES (1, 'Математика', 'МАТ');
INSERT INTO student_statuses (id, name, color, sort_order) VALUES
    (1, 'Обучается', 'success', 1),
    (2, 'Не учится', 'secondary', 2);
INSERT INTO classrooms (id, name) VALUES (1, 'Кабинет 1');
INSERT INTO payment_statuses (id, name, color) VALUES (1, 'Оплачено', 'success');

-- ── Accounts (password for all: password123) ─────────────────────────────────

INSERT INTO users (id, name, email, password, role) VALUES
    (1, 'Админ Админов',     'admin@axioma-study.kz',                     '$2y$12$mZXfRHJ3A.M8NRWem1FdgevjUR9cuftiw85DKKQyAbYqqir6S4MZi', 'admin'),
    (2, 'Айгуль Тестова',    'teacher@axioma-study.kz',                   '$2y$12$mZXfRHJ3A.M8NRWem1FdgevjUR9cuftiw85DKKQyAbYqqir6S4MZi', 'teacher'),
    (3, 'Куратор Тестов',    'adviser@axioma-study.kz',                   '$2y$12$mZXfRHJ3A.M8NRWem1FdgevjUR9cuftiw85DKKQyAbYqqir6S4MZi', 'adviser'),
    (4, 'Менеджер Тестов',   'manager@axioma-study.kz',                   '$2y$12$mZXfRHJ3A.M8NRWem1FdgevjUR9cuftiw85DKKQyAbYqqir6S4MZi', 'manager'),
    (5, 'Родитель Тестов',   'parent@axioma-study.kz',                    '$2y$12$mZXfRHJ3A.M8NRWem1FdgevjUR9cuftiw85DKKQyAbYqqir6S4MZi', 'parent'),
    (6, 'Студент Тестов',    'student.testov@students.axioma-study.kz',   '$2y$12$mZXfRHJ3A.M8NRWem1FdgevjUR9cuftiw85DKKQyAbYqqir6S4MZi', 'student');

INSERT INTO teachers (user_id, price_value) VALUES (2, 2000.00);

-- ── Student, linked to the parent/adviser/manager/student-login users above ──

INSERT INTO students (
    id, first_name, last_name, gender, phone,
    learning_type_id, class_id, language_id, status_id,
    user_id, parent_id, manager_user_id, adviser_id
) VALUES (
    1, 'Студент', 'Тестов', 1, '+77001234567',
    1, 1, 1, 1,
    6, 5, 4, 3
);

-- ── Gamification (hero levels must exist before a hero row references one) ──

INSERT INTO hero_levels (level_number, name, xp_required, coin_reward) VALUES
    (1, 'Новичок', 0, 0),
    (2, 'Ученик', 50, 10);

INSERT INTO heroes (
    student_id, level_number, xp_total, coins_balance, active_since,
    total_lessons, total_attendance_days, attendance_streak, dz_streak
) VALUES (1, 1, 10, 5, CURDATE(), 1, 1, 1, 1);

-- ── Group, schedule, tariff ───────────────────────────────────────────────────

INSERT INTO study_groups (id, teacher_id, type, group_name, discipline_id, language_id, learning_type_id, class_id, is_active)
VALUES (1, 2, 'Group', 'Математика-101', 1, 1, 1, 1, 1);

-- weekdays bitmask: Mon(1) + Wed(4) + Fri(16) = 21 — see App\Models\Group's dowMap
INSERT INTO schedule_items (id, group_id, begin_date, end_date, weekdays, begin_time, end_time, classroom_id)
VALUES (1, 1, '2026-01-01', NULL, 21, '10:00:00', '11:00:00', 1);

INSERT INTO student_groups (id, student_id, group_id, joined_at, end_date, weekdays, is_active)
VALUES (1, 1, 1, '2026-01-01', NULL, 21, 1);

INSERT INTO tariffs (id, name, category, price, lessons_count, duration_days)
VALUES (1, 'Стандарт 8 уроков', 'group', 32000.00, 8, 30);

INSERT INTO group_tariffs (id, group_id, tariff_id, start_date, end_date)
VALUES (1, 1, 1, '2026-01-01', '2026-12-31');

INSERT INTO student_tariffs (id, student_id, group_id, tariff_id, start_date, end_date, lessons_remaining)
VALUES (1, 1, 1, 1, '2026-01-01', '2026-12-31', 8);

-- ── One held lesson + attendance ──────────────────────────────────────────────

INSERT INTO lessons (id, ed_unit_id, teacher_id, lesson_date, begin_time, end_time, students_present, all_students, payment)
VALUES (1, 1, 2, CURDATE(), '10:00:00', '11:00:00', 1, 1, 1);

INSERT INTO student_lessons (id, lesson_id, student_id, present, status, kr_score, dz_score, dz_not_assigned, lateness)
VALUES (1, 1, 1, 1, 'attended', 8, 7, 0, 'Пришел во время');

-- ── Billing ───────────────────────────────────────────────────────────────────

INSERT INTO payments (id, student_id, amount, description, payment_date, status_id)
VALUES (1, 1, 32000.00, 'Оплата за январь', CURDATE(), 1);

INSERT INTO charges (id, student_id, group_id, tariff_id, amount, charged_date)
VALUES (1, 1, 1, 1, 4000.00, CURDATE());
