INSERT INTO `ohrm_audittrail_all` (action_time, action_owner_id, action_owner_name, action, action_description, version_id, affected_entity_id, affected_entity_name, section)
SELECT ati.action_time, ati.action_owner_id, ati.action_owner_name, ati.action,ati.action_description,ati.version_id,ati.affected_entity_id,ati.affected_entity_name,'Contact Information' FROM `ohrm_audittrail_pim_contact_info_trail` AS ati;

INSERT INTO `ohrm_audittrail_all` (action_time, action_owner_id, action_owner_name, action, action_description, version_id, affected_entity_id, affected_entity_name, section)
SELECT ati.action_time, ati.action_owner_id, ati.action_owner_name, ati.action,ati.action_description,ati.version_id,ati.affected_entity_id,ati.affected_entity_name,'Dependent' FROM `ohrm_audittrail_pim_dependents_trail` AS ati;

INSERT INTO `ohrm_audittrail_all` (action_time, action_owner_id, action_owner_name, action, action_description, version_id, affected_entity_id, affected_entity_name, section)
SELECT ati.action_time, ati.action_owner_id, ati.action_owner_name, ati.action,ati.action_description,ati.version_id,ati.affected_entity_id,ati.affected_entity_name,'Emergency Contacts' FROM `ohrm_audittrail_pim_emergency_contacts_trail` AS ati;

INSERT INTO `ohrm_audittrail_all` (action_time, action_owner_id, action_owner_name, action, action_description, version_id, affected_entity_id, affected_entity_name, section)
SELECT ati.action_time, ati.action_owner_id, ati.action_owner_name, ati.action,ati.action_description,ati.version_id,ati.affected_entity_id,ati.affected_entity_name,'Membership' FROM `ohrm_audittrail_pim_emp_member_detail_trail` AS ati;

INSERT INTO `ohrm_audittrail_all` (action_time, action_owner_id, action_owner_name, action, action_description, version_id, affected_entity_id, affected_entity_name, section)
SELECT ati.action_time, ati.action_owner_id, ati.action_owner_name, ati.action,ati.action_description,ati.version_id,ati.affected_entity_id,ati.affected_entity_name,'Job Details' FROM `ohrm_audittrail_pim_job_record_trail` AS ati;

INSERT INTO `ohrm_audittrail_all` (action_time, action_owner_id, action_owner_name, action, action_description, version_id, affected_entity_id, affected_entity_name, section)
SELECT ati.action_time, ati.action_owner_id, ati.action_owner_name, ati.action,ati.action_description,ati.version_id,ati.affected_entity_id,ati.affected_entity_name,'Immigration' FROM `ohrm_audittrail_pim_passport_trail` AS ati;

INSERT INTO `ohrm_audittrail_all` (action_time, action_owner_id, action_owner_name, action, action_description, version_id, affected_entity_id, affected_entity_name, section)
SELECT ati.action_time, ati.action_owner_id, ati.action_owner_name, ati.action,ati.action_description,ati.version_id,ati.affected_entity_id,ati.affected_entity_name,'Personal Details' FROM `ohrm_audittrail_pim_personal_details_trail` AS ati;

INSERT INTO `ohrm_audittrail_all` (action_time, action_owner_id, action_owner_name, action, action_description, version_id, affected_entity_id, affected_entity_name, section)
SELECT ati.action_time, ati.action_owner_id, ati.action_owner_name, ati.action,ati.action_description,ati.version_id,ati.affected_entity_id,ati.affected_entity_name,'Qualification' FROM `ohrm_audittrail_pim_qualification_trail` AS ati;

INSERT INTO `ohrm_audittrail_all` (action_time, action_owner_id, action_owner_name, action, action_description, version_id, affected_entity_id, affected_entity_name, section)
SELECT ati.action_time, ati.action_owner_id, ati.action_owner_name, ati.action,ati.action_description,ati.version_id,ati.affected_entity_id,ati.affected_entity_name,'Supervisor/Subordinate' FROM `ohrm_audittrail_pim_reportto_trail` AS ati;

