-- ============================================================
-- SalonPro X - Seed Data
-- ============================================================

USE `salonprox_db`;

-- Insert default branch
INSERT INTO `branches` (`name`, `slug`, `address`, `city`, `phone`, `email`, `status`) VALUES
('Main Salon', 'main-salon', '123 Salon Street', 'Colombo', '+94 11 234 5678', 'info@salonprox.com', 'active');

-- Insert roles
INSERT INTO `roles` (`name`, `slug`, `description`, `is_system`) VALUES
('Super Admin', 'super-admin', 'Full system access', 1),
('Admin', 'admin', 'Administrative access', 1),
('Manager', 'manager', 'Branch manager access', 1),
('Receptionist', 'receptionist', 'Front desk and appointment management', 1),
('Stylist', 'stylist', 'Service provider', 1),
('Accountant', 'accountant', 'Financial management', 1),
('Viewer', 'viewer', 'Read-only access', 1);

-- Insert all permissions
INSERT INTO `permissions` (`name`, `slug`, `module`) VALUES
('Dashboard View', 'dashboard_view', 'Dashboard'),
('Auth Login', 'auth_login', 'Authentication'),
('Auth Logout', 'auth_logout', 'Authentication'),
('Auth Profile', 'auth_profile', 'Authentication'),
('Roles View', 'roles_view', 'Roles'),
('Roles Create', 'roles_create', 'Roles'),
('Roles Edit', 'roles_edit', 'Roles'),
('Roles Delete', 'roles_delete', 'Roles'),
('Branches View', 'branches_view', 'Branches'),
('Branches Create', 'branches_create', 'Branches'),
('Branches Edit', 'branches_edit', 'Branches'),
('Branches Delete', 'branches_delete', 'Branches'),
('Customers View', 'customers_view', 'Customers'),
('Customers Create', 'customers_create', 'Customers'),
('Customers Edit', 'customers_edit', 'Customers'),
('Customers Delete', 'customers_delete', 'Customers'),
('Appointments View', 'appointments_view', 'Appointments'),
('Appointments Create', 'appointments_create', 'Appointments'),
('Appointments Edit', 'appointments_edit', 'Appointments'),
('Appointments Delete', 'appointments_delete', 'Appointments'),
('Appointments Checkin', 'appointments_checkin', 'Appointments'),
('Appointments Calendar', 'appointments_calendar', 'Appointments'),
('Services View', 'services_view', 'Services'),
('Services Create', 'services_create', 'Services'),
('Services Edit', 'services_edit', 'Services'),
('Services Delete', 'services_delete', 'Services'),
('Packages View', 'packages_view', 'Packages'),
('Packages Create', 'packages_create', 'Packages'),
('Packages Edit', 'packages_edit', 'Packages'),
('Packages Delete', 'packages_delete', 'Packages'),
('POS View', 'pos_view', 'POS'),
('POS Create', 'pos_create', 'POS'),
('POS Invoice View', 'pos_invoice_view', 'POS'),
('POS Refund', 'pos_refund', 'POS'),
('Invoices View', 'invoices_view', 'Invoices'),
('Invoices Create', 'invoices_create', 'Invoices'),
('Invoices Edit', 'invoices_edit', 'Invoices'),
('Invoices Delete', 'invoices_delete', 'Invoices'),
('Invoices Payment', 'invoices_payment', 'Invoices'),
('Employees View', 'employees_view', 'Employees'),
('Employees Create', 'employees_create', 'Employees'),
('Employees Edit', 'employees_edit', 'Employees'),
('Employees Delete', 'employees_delete', 'Employees'),
('Attendance View', 'attendance_view', 'Attendance'),
('Attendance Manage', 'attendance_manage', 'Attendance'),
('Commissions View', 'commissions_view', 'Commissions'),
('Commissions Manage', 'commissions_manage', 'Commissions'),
('Commissions Pay', 'commissions_pay', 'Commissions'),
('Salary View', 'salary_view', 'Salary'),
('Salary Manage', 'salary_manage', 'Salary'),
('Salary Pay', 'salary_pay', 'Salary'),
('Inventory View', 'inventory_view', 'Inventory'),
('Inventory Create', 'inventory_create', 'Inventory'),
('Inventory Edit', 'inventory_edit', 'Inventory'),
('Inventory Delete', 'inventory_delete', 'Inventory'),
('Suppliers View', 'suppliers_view', 'Suppliers'),
('Suppliers Create', 'suppliers_create', 'Suppliers'),
('Suppliers Edit', 'suppliers_edit', 'Suppliers'),
('Suppliers Delete', 'suppliers_delete', 'Suppliers'),
('Purchases View', 'purchases_view', 'Purchases'),
('Purchases Create', 'purchases_create', 'Purchases'),
('Purchases Edit', 'purchases_edit', 'Purchases'),
('Purchases Receive', 'purchases_receive', 'Purchases'),
('Purchases Approve', 'purchases_approve', 'Purchases'),
('Expenses View', 'expenses_view', 'Expenses'),
('Expenses Create', 'expenses_create', 'Expenses'),
('Expenses Edit', 'expenses_edit', 'Expenses'),
('Expenses Delete', 'expenses_delete', 'Expenses'),
('Income View', 'income_view', 'Income'),
('Income Create', 'income_create', 'Income'),
('Accounting View', 'accounting_view', 'Accounting'),
('Accounting Cashbook', 'accounting_cashbook', 'Accounting'),
('Accounting Bankbook', 'accounting_bankbook', 'Accounting'),
('Accounting Pettycash', 'accounting_pettycash', 'Accounting'),
('Membership View', 'membership_view', 'Membership'),
('Membership Create', 'membership_create', 'Membership'),
('Membership Edit', 'membership_edit', 'Membership'),
('Membership Delete', 'membership_delete', 'Membership'),
('Loyalty View', 'loyalty_view', 'Loyalty'),
('Loyalty Manage', 'loyalty_manage', 'Loyalty'),
('GiftCards View', 'giftcards_view', 'GiftCards'),
('GiftCards Create', 'giftcards_create', 'GiftCards'),
('GiftCards Manage', 'giftcards_manage', 'GiftCards'),
('Marketing View', 'marketing_view', 'Marketing'),
('Marketing Create', 'marketing_create', 'Marketing'),
('Marketing Send', 'marketing_send', 'Marketing'),
('Reports View', 'reports_view', 'Reports'),
('Reports Export', 'reports_export', 'Reports'),
('Settings View', 'settings_view', 'Settings'),
('Settings Edit', 'settings_edit', 'Settings'),
('Audit View', 'audit_view', 'AuditLogs'),
('Backup Create', 'backup_create', 'Backup'),
('Backup Restore', 'backup_restore', 'Backup'),
('Backup Download', 'backup_download', 'Backup');

