INSERT INTO `ohrm_config` (`property`, `value`) VALUES ('pim_wizard_status', '0');

CREATE TABLE ohrm_wizard_screen (
  `id`            int(11)      NOT NULL AUTO_INCREMENT,
  `route`         varchar(255) NOT NULL,
  `title`         varchar(255) NOT NULL,
  `enabled`       tinyint(2)   NOT NULL,
  `show_in_wizard`  tinyint(2)   DEFAULT 1,
  `menu_item_id`    int(11)      NOT NULL UNIQUE,
  `custom_field_screen_id` int DEFAULT NULL,
  PRIMARY KEY (`id`),
  CONSTRAINT `fk_ohrm_wizard_screen_custom_field_screen` FOREIGN KEY (`custom_field_screen_id`) REFERENCES `ohrm_custom_field_screen`(`id`),
   CONSTRAINT `fk_ohrm_wizard_screen_menu_item_id` FOREIGN KEY (`menu_item_id`) REFERENCES `ohrm_menu_item` (`id`)

)
  ENGINE = InnoDB
  DEFAULT charset = utf8;

CREATE TABLE IF NOT EXISTS ohrm_wizard_section (
  `id`            int(11)      NOT NULL AUTO_INCREMENT,
  `name`          varchar(255) NOT NULL UNIQUE,
  `topic`         varchar(550) NOT NULL,
  `has_list`      tinyint(2)   NULL,
  `show_in_wizard`tinyint(2)   NOT NULL,
  `enabled`       tinyint(2)   DEFAULT 1 NOT NULL,
  `data_group_id` int(11)      NOT NULL,
  `custom_field_section_id` int DEFAULT NULL,
  `wizard_screen_id` int       NOT NULL,
  PRIMARY KEY (`id`),
  CONSTRAINT `fk_ohrm_wizard_section_processor_data_group_id` FOREIGN KEY (`data_group_id`) REFERENCES `ohrm_data_group` (`id`),
  CONSTRAINT `fk_ohrm_wizard_section_processor_custom_field_section_id` FOREIGN KEY (`custom_field_section_id`) REFERENCES `ohrm_custom_field_section` (`id`),
  CONSTRAINT `fk_ohrm_wizard_section_processor_wizard_screen` FOREIGN KEY (`wizard_screen_id`) REFERENCES `ohrm_wizard_screen` (`id`)
)
  ENGINE = InnoDB
  DEFAULT charset = utf8;

SET @personalDetailsMenuId := (SELECT `id`
                               FROM `ohrm_menu_item`
                               WHERE `menu_title` = 'Personal Details' AND `menu_category` = 'pim_left_menu');
SET @contactDetailsMenuId := (SELECT `id`
                              FROM `ohrm_menu_item`
                              WHERE `menu_title` = 'Contact Details' AND `menu_category` = 'pim_left_menu');
SET @emergencyContactDetailsMenuId := (SELECT `id`
                                       FROM `ohrm_menu_item`
                                       WHERE `menu_title` = 'Emergency Contacts' AND `menu_category` = 'pim_left_menu');
SET @jobDetailsMenuId := (SELECT `id`
                          FROM `ohrm_menu_item`
                          WHERE `menu_title` = 'Job' AND `menu_category` = 'pim_left_menu');
SET @socialMediaMenuId := (SELECT `id`
                           FROM `ohrm_menu_item`
                           WHERE `menu_title` = 'Social Media Details' AND `menu_category` = 'pim_left_menu');
SET @reportToMenuId := (SELECT `id`
                        FROM `ohrm_menu_item`
                        WHERE `menu_title` = 'Report-to' AND `menu_category` = 'pim_left_menu');
SET @dependentMenuId := (SELECT `id`
                         FROM `ohrm_menu_item`
                         WHERE `menu_title` = 'Dependents' AND `menu_category` = 'pim_left_menu');
SET @salaryMenuId := (SELECT `id`
                      FROM `ohrm_menu_item`
                      WHERE `menu_title` = 'Salary' AND `menu_category` = 'pim_left_menu');
SET @qualificationMenuId := (SELECT `id`
                             FROM `ohrm_menu_item`
                             WHERE `menu_title` = 'Qualifications' AND `menu_category` = 'pim_left_menu');
SET @membershipMenuId := (SELECT `id`
                          FROM `ohrm_menu_item`
                          WHERE `menu_title` = 'Memberships' AND `menu_category` = 'pim_left_menu');
