INSERT INTO `ohrm_module` (`name`, `status`) VALUES ('leaveNotification', 1);

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

INSERT INTO ohrm_screen (`name`, `module_id`, `action_url`) VALUES
('Notifications', @module_id, 'viewLeaveNotifications');

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

SET @configure_screen_id := (SELECT `id` FROM ohrm_menu_item WHERE `menu_title` = 'Configure' AND `level` = 2); 

INSERT INTO ohrm_menu_item (`menu_title`, `screen_id`, `parent_id`, `level`, `order_hint`, `url_extras`, `status`) VALUES
('Notifications', @view_leave_notifications_screen_id, @configure_screen_id, 3, 1000, '', 1);

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

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

CREATE TABLE IF NOT EXISTS ohrm_employee_on_leave_notification (id BIGINT AUTO_INCREMENT, name VARCHAR(100) NOT NULL, send_on BIGINT, on_next BIGINT, date_created DATE, is_enable TINYINT(1) DEFAULT '1', mail_subject VARCHAR(100), notified_to_job_title_id BIGINT, notified_to_sub_unit_id BIGINT, notified_to_location_id BIGINT, applicable_to_job_title_id BIGINT, applicable_to_sub_unit_id BIGINT, applicable_to_location_id BIGINT, PRIMARY KEY(id)) ENGINE = INNODB;

