SET @personal_informationDataGroupId := (SELECT `id` FROM `ohrm_data_group` WHERE `name` = 'personal_information');
SET @personal_attachmentDataGroupId := (SELECT `id` FROM `ohrm_data_group` WHERE `name` = 'personal_attachment');
SET @personal_custom_fieldsDataGroupId := (SELECT `id` FROM `ohrm_data_group` WHERE `name` = 'personal_custom_fields');
SET @personal_information_documents_datagroup_id = (SELECT `id` FROM `ohrm_data_group` WHERE `name`='personal_information_documents');
SET @contact_detailsDataGroupId := (SELECT `id` FROM `ohrm_data_group` WHERE `name` = 'contact_details');
SET @contact_attachmentDataGroupId := (SELECT `id` FROM `ohrm_data_group` WHERE `name` = 'contact_attachment');
SET @contact_custom_fieldsDataGroupId := (SELECT `id` FROM `ohrm_data_group` WHERE `name` = 'contact_custom_fields');
SET @contact_details_documents_datagroup_id = (SELECT `id` FROM `ohrm_data_group` WHERE `name`='contact_details_documents');
SET @emergency_contactsDataGroupId := (SELECT `id` FROM `ohrm_data_group` WHERE `name` = 'emergency_contacts');
SET @emergency_attachmentDataGroupId := (SELECT `id` FROM `ohrm_data_group` WHERE `name` = 'emergency_attachment');
SET @emergency_custom_fieldsDataGroupId := (SELECT `id` FROM `ohrm_data_group` WHERE `name` = 'emergency_custom_fields');
SET @dependentsDataGroupId := (SELECT `id` FROM `ohrm_data_group` WHERE `name` = 'dependents');
SET @dependents_attachmentDataGroupId := (SELECT `id` FROM `ohrm_data_group` WHERE `name` = 'dependents_attachment');
SET @dependents_custom_fieldsDataGroupId := (SELECT `id` FROM `ohrm_data_group` WHERE `name` = 'dependents_custom_fields');
SET @immigrationDataGroupId := (SELECT `id` FROM `ohrm_data_group` WHERE `name` = 'immigration');
SET @immigration_attachmentDataGroupId := (SELECT `id` FROM `ohrm_data_group` WHERE `name` = 'immigration_attachment');
SET @immigration_custom_fieldsDataGroupId := (SELECT `id` FROM `ohrm_data_group` WHERE `name` = 'immigration_custom_fields');
SET @job_history_detailsDataGroupId := (SELECT `id` FROM `ohrm_data_group` WHERE `name` = 'job_history_details');
SET @job_attachmentDataGroupId := (SELECT `id` FROM `ohrm_data_group` WHERE `name` = 'job_attachment');
SET @job_custom_fieldsDataGroupId := (SELECT `id` FROM `ohrm_data_group` WHERE `name` = 'job_custom_fields');
SET @employee_job_documents_datagroup_id = (SELECT `id` FROM `ohrm_data_group` WHERE `name`='employee_job_documents');
SET @salary_history_detailsDataGroupId := (SELECT `id` FROM `ohrm_data_group` WHERE `name` = 'salary_history_details');
SET @salary_attachmentDataGroupId := (SELECT `id` FROM `ohrm_data_group` WHERE `name` = 'salary_attachment');
SET @salary_custom_fieldsDataGroupId := (SELECT `id` FROM `ohrm_data_group` WHERE `name` = 'salary_custom_fields');
SET @employee_salary_documents_datagroup_id = (SELECT `id` FROM `ohrm_data_group` WHERE `name`='employee_salary_documents');
SET @supervisorDataGroupId := (SELECT `id` FROM `ohrm_data_group` WHERE `name` = 'supervisor');
SET @subordinatesDataGroupId := (SELECT `id` FROM `ohrm_data_group` WHERE `name` = 'subordinates');
SET @report_to_attachmentDataGroupId := (SELECT `id` FROM `ohrm_data_group` WHERE `name` = 'report-to_attachment');
SET @report_to_custom_fieldsDataGroupId := (SELECT `id` FROM `ohrm_data_group` WHERE `name` = 'report-to_custom_fields');
SET @qualification_workDataGroupId := (SELECT `id` FROM `ohrm_data_group` WHERE `name` = 'qualification_work');
SET @qualification_educationDataGroupId := (SELECT `id` FROM `ohrm_data_group` WHERE `name` = 'qualification_education');
SET @qualification_skillsDataGroupId := (SELECT `id` FROM `ohrm_data_group` WHERE `name` = 'qualification_skills');
SET @qualification_languagesDataGroupId := (SELECT `id` FROM `ohrm_data_group` WHERE `name` = 'qualification_languages');
SET @qualification_licenseDataGroupId := (SELECT `id` FROM `ohrm_data_group` WHERE `name` = 'qualification_license');
SET @qualifications_attachmentDataGroupId := (SELECT `id` FROM `ohrm_data_group` WHERE `name` = 'qualifications_attachment');
SET @qualifications_custom_fieldsDataGroupId := (SELECT `id` FROM `ohrm_data_group` WHERE `name` = 'qualifications_custom_fields');
SET @membershipDataGroupId := (SELECT `id` FROM `ohrm_data_group` WHERE `name` = 'membership');
SET @membership_attachmentDataGroupId := (SELECT `id` FROM `ohrm_data_group` WHERE `name` = 'membership_attachment');
SET @membership_custom_fieldsDataGroupId := (SELECT `id` FROM `ohrm_data_group` WHERE `name` = 'membership_custom_fields');
SET @taxExemptionsDataGroupId := (SELECT `id` FROM `ohrm_data_group` WHERE `name` = 'tax_exemptions');
SET @tax_attachmentDataGroupId := (SELECT `id` FROM `ohrm_data_group` WHERE `name` = 'tax_attachment');
SET @tax_custom_fieldsDataGroupId := (SELECT `id` FROM `ohrm_data_group` WHERE `name` = 'tax_custom_fields');
SET @social_media_fieldsDataGroupId := (SELECT `id` FROM `ohrm_data_group` WHERE `name` = 'social_media');
SET @document_templates_DataGroupId := (SELECT `id` FROM `ohrm_data_group` WHERE `name` = 'pim_document_templates');