SET @directDepositMenuId := (SELECT `id`
                             FROM `ohrm_menu_item`
                             WHERE `menu_title` = 'Direct Deposit' AND `menu_category` = 'pim_left_menu');
SET @immigrationMenuId := (SELECT `id`
                           FROM `ohrm_menu_item`
                           WHERE `menu_title` = 'Immigration' AND `menu_category` = 'pim_left_menu');
SET @taxExemptionsMenuId := (SELECT `id`
                             FROM `ohrm_menu_item`
                             WHERE `menu_title` = 'Tax Exemptions' AND `menu_category` = 'pim_left_menu');

SET @personalDetailsDataGroupId := (SELECT `id`
                                    FROM `ohrm_data_group`
                                    WHERE `name` = 'personal_information');
SET @contactDetailsDataGroupId := (SELECT `id`
                                   FROM `ohrm_data_group`
                                   WHERE `name` = 'contact_details');
SET @emergencyContactDetailsDataGroupId := (SELECT `id`
                                            FROM `ohrm_data_group`
                                            WHERE `name` = 'emergency_contacts');
SET @jobDetailsDataGroupId := (SELECT `id`
                               FROM `ohrm_data_group`
                               WHERE `name` = 'job_history_details');
SET @socialMediaDataGroupId := (SELECT `id`
                                FROM `ohrm_data_group`
                                WHERE `name` = 'social_media');
SET @supervisorDataGroupId := (SELECT `id`
                               FROM `ohrm_data_group`
                               WHERE `name` = 'supervisor');
SET @subordinateDataGroupId := (SELECT `id`
                                FROM `ohrm_data_group`
                                WHERE `name` = 'subordinates');
SET @dependentDataGroupId := (SELECT `id`
                              FROM `ohrm_data_group`
                              WHERE `name` = 'dependents');
SET @salaryDataGroupId := (SELECT `id`
                           FROM `ohrm_data_group`
                           WHERE `name` = 'salary_history_details');
SET @workExpDataGroupId := (SELECT `id`
                            FROM `ohrm_data_group`
                            WHERE `name` = 'qualification_work');
SET @educationDataGroupId := (SELECT `id`
                              FROM `ohrm_data_group`
                              WHERE `name` = 'qualification_education');
SET @skillsDataGroupId := (SELECT `id`
                           FROM `ohrm_data_group`
                           WHERE `name` = 'qualification_skills');
SET @languageDataGroupId := (SELECT `id`
                             FROM `ohrm_data_group`
                             WHERE `name` = 'qualification_languages');
SET @licenseDataGroupId := (SELECT `id`
                            FROM `ohrm_data_group`
                            WHERE `name` = 'qualification_license');
SET @membershipDataGroupId := (SELECT `id`
                               FROM `ohrm_data_group`
                               WHERE `name` = 'membership');
SET @directDepositDataGroupId := (SELECT `id`
                                  FROM `ohrm_data_group`
                                  WHERE `name` = 'salary_history_details');
SET @immigrationDataGroupId := (SELECT `id`
                                FROM `ohrm_data_group`
                                WHERE `name` = 'immigration');
SET @taxExemptionsDataGroupId := (SELECT `id`
                                  FROM `ohrm_data_group`
                                  WHERE `name` = 'tax_exemptions');

SET @job_custom_field_standard_section_id := (SELECT cfs.`id` FROM ohrm_custom_field_section cfs
  LEFT JOIN `ohrm_custom_field_screen` cfsc ON cfs.`custom_field_screen_id` = cfsc.`id`
  LEFT JOIN `ohrm_screen` s ON cfsc.screen_id = s.id
  LEFT JOIN `ohrm_module` m ON s.module_id =m.id
  WHERE m.`name`='pim' AND s.`action_url`='viewJobHistory' AND cfsc.`name` = 'job-standard' AND cfs.`display_name` = 'Other Job Details');