INSERT INTO `ohrm_audittrail_all` (action_time, action_owner_id, action_owner_name, action, action_description, version_id, affected_entity_id, affected_entity_name, section)
SELECT ati.action_time, ati.action_owner_id, ati.action_owner_name, ati.action,ati.action_description,ati.version_id,ati.affected_entity_id,ati.affected_entity_name,'Tax Exemptions' FROM `ohrm_audittrail_pim_us_tax_trail` AS ati;

INSERT INTO `ohrm_audittrail_all` (action_time, action_owner_id, action_owner_name, action, action_description, version_id, affected_entity_id, affected_entity_name, section)
SELECT ati.action_time, ati.action_owner_id, ati.action_owner_name, ati.action,ati.action_description,ati.version_id,ati.affected_entity_id,ati.affected_entity_name,'Employee' FROM `ohrm_audittrail_pim_employee_trail` AS ati;

INSERT INTO `ohrm_audittrail_all` (action_time, action_owner_id, action_owner_name, action, action_description, version_id, affected_entity_id, affected_entity_name, section)
SELECT ati.action_time, ati.action_owner_id, ati.action_owner_name, ati.action,ati.action_description,ati.version_id,ati.affected_entity_id,ati.affected_entity_name,'PIM Tab' FROM `ohrm_audittrail_pim_tab_trail` AS ati;

INSERT INTO `ohrm_audittrail_all` (action_time, action_owner_id, action_owner_name, action, action_description, version_id, affected_entity_id, affected_entity_name, section)
SELECT ati.action_time, ati.action_owner_id, ati.action_owner_name, ati.action,ati.action_description,ati.version_id,ati.affected_entity_id,ati.affected_entity_name,'Custom Field Section' FROM `ohrm_audittrail_pim_custom_field_section_trail` AS ati;

INSERT INTO `ohrm_audittrail_all` (action_time, action_owner_id, action_owner_name, action, action_description, version_id, affected_entity_id, affected_entity_name, section)
SELECT ati.action_time, ati.action_owner_id, ati.action_owner_name, ati.action,ati.action_description,ati.version_id,ati.affected_entity_id,ati.affected_entity_name,'Custom Field' FROM `ohrm_audittrail_pim_custom_field_trail` AS ati;

INSERT INTO `ohrm_audittrail_all` (action_time, action_owner_id, action_owner_name, action, action_description, version_id, affected_entity_id, affected_entity_name, section)
SELECT ati.action_time, ati.action_owner_id, ati.action_owner_name, ati.action,ati.action_description,ati.version_id,ati.affected_entity_id,ati.affected_entity_name,'Personal Details Custom Fields' FROM `ohrm_audittrail_pim_personal_custom_field_trail` AS ati;

INSERT INTO `ohrm_audittrail_all` (action_time, action_owner_id, action_owner_name, action, action_description, version_id, affected_entity_id, affected_entity_name, section)
SELECT ati.action_time, ati.action_owner_id, ati.action_owner_name, ati.action,ati.action_description,ati.version_id,ati.affected_entity_id,ati.affected_entity_name,'Emergency Custom Fields' FROM `ohrm_audittrail_pim_emergency_custom_field_trail` AS ati;

INSERT INTO `ohrm_audittrail_all` (action_time, action_owner_id, action_owner_name, action, action_description, version_id, affected_entity_id, affected_entity_name, section)
SELECT ati.action_time, ati.action_owner_id, ati.action_owner_name, ati.action,ati.action_description,ati.version_id,ati.affected_entity_id,ati.affected_entity_name,'Contact Custom Fields' FROM `ohrm_audittrail_pim_contact_custom_field_trail` AS ati;

INSERT INTO `ohrm_audittrail_all` (action_time, action_owner_id, action_owner_name, action, action_description, version_id, affected_entity_id, affected_entity_name, section)
SELECT ati.action_time, ati.action_owner_id, ati.action_owner_name, ati.action,ati.action_description,ati.version_id,ati.affected_entity_id,ati.affected_entity_name,'Dependent Custom Fields' FROM `ohrm_audittrail_pim_dependents_custom_field_trail` AS ati;

