-- Add Application Notes, Reports Book, Journals Book, EBook catalogue reports (run once on existing DB)
INSERT IGNORE INTO `app_modules` (`module_key`, `module_name`, `module_group`, `route`, `sort_order`) VALUES
('application_notes_report', 'Application Notes Report', 'Catalogue', 'report/application_notes_report', 88),
('reports_book_report', 'Reports Book Report', 'Catalogue', 'report/reports_book_report', 89),
('journals_book_report', 'Journals Book Report', 'Catalogue', 'report/journals_book_report', 90),
('ebook_report', 'EBook Report', 'Catalogue', 'report/ebook_report', 91);

-- Copy permissions from Accession Register for roles that already have it
INSERT IGNORE INTO `app_role_permissions` (`role_id`, `module_key`, `can_view`, `can_export`)
SELECT `role_id`, 'application_notes_report', `can_view`, `can_export`
FROM `app_role_permissions`
WHERE `module_key` = 'accession_register';

INSERT IGNORE INTO `app_role_permissions` (`role_id`, `module_key`, `can_view`, `can_export`)
SELECT `role_id`, 'reports_book_report', `can_view`, `can_export`
FROM `app_role_permissions`
WHERE `module_key` = 'accession_register';

INSERT IGNORE INTO `app_role_permissions` (`role_id`, `module_key`, `can_view`, `can_export`)
SELECT `role_id`, 'journals_book_report', `can_view`, `can_export`
FROM `app_role_permissions`
WHERE `module_key` = 'accession_register';

INSERT IGNORE INTO `app_role_permissions` (`role_id`, `module_key`, `can_view`, `can_export`)
SELECT `role_id`, 'ebook_report', `can_view`, `can_export`
FROM `app_role_permissions`
WHERE `module_key` = 'accession_register';
