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.
Software Development Services
May 9, 2014
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.
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.
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.
Now you have to enable the plugin. Go to Symfony/apps/orangehrm/config/setting.yml. Symfony folder contains the code of OrangeHRM.
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.
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.
The admin should make changes in the check box class. Simply add these lines in ‘symfony\plugins\orangehrmAdminPlugin\modules\admin\templates\viewModulesSuccess.php’.
Now delete the cache and refresh your browser. Click on Admin ->Configuration ->Modules. Your plugin will be shown there.
Create 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.
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.
ViewTestMessage 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.