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.