-- ============================================================
-- ADTN MANAGEMENT SYSTEM - SEED DATA
-- Run AFTER schema.sql
-- ============================================================

-- ============================================================
-- 1. ROLES
-- ============================================================
INSERT INTO roles (role_name, role_slug, description) VALUES
('Super Admin', 'super_admin', 'Full system access - can manage everything'),
('National Admin', 'national_admin', 'Manages national-level operations'),
('State Admin', 'state_admin', 'Manages state chapter operations'),
('Secretary', 'secretary', 'Manages correspondence and records'),
('Treasurer', 'treasurer', 'Manages financial records and payments'),
('Editor', 'editor', 'Manages news, events, and content'),
('Member Manager', 'member_manager', 'Manages member registrations and approvals'),
('Gallery Manager', 'gallery_manager', 'Manages photo gallery and media'),
('News Manager', 'news_manager', 'Manages news articles and categories'),
('Viewer', 'viewer', 'Read-only access to reports and data');

-- ============================================================
-- 2. PERMISSIONS
-- ============================================================
INSERT INTO permissions (permission_name, permission_slug, module, description) VALUES
-- Dashboard
('View Dashboard', 'view_dashboard', 'dashboard', 'Access admin dashboard'),

-- Members
('View Members', 'view_members', 'members', 'View member list'),
('Create Member', 'create_member', 'members', 'Add new member'),
('Edit Member', 'edit_member', 'members', 'Edit member details'),
('Delete Member', 'delete_member', 'members', 'Delete member'),
('Approve Member', 'approve_member', 'members', 'Approve pending members'),
('Suspend Member', 'suspend_member', 'members', 'Suspend member account'),
('Export Members', 'export_members', 'members', 'Export member data'),

-- Executives
('View Executives', 'view_executives', 'executives', 'View executives list'),
('Create Executive', 'create_executive', 'executives', 'Add new executive'),
('Edit Executive', 'edit_executive', 'executives', 'Edit executive details'),
('Delete Executive', 'delete_executive', 'executives', 'Delete executive'),

-- News
('View News', 'view_news', 'news', 'View news articles'),
('Create News', 'create_news', 'news', 'Create news article'),
('Edit News', 'edit_news', 'news', 'Edit news article'),
('Delete News', 'delete_news', 'news', 'Delete news article'),
('Publish News', 'publish_news', 'news', 'Publish/unpublish news'),

-- Events
('View Events', 'view_events', 'events', 'View events'),
('Create Event', 'create_event', 'events', 'Create event'),
('Edit Event', 'edit_event', 'events', 'Edit event'),
('Delete Event', 'delete_event', 'events', 'Delete event'),

-- Gallery
('View Gallery', 'view_gallery', 'gallery', 'View gallery'),
('Upload Image', 'upload_image', 'gallery', 'Upload gallery images'),
('Delete Image', 'delete_image', 'gallery', 'Delete gallery images'),
('Manage Categories', 'manage_gallery_categories', 'gallery', 'Manage gallery categories'),

-- Downloads
('View Downloads', 'view_downloads', 'downloads', 'View documents'),
('Upload Document', 'upload_document', 'downloads', 'Upload documents'),
('Delete Document', 'delete_document', 'downloads', 'Delete documents'),

-- States
('View States', 'view_states', 'states', 'View state chapters'),
('Edit State', 'edit_state', 'states', 'Edit state chapter'),

-- Messages
('View Messages', 'view_messages', 'messages', 'View contact messages'),
('Reply Message', 'reply_message', 'messages', 'Reply to messages'),
('Delete Message', 'delete_message', 'messages', 'Delete messages'),

-- Reports
('View Reports', 'view_reports', 'reports', 'View system reports'),
('Export Reports', 'export_reports', 'reports', 'Export reports'),

-- Settings
('View Settings', 'view_settings', 'settings', 'View system settings'),
('Edit Settings', 'edit_settings', 'settings', 'Edit system settings'),