SET @pimModuleId := (SELECT `id` FROM `ohrm_module` WHERE `name` = 'pim');

SET @leftMenuScreenId := (SELECT id FROM ohrm_screen
    WHERE action_url = 'viewEmployeeProfile' AND module_id = @pimModuleId);
INSERT INTO `ohrm_menu_item` (`menu_title`,`menu_category`, `screen_id`,
                              `order_hint`, `status`, `level`) VALUES
    ('Profile', 'pim_left_menu', @leftMenuScreenId, 5, 1, 0);
-- SET @leftMenuItemId := (SELECT LAST_INSERT_ID());


SET @leftMenuScreenId := (SELECT id FROM ohrm_screen 
    WHERE action_url = 'viewPersonalDetails' AND module_id = @pimModuleId);
INSERT INTO `ohrm_menu_item` (`menu_title`,`menu_category`, `screen_id`,
`order_hint`, `status`, `level`) VALUES
('Personal Details', 'pim_left_menu', @leftMenuScreenId, 10, 1, 0);
SET @leftMenuItemId := (SELECT LAST_INSERT_ID());

-- add personal details token section
INSERT INTO `ohrm_token_section` (`name`, `display_name`,`menu_id`) VALUES ('PersonalDetails',null, @leftMenuItemId);

INSERT INTO `ohrm_menu_item_data_group` (`menu_item_id`, `data_group_id`) VALUES
(@leftMenuItemId, @personal_informationDataGroupId),
(@leftMenuItemId, @personal_attachmentDataGroupId),
(@leftMenuItemId, @personal_custom_fieldsDataGroupId),
(@leftMenuItemId, @personal_information_documents_datagroup_id);


SET @leftMenuScreenId := (SELECT id FROM ohrm_screen 
    WHERE action_url = 'contactDetails' AND module_id = @pimModuleId);

INSERT INTO `ohrm_menu_item` (`menu_title`,`menu_category`, `screen_id`,
`order_hint`, `status`, `level`) VALUES
('Contact Details', 'pim_left_menu', @leftMenuScreenId, 20, 1, 0);
SET @leftMenuItemId := (SELECT LAST_INSERT_ID());

-- add contact details token section
INSERT INTO `ohrm_token_section` (`name`, `display_name`,`menu_id`) VALUES ('ContactDetails',null, @leftMenuItemId);

INSERT INTO `ohrm_menu_item_data_group` (`menu_item_id`, `data_group_id`) VALUES
(@leftMenuItemId, @contact_detailsDataGroupId),
(@leftMenuItemId, @contact_attachmentDataGroupId),
(@leftMenuItemId, @contact_custom_fieldsDataGroupId),
(@leftMenuItemId, @contact_details_documents_datagroup_id);

SET @leftMenuScreenId := (SELECT id FROM ohrm_screen 
    WHERE action_url = 'viewEmergencyContacts' AND module_id = @pimModuleId);

INSERT INTO `ohrm_menu_item` (`menu_title`,`menu_category`, `screen_id`,
`order_hint`, `status`, `level`) VALUES
('Emergency Contacts', 'pim_left_menu', @leftMenuScreenId, 30, 1, 0);
SET @leftMenuItemId := (SELECT LAST_INSERT_ID());

-- add emergency contacts token section
INSERT INTO `ohrm_token_section` (`name`, `display_name`,`menu_id`) VALUES ('EmergencyContacts',null, @leftMenuItemId);

INSERT INTO `ohrm_menu_item_data_group` (`menu_item_id`, `data_group_id`) VALUES
(@leftMenuItemId, @emergency_contactsDataGroupId),
(@leftMenuItemId, @emergency_attachmentDataGroupId),
(@leftMenuItemId, @emergency_custom_fieldsDataGroupId);

SET @leftMenuScreenId := (SELECT id FROM ohrm_screen 
    WHERE action_url = 'viewDependents' AND module_id = @pimModuleId);
