
UPDATE `ohrm_config` SET value = '1' where property='training.program.enabled';

SET @culture_pillar_menu_id := (SELECT `id` FROM ohrm_menu_item WHERE `menu_title` = 'Culture' AND parent_id IS NULL AND level = 1);
SET @training_menu_id := (SELECT `id` FROM ohrm_menu_item WHERE `menu_title` = 'Training' AND parent_id = @culture_pillar_menu_id AND level = 2);
SET @learning_courses_menu_id := (SELECT `id` FROM ohrm_menu_item WHERE `menu_title` = 'Learning Courses' AND parent_id = @training_menu_id AND level = 3);
UPDATE `ohrm_menu_item` SET status = 1 where menu_title = 'Programs' AND parent_id = @learning_courses_menu_id AND level = 4;

SET @admin_role_id := (SELECT `id` FROM ohrm_user_role WHERE `name` = 'Admin');
SET @admin_role_type_id := (SELECT `id` FROM `ohrm_user_role_type` WHERE `name` = 'Admin');
SET @define_course_package_screen_id := (SELECT `id` FROM ohrm_screen WHERE `name` = 'DefineCoursePackage');
SET @view_packages_screen_id := (SELECT `id` FROM ohrm_screen WHERE `name` = 'Packages');
SET @manage_course_list_data_group_id := (SELECT `id` FROM ohrm_data_group WHERE `name` = 'manage_course_list');
SET @add_package_screen_id := (SELECT `id` FROM ohrm_screen WHERE `name` = 'AddPackage');
SET @view_package_session_list_screen_id := (SELECT `id` FROM ohrm_screen WHERE `name` = 'ViewPackageSessionList');
SET @edit_package_session_list_screen_id := (SELECT `id` FROM ohrm_screen WHERE `name` = 'EditPackageSessionList');
SET @manage_course_list_data_group_id = (SELECT `id` FROM ohrm_data_group WHERE `name` = 'manage_course_list');

INSERT INTO `ohrm_user_role_screen` (user_role_id, screen_id, can_read, can_create, can_update, can_delete) VALUES
(@admin_role_id, @define_course_package_screen_id, 1, 1, 1, 1),
(@admin_role_id, @view_packages_screen_id, 1, 1, 1, 1),
(@admin_role_id, @view_package_session_list_screen_id, 1, 1, 1, 1),
(@admin_role_id, @edit_package_session_list_screen_id, 1, 1, 1, 1);

INSERT INTO `ohrm_data_group` (`name`, `description`, `can_read`, `can_create`, `can_update`, `can_delete`) VALUES
('edit_package_details', 'Learning Courses - Programs', 1, 1, 1, 1);
SET @edit_package_details_data_group_id := (SELECT LAST_INSERT_ID());

INSERT INTO `ohrm_user_role_data_group` (`user_role_id`, `data_group_id`, `can_read`, `can_create`, `can_update`, `can_delete`, `self`) VALUES
(@admin_role_id, @edit_package_details_data_group_id, 1, 1, 1, 1, 0);

INSERT INTO `ohrm_user_role_type_data_group` (user_role_type_id, data_group_id) VALUES
(@admin_role_type_id, @edit_package_details_data_group_id);

INSERT INTO `ohrm_data_group_screen` (`data_group_id`, `screen_id`, `permission`) VALUES
(@manage_course_list_data_group_id, @define_course_package_screen_id, 1),
(@manage_course_list_data_group_id, @define_course_package_screen_id, 2),
(@manage_course_list_data_group_id, @define_course_package_screen_id, 3),
(@edit_package_details_data_group_id, @view_packages_screen_id, 1),
(@edit_package_details_data_group_id, @view_packages_screen_id, 2),
(@edit_package_details_data_group_id, @view_packages_screen_id, 3),
(@edit_package_details_data_group_id, @view_packages_screen_id, 4),
(@edit_package_details_data_group_id, @add_package_screen_id, 1),
(@edit_package_details_data_group_id, @add_package_screen_id, 2),
(@edit_package_details_data_group_id, @add_package_screen_id, 3),
(@edit_package_details_data_group_id, @view_package_session_list_screen_id, 1),
(@edit_package_details_data_group_id, @view_package_session_list_screen_id, 2),
(@edit_package_details_data_group_id, @view_package_session_list_screen_id, 3),
(@edit_package_details_data_group_id, @view_package_session_list_screen_id, 4),
(@edit_package_details_data_group_id, @edit_package_session_list_screen_id, 1),
(@edit_package_details_data_group_id, @edit_package_session_list_screen_id, 2),
(@edit_package_details_data_group_id, @edit_package_session_list_screen_id, 3),
(@edit_package_details_data_group_id, @edit_package_session_list_screen_id, 4);


SET @people_management_pillar_menu_id := (SELECT `id` FROM ohrm_menu_item WHERE `menu_title` = 'People Management' AND parent_id IS NULL AND level = 1);
SET @reporting_and_analytics_module_menu_id := (SELECT `id` FROM ohrm_menu_item WHERE `menu_title` = 'Reports and Analytics' AND `parent_id` = @people_management_pillar_menu_id);
SET @view_training_report_menu_id := (SELECT id FROM ohrm_menu_item WHERE parent_id = @reporting_and_analytics_module_menu_id AND menu_title = 'Training Reports');

UPDATE `ohrm_advanced_report` SET enabled = 0 WHERE unique_name IN ('Student_Session_Information', 'Trainer_Session_Information');
UPDATE `ohrm_advanced_report` SET enabled = 1 WHERE unique_name IN ('Student_Session_Information_Package', 'Trainer_Session_Information_Package');
