UPDATE `ohrm_config` SET value = '0' where property = 'training.program.enabled';
UPDATE `ohrm_menu_item` SET status = '0' where menu_title = 'Programs';

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');
SET @edit_package_details_data_group_id := (SELECT `id` FROM `ohrm_data_group` WHERE `name` = 'edit_package_details' AND `description` = 'Learning Courses - Programs');
SET @training_menu_id := (SELECT id FROM `ohrm_menu_item` WHERE parent_id IS NULL AND menu_title = 'Training');
SET @view_training_report_menu_id := (SELECT id FROM `ohrm_menu_item` WHERE parent_id = @training_menu_id AND menu_title = 'Reports');

DELETE FROM `ohrm_user_role_screen` WHERE `user_role_id` = @admin_role_id AND `screen_id` = @define_course_package_screen_id;
DELETE FROM `ohrm_user_role_screen` WHERE `user_role_id` = @admin_role_id AND `screen_id` = @view_packages_screen_id;
DELETE FROM `ohrm_user_role_screen` WHERE `user_role_id` = @admin_role_id AND `screen_id` = @view_package_session_list_screen_id;
DELETE FROM `ohrm_user_role_screen` WHERE `user_role_id` = @admin_role_id AND `screen_id` = @edit_package_session_list_screen_id;

DELETE FROM `ohrm_user_role_data_group` WHERE `user_role_id` = @admin_role_id AND `data_group_id` = @edit_package_details_data_group_id;

DELETE FROM `ohrm_user_role_type_data_group` WHERE `user_role_type_id` = @admin_role_type_id AND `data_group_id` = @edit_package_details_data_group_id;

DELETE FROM `ohrm_data_group_screen`
WHERE (`data_group_id` = @manage_course_list_data_group_id AND `screen_id` = @define_course_package_screen_id AND `permission` = 1) OR
(`data_group_id` = @manage_course_list_data_group_id AND `screen_id` = @define_course_package_screen_id AND `permission` = 2) OR
(`data_group_id` = @manage_course_list_data_group_id AND `screen_id` = @define_course_package_screen_id AND `permission` = 3) OR
(`data_group_id` = @edit_package_details_data_group_id AND `screen_id` = @view_packages_screen_id AND `permission` = 1) OR
(`data_group_id` = @edit_package_details_data_group_id AND `screen_id` = @view_packages_screen_id AND `permission` = 2) OR
(`data_group_id` = @edit_package_details_data_group_id AND `screen_id` = @view_packages_screen_id AND `permission` = 3) OR
(`data_group_id` = @edit_package_details_data_group_id AND `screen_id` = @view_packages_screen_id AND `permission` = 4) OR
(`data_group_id` = @edit_package_details_data_group_id AND `screen_id` = @add_package_screen_id AND `permission` = 1) OR
(`data_group_id` = @edit_package_details_data_group_id AND `screen_id` = @add_package_screen_id AND `permission` = 2) OR
(`data_group_id` = @edit_package_details_data_group_id AND `screen_id` = @add_package_screen_id AND `permission` = 3) OR
(`data_group_id` = @edit_package_details_data_group_id AND `screen_id` = @view_package_session_list_screen_id AND `permission` = 1) OR
(`data_group_id` = @edit_package_details_data_group_id AND `screen_id` = @view_package_session_list_screen_id AND `permission` = 2) OR
(`data_group_id` = @edit_package_details_data_group_id AND `screen_id` = @view_package_session_list_screen_id AND `permission` = 3) OR
(`data_group_id` = @edit_package_details_data_group_id AND `screen_id` = @view_package_session_list_screen_id AND `permission` = 4) OR
(`data_group_id` = @edit_package_details_data_group_id AND `screen_id` = @edit_package_session_list_screen_id AND `permission` = 1) OR
(`data_group_id` = @edit_package_details_data_group_id AND `screen_id` = @edit_package_session_list_screen_id AND `permission` = 2) OR
(`data_group_id` = @edit_package_details_data_group_id AND `screen_id` = @edit_package_session_list_screen_id AND `permission` = 3) OR
(`data_group_id` = @edit_package_details_data_group_id AND `screen_id` = @edit_package_session_list_screen_id AND `permission` = 4);

DELETE FROM `ohrm_data_group` WHERE `name` = 'edit_package_details' AND `description` = 'Learning Courses - Programs';

UPDATE `ohrm_menu_item` SET uisref = 'report_view({"id": "Student_Session_Information", "filters": null})' WHERE menu_title = 'Participating Session' AND parent_id = @view_training_report_menu_id;
UPDATE `ohrm_menu_item` SET uisref = 'report_view({"id": "Trainer_Session_Information", "filters": null})' WHERE menu_title = 'Training Session'  AND parent_id = @view_training_report_menu_id;

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