SET @admin_role_id := (SELECT `id` FROM ohrm_user_role WHERE `name` = 'Admin');
SET @supervisor_role_id := (SELECT `id` FROM ohrm_user_role WHERE `name` = 'Supervisor');

SET @module_id := (SELECT `id` FROM `ohrm_module` WHERE `name` = 'time');

INSERT INTO ohrm_screen (`name`, `module_id`, `action_url`) VALUES
('Export Attendance Data to CSV', @module_id, 'viewAttendanceDataExtract');

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

SET @attendance_menu_id := (SELECT `id` FROM ohrm_menu_item WHERE `menu_title` = 'Attendance' AND `level` = 2); 
SET @menu_enabled := (SELECT `status` FROM ohrm_menu_item WHERE `menu_title` = 'Employee Records' AND `level` = 3 AND `parent_id` = @attendance_menu_id); 

INSERT INTO ohrm_menu_item (`menu_title`, `screen_id`, `parent_id`, `level`, `order_hint`, `url_extras`, `status`) VALUES
('Export To CSV', @export_csv_screen_id, @attendance_menu_id, 3, 500, '', @menu_enabled);

INSERT INTO ohrm_user_role_screen (user_role_id, screen_id, can_read, can_create, can_update, can_delete) VALUES
(@admin_role_id, @export_csv_screen_id, 1, 0, 0, 0),
(@supervisor_role_id, @export_csv_screen_id, 1, 0, 0, 0);