-- Assign all permissions to Super Admin role
INSERT INTO `role_permissions` (`role_id`, `permission_id`)
SELECT 1, `id` FROM `permissions`;

-- Insert admin user (password: admin123)
INSERT INTO `users` (`branch_id`, `role_id`, `username`, `email`, `password`, `first_name`, `last_name`, `phone`, `status`, `is_superadmin`) VALUES
(1, 1, 'admin', 'admin@salonprox.com', '$2y$12$LJ3m4ys3Lg3YOCwH.7zYSOk5TxgP0OXH9H0YV0a0a0a0a0a0a0a0a', 'System', 'Administrator', '+94 11 234 5678', 'active', 1);

-- Insert default settings
INSERT INTO `settings` (`branch_id`, `key`, `value`, `group_name`, `type`) VALUES
(NULL, 'app_name', 'SalonPro X', 'general', 'text'),
(NULL, 'app_email', 'info@salonprox.com', 'general', 'text'),
(NULL, 'app_phone', '+94 11 234 5678', 'general', 'text'),
(NULL, 'app_address', '123 Salon Street, Colombo, Sri Lanka', 'general', 'textarea'),
(NULL, 'app_timezone', 'Asia/Colombo', 'general', 'text'),
(NULL, 'app_currency', 'LKR', 'general', 'text'),
(NULL, 'app_currency_symbol', 'Rs.', 'general', 'text'),
(NULL, 'tax_label', 'VAT', 'general', 'text'),
(NULL, 'tax_rate', '0', 'general', 'text'),
(NULL, 'enable_loyalty', '1', 'loyalty', 'boolean'),
(NULL, 'loyalty_points_per_currency', '1', 'loyalty', 'text'),
(NULL, 'loyalty_currency_per_point', '100', 'loyalty', 'text'),
(NULL, 'enable_notifications', '1', 'notifications', 'boolean'),
(NULL, 'appointment_reminder_hours', '24', 'notifications', 'text'),
(NULL, 'business_start_time', '09:00', 'business_hours', 'text'),
(NULL, 'business_end_time', '20:00', 'business_hours', 'text'),
(NULL, 'business_days', 'Monday,Tuesday,Wednesday,Thursday,Friday,Saturday', 'business_hours', 'text'),
(NULL, 'appointment_slot_interval', '30', 'appointments', 'text'),
(NULL, 'max_future_days', '90', 'appointments', 'text');