INSERT INTO ohrm_wizard_screen (id, route, title, enabled, show_in_wizard, menu_item_id) VALUES
(1, 'pim.wizard.personal_details', 'Personal Details', 1, 1, @personalDetailsMenuId),
(2, 'pim.wizard.job', 'Job', 1, 1, @jobDetailsMenuId),
(3, 'pim.wizard.salary', 'Salary', 1, 1, @salaryMenuId),
(4, 'pim.wizard.contact_details', 'Contact Details', 1, 1, @contactDetailsMenuId),
(5, 'pim.wizard.social_media', 'Social Media Details', 1, 1, @socialMediaMenuId),
(6, 'pim.wizard.emergency_contact', 'Emergency Contacts', 1, 1, @emergencyContactDetailsMenuId),
(7, 'pim.wizard.dependent', 'Dependents', 1, 1, @dependentMenuId),
(8, 'pim.wizard.immigration', 'Immigration', 1, 1, @immigrationMenuId),
(9, 'pim.wizard.report_to', 'Report-to', 1, 1, @reportToMenuId),
(10, 'pim.wizard.qualifications', 'Qualifications', 1, 1, @qualificationMenuId),
(11, 'pim.wizard.memberships', 'Memberships', 1, 1, @membershipMenuId),
(12, 'pim.wizard.direct_deposit', 'Direct Deposit', 1, 1, @directDepositMenuId),
(13, 'pim.wizard.tax_exemptions', 'Tax Exemptions', 1, 1, @taxExemptionsMenuId);

INSERT INTO `ohrm_wizard_section` (`id`, `name`, `topic`, `has_list`, `show_in_wizard`, `enabled`, `data_group_id`, `custom_field_section_id`, `wizard_screen_id`)
VALUES
  (1, 'PimPersonalDetail', 'Personal Details', 0, 1, 1, @personalDetailsDataGroupId, NULL, 1),
  (2, 'PimJob', 'Job', 0, 1, 1, @jobDetailsDataGroupId, NULL, 2),
  (3, 'PimSalary', 'Salary', 0, 0, 1, @salaryDataGroupId, NULL, 3),
  (4, 'PimContactDetails', 'Contact Details', 0, 1, 1, @contactDetailsDataGroupId, NULL, 4),
  (5, 'PimSocialMedia', 'Social Media Details', 1, 0, 1, @socialMediaDataGroupId, NULL, 5),
  (6, 'PimEmergencyContacts', 'Emergency Contacts', 1, 0, 1, @emergencyContactDetailsDataGroupId, NULL, 6),
  (7, 'PimDependent', 'Dependents', 1, 0, 1, @dependentDataGroupId, NULL, 7),
  (8, 'PimImmigrationDetails', 'Immigration', 1, 0, 1, @immigrationDataGroupId, NULL, 8),
  (9, 'PimSupervisor', 'Supervisors', 1, 0, 1, @supervisorDataGroupId, NULL, 9),
  (10, 'PimSubordinate', 'Subordinates', 1, 0, 1, @subordinateDataGroupId, NULL, 9),
  (11, 'PimWorkExperience', 'Work Experience', 1, 0, 1, @workExpDataGroupId, NULL, 10),
  (12, 'PimEducation', 'Education', 1, 0, 1, @educationDataGroupId, NULL, 10),
  (13, 'PimSkill', 'Skills', 1, 0, 1, @skillsDataGroupId, NULL, 10),
  (14, 'PimLanguage', 'Languages', 1, 0, 1, @languageDataGroupId, NULL, 10),
  (15, 'PimLicense', 'License', 1, 0, 1, @licenseDataGroupId, NULL, 10),
  (16, 'PimMembership', 'Memberships', 1, 0, 1, @membershipDataGroupId, NULL, 11),
  (17, 'PimDirectDeposit', 'Direct Deposit', 1, 0, 1, @salaryDataGroupId, NULL, 12),
  (18, 'PimTaxExemptions', 'Tax Exemptions', 0, 0, 0, @taxExemptionsDataGroupId, NULL, 13),
  (19, 'PimCustomFieldJob-Standard', 'Other Job Details', 0, 0, 1, @jobDetailsDataGroupId, @job_custom_field_standard_section_id, 2);


CREATE TABLE IF NOT EXISTS `ohrm_wizard_field` (
  `id`                 int(11)       NOT NULL AUTO_INCREMENT,
  `field_name`         varchar(100)  NOT NULL,
  `mandatory_in_wizard` tinyint(2)   NOT NULL,
  `show_in_wizard`     tinyint(2)    NOT NULL,
  `sequence`           int(11)       NOT NULL,
  `wizard_section_id`  int(11)       NOT NULL,
  `label`              varchar(500)  NOT NULL,
  `read_only`          tinyint(2)    NOT NULL,
  `enabled`            tinyint(2)    NOT NULL,
  `custom_field_id`    int(11)       NULL,
  PRIMARY KEY (`id`),
  CONSTRAINT `fk_ohrm_wizard_field_custom_field` FOREIGN KEY (`custom_field_id`) REFERENCES `ohrm_custom_field` (`id`)
    ON DELETE CASCADE
    ON UPDATE CASCADE,
  CONSTRAINT `fk_ohrm_wizard_field_wizard_section` FOREIGN KEY (`wizard_section_id`) REFERENCES `ohrm_wizard_section` (`id`)
    ON DELETE CASCADE
    ON UPDATE CASCADE
)
  ENGINE = InnoDB
  DEFAULT CHARSET = utf8;