INSERT INTO `ohrm_menu_item` (`menu_title`,`menu_category`, `screen_id`,
`order_hint`, `status`, `level`) VALUES
('Dependents', 'pim_left_menu', @leftMenuScreenId, 40, 1, 0);
SET @leftMenuItemId := (SELECT LAST_INSERT_ID());
-- add Dependents token section
INSERT INTO `ohrm_token_section` (`name`, `display_name`,`menu_id`) VALUES ('Dependents',null, @leftMenuItemId);

INSERT INTO `ohrm_menu_item_data_group` (`menu_item_id`, `data_group_id`) VALUES
(@leftMenuItemId, @dependentsDataGroupId),
(@leftMenuItemId, @dependents_attachmentDataGroupId),
(@leftMenuItemId, @dependents_custom_fieldsDataGroupId);

SET @leftMenuScreenId := (SELECT id FROM ohrm_screen 
    WHERE action_url = 'viewImmigration' AND module_id = @pimModuleId);
INSERT INTO `ohrm_menu_item` (`menu_title`,`menu_category`, `screen_id`,
`order_hint`, `status`, `level`) VALUES
('Immigration', 'pim_left_menu', @leftMenuScreenId, 50, 1, 0);
SET @leftMenuItemId := (SELECT LAST_INSERT_ID());

-- add Immigration section
INSERT INTO `ohrm_token_section` (`name`, `display_name`,`menu_id`) VALUES ('Immigration',null, @leftMenuItemId);

INSERT INTO `ohrm_menu_item_data_group` (`menu_item_id`, `data_group_id`) VALUES
(@leftMenuItemId, @immigrationDataGroupId),
(@leftMenuItemId, @immigration_attachmentDataGroupId),
(@leftMenuItemId, @immigration_custom_fieldsDataGroupId);

SET @leftMenuScreenId := (SELECT id FROM ohrm_screen 
    WHERE action_url = 'viewJobHistory' AND module_id = @pimModuleId);
INSERT INTO `ohrm_menu_item` (`menu_title`,`menu_category`, `screen_id`,
`order_hint`, `status`, `level`) VALUES
('Job', 'pim_left_menu', @leftMenuScreenId, 60, 1, 0);
SET @leftMenuItemId := (SELECT LAST_INSERT_ID());
INSERT INTO `ohrm_menu_item_data_group` (`menu_item_id`, `data_group_id`) VALUES
(@leftMenuItemId, @job_history_detailsDataGroupId),
(@leftMenuItemId, @job_attachmentDataGroupId),
(@leftMenuItemId, @job_custom_fieldsDataGroupId),
(@leftMenuItemId, @employee_job_documents_datagroup_id);

SET @leftMenuScreenId := (SELECT id FROM ohrm_screen 
    WHERE action_url = 'viewSalaryHistory' AND module_id = @pimModuleId);
INSERT INTO `ohrm_menu_item` (`menu_title`,`menu_category`, `screen_id`,
`order_hint`, `status`, `level`) VALUES
('Salary', 'pim_left_menu', @leftMenuScreenId, 70, 1, 0);
SET @leftMenuItemId := (SELECT LAST_INSERT_ID());

-- add salary token section
INSERT INTO `ohrm_token_section` (`name`, `display_name`,`menu_id`) VALUES ('Salary',null, @leftMenuItemId);

INSERT INTO `ohrm_menu_item_data_group` (`menu_item_id`, `data_group_id`) VALUES
(@leftMenuItemId, @salary_history_detailsDataGroupId),
(@leftMenuItemId, @salary_attachmentDataGroupId),
(@leftMenuItemId, @salary_custom_fieldsDataGroupId),
(@leftMenuItemId, @employee_salary_documents_datagroup_id);

SET @leftMenuScreenId := (SELECT id FROM ohrm_screen
    WHERE action_url = 'viewUsTaxExemptions' AND module_id = @pimModuleId);
INSERT INTO `ohrm_menu_item` (`menu_title`,`menu_category`, `screen_id`,
`order_hint`, `status`, `level`) VALUES
('Tax Exemptions', 'pim_left_menu', @leftMenuScreenId, 75, 0, 0);
SET @leftMenuItemId := (SELECT LAST_INSERT_ID());

-- add tax token section
INSERT INTO `ohrm_token_section` (`name`, `display_name`,`menu_id`) VALUES ('TaxExemptions',null, @leftMenuItemId);

INSERT INTO `ohrm_menu_item_data_group` (`menu_item_id`, `data_group_id`) VALUES
(@leftMenuItemId, @taxExemptionsDataGroupId),
(@leftMenuItemId, @tax_attachmentDataGroupId),
(@leftMenuItemId, @tax_custom_fieldsDataGroupId);

SET @leftMenuScreenId := (SELECT id FROM ohrm_screen 
    WHERE action_url = 'viewReportToDetails' AND module_id = @pimModuleId);
INSERT INTO `ohrm_menu_item` (`menu_title`,`menu_category`, `screen_id`,
`order_hint`, `status`, `level`) VALUES
('Report-to', 'pim_left_menu', @leftMenuScreenId, 80, 1, 0);
SET @leftMenuItemId := (SELECT LAST_INSERT_ID());