-- Users
('View Users', 'view_users', 'users', 'View admin users'),
('Create User', 'create_user', 'users', 'Create admin user'),
('Edit User', 'edit_user', 'users', 'Edit admin user'),
('Delete User', 'delete_user', 'users', 'Delete admin user'),
('Manage Roles', 'manage_roles', 'users', 'Manage roles and permissions');

-- ============================================================
-- 3. ROLE-PERMISSION MAPPING
-- ============================================================
-- Super Admin gets ALL permissions
INSERT INTO user_permissions (role_id, permission_id)
SELECT 1, id FROM permissions;

-- National Admin gets most permissions except user management
INSERT INTO user_permissions (role_id, permission_id)
SELECT 2, id FROM permissions 
WHERE permission_slug NOT IN ('manage_roles', 'delete_user');

-- State Admin gets state-level permissions
INSERT INTO user_permissions (role_id, permission_id)
SELECT 3, id FROM permissions 
WHERE module IN ('members', 'events', 'news', 'gallery', 'messages', 'reports') 
AND permission_slug NOT LIKE 'delete_%';

-- Secretary gets members and messages
INSERT INTO user_permissions (role_id, permission_id)
SELECT 4, id FROM permissions 
WHERE module IN ('members', 'messages', 'reports') 
AND permission_slug NOT LIKE 'delete_%';

-- Treasurer gets members and reports
INSERT INTO user_permissions (role_id, permission_id)
SELECT 5, id FROM permissions 
WHERE module IN ('members', 'reports', 'downloads');

-- Editor gets news, events, gallery
INSERT INTO user_permissions (role_id, permission_id)
SELECT 6, id FROM permissions 
WHERE module IN ('news', 'events', 'gallery');

-- Member Manager
INSERT INTO user_permissions (role_id, permission_id)
SELECT 7, id FROM permissions 
WHERE module = 'members';

-- Gallery Manager
INSERT INTO user_permissions (role_id, permission_id)
SELECT 8, id FROM permissions 
WHERE module = 'gallery';

-- News Manager
INSERT INTO user_permissions (role_id, permission_id)
SELECT 9, id FROM permissions 
WHERE module = 'news';

-- Viewer gets view-only
INSERT INTO user_permissions (role_id, permission_id)
SELECT 10, id FROM permissions 
WHERE permission_slug LIKE 'view_%';

-- ============================================================
-- 4. DEFAULT SUPER ADMIN USER
-- Password: Admin@ADTN2024! (bcrypt hash)
-- ============================================================
INSERT INTO users (username, email, password_hash, first_name, last_name, phone, role_id, is_active, email_verified_at) VALUES
('superadmin', 'admin@adtn.ng', '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', 'Super', 'Administrator', '+2348012345678', 1, 1, NOW());