-- Insert expense categories
INSERT INTO `expense_categories` (`name`, `slug`, `description`) VALUES
('Rent', 'rent', 'Monthly rent expense'),
('Utilities', 'utilities', 'Electricity, water, internet bills'),
('Salaries', 'salaries', 'Employee salaries and wages'),
('Supplies', 'supplies', 'Salon supplies and consumables'),
('Equipment', 'equipment', 'Equipment purchase and maintenance'),
('Marketing', 'marketing', 'Advertising and promotional expenses'),
('Maintenance', 'maintenance', 'Repair and maintenance costs'),
('Insurance', 'insurance', 'Insurance premiums'),
('Other', 'other', 'Miscellaneous expenses');

-- Insert income categories
INSERT INTO `income_categories` (`name`, `slug`, `description`) VALUES
('Services', 'services', 'Income from salon services'),
('Products', 'products', 'Income from product sales'),
('Packages', 'packages', 'Income from package sales'),
('Memberships', 'memberships', 'Membership fees'),
('Gift Cards', 'gift-cards', 'Gift card sales'),
('Other', 'other', 'Other income');

-- Insert product categories
INSERT INTO `product_categories` (`name`, `slug`, `description`) VALUES
('Hair Care', 'hair-care', 'Shampoos, conditioners, treatments'),
('Hair Styling', 'hair-styling', 'Gels, waxes, sprays'),
('Skin Care', 'skin-care', 'Moisturizers, serums, masks'),
('Nail Care', 'nail-care', 'Polishes, treatments'),
('Makeup', 'makeup', 'Cosmetics and beauty products'),
('Tools', 'tools', 'Brushes, combs, scissors'),
('Retail', 'retail', 'Retail products for sale');

-- Insert sample services
INSERT INTO `service_categories` (`branch_id`, `name`, `slug`, `description`) VALUES
(1, 'Haircuts', 'haircuts', 'Professional haircut services'),
(1, 'Coloring', 'coloring', 'Hair coloring services'),
(1, 'Styling', 'styling', 'Hair styling services'),
(1, 'Treatments', 'treatments', 'Hair and scalp treatments'),
(1, 'Nails', 'nails', 'Manicure and pedicure services'),
(1, 'Facial', 'facial', 'Facial and skin care services'),
(1, 'Makeup', 'makeup', 'Makeup application services');

