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

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

Orange HRM - Module tutorial

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

Step 1 – Download Orange HRM

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

 

create module orange hrmStep 2 – Name of the Plugin

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

OrangeHRM Plugin name

 

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.

 

Enable Plugin

Step 4 – Configure Plugin

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

orangehrm plugin configure

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

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

orange hrm module

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

orange hrm code

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

Step 5

orange hrm folders

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

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

Step 6 – Final Step

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

orange hrm module enabled

ViewTestMessage is the file inside actions and templates folder. This is the default class. Whenever user clicks on Test Message execute function inside ViewTestMessageAction.class.php executes. Inside Actions folder, 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 other.
Every screen must have a user which means that specific user can access this screen. Simply add screen id (105) and any user roleid (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 main Menu.
Open up ‘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 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 logout delete cache and login back. You will see Test Message in your main menu bar.

Author Owais Ramzan

More posts by Owais Ramzan
  • shagufta.km

    Hey Ramzan

    • Muhammad Wasim

      Hello shagufta,I could help you regarding any issues of orange HRM ……You can contact me for any queries @muhammadwasimshahzad:disqus

  • Kalai Ex

    module is showing, but not able enable it…How to enable it? Help me

    • @StuAFCB

      Add a class extending sfPluginConfiguration to your module’s config folder.. e.g. orangehrmHelloWorldPluginConfiguration.class.php

      This needs to override the initialize() function. In that function you will add your module to the enabled modules.. where helloWorld is your module’s name..

      e.g.

      public function initialize() {
      $enabledModules = sfConfig::get(‘sf_enabled_modules’);
      if (is_array($enabledModules)) {
      sfConfig::set(‘sf_enabled_modules’, array_merge($enabledModules, array(‘helloWorld’)));
      }
      }

      • delickate

        Hi,
        Thanks for the help.
        I did same but no luck. My module name “rating”
        Here is my configure class:
        class orangehrmRatingPluginConfiguration extends sfPluginConfiguration
        {
        public function initialize()
        {
        $enabledModules = sfConfig::get(‘sf_enabled_modules’);
        if (is_array($enabledModules))
        {
        sfConfig::set(‘sf_enabled_modules’, array_merge($enabledModules, array(‘rating’)));
        }
        }
        }

        Please help

        • delickate

          Got it… Thanks

    • delickate

      You are missing one step. In ModuleForm.php file. Add your module name in following function as well:
      protected function _getDefaultValues() {

      $modules = array(‘admin’, ‘pim’, ‘leave’, ‘time’, ‘recruitment’, ‘performance’, ‘rating’);
      …………..
      …………….

      As my plugin name is rating.
      Thanks

  • Joseph

    I managed to do alot with this tutorial thanks alot..

    • nenito2k .

      hi…ORANGE is open source…and used by millions…yet i can’t find a singe FREE module….do they exist ? or can you send me one on email or somethng ??? is that doable ?

      • Joseph

        unfortunately from my research i didn’t find ‘FREE Modules’ I guess selling modules was the whole business idea so i decided to code the module myself.

        • nenito2k .

          i see…do you mind sharing this module? uploading it somewhere of sending via mail? if yes, i should then follow these steps to use it ?

    • Xavery.L.K Chikatizo Njovu

      hi joseph. i am based in arusha tz. may we get in touch. contact me through [email protected]

    • Sammy

      Hi Joseph,please contact me through [email protected] in Nairobi Kenya.We can do business together now that you have the payroll well integrated.Thank you

    • Merlin Sidabutar

      i have try the above process but the menu is not appear?
      what should I do?

      • Muhammad Wasim

        Either clear you symfony cache or logout from orange hrm and then login to orange hrm menu will appear….

    • @disqus_In7jO8TzGN can we discuss more about your payroll integration? [email protected]

    • Ratna

      Dear Expers please provide assistance to the below problem (Orange HRM).

      I don’t have much programming knowledge.

      I want to Add New Attachment Field before the comment field in leaveplugin in apply leave form which have to allow to attach a file while applying. I have done the following.

      **In getFormWidgets(): **

      ~~~~

      ‘attach’ => new sfWidgetFormInputFileEditable(array(‘edit_mode’ => false,’with_delete’ => false, ‘file_src’ => ”))

      ~~~~

      **In getFormValidators() function :**

      ~~~~

      ‘attach’ => new sfValidatorFile(array(‘required’ => false, ‘max_size’ => 1024000, ‘validated_file_class’ => ‘orangehrmValidatedFile’))

      ~~~~

      In action class, binded that form with $request->getFiles().

      Now How can I store it in database and make the above uploaded file (Through applyLeave) visible in viewLeaveRequest of the Superviser login (while accepting/rejecting)?

      Please post in detail. Thanks in advance.

    • Howard

      Hi Joseph. Am interested in this module you wrote for Orange HRM. Please assist me with this as I would like to write a customized payrol module suited for Zambian laws.

    • michaelkwame

      Hi. Kudos on this work. I am fairly new to web dev. I want to add a new panel to the dashboard and make put download links in it. Kindly guide me through that. thanks.

  • Sanjit

    Hi i followed the above process but could not get the menu to show.. Am i missing something.

    • delickate

      Yes Sanjit.. extending to this blog. insert values in “ohrm_user_role_screen” table as well. Then menu will show up. This table show which user have what rights.

    • Muhammad Wasim

      If you have applied the @delickate answer and still menu not showing
      then you have to logout from HRM and then again login to HRM it will
      work………..

  • symfony

    thanks man, this saved my skin…

  • partha sarathi

    Any one please tell me how to create basic page and link to this menu

    Thanks

  • Rakhi Prajapati

    Hello, Can anyone suggest me how to add static html page with static content. I created menu but its showing ‘Internal Error Occured’ ..

    • Muhammad Wasim

      Clear you symfony cache…….. go to your xamp or wamp -> open shell
      reach symfony folder e.g my project is in
      d:xamphtdocsprojectnamesymfony ->write this command ‘php symfony
      cc’ your cache will be cleared………. For static content when you click on menu you will be directed to the view against your menu there you will write any html content ……… If you need more information you can contact me @muhammadwasimshahzad:disqus

  • A. K. M. Mohiuddin Ahammed (Mu

    Thanks for the tutorial. It’s so nice. But I am facing a problem. How can I show my own html or php page when I click on Test Message menu item ? It showing me “Internal Error Occurred” ; Please help.

    • Muhammad Wasim

      Clear you symfony cache…….. go to your xamp or wamp -> open shell reach symfony folder e.g my project is in d:xamphtdocsprojectnamesymfony ->write this command ‘php symfony cc’ your cache will be cleared……..

  • amol chaudhari

    Hello, I have created manu. but how created static page with proper url.

  • Angel Antouny

    I did all these steps but still the menu item can’t be displayed in the GUI !!!!

    • Muhammad Wasim

      You have to log out from the orange
      HRM and then login to the HRM system it will work…….. If problem persist you
      can give me detail @muhammadwasimshahzad:disqus

  • rockie

    Hello Owais Ramzan Can you zip all files which you did in this tutorials

    • Muhammad Wasim

      You have to clear the symfony cache internal error would disappear……… go to your xamp or wamp -> open shell reach symfony folder e.g my project is in d:xamphtdocsprojectnamesymfony ->write this command ‘php symfony cc’ your cache will be cleared……..

  • Ratna

    Dear Expers please provide assistance to the below problem (Orange HRM).

    I don’t have much programming knowledge.

    I want to Add New Attachment Field before the comment field in leaveplugin in apply leave form which have to allow to attach a file while applying. I have done the following.

    **In getFormWidgets(): **

    ~~~~

    ‘attach’ => new sfWidgetFormInputFileEditable(array(‘edit_mode’ => false,’with_delete’ => false, ‘file_src’ => ”))

    ~~~~

    **In getFormValidators() function :**

    ~~~~

    ‘attach’ => new sfValidatorFile(array(‘required’ => false, ‘max_size’ => 1024000, ‘validated_file_class’ => ‘orangehrmValidatedFile’))

    ~~~~

    In action class, binded that form with $request->getFiles().

    Now How can I store it in database and make the above uploaded file (Through applyLeave) visible in viewLeaveRequest of the Superviser login (while accepting/rejecting)?

    Please post in detail. Thanks in advance.

  • tuan.do

    Dear expert, I have create a new menu_item and display successfully a new screen with the input is a static PHP contents some text,
    But when I click into my new menu_item, the current item not turn into Activated . Could you show me some hints to change the status of menu to Activated ?

    • tuan.do

      Problem was solved !

      • Andre Catur Prasetyo

        i got same problem with u. how you solve that problem?

  • Upender Upendra

    Admin ->Configuration ->Modules

    In Above process how can we see this modules

  • Natesan Velayudham

    Show my custom module in config->modules but modules not enable(always check box unchecked)

  • Chobela Kakumbi

    How do I make the recruitment module available to ESS or employees??

  • Tharunjeni

    Good Tutorial, but no where helped atleast how to display hello world in menu.

  • Priti

    how do i add “Performance Review Submissions” under Email Subscription of Admin module in OrangeHRM.? There is only leave related notifications…….
    https://uploads.disquscdn.com/images/88f3aca173ba71fe92046711a9e9336eb0ef380395bdb2af785d15cde9320fb9.png

  • Yaboya NdowJallow

    I am new to orangehrm.I have hosted it locally on xampp and now i want move it to another computer.Basically i want to know how to to Backup and restore Orangehrm.

    • Janner Daniel Martinez Rosero

      you must make a copy of the database and copy the entire folder of orangehrm-3.3.3 that folder you must paste on your new pc in your htdocs folder if you use xampp or www if you use wamp, restore the database with some tool how workbench, navicat or the classic phpmyadmin from xampp, run the web server apache and server mysql, that should work correctly, access to the database from mysql should have the same users and passwords (default root and empty password)