-- add report-to token section
INSERT INTO `ohrm_token_section` (`name`, `display_name`,`menu_id`) VALUES ('ReportTo',null, @leftMenuItemId);

INSERT INTO `ohrm_menu_item_data_group` (`menu_item_id`, `data_group_id`) VALUES
(@leftMenuItemId, @supervisorDataGroupId),
(@leftMenuItemId, @subordinatesDataGroupId),
(@leftMenuItemId, @report_to_attachmentDataGroupId),
(@leftMenuItemId, @report_to_custom_fieldsDataGroupId);

SET @leftMenuScreenId := (SELECT id FROM ohrm_screen 
    WHERE action_url = 'viewQualifications' AND module_id = @pimModuleId);
INSERT INTO `ohrm_menu_item` (`menu_title`,`menu_category`, `screen_id`,
`order_hint`, `status`, `level`) VALUES
('Qualifications', 'pim_left_menu', @leftMenuScreenId, 90, 1, 0);
SET @leftMenuItemId := (SELECT LAST_INSERT_ID());

-- add Qualifications token section
INSERT INTO `ohrm_token_section` (`name`, `display_name`,`menu_id`) VALUES ('Qualifications',null, @leftMenuItemId);

INSERT INTO `ohrm_menu_item_data_group` (`menu_item_id`, `data_group_id`) VALUES
(@leftMenuItemId, @qualification_workDataGroupId),
(@leftMenuItemId, @qualification_educationDataGroupId),
(@leftMenuItemId, @qualification_skillsDataGroupId),
(@leftMenuItemId, @qualification_languagesDataGroupId),
(@leftMenuItemId, @qualification_licenseDataGroupId),
(@leftMenuItemId, @qualifications_attachmentDataGroupId),
(@leftMenuItemId, @qualifications_custom_fieldsDataGroupId);

SET @leftMenuScreenId := (SELECT id FROM ohrm_screen 
    WHERE action_url = 'viewMemberships' AND module_id = @pimModuleId);

INSERT INTO `ohrm_menu_item` (`menu_title`,`menu_category`, `screen_id`,
`order_hint`, `status`, `level`) VALUES
('Memberships', 'pim_left_menu', @leftMenuScreenId, 100, 1, 0);
SET @leftMenuItemId := (SELECT LAST_INSERT_ID());

-- add Memberships token section
INSERT INTO `ohrm_token_section` (`name`, `display_name`,`menu_id`) VALUES ('Memberships',null, @leftMenuItemId);

INSERT INTO `ohrm_menu_item_data_group` (`menu_item_id`, `data_group_id`) VALUES
(@leftMenuItemId, @membershipDataGroupId),
(@leftMenuItemId, @membership_attachmentDataGroupId),
(@leftMenuItemId, @membership_custom_fieldsDataGroupId);

INSERT INTO `ohrm_screen` (`name`, `module_id`, `action_url`) VALUES
('Direct Deposit', @pimModuleId, 'viewDirectDepositDetails');
SET @leftMenuScreenId := (SELECT LAST_INSERT_ID());

INSERT INTO ohrm_user_role_screen (user_role_id, screen_id, can_read, can_create, can_update, can_delete) VALUES
(1, @leftMenuScreenId, 1, 1, 1, 1),
(2, @leftMenuScreenId, 1, 1, 1, 1),
(3, @leftMenuScreenId, 1, 1, 1, 1);

INSERT INTO `ohrm_default_permitted_screen`(`user_role_type_id`, `screen_id`) VALUES 
(1, @leftMenuScreenId),
(2, @leftMenuScreenId),
(3, @leftMenuScreenId);

INSERT INTO `ohrm_menu_item` (`menu_title`,`menu_category`, `screen_id`,
`order_hint`, `status`, `level`) VALUES
('Direct Deposit', 'pim_left_menu', @leftMenuScreenId, 110, 1, 0);
SET @leftMenuItemId := (SELECT LAST_INSERT_ID());
INSERT INTO `ohrm_menu_item_data_group` (`menu_item_id`, `data_group_id`) VALUES
(@leftMenuItemId, @salary_history_detailsDataGroupId);

-- add direct deposit section
INSERT INTO `ohrm_token_section` (`name`, `display_name`,`menu_id`) VALUES ('DirectDeposit',null, @leftMenuItemId);

SET @leftMenuScreenId := (SELECT id FROM ohrm_screen 
    WHERE action_url = 'viewEmployeeSocialMediaDetails' AND module_id = @pimModuleId);
INSERT INTO `ohrm_menu_item` (`menu_title`,`menu_category`, `screen_id`,
`order_hint`, `status`) VALUES
('Social Media Details', 'pim_left_menu', @leftMenuScreenId, 10, 1);
SET @leftMenuItemId := (SELECT LAST_INSERT_ID());

-- add Social Media token section
INSERT INTO `ohrm_token_section` (`name`, `display_name`,`menu_id`) VALUES ('SocialMedia',null, @leftMenuItemId);


SET @leftMenuScreenId := (SELECT id FROM ohrm_screen
    WHERE action_url = 'viewCreatedDocuments' AND module_id = @pimModuleId);