-- ============================================================
-- 5. NIGERIAN STATES (36 + FCT)
-- ============================================================
INSERT INTO states (state_name, state_code, capital, region) VALUES
('Abia', 'AB', 'Umuahia', 'South-East'),
('Adamawa', 'AD', 'Yola', 'North-East'),
('Akwa Ibom', 'AK', 'Uyo', 'South-South'),
('Anambra', 'AN', 'Awka', 'South-East'),
('Bauchi', 'BA', 'Bauchi', 'North-East'),
('Bayelsa', 'BY', 'Yenagoa', 'South-South'),
('Benue', 'BE', 'Makurdi', 'North-Central'),
('Borno', 'BO', 'Maiduguri', 'North-East'),
('Cross River', 'CR', 'Calabar', 'South-South'),
('Delta', 'DE', 'Asaba', 'South-South'),
('Ebonyi', 'EB', 'Abakaliki', 'South-East'),
('Edo', 'ED', 'Benin City', 'South-South'),
('Ekiti', 'EK', 'Ado-Ekiti', 'South-West'),
('Enugu', 'EN', 'Enugu', 'South-East'),
('Gombe', 'GO', 'Gombe', 'North-East'),
('Imo', 'IM', 'Owerri', 'South-East'),
('Jigawa', 'JI', 'Dutse', 'North-West'),
('Kaduna', 'KD', 'Kaduna', 'North-West'),
('Kano', 'KN', 'Kano', 'North-West'),
('Katsina', 'KT', 'Katsina', 'North-West'),
('Kebbi', 'KE', 'Birnin Kebbi', 'North-West'),
('Kogi', 'KO', 'Lokoja', 'North-Central'),
('Kwara', 'KW', 'Ilorin', 'North-Central'),
('Lagos', 'LA', 'Ikeja', 'South-West'),
('Nasarawa', 'NA', 'Lafia', 'North-Central'),
('Niger', 'NI', 'Minna', 'North-Central'),
('Ogun', 'OG', 'Abeokuta', 'South-West'),
('Ondo', 'ON', 'Akure', 'South-West'),
('Osun', 'OS', 'Oshogbo', 'South-West'),
('Oyo', 'OY', 'Ibadan', 'South-West'),
('Plateau', 'PL', 'Jos', 'North-Central'),
('Rivers', 'RI', 'Port Harcourt', 'South-South'),
('Sokoto', 'SO', 'Sokoto', 'North-West'),
('Taraba', 'TA', 'Jalingo', 'North-East'),
('Yobe', 'YO', 'Damaturu', 'North-East'),
('Zamfara', 'ZA', 'Gusau', 'North-West'),
('Federal Capital Territory', 'FCT', 'Abuja', 'North-Central');

-- ============================================================
-- 6. NEWS CATEGORIES
-- ============================================================
INSERT INTO news_categories (category_name, category_slug, description) VALUES
('Announcements', 'announcements', 'Official association announcements'),
('Conferences', 'conferences', 'National and state conference updates'),
('Workshops', 'workshops', 'Training and workshop information'),
('Awards', 'awards', 'Awards and recognitions'),
('Policy', 'policy', 'Government policy updates affecting dental technology'),
('Research', 'research', 'Research and innovation in dental technology'),
('Industry News', 'industry-news', 'Industry-related news and updates');

-- ============================================================
-- 7. GALLERY CATEGORIES
-- ============================================================
INSERT INTO gallery_categories (category_name, category_slug, description, display_order) VALUES
('National Conference', 'national-conference', 'Photos from national conferences', 1),
('Workshops', 'workshops', 'Training workshop photos', 2),
('AGM', 'agm', 'Annual General Meeting photos', 3),
('Induction', 'induction', 'New member induction ceremonies', 4),
('Meetings', 'meetings', 'Executive and general meetings', 5),
('Training', 'training', 'Professional training sessions', 6),
('State Events', 'state-events', 'State chapter events', 7),
('Community Outreach', 'community-outreach', 'Community service activities', 8);

-- ============================================================
-- 8. STATISTICS
-- ============================================================
INSERT INTO statistics (stat_name, stat_value, stat_icon, display_order) VALUES
('Registered Members', 0, 'fa-users', 1),
('State Chapters', 37, 'fa-map-marker-alt', 2),
('Local Branches', 0, 'fa-building', 3),
('National Executives', 0, 'fa-user-tie', 4),
('Annual Conferences', 0, 'fa-calendar-check', 5),
('Years of Existence', 0, 'fa-award', 6);

-- ============================================================
-- 9. SETTINGS
-- ============================================================
INSERT INTO settings (setting_key, setting_value, setting_group, is_public) VALUES
-- General
('site_name', 'Association of Dental Technologists of Nigeria', 'general', 1),
('site_tagline', 'Professional Excellence in Dental Technology', 'general', 1),
('site_description', 'The official website of the Association of Dental Technologists of Nigeria (ADTN)', 'general', 1),
('site_url', 'https://adtn.ng', 'general', 1),
('site_logo', 'assets/images/logo.png', 'general', 1),
('site_favicon', 'assets/images/favicon.ico', 'general', 1),
('site_language', 'en', 'general', 1),
('site_timezone', 'Africa/Lagos', 'general', 1),
('site_currency', 'NGN', 'general', 1),

