

INSERT INTO `modules` (`id`,`code`,`name`,`icon`,`sort_order`,`is_active`) VALUES
(1,'income','Income Management','cash-register',1,1),
(2,'staff','Staff Management','calendar',2,1),
(3,'accounts','Accounts','file-text',3,1),
(4,'hr','HR Management','id-card',4,1),
(5,'logs','Logs','clipboard-list',5,1),
(6,'reports','Reports','bar-chart',6,1);

INSERT INTO `businesses` (`id`,`legal_name`,`trade_name`,`slug`,`email`,`phone`,`website`,`status`,`is_active`,`staff_login_mode`,`staff_link_key`,`pin_min`,`pin_max`) VALUES
(1,'Nandu Foods Ltd','Fired Dough','fired-dough','demo@fired-dough.example','0131 000 0000','https://example.com','active',1,'pin','02e4dcb7b571e3cf168ce6d7f0a18b41b9d6b4eb',4,8);

INSERT INTO `business_modules` (`business_id`,`module_id`,`enabled`,`enabled_source`) VALUES
(1,1,1,'manual'),
(1,2,1,'manual'),
(1,3,1,'manual'),
(1,4,1,'manual'),
(1,5,1,'manual'),
(1,6,1,'manual');
INSERT INTO business_settings (business_id,setting_key,setting_value) VALUES(1,'name_format.rota','short'),(1,'name_format.timesheet','short'),(1,'name_format.logs','initials');

INSERT INTO `users` (`id`,`business_id`,`user_type`,`username`,`email`,`password_hash`,`pin_hash`,`pin_lookup`,`display_name`,`is_active`,`must_change_password`,`last_login_at`,`created_at`) VALUES
(1,NULL,'super_admin','superadmin','superadmin@example.com','$2b$10$RD/zDjchOrnvlGLjZuz9D.8erRQv.gAz2uyn8qyze64FJ8.wOGlt2',NULL,NULL,'Super Admin',1,0,NULL,CURRENT_TIMESTAMP),
(2,1,'business_admin','firedadmin','admin@fired-dough.example','$2b$10$/C.Ehv0CUUJGdpP0tPe.euRuZeqnItAn9efudtT1ytQEyJgf7WpBW',NULL,NULL,'Fired Dough Admin',1,0,NULL,CURRENT_TIMESTAMP),
(10,1,'staff',NULL,NULL,NULL,'$2b$10$B6LqrQdLXpQc/Ce3n7JfmOO.TQxA5FSkMEGWFcF19pz2Thhkh4GCW','68396e6303f206ca20114ca3891939c2faf7be5d946e665c50cfd79d59871aa2','Demo Chef',1,0,NULL,CURRENT_TIMESTAMP),
(11,1,'staff',NULL,NULL,NULL,'$2b$10$WlZftyt9FOFWZ0ExdP./MOdNfBF7iuPXp44GXvrcRIdeB0DupODJK','b6ebf8d27e139b6760df3f3a32c8fde9e34d8e9afe7c7bbb2dca56c35af28e81','Demo Server',1,0,NULL,CURRENT_TIMESTAMP);

INSERT INTO `departments` (`id`,`business_id`,`name`) VALUES
(1,1,'Kitchen'),
(2,1,'Front of House');

INSERT INTO `staff_roles` (`id`,`business_id`,`role_name`) VALUES
(1,1,'Chef'),
(2,1,'Waiting Staff');

INSERT INTO `staff_profile` (`id`,`business_id`,`full_name`,`short_name`,`role_id`,`hourly_rate`,`department_id`,`is_active`,`created_at`,`user_id`,`initials`) VALUES
(1,1,'Demo Chef','Chef',1,14.50,1,1,CURRENT_TIMESTAMP,10,'DC'),
(2,1,'Demo Server','Server',2,12.00,2,1,CURRENT_TIMESTAMP,11,'DS');

INSERT INTO `permissions` (`id`,`code`,`module_code`,`label`) VALUES
(1,'module.income.access','income','Access Income'),
(2,'module.staff.access','staff','Access Staff Management'),
(3,'module.accounts.access','accounts','Access Accounts'),
(4,'module.hr.access','hr','Access HR'),
(5,'module.logs.access','logs','Access Logs'),
(6,'module.reports.access','reports','Access Reports'),
(7,'sales.entry.create','income','Create Sales Entries'),
(8,'sales.entry.view','income','View Sales Entries'),
(9,'rota.view','staff','View Rota'),
(10,'rota.edit','staff','Edit Rota'),
(11,'expenses.create','accounts','Create Expenses'),
(12,'expenses.view','accounts','View Expenses'),
(13,'invoices.create','accounts','Create Invoices'),
(14,'invoices.view','accounts','View Invoices'),
(15,'logs.cleaning.record','logs','Record Cleaning Logs'),
(16,'logs.cleaning.view','logs','View Cleaning Logs'),
(17,'logs.temps.record','logs','Record Temperature Logs'),
(18,'logs.temps.view','logs','View Temperature Logs'),
(19,'hr.leave.request','hr','Request Leave'),
(20,'hr.leave.manage','hr','Manage Leave');

INSERT INTO `roles` (`id`,`business_id`,`name`,`is_admin`) VALUES
(1,1,'Business Admin',1),
(2,1,'Manager',0),
(3,1,'Staff',0);

-- Map kitchen/FOH staff to the Staff RBAC role via department and job role
INSERT INTO `department_roles` (`department_id`,`role_id`) VALUES
(1,3),
(2,3);

