vTiger, Payslip and vtlib

If you look at the website https://wiki.vtiger.com/index.php/520:Vtlib there is a download of VtigerCRM_5.2.0_Vtlib.pdf which describes the basic (very basics) of getting going with developing for vtigerCRM. Unfortunately it isn’t 100% accurate when it comes to working with version 5.4. I’ve thrown together a few notes that I made when getting things working on my first install in case they are of use to others.

First off, in Step 1: Creating Module, there have been a couple of changes. With vtiger 5.4 the backend database structure for controlling the menu positioning has been changes. The vtiger_parenttabrel doesn’t seem to be used for the menu positioning and a column called ‘parent‘ in the vtiger_tab table is used. This means that the lines:

$menuInstance = Vtiger_Menu::getInstance('Tools');

don’t do what is required. I have left them in for legacy purposes, but in order to set the Payslip module to be listed under the Tools menu you need to add a line to define parent in the above $moduleInstance section:

$moduleInstance = new Vtiger_Module();
$moduleInstance->name = 'Payslip';
$moduleInstance->parent = 'Tools';

this adds the data in the necessary column of the database table without needing to manually edit it.

Webservices will need enabling under vtiger 5.4, so add the following to the end of the file (before the ?> on the last line):

/** Enable Webservices */
$moduleInstance = Vtiger_Module::getInstance('Payslip');

Alternatively this can be included more tidily at the top by simply adding the lines:

/** Enable Webservices */

immediately before the $module->initTables(); section.

There is also a mistake (at least as far as use for 5.4 goes, I’ve not tested other versions) in that the line:

$field2->name = 'PayslipType';

needs to be modified to:

$field2->name = 'paysliptype';

the capitalisation of the name stops the picklist working.

Once this has been done and you have run the script by placing it on the web server and accessing it with a web browser, you need to create and check the module directory. This is done by copying the 5.4.0 directory (or matching version number, I’m working with 5.4.0) from vtlib/ModuleDir/ to modules/ and renaming it (in this case to Payslip) – remember to change the permissions to match the other module directories.

After renaming the three ModuleFile* files in the root of this directory to match the module name (e.g. Payslip* in this case), there are a few differences in the edits to what is now the Payslip.php file:

  • The $groupTable variable doesn’t appear to have been used since 5.0.4 so will not be found in the 5.4.0 version of the file
  • The $sortby_fields variable doesn’t appear to actually have a value in versions laster than 5.0.4 so doesn’t need changing
  • There is no sign of $detailview_links in any of the versions from 5.0.4 onwards
  • The same goes for function ModuleClass, no sign in versions 5.0.4 onwards

The Payslip module should now be functional, but there are two further things to note:

  • The Picklist is not automatically populated, so you will have to manually assign the values to the roles (the values have been set, jut not assigned).
  • Some of the text pulled from the language file needs to be set, as an example for en_gb create a file called en_gb.lang.php which is basically a copy of en_us.lang.php.

Change the first 3 lines under the line:

$mod_strings = Array(


'ModuleName' => 'Payslip',
'SINGLE_Payslip' => 'Payslip',
'ModuleName ID' => 'Payslip ID',

i.e. replace the generice ‘Module Name‘ with ‘Payslip

at the end of the list, before the ); add the line:

'LBL_PAYSLIP_INFORMATION' => 'Payslip Information',

this one is for the Mass Edit function.

Obviously you can do the same edits directly on the en_us.lang.php file if that is the one you are using, or make matching edits to the equivalent edits to the language file you are using.

To put the tab into the main set of tabs across the top rather than in the More drop down it is necessary to set the ‘tabsequence‘ field in the vtiger_tab table. By default the first eleven are shown, and these correspond to values 1 through 12 (for some reason 2 is not used). The value -1 corresponds to leaving the item in the More drop down. The value of 2 seems a good choice and puts it to the right of the Home item. If you match one of the numbers already there it will show up to the left of the one one listed, with the exception of 12 where it ends up in the More menu. Whatever is chosed only 11 items are shown and and others end up in the More menu. To actually set the value when creating the module use the line:

$moduleInstance->tabsequence = 2;

or whatever value you choose, above the line:


as detailed above.

Comments (9)

  1. avatarPayslip1

    Thanks for the trick buddy, you save my day. been straggling to get this done properly and you just made my life easy with you very well detailed tutorial. Thanks a lot.

  2. avatarram prakash singh

    Hi ,

    Thanks for the changes you mentioned it helps a lot.

    Finally i am able to view the payslip module in 5.4.0
    but facing one issue there is no fields display when i want to create new payslip.

    can you please help me , i am window user (xampp).

  3. avatarPaul Tansom (Post author)

    Glad you found it useful. I’m not familiar with the setup on Windows or with xampp. I’d probably check things like permissions, executable status and presence of all the necessary files in the modules/Payslip directory as a starting point. This isn’t something I had any issues with I’m afraid. It would probably be worth double checking your vtlib script as well to make sure there are no typing mistakes in there.

  4. avatarAG

    Thank you very much, really really useful!

  5. avatarVtiger developer

    On which module file Step 1 code is implemented? I am using the ModuleDir/5.4 file structure for vtiger 5.4.0.?

  6. avatarSteve H

    Thank you very much! After days of struggle, I’ve finally got a custom module script that works. I found it very difficult – not only because I’m a noob, but because there are so many different sources: this one from LinuxLore, the official vtLib one you refer to, the vtiger CRM book by Ian D. Rossi and other posts such as this: http://codebyte.blogspot.com.au/2012/06/solved-problems-installing-payslip.html

    I’ve been maintaining a vtiger CRM for three years now. I find it reliable and easy to work, but ithout custom modules, it has made the CRM slow and given it a poor user experience.

    It would be great if someone could update the process of adding custom modules to match the current vTiger version.

    Maybe I should stop complaining and do it from a noob’s perspective?

    Thanks again Linuxlore!

  7. avatarRaj Anand

    I have to do these task..i am very newbie in vtigercrm

    1. Show Hide Blocks based upon selected value in Picklist

    In Leads [or any other] module, add one Picklist [or use any existing].
    Then create two new Blocks and add few fields in them [this you can do using the Layout Editor]
    Now upon selection of the values in Picklist, you have to hide one block and show other and vice versa
    Also need you to ensure data is saved properly

    2. Copy additional fields, upon selecting ID

    In any module, say in Contacts Module, when we select an Account [This kind of selection fields is using UI Type 10]
    Right now it shows Account Name for selection Account. And also fetches address fields from accounts module to contacts module
    What you need to do, is add few more fields say [Account Employees, or Industry, etc] and upon selecting, bring these values also and store in some fields in contact [you can add these additional fields in contacts using layout editor]

    3.a) Write sample code to extract data from some of the vtiger module, by passing parameters like data created in last 3 months, etc
    The data will be from Accounts, Contacts, Invoices, Products, Users, Groups
    Extracted data shall be in csv format
    b) Create one php page, which is a Web Form [e.g. Inquiry form], upon user enter data in this form, it should call the vtiger web service to create a new Lead.

  8. avatarMehrnaz

    I have to say you saved my job!!!
    this article was PERFECT.
    thank you so much :)

  9. avatarSR


    Thanks for the heads up. Will this apply to vtiger 6 ?

Leave a Comment

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>