INSERT INTO `ohrm_wizard_field` (`id`, `field_name`, `mandatory_in_wizard`, `show_in_wizard`, `sequence`, `wizard_section_id`, `label`, `read_only`, `enabled`, `custom_field_id`) VALUES
  (1,'personal_details_nation_code',0,1,10,1,'Nationality',0,1,NULL),
  (2,'emp_dri_lice_exp_date',0,1,23,1,'License Expiry Date',0,1,NULL),
  (3,'emp_marital_status',0,1,8,1,'Marital Status',0,1,NULL),
  (4,'emp_gender',0,1,9,1,'Gender',0,1,NULL),
  (5,'emp_birthday',0,1,7,1,'Date of Birth',0,1,NULL),
  (6,'licenseNo',0,1,14,1,'Driver\'s License Number',0,1,NULL),
  (7,'employeeId',0,1,4,1,'Employee Id',0,1,NULL),
  (8,'ssn',0,1,6,1,'Main Id',0,1,NULL),
  (9,'street1',0,1,310,4,'Address Street 1',0,1,NULL),
  (10,'street2',0,1,311,4,'Address Street 2',0,1,NULL),
  (11,'city',0,1,312,4,'City',0,1,NULL),
  (12,'province',0,1,324,4,'State/Province',0,1,NULL),
  (13,'emp_zipcode',0,1,315,4,'Zip/PostalCode',0,1,NULL),
  (14,'country',0,1,313,4,'Country',0,1,NULL),
  (15,'emp_hm_telephone',0,1,320,4,'Home Telephone',0,1,NULL),
  (16,'emp_mobile',0,1,321,4,'Mobile',0,1,NULL),
  (17,'emp_work_telephone',0,1,322,4,'Work Telephone',0,1,NULL),
  (18,'emp_work_email',0,1,333,4,'Work Email',0,1,NULL),
  (19,'emp_oth_email',0,1,334,4,'Other Email',0,1,NULL),
  (20,'joined_date',0,1,104,2,'Joined Date',0,0,NULL),
  (25,'typeId',1,1,410,5,'Type',1,1,NULL),
  (26,'profileName',1,1,430,5,'Handle',1,1,NULL),
  (27,'profileLink',0,1,420,5,'Link',0,1,NULL),
  (28,'name',1,1,510,6,'Name',1,1,NULL),
  (29,'relationship',1,1,520,6,'Relationship',1,1,NULL),
  (30,'home_phone',0,1,540,6,'Home Telephone',0,1,NULL),
  (31,'mobile_phone',0,1,550,6,'Mobile',0,1,NULL),
  (32,'office_phone',0,1,560,6,'Work Telephone',0,1,NULL),
  (34,'probation_end_date',0,1,105,2,'Probation End Date',0,1,NULL),
  (35,'date_of_permanency',0,1,106,2,'Date Of Permanency',0,1,NULL),
  (36,'job_title_id',0,1,107,2,'Job Title',0,1,NULL),
  (37,'supervisorId',1,1,800,9,'Name',1,1,NULL),
  (38,'subordinateId',1,1,800,10,'Name',1,1,NULL),
  (39,'reportingMethodId',1,1,900,9,'Reporting Method',1,1,NULL),
  (40,'employment_status_id',0,1,108,2,'Employment Status',0,1,NULL),
  (41,'job_category_id',0,1,109,2,'Job Category',0,1,NULL),
  (42,'subunit_id',0,1,112,2,'Sub Unit',0,1,NULL),
  (44,'work_schedule_id',1,1,115,2,'Work Schedule',1,1,NULL),
  (45,'comment',0,1,170,2,'Comment',0,1,NULL),
  (46,'contract_start_date',0,1,116,2,'Contract Start Date',0,1,NULL),
  (47,'contract_end_date',0,1,117,2,'Contract End Date',0,1,NULL),
  (48,'firstName',1,1,1,1,'First Name',1,1,NULL),
  (49,'lastName',1,1,3,1,'Last Name',1,1,NULL),
  (50,'reportingMethodId',1,1,900,10,'Reporting Method',1,1,NULL),
  (51,'name',1,1,610,7,'Name',1,1,NULL),
  (52,'relationship_type',1,1,620,7,'Relationship',1,1,NULL),
  (53,'date_of_birth',0,1,630,7,'Date of Birth',0,1,NULL),
  (54,'type',1,1,710,8,'Document',1,1,NULL),
  (55,'number',1,1,720,8,'Number',1,1,NULL),
  (56,'issuedDate',0,1,750,8,'Issued Date',0,1,NULL),
  (57,'expiryDate',0,1,760,8,'Expiry Date',0,1,NULL),
  (58,'status',0,1,730,8,'Eligible Status',0,1,NULL),
  (59,'countryCode',0,1,740,8,'Issued By',0,1,NULL),
  (60,'reviewDate',0,1,770,8,'Eligible Review Date',0,1,NULL),
  (61,'notes',0,1,780,8,'Comments',0,1,NULL),
  (62,'amount',1,1,1609,17,'Amount',1,1,NULL),
  (63,'account_number',1,1,1610,17,'Account Number',1,1,NULL),
  (64,'institute_name',0,1,1612,17,'Financial Institute',0,1,NULL),
  (65,'account_type',0,1,1622,17,'Account Type',0,1,NULL),
  (66,'branch_location',0,1,1624,17,'Branch Location',0,1,NULL),
  (67,'routing_number',0,1,1640,17,'Routing Number',0,1,NULL),
  (68,'membership',1,1,1510,16,'Membership',1,1,NULL),
  (69,'subscriptionPaidBy',0,1,1511,16,'Subscription Paid By',0,1,NULL),
  (70,'subscriptionCurrency',0,1,1512,16,'Currency',0,1,NULL),
  (71,'subscriptionCommenceDate',0,1,1535,16,'Subscription Commence Date',0,1,NULL),
  (72,'subscriptionRenewalDate',0,1,1513,16,'Subscription Renewal Date',0,1,NULL),
  (73,'subscriptionFee',0,1,1562,16,'Subscription Amount',0,1,NULL),
  (74,'employer',1,1,1010,11,'Company',1,1,NULL),
  (75,'jobtitle',1,1,1020,11,'Job Title',1,1,NULL),
  (76,'from_date',0,1,1050,11,'From',0,1,NULL),
  (77,'to_date',0,1,1060,11,'To',0,1,NULL),
  (78,'comments',0,1,1090,11,'Comment',0,1,NULL),
  (79,'licenseId',1,1,1410,15,'License Type',1,1,NULL),
  (80,'licenseNo',0,1,1420,15,'License Number',0,1,NULL),
  (81,'licenseIssuedDate',1,1,1430,15,'Issued Date',0,1,NULL),
  (82,'licenseExpiryDate',1,1,1445,15,'Expiry Date',0,1,NULL),
  (83,'langId',1,1,1310,14,'Language',1,1,NULL),
  (84,'competency',1,1,1320,14,'Skill',1,1,NULL),
  (85,'fluency',1,1,1325,14,'Fluency Level',1,1,NULL),
  (86,'comments',0,1,1390,14,'Comments',0,1,NULL),
  (87,'skillId',1,1,1230,13,'Skills',1,1,NULL),
  (88,'years_of_exp',0,1,1235,13,'Year of Experience',0,1,NULL),
  (89,'comments',0,1,1240,13,'Comments',0,1,NULL),
  (90,'educationId',1,1,1110,12,'Level',1,1,NULL),
  (91,'major',0,1,1130,12,'Major/Specialization',0,1,NULL),
  (92,'year',0,1,1140,12,'Year',0,1,NULL),
  (93,'score',0,1,1150,12,'GPA/Score',0,1,NULL),
  (94,'startDate',0,1,1160,12,'Start Date',0,1,NULL),
  (95,'endDate',0,1,1170,12,'End Date',0,1,NULL),
  (96,'payGrade',0,1,220,3,'Pay Grade',0,1,NULL),
  (97,'currency',0,1,230,3,'Currency',0,1,NULL),
  (98,'comment',0,1,270,3,'Comments',0,1,NULL),
  (99,'annualBasicPayment',1,1,240,3,'Annual Basic Payment(amount)',1,1,NULL),
  (100,'effectiveDate',1,1,210,3,'Effective From',1,1,NULL),
  (101,'institute',0,1,1120,12,'Institute',0,1,NULL),
  (104,'creditable',0,1,1080,11,'Creditable',1,1,NULL),
  (105,'smoker',0,1,1080,1,'Smoker',1,0,NULL),
  (106,'nickName',0,1,1080,1,'Nick Name',0,0,NULL),
  (107,'militaryService',0,1,1080,1,'Military Service',0,0,NULL),
  (108,'costCentre',0,1,120,2,'Cost Center',0,0,NULL),
  (109,'event',1,1,140,2,'Event',1,0,NULL),
  (110,'changes_Effective_from',1,1,180,2,'Effective From',1,1,NULL),
  (111,'sin',0,1,120,1,'SIN Number',0,0,NULL),
  (112,'eeo_race_ent',1,1,1000,1,'EEO Race and Ethnicity',1,0,NULL),
  (113,'flsa_exempt',0,1,150,2,'FLSA Exempt',1,0,NULL),
  (114,'eeo_job_category',0,1,160,2,'EEO Job Category',0,0,NULL),
  (115,'eeoPayGrade',0,1,250,3,'EEO Pay Band',0,0,NULL),
  (116,'otherId',0,1,5,1,'Other Id',0,1,NULL),
  (118,'federalStatus',0,1,550,18,'Federal Income Tax Status',0,0,NULL),
  (119,'federalExemptions',0,1,551,18,'Federal Income Tax Exemption',0,0,NULL),
  (120,'state',0,1,552,18,'State',0,0,NULL),
  (121,'stateStatus',0,1,553,18,'State Income Tax Status',0,0,NULL),
  (122,'stateExemptions',0,1,554,18,'State Income Tax Exemption',0,0,NULL),
  (123,'unemploymentState',0,1,555,18,'Unemployment State',0,0,NULL),
  (124,'workState',0,1,556,18,'Work State',0,0,NULL),
  (125,'nation_code',0,1,640,7,'Nationality',0,0,NULL),
  (126,'middleName',0,1,3,1,'Middle Name',0,1,NULL),
  (127,'allowShare',0,1,440,5,'Allow share in public',0,1,NULL),
  (128,'job_spec',0,1,190,2,'Job Specification',1,1,NULL);

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