INSERT INTO `ohrm_menu_item` (`menu_title`,`menu_category`, `screen_id`,
                              `order_hint`, `status`) VALUES
    ('Created Documents', 'pim_left_menu', @leftMenuScreenId, 10, 1);

INSERT INTO `ohrm_menu_item_data_group` (`menu_item_id`, `data_group_id`) VALUES
(@leftMenuItemId, @social_media_fieldsDataGroupId);

-- HOD left menu permissions

SET @hodid := (SELECT `id` FROM `ohrm_user_role` WHERE `name` = 'HeadOfDepartment');


-- View Employee List
SELECT id INTO @viewPimModuleScreenid FROM ohrm_screen WHERE `action_url` = 'viewPimModule';
SELECT id INTO @viewEmployeeListScreenid FROM ohrm_screen WHERE `action_url` = 'viewEmployeeList';
SELECT id INTO @viewAuthorizationEmployeeListScreenid FROM ohrm_screen WHERE `action_url` = 'viewAuthorizationEmployeeList';
-- left menu screens
SELECT id INTO @viewEmployeeProfileScreenid FROM ohrm_screen WHERE `action_url` = 'viewEmployeeProfile';
SELECT id INTO @viewPersonalDetailsScreenid FROM ohrm_screen WHERE `action_url` = 'viewPersonalDetails';
SELECT id INTO @contactDetailsScreenid FROM ohrm_screen WHERE `action_url` = 'contactDetails';
SELECT id INTO @viewEmergencyContactsScreenid FROM ohrm_screen WHERE `action_url` = 'viewEmergencyContacts';
SELECT id INTO @viewDependentsScreenid FROM ohrm_screen WHERE `action_url` = 'viewDependents';
SELECT id INTO @viewImmigrationScreenid FROM ohrm_screen WHERE `action_url` = 'viewImmigration';
SELECT id INTO @viewJobHistoryScreenid FROM ohrm_screen WHERE `action_url` = 'viewJobHistory';
SELECT id INTO @viewSalaryHistoryScreenid FROM ohrm_screen WHERE `action_url` = 'viewSalaryHistory';
SELECT id INTO @viewReportToDetailsScreenid FROM ohrm_screen WHERE `action_url` = 'viewReportToDetails';
SELECT id INTO @viewQualificationsScreenid FROM ohrm_screen WHERE `action_url` = 'viewQualifications';
SELECT id INTO @viewMembershipsScreenid FROM ohrm_screen WHERE `action_url` = 'viewMemberships';
SELECT id INTO @viewUsTaxExemptionsScreenid FROM ohrm_screen WHERE `action_url` = 'viewUsTaxExemptions';
SELECT id INTO @viewDirectDepositDetailsScreenid FROM ohrm_screen WHERE `action_url` = 'viewDirectDepositDetails';