INSERT INTO `ohrm_audittrail_all` (action_time, action_owner_id, action_owner_name, action, action_description, version_id, affected_entity_id, affected_entity_name, section)
SELECT ati.action_time, ati.action_owner_id, ati.action_owner_name, ati.action,ati.action_description,ati.version_id,ati.affected_entity_id,ati.affected_entity_name,'Immigration Custom Fields' FROM `ohrm_audittrail_pim_immigration_custom_field_trail` AS ati;

INSERT INTO `ohrm_audittrail_all` (action_time, action_owner_id, action_owner_name, action, action_description, version_id, affected_entity_id, affected_entity_name, section)
SELECT ati.action_time, ati.action_owner_id, ati.action_owner_name, ati.action,ati.action_description,ati.version_id,ati.affected_entity_id,ati.affected_entity_name,'Job Custom Fields' FROM `ohrm_audittrail_pim_job_custom_field_trail` AS ati;

INSERT INTO `ohrm_audittrail_all` (action_time, action_owner_id, action_owner_name, action, action_description, version_id, affected_entity_id, affected_entity_name, section)
SELECT ati.action_time, ati.action_owner_id, ati.action_owner_name, ati.action,ati.action_description,ati.version_id,ati.affected_entity_id,ati.affected_entity_name,'Salary Custom Fields' FROM `ohrm_audittrail_pim_salary_custom_field_trail` AS ati;

INSERT INTO `ohrm_audittrail_all` (action_time, action_owner_id, action_owner_name, action, action_description, version_id, affected_entity_id, affected_entity_name, section)
SELECT ati.action_time, ati.action_owner_id, ati.action_owner_name, ati.action,ati.action_description,ati.version_id,ati.affected_entity_id,ati.affected_entity_name,'Supervisor/Subordinate Custom Fields' FROM `ohrm_audittrail_pim_reportto_custom_field_trail` AS ati;

INSERT INTO `ohrm_audittrail_all` (action_time, action_owner_id, action_owner_name, action, action_description, version_id, affected_entity_id, affected_entity_name, section)
SELECT ati.action_time, ati.action_owner_id, ati.action_owner_name, ati.action,ati.action_description,ati.version_id,ati.affected_entity_id,ati.affected_entity_name,'Qualifications Custom Field' FROM `ohrm_audittrail_pim_qualifications_custom_field_trail` AS ati;

INSERT INTO `ohrm_audittrail_all` (action_time, action_owner_id, action_owner_name, action, action_description, version_id, affected_entity_id, affected_entity_name, section)
SELECT ati.action_time, ati.action_owner_id, ati.action_owner_name, ati.action,ati.action_description,ati.version_id,ati.affected_entity_id,ati.affected_entity_name,'Membership Custom Fields' FROM `ohrm_audittrail_pim_membership_custom_field_trail` AS ati;

INSERT INTO `ohrm_audittrail_all` (action_time, action_owner_id, action_owner_name, action, action_description, version_id, affected_entity_id, affected_entity_name, section)
SELECT ati.action_time, ati.action_owner_id, ati.action_owner_name, ati.action,ati.action_description,ati.version_id,ati.affected_entity_id,ati.affected_entity_name,'Tax Custom Fields' FROM `ohrm_audittrail_pim_tax_custom_field_trail` AS ati;

INSERT INTO `ohrm_audittrail_all` (action_time, action_owner_id, action_owner_name, action, action_description, version_id, affected_entity_id, affected_entity_name, section)
SELECT ati.action_time, ati.action_owner_id, ati.action_owner_name, ati.action,ati.action_description,ati.version_id,ati.affected_entity_id,ati.affected_entity_name,'Tax Custom Fields' FROM `ohrm_audittrail_pim_tax_custom_field_trail` AS ati;

INSERT INTO `ohrm_audittrail_all` (action_time, action_owner_id, action_owner_name, action, action_description, version_id, affected_entity_id, affected_entity_name, section)
SELECT ati.action_time, ati.action_owner_id, ati.action_owner_name, ati.action,ati.action_description,ati.version_id,ati.affected_entity_id,ati.affected_entity_name, ats.description  FROM `ohrm_audittrail_pim_tab_custom_field_trail` AS ati LEFT OUTER JOIN `ohrm_audittrail_section` AS ats ON ats.name = ati.pim_tab WHERE ats.is_deleted = 0;