INSERT INTO `ohrm_screen` (`name`, `module_id`, `action_url`)
VALUES ('Add Employee Wizard', @module_id, 'employeeWizardConfiguration');

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

SET @people_management_pillar_menu_id := (SELECT `id` FROM ohrm_menu_item WHERE `menu_title` = 'People Management' AND parent_id IS NULL AND level = 1);
SET @employee_management_module_menu_id := (SELECT `id` FROM ohrm_menu_item WHERE `menu_title` = 'Employee Management' AND parent_id = @people_management_pillar_menu_id AND level = 2);
SET @employee_management_configurations_menu_id := (SELECT `id` FROM ohrm_menu_item WHERE `menu_title` = 'Configurations' AND parent_id = @employee_management_module_menu_id AND level = 3);

INSERT INTO `ohrm_menu_item` (`menu_title`, `menu_category`, `screen_id`, `parent_id`, `level`, `order_hint`, `url_extras`, `status`, `uisref`)
VALUES ('Add Employee Wizard', NULL, @screenId, @employee_management_configurations_menu_id, 4, 400, NULL, '1', 'pim.configure_employee_wizard');

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

INSERT INTO `ohrm_data_group` (`name`, `description`, `can_read`, `can_create`, `can_update`, `can_delete`)
VALUES ('add_employee_wizard', 'Employee Management - Configure - Add Employee Wizard', '1', '1', '1', '1');

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

SET @userRoleTypeId := (SELECT `id`
                        FROM `ohrm_user_role_type`
                        WHERE `name` = 'Admin');

INSERT INTO `ohrm_menu_item_data_group` (`menu_item_id`, `data_group_id`)
VALUES (@menuItemId, @addEmployeeWizardDataGroupId);

INSERT INTO `ohrm_data_group_screen` (`data_group_id`, `screen_id`, `permission`, `self`)
VALUES (@addEmployeeWizardDataGroupId, @screenId, '1', '0');

SET @userRoleId := (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 (@userRoleId, @screenId, '1', '1', '1', '1');

INSERT INTO `ohrm_user_role_data_group` (`user_role_id`, `data_group_id`, `can_read`, `can_create`, `can_update`, `can_delete`, `self`)
VALUES (@userRoleId, @addEmployeeWizardDataGroupId, '1', '1', '1', '1', '0');

INSERT INTO `ohrm_user_role_type_data_group` (`user_role_type_id`, `data_group_id`, `can_read`, `can_create`, `can_update`, `can_delete`)
VALUES (@userRoleTypeId, @addEmployeeWizardDataGroupId, '1', '0', '1', '0');