INSERT INTO `services` (`branch_id`, `category_id`, `name`, `slug`, `description`, `duration_minutes`, `price`, `cost_price`, `commission_type`, `commission_value`, `color`) VALUES
(1, 1, 'Haircut - Men', 'haircut-men', 'Professional haircut for men', 30, 1500.00, 0.00, 'percentage', 40.00, '#C8A44E'),
(1, 1, 'Haircut - Women', 'haircut-women', 'Professional haircut for women', 45, 2500.00, 0.00, 'percentage', 40.00, '#D4AF37'),
(1, 1, 'Haircut - Kids', 'haircut-kids', 'Professional haircut for children', 30, 1000.00, 0.00, 'percentage', 40.00, '#E8D48B'),
(1, 2, 'Full Color', 'full-color', 'Full head hair coloring', 120, 5000.00, 0.00, 'percentage', 35.00, '#A8893A'),
(1, 2, 'Highlights', 'highlights', 'Partial or full highlights', 90, 4500.00, 0.00, 'percentage', 35.00, '#C8A44E'),
(1, 2, 'Root Touch-up', 'root-touch-up', 'Root color touch-up', 60, 3000.00, 0.00, 'percentage', 35.00, '#D4AF37'),
(1, 3, 'Blow Dry', 'blow-dry', 'Professional blow dry styling', 30, 1500.00, 0.00, 'percentage', 40.00, '#E8D48B'),
(1, 3, 'Updo/Special Occasion', 'updo-special', 'Updo hairstyle for special occasions', 60, 3500.00, 0.00, 'percentage', 40.00, '#C8A44E'),
(1, 4, 'Keratin Treatment', 'keratin-treatment', 'Smoothing keratin treatment', 120, 8000.00, 0.00, 'percentage', 30.00, '#A8893A'),
(1, 4, 'Scalp Treatment', 'scalp-treatment', 'Therapeutic scalp treatment', 45, 2500.00, 0.00, 'percentage', 35.00, '#C8A44E'),
(1, 5, 'Manicure', 'manicure', 'Classic manicure service', 45, 2000.00, 0.00, 'percentage', 40.00, '#D4AF37'),
(1, 5, 'Pedicure', 'pedicure', 'Classic pedicure service', 45, 2500.00, 0.00, 'percentage', 40.00, '#E8D48B'),
(1, 6, 'Classic Facial', 'classic-facial', 'Deep cleansing facial', 60, 3500.00, 0.00, 'percentage', 35.00, '#C8A44E'),
(1, 7, 'Full Face Makeup', 'full-face-makeup', 'Professional full face makeup', 60, 5000.00, 0.00, 'percentage', 35.00, '#D4AF37');

-- Insert membership tiers
INSERT INTO `membership_tiers` (`name`, `slug`, `duration_days`, `price`, `discount_percent`, `priority`, `color`, `benefits`) VALUES
('Silver', 'silver', 30, 1500.00, 5.00, 1, '#C0C0C0', '5% discount on all services, Priority booking'),
('Gold', 'gold', 90, 3500.00, 10.00, 2, '#D4AF37', '10% discount on all services, Priority booking, Free blow dry monthly'),
('Platinum', 'platinum', 180, 6000.00, 15.00, 3, '#E5E4E2', '15% discount on all services, Priority booking, Free treatment monthly, Birthday special'),
('Diamond', 'diamond', 365, 10000.00, 20.00, 4, '#B9F2FF', '20% discount on all services, VIP booking, Free service monthly, Birthday special, Exclusive events');