-- Contact
('contact_email', 'info@adtn.ng', 'contact', 1),
('contact_phone', '+234-803-000-0000', 'contact', 1),
('contact_address', 'National Secretariat, Abuja, Nigeria', 'contact', 1),
('contact_whatsapp', '+234-803-000-0000', 'contact', 1),

-- Social
('social_facebook', 'https://facebook.com/adtnigeria', 'social', 1),
('social_twitter', 'https://twitter.com/adtnigeria', 'social', 1),
('social_linkedin', 'https://linkedin.com/company/adtnigeria', 'social', 1),
('social_instagram', 'https://instagram.com/adtnigeria', 'social', 1),
('social_youtube', 'https://youtube.com/adtnigeria', 'social', 1),

-- SMTP
('smtp_host', 'smtp.gmail.com', 'smtp', 0),
('smtp_port', '587', 'smtp', 0),
('smtp_username', '', 'smtp', 0),
('smtp_password', '', 'smtp', 0),
('smtp_encryption', 'tls', 'smtp', 0),
('smtp_from_email', 'noreply@adtn.ng', 'smtp', 0),
('smtp_from_name', 'ADTN Nigeria', 'smtp', 0),

-- SEO
('seo_meta_title', 'ADTN - Association of Dental Technologists of Nigeria', 'seo', 1),
('seo_meta_description', 'Professional association for dental technologists in Nigeria. Register, renew membership, and access resources.', 'seo', 1),
('seo_meta_keywords', 'dental technology, dental technologist, Nigeria, ADTN, dental lab, prosthodontics', 'seo', 1),
('seo_google_analytics', '', 'seo', 0),

-- Membership
('membership_registration_fee', '5000.00', 'membership', 0),
('membership_annual_dues', '10000.00', 'membership', 0),
('membership_renewal_period', '30', 'membership', 0),
('membership_grace_period', '90', 'membership', 0),

-- Security
('max_login_attempts', '5', 'security', 0),
('lockout_duration', '30', 'security', 0),
('session_timeout', '60', 'security', 0),
('password_min_length', '8', 'security', 0),
('maintenance_mode', '0', 'security', 0);

-- ============================================================
-- 10. SAMPLE NATIONAL EXECUTIVES
-- ============================================================
INSERT INTO executives (name, position, title, level, photo, biography, email, phone, tenure_start, is_current, display_order) VALUES
('Dr. John Doe', 'National President', 'Dr.', 'national', 'uploads/executives/president.jpg', 'Dr. John Doe is a renowned dental technologist with over 25 years of experience...', 'president@adtn.ng', '+2348011111111', '2024-01-01', 1, 1),
('Prof. Jane Smith', 'National Vice President', 'Prof.', 'national', 'uploads/executives/vp.jpg', 'Prof. Jane Smith brings extensive academic and professional experience...', 'vp@adtn.ng', '+2348022222222', '2024-01-01', 1, 2),
('Mr. Michael Brown', 'National Secretary', 'Mr.', 'national', 'uploads/executives/secretary.jpg', 'Mr. Michael Brown oversees the administrative functions of the association...', 'secretary@adtn.ng', '+2348033333333', '2024-01-01', 1, 3),
('Mrs. Sarah Johnson', 'National Treasurer', 'Mrs.', 'national', 'uploads/executives/treasurer.jpg', 'Mrs. Sarah Johnson manages the financial operations of ADTN...', 'treasurer@adtn.ng', '+2348044444444', '2024-01-01', 1, 4),
('Dr. Peter Wilson', 'National Publicity Secretary', 'Dr.', 'national', 'uploads/executives/publicity.jpg', 'Dr. Peter Wilson handles media relations and public communications...', 'publicity@adtn.ng', '+2348055555555', '2024-01-01', 1, 5);