-- left menu data groups
SELECT id INTO @personal_information_DataGroupid FROM `ohrm_data_group` WHERE `name` = 'personal_information';
SELECT id INTO @personal_attachment_DataGroupid FROM `ohrm_data_group` WHERE `name` = 'personal_attachment';
SELECT id INTO @personal_custom_fields_DataGroupid FROM `ohrm_data_group` WHERE `name` = 'personal_custom_fields';
SELECT id INTO @contact_details_DataGroupid FROM `ohrm_data_group` WHERE `name` = 'contact_details';
SELECT id INTO @contact_attachment_DataGroupid FROM `ohrm_data_group` WHERE `name` = 'contact_attachment';
SELECT id INTO @contact_custom_fields_DataGroupid FROM `ohrm_data_group` WHERE `name` = 'contact_custom_fields';
SELECT id INTO @emergency_contacts_DataGroupid FROM `ohrm_data_group` WHERE `name` = 'emergency_contacts';
SELECT id INTO @emergency_attachment_DataGroupid FROM `ohrm_data_group` WHERE `name` = 'emergency_attachment';
SELECT id INTO @emergency_custom_fields_DataGroupid FROM `ohrm_data_group` WHERE `name` = 'emergency_custom_fields';
SELECT id INTO @dependents_DataGroupid FROM `ohrm_data_group` WHERE `name` = 'dependents';
SELECT id INTO @dependents_custom_fields_DataGroupid FROM `ohrm_data_group` WHERE `name` = 'dependents_custom_fields';
SELECT id INTO @dependents_attachment_custom_fields_DataGroupid FROM `ohrm_data_group` WHERE `name` = 'dependents_attachment';
SELECT id INTO @immigration_DataGroupid FROM `ohrm_data_group` WHERE `name` = 'immigration';
SELECT id INTO @immigration_attachment_DataGroupid FROM `ohrm_data_group` WHERE `name` = 'immigration_attachment';
SELECT id INTO @immigration_custom_fields_DataGroupid FROM `ohrm_data_group` WHERE `name` = 'immigration_custom_fields';
SELECT id INTO @job_history_details_DataGroupid FROM `ohrm_data_group` WHERE `name` = 'job_history_details';
SELECT id INTO @job_attachment_DataGroupid FROM `ohrm_data_group` WHERE `name` = 'job_attachment';
SELECT id INTO @job_custom_fields_DataGroupid FROM `ohrm_data_group` WHERE `name` = 'job_custom_fields';
SELECT id INTO @salary_history_details_DataGroupid FROM `ohrm_data_group` WHERE `name` = 'salary_history_details';
SELECT id INTO @salary_attachment_DataGroupid FROM `ohrm_data_group` WHERE `name` = 'salary_attachment';
SELECT id INTO @salary_custom_fields_DataGroupid FROM `ohrm_data_group` WHERE `name` = 'salary_custom_fields';
SELECT id INTO @tax_exemptions_DataGroupid FROM `ohrm_data_group` WHERE `name` = 'tax_exemptions';
SELECT id INTO @tax_attachment_DataGroupid FROM `ohrm_data_group` WHERE `name` = 'tax_attachment';
SELECT id INTO @tax_custom_fields_DataGroupid FROM `ohrm_data_group` WHERE `name` = 'tax_custom_fields';
SELECT id INTO @supervisor_DataGroupid FROM `ohrm_data_group` WHERE `name` = 'supervisor';
SELECT id INTO @subordinates_DataGroupid FROM `ohrm_data_group` WHERE `name` = 'subordinates';
SELECT id INTO @report_to_attachment_DataGroupid FROM `ohrm_data_group` WHERE `name` = 'report-to_attachment';
SELECT id INTO @report_to_custom_fields_DataGroupid FROM `ohrm_data_group` WHERE `name` = 'report-to_custom_fields';
SELECT id INTO @qualification_work_DataGroupid FROM `ohrm_data_group` WHERE `name` = 'qualification_work';
SELECT id INTO @qualification_education_DataGroupid FROM `ohrm_data_group` WHERE `name` = 'qualification_education';
SELECT id INTO @qualification_skills_DataGroupid FROM `ohrm_data_group` WHERE `name` = 'qualification_skills';
SELECT id INTO @qualification_languages_DataGroupid FROM `ohrm_data_group` WHERE `name` = 'qualification_languages';
SELECT id INTO @qualification_license_DataGroupid FROM `ohrm_data_group` WHERE `name` = 'qualification_license';
SELECT id INTO @qualifications_attachment_DataGroupid FROM `ohrm_data_group` WHERE `name` = 'qualifications_attachment';
SELECT id INTO @qualifications_custom_fields_DataGroupid FROM `ohrm_data_group` WHERE `name` = 'qualifications_custom_fields';
SELECT id INTO @membership_DataGroupid FROM `ohrm_data_group` WHERE `name` = 'membership';
SELECT id INTO @membership_attachment_DataGroupid FROM `ohrm_data_group` WHERE `name` = 'membership_attachment';
SELECT id INTO @membership_custom_fields_DataGroupid FROM `ohrm_data_group` WHERE `name` = 'membership_custom_fields';
SELECT id INTO @photograph_DataGroupid FROM `ohrm_data_group` WHERE `name` = 'photograph';


INSERT INTO  `ohrm_user_role_screen` (
`id` ,
`user_role_id` ,
`screen_id` ,
`can_read` ,
`can_create` ,
`can_update` ,
`can_delete`
)
VALUES
(NULL ,  @hodid ,  @viewEmployeeListScreenid,  '1',  '1',  '1',  '1'),
(NULL ,  @hodid ,  @viewAuthorizationEmployeeListScreenid,  '1',  '1',  '1',  '1'),
(NULL ,  @hodid ,  @viewPimModuleScreenid,  '1',  '1',  '1',  '1'),

(NULL ,  @hodid ,  @viewEmployeeProfileScreenid,  '1',  '1',  '1',  '1'),
(NULL ,  @hodid ,  @viewPersonalDetailsScreenid,  '1',  '1',  '1',  '1'),
(NULL ,  @hodid ,  @contactDetailsScreenid,  '1',  '1',  '1',  '1'),
(NULL ,  @hodid ,  @viewEmergencyContactsScreenid,  '1',  '1',  '1',  '1'),
(NULL ,  @hodid ,  @viewDependentsScreenid,  '1',  '1',  '1',  '1'),
(NULL ,  @hodid ,  @viewImmigrationScreenid,  '1',  '1',  '1',  '1'),
(NULL ,  @hodid ,  @viewJobHistoryScreenid,  '1',  '1',  '1',  '1'),
(NULL ,  @hodid ,  @viewSalaryHistoryScreenid,  '1',  '1',  '1',  '1'),
(NULL ,  @hodid ,  @viewReportToDetailsScreenid,  '1',  '1',  '1',  '1'),
(NULL ,  @hodid ,  @viewQualificationsScreenid,  '1',  '1',  '1',  '1'),
(NULL ,  @hodid ,  @viewMembershipsScreenid,  '1',  '1',  '1',  '1'),
(NULL ,  @hodid ,  @viewUsTaxExemptionsScreenid,  '1',  '1',  '1',  '1'),
(NULL ,  @hodid ,  @viewDirectDepositDetailsScreenid,  '1',  '1',  '1',  '1');


