INSERT INTO `ohrm_audittrail_module` (`name`) VALUES ('Travel and Expense');
SET @expense_module_id := (SELECT `id` FROM `ohrm_audittrail_module` WHERE `name`='Travel and Expense');

DROP TABLE IF EXISTS `ohrm_audittrail_expense_travel_request_trail`;
CREATE TABLE `ohrm_audittrail_expense_travel_request_trail` (
  `id` INT NOT NULL AUTO_INCREMENT,
  `action_time` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  `action_owner_id` varchar(6),
  `action_owner_name` VARCHAR(300),
  `version_id` INT NOT NULL DEFAULT 0,
  `action` varchar(255) NOT NULL,
  `affected_entity_id` VARCHAR(20),
  `affected_entity_name` VARCHAR(300) NOT NULL DEFAULT '',
  `action_description` VARCHAR(3000) CHARSET UTF8,
  `app_id` INT DEFAULT NULL,
  `app_name` VARCHAR(1000) DEFAULT NULL,
  `screen_name` VARCHAR(1000) DEFAULT NULL,
  PRIMARY KEY (`id`),
  INDEX audit_expense_travel_request_trail_idx_app_id (app_id),
  INDEX audit_expense_travel_request_trail_idx_screen_name (screen_name)

) ENGINE=InnoDB DEFAULT CHARSET=utf8;

INSERT INTO `ohrm_audittrail_section` (`name`, `description`, `affected_entity`, `module_id`) VALUES
('TravelRequest', 'Travel Request', 'Employee', @expense_module_id);

SET @travel_request_section_id := (SELECT `id` FROM `ohrm_audittrail_section` WHERE `name` = 'TravelRequest' AND `module_id` = @expense_module_id);
SET @travel_request_datagroup_id := (SELECT `id` FROM `ohrm_data_group` WHERE `name`='expense_estimate_request');

INSERT INTO `ohrm_datagroup_audittrail_section`(`audit_section_id`,`datagroup_id`,`permission`) VALUES
(@travel_request_section_id, @travel_request_datagroup_id, 1);

INSERT INTO `ohrm_audittrail_section_actions` (`section_id`, `action`, `description`) VALUES
(@travel_request_section_id, 'Create', 'Create');

INSERT INTO `ohrm_audittrail_section_actions` (`section_id`, `action`, `description`) VALUES
(@travel_request_section_id, 'Save', 'Save');

INSERT INTO `ohrm_audittrail_section_actions` (`section_id`, `action`, `description`) VALUES
(@travel_request_section_id, 'Submit', 'Submit');

INSERT INTO `ohrm_audittrail_section_actions` (`section_id`, `action`, `description`) VALUES
(@travel_request_section_id, 'Assign', 'Assign');

INSERT INTO `ohrm_audittrail_section_actions` (`section_id`, `action`, `description`) VALUES
(@travel_request_section_id, 'Approve', 'Approve');

INSERT INTO `ohrm_audittrail_section_actions` (`section_id`, `action`, `description`) VALUES
(@travel_request_section_id, 'Reject', 'Reject');

INSERT INTO `ohrm_audittrail_section_actions` (`section_id`, `action`, `description`) VALUES
(@travel_request_section_id, 'Cancel', 'Cancel');

INSERT INTO `ohrm_audittrail_section_actions` (`section_id`, `action`, `description`) VALUES
(@travel_request_section_id, 'Delete', 'Delete');