-- Insert notification templates
INSERT INTO `notification_templates` (`name`, `slug`, `title`, `message`, `type`) VALUES
('Appointment Reminder', 'appointment-reminder', 'Appointment Reminder', 'Dear {customer_name}, this is a reminder of your appointment on {appointment_date} at {appointment_time}. Thank you!', 'info'),
('Appointment Confirmation', 'appointment-confirmed', 'Appointment Confirmed', 'Dear {customer_name}, your appointment on {appointment_date} at {appointment_time} has been confirmed.', 'success'),
('Appointment Cancelled', 'appointment-cancelled', 'Appointment Cancelled', 'Dear {customer_name}, your appointment on {appointment_date} at {appointment_time} has been cancelled.', 'warning'),
('Welcome', 'welcome-new-customer', 'Welcome to SalonPro X!', 'Dear {customer_name}, welcome to SalonPro X! We look forward to serving you.', 'success'),
('Birthday', 'birthday-wish', 'Happy Birthday!', 'Dear {customer_name}, warmest birthday wishes from SalonPro X! Enjoy a special discount on your next visit.', 'info'),
('Membership Expiring', 'membership-expiring', 'Membership Expiring Soon', 'Dear {customer_name}, your {tier_name} membership will expire on {expiry_date}. Renew now to continue enjoying benefits.', 'warning');

-- Insert email templates
INSERT INTO `email_templates` (`name`, `slug`, `subject`, `body_html`, `variables`) VALUES
('Appointment Confirmation', 'appointment-confirmation', 'Appointment Confirmed - SalonPro X', '<h2>Dear {customer_name},</h2><p>Your appointment has been confirmed.</p><p><strong>Date:</strong> {appointment_date}<br><strong>Time:</strong> {appointment_time}<br><strong>Service:</strong> {service_name}<br><strong>Stylist:</strong> {stylist_name}</p><p>Thank you for choosing SalonPro X!</p>', '["customer_name","appointment_date","appointment_time","service_name","stylist_name"]'),
('Appointment Reminder', 'appointment-reminder', 'Appointment Reminder - SalonPro X', '<h2>Dear {customer_name},</h2><p>This is a friendly reminder about your upcoming appointment.</p><p><strong>Date:</strong> {appointment_date}<br><strong>Time:</strong> {appointment_time}<br><strong>Service:</strong> {service_name}<br><strong>Stylist:</strong> {stylist_name}</p><p>See you soon!</p>', '["customer_name","appointment_date","appointment_time","service_name","stylist_name"]'),
('Invoice', 'invoice', 'Your Invoice - SalonPro X', '<h2>Dear {customer_name},</h2><p>Thank you for visiting SalonPro X. Please find your invoice attached.</p><p><strong>Invoice No:</strong> {invoice_number}<br><strong>Total:</strong> {total_amount}</p><p>We look forward to serving you again!</p>', '["customer_name","invoice_number","total_amount"]'),
('Welcome', 'welcome', 'Welcome to SalonPro X!', '<h2>Welcome {customer_name}!</h2><p>Thank you for registering with SalonPro X. We are excited to have you!</p><p>Book your first appointment today and enjoy a special welcome discount.</p><p>Best regards,<br>SalonPro X Team</p>', '["customer_name"]');

-- Insert SMS templates
INSERT INTO `sms_templates` (`name`, `slug`, `message`, `variables`) VALUES
('Appointment Reminder', 'appointment-reminder', 'Dear {customer_name}, your appointment at {salon_name} is confirmed for {appointment_date} at {appointment_time}. Thank you!', '["customer_name","salon_name","appointment_date","appointment_time"]'),
('Appointment Confirmation', 'appointment-confirmation', 'Dear {customer_name}, your appointment on {appointment_date} at {appointment_time} has been confirmed. Thank you for choosing {salon_name}!', '["customer_name","salon_name","appointment_date","appointment_time"]'),
('Promotional', 'promotional', 'Exclusive offer from {salon_name}! Get {discount}% off on {service_name}. Valid until {valid_until}. Book now!', '["salon_name","discount","service_name","valid_until"]'),
('Birthday', 'birthday', 'Happy Birthday {customer_name}! Enjoy {discount}% off on your next visit to {salon_name}. Offer valid until {valid_until}.', '["customer_name","salon_name","discount","valid_until"]');