INSERT INTO `ohrm_user_role_data_group` (`id`, `user_role_id`, `data_group_id`, `can_read`, `can_create`, `can_update`, `can_delete`, `self`)
VALUES
(NULL, @hodid , @personal_information_DataGroupid, '1', '0', '1', '0', '0'),
(NULL, @hodid , @personal_attachment_DataGroupid, '1', '1', '1', '1', '0'),
(NULL, @hodid , @personal_custom_fields_DataGroupid, '1', '0', '1', '0', '0'),
(NULL, @hodid , @personal_custom_fields_DataGroupid, '1', '0', '1', '0', '0'),
(NULL, @hodid , @contact_details_DataGroupid, '1', '0', '1', '0', '0'),
(NULL, @hodid , @contact_attachment_DataGroupid, '1', '1', '1', '1', '0'),
(NULL, @hodid , @contact_custom_fields_DataGroupid, '1', '0', '1', '0', '0'),
(NULL, @hodid , @emergency_contacts_DataGroupid, '1', '1', '1', '1', '0'),
(NULL, @hodid , @emergency_attachment_DataGroupid, '1', '1', '1', '1', '0'),
(NULL, @hodid , @emergency_custom_fields_DataGroupid, '1', '0', '1', '0', '0'),
(NULL, @hodid , @dependents_DataGroupid, '1', '1', '1', '1', '0'),
(NULL, @hodid , @dependents_custom_fields_DataGroupid, '1', '0', '1', '0', '0'),
(NULL, @hodid , @dependents_attachment_custom_fields_DataGroupid, '1', '1', '1', '1', '0'),
(NULL, @hodid , @immigration_DataGroupid, '1', '1', '1', '1', '0'),
(NULL, @hodid , @immigration_attachment_DataGroupid, '1', '1', '1', '1', '0'),
(NULL, @hodid , @immigration_custom_fields_DataGroupid, '1', '0', '1', '0', '0'),
(NULL, @hodid , @job_history_details_DataGroupid, '1', '0', '0', '0', '0'),
(NULL, @hodid , @job_attachment_DataGroupid, '1', '0', '0', '0', '0'),
(NULL, @hodid , @job_custom_fields_DataGroupid, '1', '0', '0', '0', '0'),
(NULL, @hodid , @salary_history_details_DataGroupid, '0', '0', '0', '0', '0'),
(NULL, @hodid , @salary_attachment_DataGroupid, '0', '0', '0', '0', '0'),
(NULL, @hodid , @salary_custom_fields_DataGroupid, '0', '0', '0', '0', '0'),
(NULL, @hodid , @tax_exemptions_DataGroupid, '1', '0', '0', '0', '0'),
(NULL, @hodid , @tax_attachment_DataGroupid, '1', '0', '0', '0', '0'),
(NULL, @hodid , @tax_custom_fields_DataGroupid, '1', '0', '0', '0', '0'),
(NULL, @hodid , @supervisor_DataGroupid, '1', '0', '0', '0', '0'),
(NULL, @hodid , @subordinates_DataGroupid, '1', '0', '0', '0', '0'),
(NULL, @hodid , @report_to_attachment_DataGroupid, '1', '0', '0', '0', '0'),
(NULL, @hodid , @report_to_custom_fields_DataGroupid, '1', '0', '0', '0', '0'),
(NULL, @hodid , @qualification_work_DataGroupid, '1', '1', '1', '1', '0'),
(NULL, @hodid , @qualification_education_DataGroupid, '1', '1', '1', '1', '0'),
(NULL, @hodid , @qualification_skills_DataGroupid, '1', '1', '1', '1', '0'),
(NULL, @hodid , @qualification_languages_DataGroupid, '1', '1', '1', '1', '0'),
(NULL, @hodid , @qualification_license_DataGroupid, '1', '1', '1', '1', '0'),
(NULL, @hodid , @qualifications_attachment_DataGroupid, '1', '1', '1', '1', '0'),
(NULL, @hodid , @qualifications_custom_fields_DataGroupid, '1', '0', '1', '0', '0'),
(NULL, @hodid , @membership_DataGroupid, '1', '1', '1', '1', '0'),
(NULL, @hodid , @membership_attachment_DataGroupid, '1', '1', '1', '1', '0'),
(NULL, @hodid , @membership_custom_fields_DataGroupid, '1', '0', '1', '0', '0'),
(NULL, @hodid , @photograph_DataGroupid, '1', '0', '1', '1', '0');


UPDATE `ohrm_menu_item` SET `uisref`= 'pim.employees.profile.profile', `image_name` = 'ohrm_pim' WHERE `ohrm_menu_item`.`menu_title` ='Profile' AND `ohrm_menu_item`.`menu_category` = 'pim_left_menu';

UPDATE `ohrm_menu_item` SET `uisref`= 'pim.employees.profile.personal_details', `image_name` = 'ohrm_pim' WHERE `ohrm_menu_item`.`menu_title` ='Personal Details' AND `ohrm_menu_item`.`menu_category` = 'pim_left_menu';

UPDATE `ohrm_menu_item` SET `uisref`= 'pim.employees.profile.contact_details',`image_name` = 'ohrm_contact' WHERE `ohrm_menu_item`.`menu_title` ='Contact Details' AND `ohrm_menu_item`.`menu_category` = 'pim_left_menu';

