6 Steps on How to Write a New Module in Orange HRM

6 Steps on How to Write a New Module in Orange HRM: Check out this comprehensive guide to know everything about Orange HRM.

image

Software Development Services

image

May 9, 2014

image

Babar

image

 

It is not easy to write a new module in Orange HRM since it is divided into many layers. I will guide you step by step on how to create a new module in Orange HRM.

 

Step 1 – Download Orange HRM

First, download the latest version of Orange HRM. Then extract it, and place it into the root directory. Now install the Orange HRM. After the installation is complete, your file folder should look like this.

05c70c_60018af77867468b8686b85f9d4db086_mv2.jpg

Create a folder

Create a folder named orangehrmTestPlugin in the plugins folder. The test is the name of the plugin, you can change its name. This folder contains the code of the module.

05c70c_ddd5a074a0fe43f4b89a9bbef0a9ad75_mv2.webp

Step 3 – Enable the Plugin

Now you have to enable the plugin. Go to Symfony/apps/orangehrm/config/setting.yml. Symfony folder contains the code of OrangeHRM.

05c70c_75a0876657b54593b410ee8fef9d9d5f_mv2.webp

Step 4 – Configure Plugin

Now add a plugin to the admin configure list. This allows the admin to easily enable or disable plugins at any time. To do this you need to include your plugin in the database. Open up the ‘ohrm_module’ and ‘hs_hr_module’ tables in a database and make these changes.

05c70c_592e9f9bb312455394882068926f0528_mv2 (1).webp

Status ‘1’ in ‘ohrm_module’ shows that this module is enabled.

Now the plugin needs to be included in the database. To add the module in the code go to ‘symfony\plugins\orangehrmAdminPlugin\lib\form\ModuleForm.php’ and make changes there.

05c70c_d6550963120d43ae94776743d6bac13a_mv2 (1).webp

The admin should make changes in the check box class. Simply add these lines in ‘symfony\plugins\orangehrmAdminPlugin\modules\admin\templates\viewModulesSuccess.php’.

05c70c_35dad862ffbf4e439bc9455644702c10_mv2.webp
Now delete the cache and refresh your browser. Click on Admin ->Configuration ->Modules. Your plugin will be shown there.

 

Step 5 - Create Folder In Plugin

05c70c_f3f94ddd65bf43a0923bffe1203ea530_mv2.webpCreate these folders inside your plugin. The Lib folder contains data, forms, and services. Dao (Database Access Object) contains all the database operations (fetch, update, insert and delete). The form contains forms to get data from users. The service allows users to call day operations. Modules contain your plugin with 2 folders inside (actions and templates). Actions consist of different classes that will perform actions when the user interacts with the system.

Default action must have a template file. An action class may have 1 or more template files. The action file ends with Action.class.php. Templates consist of HTML code for GUI.

 

Step 6 – Final Step

Now include your plugin on the main menu. To do this you need to create a screen in your database. Open up the ‘`ohrm_screen’ Table and insert line no 105 as shown in the figure below.

05c70c_4cd166731f514429b8a280a5d34cb541_mv2.webpViewTestMessage is the file inside the actions and templates folder. This is the default class. Whenever the user clicks on Test Message execute function inside ViewTestMessageAction.class.php executes. Inside the Actions folder, the template against this file is viewTestMessageSuccess.php which is executed. You can create 1 or more screens in a plugin, but every screen name must be different from the other. Every screen must have a user which means that a specific user can access this screen. Simply add screen id (105) and any user role (user role id from ‘ohrm_user_role’ Table) in‘ohrm_user_role_screen’ Table. Also, specify what operation can perform this user role. Now time to show TestMessage in the main Menu. Open up the ‘ohrm_menu_item’ Table. Insert menu_title as Test Message, screen_id as 105 (created in ‘ohrm_screen’ Table), parent_id as Null (if it is parent itself), level as 1 (2 for sub-menu and 3 for 3rd level), order_hint as 800 (100 for the most left side, 200 for second place from left, 300 for 3rd place and so on), url_extras as Null, and states as 1 (0 mean don’t show).

Now log out delete the cache and login back. You will see the Test Message in your main menu bar.

Note: This article was written in 2014 and will not work for the latest versions of OrangeHRM. Please contact us if you are looking to develop a module for OrangeHRM.

 

Islamabad, Pakistan

Floor 2, Building 145, Civic Center Bahria Town Phase 4, Islamabad, Pakistan

USA

1 squire armor road, windham, NH,03076