-- ============================================================
-- 11. SAMPLE NEWS ARTICLES
-- ============================================================
INSERT INTO news (title, slug, content, excerpt, category_id, author_id, is_published, is_featured, published_at, meta_title, meta_description) VALUES
('ADTN Announces 2025 National Conference', 'adtn-announces-2025-national-conference', 
'<p>The Association of Dental Technologists of Nigeria is pleased to announce its 2025 National Conference scheduled to hold in Lagos...</p><p>The conference will feature keynote addresses from international experts, workshops, and exhibitions.</p>', 
'ADTN sets dates for the 2025 National Conference in Lagos with international speakers and workshops.', 
2, 1, 1, 1, NOW(), 'ADTN 2025 National Conference - ADTN Nigeria', 'Join us for the 2025 National Conference of the Association of Dental Technologists of Nigeria'),

('New Membership Registration Portal Launched', 'new-membership-registration-portal-launched',
'<p>We are excited to announce the launch of our new online membership registration portal...</p><p>Members can now register, renew, and access resources from anywhere in the world.</p>',
'ADTN launches new digital platform for membership registration and management.',
1, 1, 1, 1, NOW(), 'New Membership Portal - ADTN Nigeria', 'Register online for ADTN membership through our new digital portal'),

('Dental Technology Standards Updated', 'dental-technology-standards-updated',
'<p>The Medical and Dental Council of Nigeria has released updated standards for dental technology practice...</p><p>All members are advised to review the new guidelines.</p>',
'New practice standards released by MDCN for dental technologists in Nigeria.',
5, 1, 1, 0, NOW(), 'Updated Dental Technology Standards - ADTN', 'MDCN releases updated standards for dental technology practice in Nigeria');

-- ============================================================
-- 12. SAMPLE EVENTS
-- ============================================================
INSERT INTO events (title, slug, description, event_type, venue, address, start_date, end_date, organizer, contact_email, contact_phone, is_published, is_featured, created_by) VALUES
('2025 ADTN National Conference', '2025-adtn-national-conference',
'<p>The annual national conference bringing together dental technologists from all 36 states and FCT.</p><p>Theme: "Innovation and Excellence in Dental Technology"</p>',
'conference', 'Eko Hotel & Suites', '1415 Adetokunbo Ademola Street, Victoria Island, Lagos',
'2025-03-15 09:00:00', '2025-03-17 16:00:00', 'ADTN National Secretariat', 'conference@adtn.ng', '+2348012345678', 1, 1, 1),

('Dental Technology Workshop - Abuja', 'dental-technology-workshop-abuja',
'<p>Hands-on workshop on advanced crown and bridge techniques.</p><p>Limited slots available. Register early!</p>',
'workshop', 'ADTN Training Centre', 'National Secretariat Complex, Abuja',
'2025-02-20 10:00:00', '2025-02-20 16:00:00', 'ADTN Training Committee', 'training@adtn.ng', '+2348098765432', 1, 0, 1),

('Annual General Meeting 2025', 'annual-general-meeting-2025',
'<p>The Annual General Meeting of the Association of Dental Technologists of Nigeria.</p><p>All members are encouraged to attend.</p>',
'agm', 'International Conference Centre', 'Central Business District, Abuja',
'2025-06-30 10:00:00', '2025-06-30 14:00:00', 'ADTN National Executive Council', 'secretary@adtn.ng', '+2348033333333', 1, 1, 1);

-- ============================================================
-- 13. SAMPLE DOCUMENTS
-- ============================================================
INSERT INTO documents (document_name, document_slug, description, file_path, file_type, file_size, is_public, is_active, uploaded_by) VALUES
('ADTN Constitution', 'adtn-constitution', 'The official constitution of the Association of Dental Technologists of Nigeria', 'uploads/documents/ADTN_Constitution.pdf', 'pdf', 2048000, 1, 1, 1),
('Membership Registration Form', 'membership-registration-form', 'Official membership registration form for new members', 'uploads/documents/Registration_Form.pdf', 'pdf', 512000, 1, 1, 1),
('Annual Report 2024', 'annual-report-2024', 'ADTN Annual Report for the year 2024', 'uploads/documents/Annual_Report_2024.pdf', 'pdf', 4096000, 1, 1, 1),
('Code of Ethics', 'code-of-ethics', 'Professional code of ethics for dental technologists', 'uploads/documents/Code_of_Ethics.pdf', 'pdf', 1024000, 1, 1, 1),
('Meeting Minutes Template', 'meeting-minutes-template', 'Standard template for meeting minutes', 'uploads/documents/Minutes_Template.docx', 'docx', 256000, 1, 1, 1);