UPDATE `ohrm_menu_item` SET `uisref`= 'pim.employees.profile.social_media', `image_name` = 'ohrm_social_media', `order_hint` = 25 WHERE `ohrm_menu_item`.`menu_title` ='Social Media Details' AND `ohrm_menu_item`.`menu_category` = 'pim_left_menu';

UPDATE `ohrm_menu_item` SET `uisref`= 'pim.employees.profile.created_documents', `order_hint` = 26 WHERE `ohrm_menu_item`.`menu_title` ='Created Documents' AND `ohrm_menu_item`.`menu_category` = 'pim_left_menu';

UPDATE `ohrm_menu_item` SET `uisref`= 'pim.employees.profile.emergency_contact', `image_name` = 'ohrm_emergency_contacts' WHERE `ohrm_menu_item`.`menu_title` ='Emergency Contacts' AND `ohrm_menu_item`.`menu_category` = 'pim_left_menu';

UPDATE `ohrm_menu_item` SET `uisref`= 'pim.employees.profile.dependent', `image_name` = 'ohrm_dependents' WHERE `ohrm_menu_item`.`menu_title` ='Dependents' AND `ohrm_menu_item`.`menu_category` = 'pim_left_menu';
              
UPDATE `ohrm_menu_item` SET `uisref`= 'pim.employees.profile.immigration', `image_name` = 'ohrm_immigration' WHERE `ohrm_menu_item`.`menu_title` ='Immigration' AND `ohrm_menu_item`.`menu_category` = 'pim_left_menu';

UPDATE `ohrm_menu_item` SET `uisref`= 'pim.employees.profile.tax_exemptions', `image_name` = 'ohrm_tax' WHERE `ohrm_menu_item`.`menu_title` ='Tax Exemptions' AND `ohrm_menu_item`.`menu_category` = 'pim_left_menu';

UPDATE `ohrm_menu_item` SET `uisref`= 'pim.employees.profile.report_to', `image_name` = 'ohrm_report_to' WHERE `ohrm_menu_item`.`menu_title` ='Report-To' AND `ohrm_menu_item`.`menu_category` = 'pim_left_menu';

UPDATE `ohrm_menu_item` SET `uisref`= 'pim.employees.profile.qualifications', `image_name` = 'ohrm_qualifications' WHERE `ohrm_menu_item`.`menu_title` ='Qualifications' AND `ohrm_menu_item`.`menu_category` = 'pim_left_menu';

UPDATE `ohrm_menu_item` SET `uisref`= 'pim.employees.profile.memberships', `image_name` = 'ohrm_memberships' WHERE `ohrm_menu_item`.`menu_title` ='Memberships' AND `ohrm_menu_item`.`menu_category` = 'pim_left_menu';

UPDATE `ohrm_menu_item` SET `uisref`= 'pim.employees.profile.job', `image_name` = 'ohrm_jobs' , `order_hint` = 14 WHERE `ohrm_menu_item`.`menu_title` ='Job' AND `ohrm_menu_item`.`menu_category` = 'pim_left_menu';

UPDATE `ohrm_menu_item` SET `uisref`= 'pim.employees.profile.salary',  `image_name` = 'ohrm_salary' , `order_hint` = 15 WHERE `ohrm_menu_item`.`menu_title` ='Salary' AND `ohrm_menu_item`.`menu_category` = 'pim_left_menu';

UPDATE `ohrm_menu_item` SET `uisref`= 'pim.employees.profile.direct_deposit', `image_name` = 'ohrm_direct_deposit' WHERE `ohrm_menu_item`.`menu_title` ='Direct Deposit' AND `ohrm_menu_item`.`menu_category` = 'pim_left_menu';


SET @salary_history_DataGroupId := (SELECT `id` FROM `ohrm_data_group` WHERE `name`= 'salary_history');
SET @leftMenuItemId :=(SELECT `id` FROM `ohrm_menu_item` WHERE `menu_title`='Salary');

INSERT INTO `ohrm_menu_item_data_group` (`menu_item_id`, `data_group_id`) VALUES
(@leftMenuItemId, @salary_history_DataGroupId);

SET @job_history_DataGroupId := (SELECT `id` FROM `ohrm_data_group` WHERE `name`= 'job_history');
SET @leftMenuItemId := (SELECT `id` FROM `ohrm_menu_item` WHERE `menu_title`='Job' AND `menu_category`='pim_left_menu');

-- add job token section
INSERT INTO `ohrm_token_section` (`name`, `display_name`,`menu_id`) VALUES ('Job',null, @leftMenuItemId);

INSERT INTO `ohrm_menu_item_data_group` (`menu_item_id`, `data_group_id`) VALUES (@leftMenuItemId, @job_history_DataGroupId);

SET @created_documents_menu_id := (SELECT id FROM `ohrm_menu_item` WHERE `menu_title` = 'Created Documents' AND `uisref` = 'pim.employees.profile.created_documents');
INSERT INTO `ohrm_menu_item_data_group` (`menu_item_id`, `data_group_id`) VALUES
    (@created_documents_menu_id, @document_templates_DataGroupId);