INSERT INTO `ohrm_token`(`name`, `display_name`, `class_name`, `entity_name`, `value_getters`, `data_group_id`, `is_date`, `localize`,`parameters`) VALUES
('auditTrail.employeeName', 'AuditTrail Employee Name', 'AuditDescriptionEmployeeNameToken', null, null, null, 0, 0, null);

SET @auditTrail_employee_name_token_id  := (SELECT LAST_INSERT_ID());

SET @audittrail_module_id := (SELECT `id` FROM `ohrm_module` WHERE `name` = 'audittrail');

INSERT INTO `ohrm_restricted_module_token` (`token_id`, `restricted_module`) VALUES (@auditTrail_employee_name_token_id, @audittrail_module_id);

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

SET @view_audittrail_screen := (SELECT id FROM ohrm_screen WHERE action_url = 'viewAuditTrail');
SET @admin_audit_trail_data_group_id = (SELECT `id` FROM ohrm_data_group WHERE `name` = 'admin_audit_trail');
SET @admin_user_role_type = (SELECT `id` FROM `ohrm_user_role_type` WHERE `name`='Admin');

INSERT INTO `ohrm_data_group_screen` (`id`, `data_group_id`, `screen_id`, `permission`, `self`) VALUES (NULL, @admin_audit_trail_data_group_id, @view_audittrail_screen, '1', '0');

INSERT INTO `ohrm_user_role_screen` (`id`, `user_role_id`, `screen_id`, `can_read`, `can_create`, `can_update`, `can_delete`) VALUES (NULL, @hod_id, @view_audittrail_screen, 1, 0, 0, 0);

INSERT INTO `ohrm_user_role_data_group` (`id`, `user_role_id`, `data_group_id`, `can_read`, `can_create`, `can_update`, `can_delete`, `self`, `restriction_id`) VALUES (NULL, @hod_id ,@admin_audit_trail_data_group_id, 1, 0, 0, 0, 0, NULL);

INSERT INTO `ohrm_user_role_type_data_group` (`user_role_type_id`, `data_group_id`, `can_read`, `can_create`, `can_update`, `can_delete`) VALUES (@admin_user_role_type, @admin_audit_trail_data_group_id, 1, 0, 0, 0);