-- ============================================================
-- 14. SAMPLE PARTNERS
-- ============================================================
INSERT INTO partners (partner_name, logo, website, description, display_order, is_active) VALUES
('Medical and Dental Council of Nigeria', 'uploads/partners/mdcn.png', 'https://mdcn.gov.ng', 'Regulatory body for medical and dental practice in Nigeria', 1, 1),
('Federal Ministry of Health', 'uploads/partners/fmh.png', 'https://health.gov.ng', 'Federal Ministry of Health Nigeria', 2, 1),
('Nigerian Dental Association', 'uploads/partners/nda.png', 'https://nda.org.ng', 'Professional association for dentists in Nigeria', 3, 1),
('WHO Nigeria', 'uploads/partners/who.png', 'https://who.int/nigeria', 'World Health Organization Nigeria Office', 4, 1);

-- ============================================================
-- 15. SAMPLE TESTIMONIALS
-- ============================================================
INSERT INTO testimonials (name, position, company, photo, content, rating, is_active, display_order) VALUES
('Dr. Amina Bello', 'Senior Dental Technologist', 'National Hospital Abuja', 'uploads/testimonials/amina.jpg', 'ADTN has been instrumental in my professional growth. The training programs and networking opportunities are world-class.', 5, 1, 1),
('Mr. Chukwuemeka Okafor', 'Lab Owner', 'Emeka Dental Lab, Lagos', 'Being a member of ADTN has elevated my practice. The standards and ethics promoted by the association are exemplary.', 5, 1, 2),
('Mrs. Fatima Abdullahi', 'State Chairman', 'ADTN Kano State', 'The state chapter support from the national body has been tremendous. Our members now have access to better resources and training.', 5, 1, 3);

-- ============================================================
-- 16. SAMPLE BRANCHES
-- ============================================================
INSERT INTO branches (branch_name, state_id, address, phone, email, chairman, secretary, meeting_day, meeting_time, meeting_venue, is_active) VALUES
('Lagos Main Branch', 24, 'ADTN Secretariat, Ikeja, Lagos', '+2348011110001', 'lagos@adtn.ng', 'Dr. Tunde Bakare', 'Mr. Segun Adeyemi', 'First Saturday', '10:00 AM', 'ADTN Lagos Office', 1),
('Abuja Central Branch', 37, 'National Secretariat, Garki, Abuja', '+2348022220002', 'abuja@adtn.ng', 'Dr. Ngozi Eze', 'Mrs. Blessing Okafor', 'Second Saturday', '11:00 AM', 'National Secretariat Hall', 1),
('Kano North Branch', 19, 'ADTN Office, Sabon Gari, Kano', '+2348033330003', 'kano@adtn.ng', 'Alh. Ibrahim Musa', 'Mr. Yusuf Abdullahi', 'Third Saturday', '10:00 AM', 'Kano State Secretariat', 1);

-- ============================================================
-- 17. ACTIVITY LOGS (Sample)
-- ============================================================
INSERT INTO activity_logs (user_id, user_type, action, module, description, ip_address) VALUES
(1, 'admin', 'login', 'auth', 'Super Admin logged in successfully', '127.0.0.1'),
(1, 'admin', 'create', 'news', 'Created news article: ADTN Announces 2025 National Conference', '127.0.0.1'),
(1, 'admin', 'create', 'events', 'Created event: 2025 ADTN National Conference', '127.0.0.1'),
(1, 'admin', 'create', 'executives', 'Added national executive: Dr. John Doe', '127.0.0.1');