INSERT INTO `staffrole_roles` (`staff_role_id`,`role_id`) VALUES
(1,3),
(2,3);

INSERT INTO `user_roles` (`user_id`,`role_id`) VALUES
(2,1),
(10,3),
(11,3);

INSERT INTO `role_permissions` (`role_id`,`permission_id`) VALUES
(1,1),
(1,2),
(1,3),
(1,4),
(1,5),
(1,6),
(1,7),
(1,8),
(1,9),
(1,10),
(1,11),
(1,12),
(1,13),
(1,14),
(1,15),
(1,16),
(1,17),
(1,18),
(1,19),
(1,20),
(2,1),
(2,2),
(2,3),
(2,4),
(2,5),
(2,6),
(2,7),
(2,8),
(2,9),
(2,10),
(2,11),
(2,12),
(2,13),
(2,14),
(2,15),
(2,16),
(2,17),
(2,18),
(2,19),
(2,20),
(3,5),
(3,15),
(3,16),
(3,17),
(3,18),
(3,19);

INSERT INTO `sales_entries` (`id`,`business_id`,`entry_date`,`data`,`total_cash`,`total_card`,`total_expense`,`cash_in_hand`,`created_at`) VALUES
(1,1,'2026-01-22','{"notes":"demo"}',120.00,380.00,45.00,75.00,CURRENT_TIMESTAMP);

INSERT INTO `sales_entry_details` (`id`,`business_id`,`entry_id`,`category`,`field_name`,`field_value`) VALUES
(1,1,1,'cash','Cash sales',120.00),
(2,1,1,'card','Card sales',380.00);

INSERT INTO `expense_reasons` (`id`,`business_id`,`name`) VALUES
(1,1,'Supplies'),
(2,1,'Delivery'),
(3,1,'Staff Meal');

INSERT INTO `expenses` (`id`,`business_id`,`expense_date`,`reason_id`,`is_cash_expense`,`amount`,`notes`,`created_at`) VALUES
(1,1,'2026-01-22',1,1,45.00,'Demo expense',CURRENT_TIMESTAMP);

INSERT INTO `suppliers` (`id`,`business_id`,`name`,`created_at`) VALUES
(1,1,'Demo Supplier',CURRENT_TIMESTAMP);

INSERT INTO `invoices` (`id`,`business_id`,`supplier_id`,`invoice_date`,`total_amount`,`notes`,`created_at`) VALUES
(1,1,1,'2026-01-22',200.00,'Demo invoice',CURRENT_TIMESTAMP);

INSERT INTO `payments` (`id`,`business_id`,`invoice_id`,`paid_date`,`amount`,`method`,`note`,`created_at`,`expense_id`) VALUES
(1,1,1,'2026-01-23',200.00,'bank','Demo payment',CURRENT_TIMESTAMP,NULL);

INSERT INTO `rota_weekly_settings` (`business_id`,`week_start`,`closing_time`,`is_published`,`published_at`,`last_modified`) VALUES
(1,'2026-01-19','22:45:00',1,CURRENT_TIMESTAMP,CURRENT_TIMESTAMP);

INSERT INTO `staff_rota` (`id`,`business_id`,`staff_id`,`shift_date`,`start_time`,`end_time`,`note`,`created_at`,`updated_at`) VALUES
(1,1,1,'2026-01-23','16:00:00','22:00:00','Demo rota',CURRENT_TIMESTAMP,CURRENT_TIMESTAMP);

INSERT INTO `cleaning_areas` (`id`,`business_id`,`name`,`assigned_group`) VALUES
(1,1,'Kitchen','Kitchen');

INSERT INTO `cleaning_items` (`id`,`business_id`,`area_id`,`item_name`,`frequency`,`photo_required`,`cleaning_procedure`,`cleaning_when`,`interval_days`) VALUES
(1,1,1,'Worktops','Daily',0,'Wipe down and sanitise','Closing',NULL);

INSERT INTO `cleaning_logs` (`id`,`business_id`,`item_id`,`user_initials`,`cleaned_at`,`photo_path`,`user_id`) VALUES
(1,1,1,'DC',NOW(),NULL,10);

INSERT INTO `equipment_types` (`id`,`business_id`,`name`) VALUES
(1,1,'Fridge');

INSERT INTO `equipment` (`id`,`business_id`,`name`,`type`,`is_active`,`department`) VALUES
(1,1,'Main Fridge','Fridge',1,'Kitchen');

INSERT INTO `fridge_logs` (`id`,`business_id`,`equipment_id`,`user_initials`,`temperature`,`check_time`,`photo_path`,`user_id`) VALUES
(1,1,1,'DS',3.5,NOW(),NULL,11);

INSERT INTO `leave_requests` (`id`,`business_id`,`user_id`,`leave_type`,`start_date`,`end_date`,`start_half_day`,`end_half_day`,`total_days`,`reason`,`status`,`requested_by`,`requested_at`,`decided_by`,`decided_at`,`decision_note`,`is_archived`,`created_at`,`updated_at`) VALUES
(1,1,11,'holiday','2026-02-02','2026-02-04',0,0,3.00,'Demo holiday','pending',11,NOW(),NULL,NULL,NULL,0,NOW(),NULL);

INSERT INTO `absences` (`id`,`business_id`,`user_id`,`absence_type`,`date_from`,`date_to`,`total_days`,`reason`,`recorded_by`,`recorded_at`,`is_archived`,`created_at`,`updated_at`) VALUES
(1,1,10,'sick','2026-01-21','2026-01-22',2.00,'Demo sick',2,NOW(),0,NOW(),NULL);

